binutils-2.17|gcc-4.1.1|glibc-2.5 作交叉编译器记录要点
iibull
|
1#
iibull 发表于 2008-05-15 13:04
binutils-2.17|gcc-4.1.1|glibc-2.5 作交叉编译器记录要点
author: iibull email: iibull@yahoo.com.cn nick: 阿牛@FUZHOU 20080515
如需转载请注明作者出处。 折腾了一天,终于把arm-linux-gcc4.11搞定了。记录如下,哈哈 免得大家走弯路。顺便预祝女儿周岁生日快乐。 首页要准备好编译用的软件包: 软件包 wget -c http://ftp.gnu.org/gnu/binutils/binutils-2.17.tar.bz2 wget -c http://ftp.gnu.org/gnu/gcc/gcc-4.1.1/gcc-4.1.1.tar.bz2 wget -c http://ftp.gnu.org/gnu/glibc/glibc-2.5.tar.bz2 wget -c http://ftp.gnu.org/gnu/glibc/glibc-ports-2.5.tar.bz2 wget -c http://ftp.gnu.org/gnu/gdb/gdb-6.6.tar.bz2 wget -c http://www.kernel.org/pub/linux/kernel/v2.6/源码文件及各项补丁 patches wget http://svn.cross-lfs.org/svn/rep ... _ioperm_fix-1.patch wget http://svn.cross-lfs.org/svn/rep ... anch_update-3.patch wget http://svn.cross-lfs.org/svn/rep ... cross_hacks-1.patch wget http://svn.cross-lfs.org/svn/rep ... cross_hacks-2.patch wget http://svn.cross-lfs.org/svn/rep ... 5-hppa_nptl-1.patch wget http://svn.cross-lfs.org/svn/rep ... 5-libgcc_eh-1.patch wget http://svn.cross-lfs.org/svn/rep ... 5-libgcc_eh-2.patch wget http://svn.cross-lfs.org/svn/rep ... ef_segfault-1.patch wget http://svn.cross-lfs.org/svn/rep ... .5-mawk_fix-1.patch wget http://svn.cross-lfs.org/svn/rep ... -mips_fixes-1.patch wget http://svn.cross-lfs.org/svn/rep ... cc-4.1.1-32-1.patch wget http://svn.cross-lfs.org/svn/rep ... 1.1-PR20425-1.patch wget http://svn.cross-lfs.org/svn/rep ... 1.1-PR29114-1.patch wget http://svn.cross-lfs.org/svn/rep ... earch_paths-1.patch wget http://svn.cross-lfs.org/svn/rep ... c-4.1.1-n32-1.patch wget http://svn.cross-lfs.org/svn/rep ... 4.1.1-posix-1.patch wget http://svn.cross-lfs.org/svn/rep ... .1.1-pure64-1.patch wget http://svn.cross-lfs.org/svn/rep ... ure64_specs-1.patch wget http://svn.cross-lfs.org/svn/rep ... 1-sparc_tls-1.patch wget http://svn.cross-lfs.org/svn/rep ... 4.1.1-specs-1.patch wget http://svn.cross-lfs.org/svn/rep ... 1-specs_n32-1.patch wget http://svn.cross-lfs.org/svn/rep ... .1.1-uclibc-1.patch wget http://svn.cross-lfs.org/svn/rep ... anch_update-1.patch wget http://svn.cross-lfs.org/svn/rep ... anch_update-2.patch wget http://svn.cross-lfs.org/svn/rep ... anch_update-3.patch wget http://svn.cross-lfs.org/svn/rep ... ts_multilib-1.patch wget http://svn.cross-lfs.org/svn/rep ... 17-hppa_tls-1.patch wget http://svn.cross-lfs.org/svn/rep ... -2.17-posix-1.patch wget http://svn.cross-lfs.org/svn/rep ... 2.17-uclibc-1.patch 安装一些可能需要的软件包: sudo apt-get install bison flex texinfo gawk 整个编译过程的工作目录: sudo mkdir /crosstool sudo chmod a+rwx /crosstool cd /crosstool mkdir linux-2.6.20 mkdir -p src/patches linux-2.6.20存放要用到的内核头文件,patches存放需要的补丁,src存放要用到的软件包 PS:编译完成后的文件将安装到 ~/arm-linux上 设置一些环境变量 (~/.bashrc) export CLFS_HOST="$(echo $MACHTYPE | sed "s/$(echo ${MACHTYPE} | cut -d- -f2)/cross/")" export CLFS_TARGET="arm-linux" export CLFS=/crosstool/arm-linux export PATH=$CLFS/bin:$CLFS/cross-tools/bin:$PATH unset CFLAGS unset CXXFLAGS source ~/.bashrc 使之生效 新建头文件存放地址 install -dv $CLFS/include install -dv $CLFS/usr install -dv $CLFS/usr/include 安装内核头文件: 新建保存头文件的目录,并生成linux/version.h文件指示内核版本,如果缺少这个文件后面编译会出错 install -dv ${CLFS}/usr/include cd linux-2.6.20 make include/linux/version.h 复制必要的头文件和与体系结构(arm)相关的头文件 install -dv ${CLFS}/usr/include cp -av include/{asm-generic,linux,mtd,scsi,sound} ${CLFS}/usr/include cp -av include/asm-arm ${CLFS}/usr/include/asm 编译binutils-2.17: #打上必要的补丁 cd src tar jxvf binutils-2.17.tar.bz2 cd binutils-2.17 patch -Np1 -i ../patches/binutils-2.17-posix-1.patch (不要乱打补丁,否则make不成功) 创建编译目录: mkdir -v ../binutils-build cd ../binutils-build 配置configure: ../binutils-2.17/configure --prefix=${CLFS}/cross-tools --host=${CLFS_HOST} --target=${CLFS_TARGET} --with-sysroot=${CLFS} --disable-nls --enable-shared --disable-multilib 编译binutils: make configure-host make 安装binutils到 ${CLFS}/cross-tools: make install 打开${CLFS}/cross-tools/bin,就会发现生成了好多arm-linux-开头的文件 以后会用到下面这个头文件,所以安装到include: cp -v ../binutils-2.17/include/libiberty.h ${CLFS}/usr/include 安装 glibc的头文件到内核头文件中 编译glibc的时候需要glibc的头文件,所以要复制到内核头文件夹中 cd src tar jxvf glibc-2.5.tar.bz2 cd glibc-2.5 去处glibc的gcc 3.4.x依赖 cp configure{,.orig} sed -e 's/3.4/3.[0-9]/g' configure.orig > configure 安装glibc的arm支持: tar -jxvf ../glibc-ports-2.5.tar.bz2 mv -v glibc-ports-2.5 ports 新建编译目录: mkdir -v ../glibc-build_1 cd ../glibc-build_1 添加NPTL线程库支持: echo "libc_cv_forced_unwind=yes" > config.cache echo "libc_cv_c_cleanup=yes" >> config.cache echo "libc_cv_arm_tls=yes" >> config.cache 指定安装路径: echo "install_root=${CLFS}" > configparms 配置configure CC=gcc ../glibc-2.5/configure --prefix=/usr --host=${CLFS_TARGET} --build=${CLFS_HOST} --with-headers=${CLFS}/usr/include --cache-file=config.cache 安装glibc头文件: make install-headers ##(vi ../glibc-2.5/scripts/gen-sorted.awk出现错误时19/59/65行修改代码把 \[^\] 改成 \[\^]) 或者装gawk工具 cp -v bits/stdio_lim.h ${CLFS}/usr/include/bits touch ${CLFS}/usr/include/gnu/stubs.h cp -v ../glibc-2.5/ports/sysdeps/unix/sysv/linux/arm/nptl/bits/pthreadtypes.h ${CLFS}/usr/include/bits |