[main]
filesize=13366790
sha512=06645865a851bfdeca399ed1266f99e072a9bb1d8c6f0d3d6d0f809080ce1e60f45d9e4b52c93cf89f2062a4db0a69f519f23ac5de918bc89bdd794ebd2b96b4
tardir=gcc-3.4.6

[deps]

[mirrors]
http://ftp.gnu.org/gnu/gcc/gcc-3.4.6/gcc-core-3.4.6.tar.bz2

[build]
#apparently some control freak gcc used by ubuntu enforces that the mode arg is set in open calls
sed -i 's@O_CREAT@O_CREAT, 0770@' gcc/collect2.c

sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in

sed -i 's@/lib/ld-linux.so.[12]@/lib/ld-musl-i386.so.1@' gcc/config/i386/linux.h
sed -i 's@/lib/ld-linux.so.[12]@/lib/ld-musl-i386.so.1@' gcc/config/i386/linux64.h
sed -i 's@/lib64/ld-linux-x86-64.so.2@/lib/ld-musl-x86_64.so.1@' gcc/config/i386/linux64.h

archflags=
#[ "$A" = "arm" ] && archflags="--with-float=soft --enable-multilib --enable-interwork"
# gcc 3.4.6 is broken, it emits code for __floatsisf, which according to linaro staff shouldn't be used
# it is supposed to be in libgcc for some archs. should not be too hard to fix, but it yet has to be done
# musl-0.9.2/src/malloc/malloc.c:120: undefined reference to `__floatsisf'

[ "$A" = "arm" ] && archflags="--with-float=soft --with-fpu=vfp --disable-multilib"
[ "$A" = "x86_64" ] && archflags=--disable-multilib
[ "$A" = "i386" ] && archflags=--disable-multilib

./configure --prefix=/ --disable-bootstrap --disable-shared --disable-nls $archflags || exit 1
make CFLAGS="-DSTDC_HEADERS -Werror-implicit-function-declaration" LDFLAGS="-static" -j$MAKE_THREADS || exit 1
make DESTDIR="$butch_install_dir" install-gcc || exit 1

# rename gcc to rawcc so musl-gcc can call the *right* gcc
mv "$butch_install_dir/bin/gcc" "$butch_install_dir/bin/rawcc"
ln -sf "rawcc" "$butch_install_dir/bin/gcc"

[ "$A" = x86_64 ] && mv "$butch_install_dir/lib64/"* "$butch_install_dir/lib/" || true

