#! /bin/sh

s=../../local/gcc-20010205

$s/configure --build="`cat ../../SYSTEM`" \
  --host=arm-epoc-pe --target=arm-epoc-pe --prefix=/usr

cat >>gcc/auto-host.h <<EOF
#define HOST_BITS_PER_WIDEST_INT HOST_BITS_PER_LONG
#define HOST_WIDEST_INT long
#define HOST_WIDEST_INT_PRINT_DEC "%ld"
#define HOST_WIDEST_INT_PRINT_UNSIGNED "%lu"
#define HOST_WIDEST_INT_PRINT_HEX "0x%lx"
EOF

# We need special LDFLAGS for cc1 and cc1plus
# And configure ignores use_collect2=no of config.gcc

mv gcc/Makefile gcc/Makefile.orig
sed -e '/^cc1/,/^$/s/ -o / -heap 32M -o /' \
    -e 's/^OLDCC =.*$/OLDCC = $(CC)/' \
    -e 's/^USE_COLLECT2 *=.*$/USE_COLLECT2=/' \
    gcc/Makefile.orig >gcc/Makefile
touch -r gcc/Makefile.orig gcc/Makefile
