仅作记录。如果您遇到错误,可以联系我msn
linux-2.6.29, gcc-4.3.3, glibc-2.7, binutils-2.19
sudo mkdir /opt/i686
gmp-4.2.4 ./configure && make && sudo make install
mpfr-2.4.1 ./configure && make && sudo make install
cp /usr/local/include/* /usr/include/ -f
sudo echo "/usr/local/lib" >> /etc/ld.so.conf
sudo ldconfig /usr/local/bin
export TARGET=i686-linux
export PREFIX=/opt/i686
export PATH=$PATH:/opt/i686/bin
(1)编译binutils-2.19
mkdir binutils-2.19-build
cd binutils-2.19-build
../binutils-2.19/configure --target=$TARGET --prefix=$PREFIX
make
sudo make install
(2)编译bootstrap gcc
mkdir gcc-4.3.3-build
cd gcc-4.3.3-build
../gcc-4.3.3/configure --target=$TARGET --prefix=$PREFIX --enable-languages=c --with-local-prefix=$PREFIX/i686-linux
--without-headers --with-newlib --disable-shared --disable-threads --disable-libmudflap --disable-libssp
make all-gcc
sudo make install-gcc
make all-target-libgcc
sudo make install-target-libgcc
(3)建立linux头文件
tar jxf linux-2.6.29.tar.bz2
cd linux-2.6.29
cp arch/x86/configs/i386_defconfig .config -f
make ARCH=x86 menuconfig
make ARCH=x86 CROSS_COMPILE=$PREFIX/bin/i686-linux- prepare
sudo mkdir -p ${PREFIX}/usr/include
sudo cp include/asm-x86 ${PREFIX}/include/asm -fr
sudo cp include/asm-generic ${PREFIX}/include/asm-generic -fr
sudo cp include/linux ${PREFIX}/include/linux -fr
sudo cp arch/x86/include/asm/* ${PREFIX}/include/asm -fr
(4)编译glibc
tar jxf glibc-2.7.tar.bz2
cd glibc-2.7
sed -i 's/-nostdinc -isystem $ccheaders /-nostdinc -isystem $ccheaders -isystem $ccheaders-fixed /' configure
sed -i 's/-isystem $cxxheaders /-isystem $cxxheaders -isystem $cxxheaders-fixed /' configure
sed -i 's/-lgcc $(libgcc_eh)/-lgcc/' Makeconfig
sed -i 's/-lgcc -lgcc_eh/-lgcc/' Makeconfig
sed -i 's/int temp/short temp/' ./sysdeps/i386/fpu/ftestexcept.c
mkdir glibc-2.7-build
cd glibc-2.7-build
CC='i686-linux-gcc -m32 -march=i486' CXX='i686-linux-gcc -m32 -march=i486' CFLAGS='-O2 -g -fno-stack-protector'
../glibc-2.7/configure --host=i686-linux --prefix=${PREFIX} --enable-add-ons
--with-headers=${PREFIX}/include libc_cv_forced_unwind=yes libc_cv_c_cleanup=yes
make
sudo make install
如果编译错误,把glibc-2.7-build/config.h的#define HAVE_LIBCAP 1这一行注释掉
(5)final gcc
mkdir gcc-4.3.3-build-final
cd gcc-4.3.3-build-final
../gcc-4.3.3/configure --target=$TARGET --prefix=$PREFIX --enable-languages=c,c++ --with-local-prefix=$PREFIX/$TARGET
make
sudo make install
(6)调整工具链
暂时不做,库就放在/opt/i686里面。contact msn: jinglexy at yahoo.com.cn
2009.04.11
上海莘庄绿地蓝海大厦A座210
阅读(1902) | 评论(1) | 转发(0) |