script to build gcc3.02 using Hard Hat Linux's gcc for sh4

Dan Kegel
Thu Dec 20 20:28:00 GMT 2001

We had to build gcc 3.02 with Hard Hat Linux's gcc2.9x for sh4.

Here's how we did it, just in case anyone else needs to do that.
- Dan

set -x -e


# Muck around in the hardhat tree to let the gcc build process find what it
# needs.  FIXME These steps must all be run as root.
cd /opt/hardhat/devkit/sh/sh4_le

# Avoid exit if links exist by using a subshell
ln -s sh4el-hardhat-linux  sh4-linux
cd bin
ln -s sh_sh4_le-ar sh4-linux-ar
ln -s sh_sh4_le-ld sh4-linux-ld
ln -s sh_sh4_le-nm sh4-linux-nm
ln -s sh_sh4_le-ranlib sh4-linux-ranlib
ln -s sh_sh4_le-strip sh4-linux-strip

find . -name crt?.o -exec cp {} sh4-linux/lib \;

# Extract the source into the same directory as the tarballs
tar zxvf gcc-3.0.2.tar.gz
rm -rf gcc-sh-linux-3.0.2
mv gcc-3.0.2 gcc-sh-linux-3.0.2
zcat gcc-sh-linux_3.0.2-3.diff.gz | patch -p0

export PATH

rm -rf gcc-build
mkdir gcc-build
cd gcc-build
../gcc-sh-linux-3.0.2/configure \
        --target=sh4-linux \
        --prefix=/opt/hardhat/devkit/sh/sh4_le \
        --with-headers=/opt/hardhat/devkit/sh/sh4_le/target/usr/include \
        --enable-shared \
        --enable-long-long \
        --enable-threads=posix \
        --enable-langugages=c,c++ \
        --disable-c99 \
sed -e 's/^TARGET_CONFIGDIRS.*$/TARGET_CONFIGDIRS = libiberty libstdc++-v3/' Makefile >
mv -f Makefile
make install

# remove gcc3.0.0 stuff
rm /opt/hardhat/devkit/sh/sh4_le/target/usr/lib/libstdc++.*
# cp -d is not portable; could do same thing with cpio...
cp -d /opt/hardhat/devkit/sh/sh4_le/sh4-linux/lib/libs* /opt/hardhat/devkit/sh/sh4_le/target/usr/lib
cp -d /opt/hardhat/devkit/sh/sh4_le/sh4-linux/lib/libgcc_s* /opt/hardhat/devkit/sh/sh4_le/target/lib
cp -R -d /opt/hardhat/devkit/sh/sh4_le/include/g++-v3 /opt/hardhat/devkit/sh/sh4_le/target/usr/include
(cd /opt/hardhat/devkit/sh/sh4_le/sh4-linux ; cp -R -d ../target/usr/include .)

Want more information?  See the CrossGCC FAQ,
Want to unsubscribe? Send a note to

More information about the crossgcc mailing list