阅读:4264回复:5
(转)linux 2.6 交叉编译工具链制作详解
生成Linux2.6交叉编译工具链
Linux kernel 2.6 交叉编译工具链 本文由思考树整理,转载请注明出处,谢谢。 (本文根据网上资料修改而成,确保每步都正确执行。) 软件包准备(请到ftp.gnu.org下载) binutils-2.15.tar.gz gcc-core-3.4.2.tar.bz2 gcc-g++3.4.2.tar.bz2 glibc-2.3.5.tar.gz glibc-linuxthreads-2.3.5.tar.bz2 linux-2.6.9.tar.gz 我们的工作路径是(用root用户登录): ~/tars/SourceDir ~/tars/BuildDir /armtools # cd ~ # mkdir –p tars/SourceDir # mkdir tars/BuildDir # mkdir /armtools tars --------------- 在这里放我们的下载来的所有源文件 SourceDir ------ 这个临时目录放我们解压缩后的源文件 BuildDir --------- 我们在这里编译 armtools -------- 把arm-linux 交叉编译环境的安装在这里 1.编译binutils # cd ~/tars/SourceDir # tar -zxf ../binutils-2.15.tar.gz # cd ~/tars/BuildDir # mkdir binutils # cd binutils # ../../SourceDir/binutils-2.15/configure --target=arm-linux \ --prefix=/armtools # make ; make install # export PATH=/armtools/bin:$PATH (安装成功。) 2.解压缩,配置,拷贝头文件 # cd ~/tars/SourceDir # tar -zxf ../linux-2.6.9.tar.gz # cd linux-2.6.9 # vi Makefile 把里面的SUBARCH那行 注释掉 # SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ -e s/arm.*/arm/ -e s/sa110/arm/ \ -e s/s390x/s390/ -e s/parisc64/parisc/ ) 然后新加一行SUBARCH := arm # CROSS_COMPILE ?=(注释掉) 然后新加一行CROSS_COMPILE = arm-linux # make menuconfig 选中s3c2410 # make include/linux/version.h就创建了一个在源码目录下include/linux/version.h的文件 # mkdir -p /armtools/arm-linux/include # cp -dR include/asm-arm /armtools/arm-linux/include/asm # cp -dR include/linux /armtools/arm-linux/include/linux (完成) 3.编译gcc-3.4.2 # cd ~/tars/SourceDir # tar -jxf ../gcc-core-3.4.2.tar.bz2 给gcc打一个补丁,在目录gcc-3.4.2/gcc/下编辑一个文件flow.c.diff,内容如下 =============================================================== RCS file: /cvs/gcc/gcc/gcc/flow.c,v retrieving revision 1.593 retrieving revision 1.594 diff -u -r1.593 -r1.594 --- gcc/gcc/flow.c 2004/07/09 03:29:32 1.593 +++ gcc/gcc/flow.c 2004/08/02 13:19:39 1.594 @@ -1865,19 +1865,22 @@ rtx set_src = SET_SRC (pc_set (BB_END (bb))); rtx cond_true = XEXP (set_src, 0); rtx reg = XEXP (cond_true, 0); + enum rtx_code inv_cond; if (GET_CODE (reg) == SUBREG) reg = SUBREG_REG (reg); /* We can only track conditional lifetimes if the condition is - in the form of a comparison of a register against zero. - If the condition is more complex than that, then it is safe - not to record any information. */ - if (REG_P (reg) + in the form of a reversible comparison of a register against + zero. If the condition is more complex than that, then it is + safe not to record any information. */ + inv_cond = reversed_comparison_code (cond_true, BB_END (bb)); + if (inv_cond != UNKNOWN + && REG_P (reg) && XEXP (cond_true, 1) == const0_rtx) { rtx cond_false - = gen_rtx_fmt_ee (reverse_condition (GET_CODE (cond_true)), + = gen_rtx_fmt_ee (inv_cond, GET_MODE (cond_true), XEXP (cond_true, 0), XEXP (cond_true, 1)); if (GET_CODE (XEXP (set_src, 1)) == PC) =================================================================== 用此文件给flow.c打补丁,或者依此文件直接修改flow.c(修改前请备份这两个文件) # cd ~/tars/BuildDir # mkdir gcc-core # cd gcc-core # ../../SourceDir/gcc-3.4.2/configure --target=arm-linux --prefix=/armtools --enable- languages=c --disable-shared --disable-threads --without-headers --with-newlib # make ; make install 4.编译安装glibc # cd ~/tars/SourceDir # tar -zxf ../glibc-2.3.5.tar.gz # cd glibc-2.3.5 # tar -jxf ../../glibc-linuxthreads-2.3.5.tar.gz # cd ~/tars/BuildDir # mkdir glibc # cd glibc # export CC=arm-linux-gcc # cp -dR ~/tars/SourceDir/linux-2.6.9/include/asm-generic /armtools/arm-linux/include/ # vi ~/tars/SourceDir/glibc-2.3.5/sysdeps/unix/sysv/linux/arm/ioperm.c 将里面的BUS_ISA改为CTL_BUS_ISA # vi ~/tars/SourceDir/glibc-2.3.5/Makeconfig,把里面的-lgcc_eh都删掉 # ~/tars/SourceDir/glibc-2.3.5/configure --prefix=/armtools/arm-linux \ --host=arm-linux \ --build=i686-pc-linux-gnu \ --with-headers=/armtools/arm-linux/include \ --enable-add-ons=linuxthreads # make ;make install (这步花了很长时间) 5.编译安装gcc 的c, c++ 编译器。 # cd ~/tars/SourceDir/ # tar -jxf ../gcc-g++-3.4.2.tar.bz2 # cd ~/tars/BuildDir/ # mkdir gcc # cd gcc # unset CC # ../../SourceDir/gcc-3.4.2/configure --prefix=/usr/arm_tools\ --target=arm-linux \ --enable-languages=c,c++ \ --without-headers \ --disable-shared # make ;make install 编辑一个helloworld.c 编译一下,没有问题吧?哈哈 OK,Congratulations! 最后打包压缩一下 # cd ~ # tar -cf armtools.tar /armtools (大小198021120) # bzip2 -z armtools.tar (大小51055772) ************************************************************** |
|
|
沙发#
发布于:2008-05-16 00:30
不错 顶
|
|
板凳#
发布于:2008-05-19 14:13
我严重怀疑我们是否还在社会主义,我们已经进入共产主义时代了!
|
|
地板#
发布于:2008-07-13 21:43
还是2.4的核比较顺手!嘿嘿!
|
|
地下室#
发布于:2008-07-23 22:29
看看啊
|
|
5楼#
发布于:2009-10-11 13:54
谁整理写个bash 脚本 造福大家
|
|