Building GCC4
From wiki.gp2x.org
Just notes for now
Download these to your downloads directory
- binutils-2.16.1.tar.bz2
- gcc-4.0.2.tar.bz2
- glibc-2.3.5.tar.bz2
- glibc-linuxthreads-2.3.5.tar.bz2
use the ME kernel source, you must make menuconfig and make dep using the ME gcc-2.95.3 to get usable headers
if you don't have the ME kernel, try Kernel Headers, don't forget to change the KERNEL_DIR in the script.
Minimal patch for glibc: glibc-2.3.5-arm.patch. Note this is downloaded and applied automatically.
where i cribbed most of the patches: 0218363205270.patch.
Here's a first attempt at a script (it works for me):
# Your target binary prefix
TARGET=arm-linux-gnu
# Your installation prefix
PREFIX=/usr/local/open2x
# Directory where you keep your tarballs
DOWNLOADS=/usr/portage/distfiles
KERNEL_DIR=./linux-mmsp2
# check md5s ??
# install binutils
tar xjf ${DOWNLOADS}/binutils-2.16.1.tar.bz2
cd binutils-2.16.1/
./configure --prefix=${PREFIX} --target=${TARGET} --with-sysroot=${PREFIX} || exit
make || exit
make install
cd ..
echo --- binutils all done ---
# update our path for the new programs we just installed
export PATH=${PREFIX}/bin:$PATH
# you should have already make dep in the kernel using the gcc 2.9.5 tools
# do this manually for now
#cd ${KERNEL_DIR}
#make menuconfig
#make dep
#cd ..
mkdir -p ${PREFIX}/include
mkdir -p ${PREFIX}/${TARGET}/include
cp -r ${KERNEL_DIR}/include/linux ${PREFIX}/include || exit
cp -r ${KERNEL_DIR}/include/asm-arm ${PREFIX}/include/asm
cp -r ${KERNEL_DIR}/include/linux ${PREFIX}/${TARGET}/include
cp -r ${KERNEL_DIR}/include/asm-arm ${PREFIX}/${TARGET}/include/asm
# extract gcc
tar xjf ${DOWNLOADS}/gcc-4.0.2.tar.bz2
mkdir gcc-build
cd gcc-build
# make a minial gcc
../gcc-4.0.2/configure --disable-shared --enable-languages=c --without-headers --disable-threads \
--target=${TARGET} --prefix=${PREFIX} || exit
make all-gcc || exit
make install-gcc || exit
cd ..
# install all of glibc
# get the glibc patch
wget http://www.oddsoftware.net/gp2x/glibc-2.3.5-arm.patch
# glibc headers
## untar glibc
tar xjf ${DOWNLOADS}/glibc-2.3.5.tar.bz2
## untar linuxthreads
cd glibc-2.3.5
tar xjf ${DOWNLOADS}/glibc-linuxthreads-2.3.5.tar.bz2
## apply patch
patch -p1 < ../glibc-2.3.5-arm.patch || exit
cd ..
mkdir glibc-build
cd glibc-build
# configure
../glibc-2.3.5/configure --enable-add-ons=linuxthreads --host=${TARGET} --prefix=${PREFIX} \
--with-headers=${PREFIX}/${TARGET}/include || exit
make cross-compiling=yes || exit
make install_root=${PREFIX} prefix="" install
make install_root=${PREFIX}/${TARGET} prefix="" install
# build full gcc
cd ..
rm -rf gcc-build
mkdir gcc-build
cd gcc-build
# build and install a real gcc
pwd
../gcc-4.0.2/configure --target=${TARGET} --prefix=${PREFIX} --enable-languages=c,c++,objc --with-cross-host || exit
make TARGET_CONFIGARGS='--with-cross-host=arm-linux-gnu --host=arm-linux-gnu' || exit
make TARGET_CONFIGARGS='--with-cross-host=arm-linux-gnu --host=arm-linux-gnu' install
wget -O hello.c http://www.oddsoftware.net/gp2x/hello.c
wget -O hello.cpp http://www.oddsoftware.net/gp2x/hello.cpp
echo Verifying the C compiler
echo ${TARGET}-gcc -shared -o hello-c hello.c
${TARGET}-gcc -shared -o hello-c hello.c
echo Verifying the C compiler
echo ${TARGET}-g++ -shared -o hello-cpp hello.cpp
${TARGET}-g++ -shared -o hello-cpp hello.cpp
Whew :)