Although it was quite straightforward in principle it required some Solaris packages to be unpacked in order to obtain all the headers and libraries I needed for compilation
The packages I used were SUNWhea, SUNWlibC, SUNWlibm.
I needed also the PThread library in order to build libgomp.
In order to get their content unpack the none.bz2 from each one with the command
$ bzcat none.bz2 cpio -C 512 -idu
I have then downloaded gcc-4.2.2 and binutils-2.17.
In order to build it I have used this script:
#!/bin/bash
export TARGET=sparc-sun-solaris2.10
export BUILD=x86_64-unknown-linux-gnu
export PREFIX=`pwd`/$TARGET
export SRC=`pwd`/src
export BINUTILS=binutils-2.17
export GCC=gcc-4.2.0
export PATH=$PREFIX/bin:$PATH
INCLUDE=`pwd`/src/$TARGET/include
LIBS=`pwd`/src/$TARGET/lib
init ()
{
mkdir -p $PREFIX
mkdir -p build
}
binutils ()
{
mkdir build/$BINUTILS
cd build/$BINUTILS
$SRC/$BINUTILS/configure \
--prefix=$PREFIX \
--target=$TARGET \
--with-gnu-as \
--with-gnu-ld \
--disable-nls \
--with-headers=$INCLUDE \
--with-libs=$LIBS
make all install
cd ..
}
gcc ()
{
#export CC=$TARGET-gcc
#export PATH=$PREFIX/$TARGET/bin:$PATH
#export LD_LIBRARY_PATH=$PREFIX/$TARGET/lib
mkdir build/$GCC
cd build/$GCC
$SRC/$GCC/configure \
--prefix=$PREFIX \
--target=$TARGET \
--enable-languages=c,c++ \
--disable-nls \
--with-gnu-as \
--with-gnu-ld \
--with-headers=$INCLUDE \
--with-libs=$LIBS
make all install
cd ..
}
init
binutils
gcc
Afterwards I was able to compile a simple hello world with the newly generated compiler. It felt good... Mission accomplished...
Still I am not quite okay with the size of the includes and libraries used - I had to do some tricks in order to build them. The cleanest solution would be to install a fresh system and take the files directly from there.