基于3c2410的linux2.6.22移植(2)
2016-04-29 来源:eefocus
(5) 开始编译 编译的过程主要有6个步骤;
a. 内核头文件的生成
b. Binary utilties的生成
c. Glibc头文件的生成
d. 第一阶段gcc的生成
e. glibc库文件的生成
f. 完整编译工具的生成
注:生成第一阶段gcc主要是用来生成glibc库文件。
1、 生成内核头文件
$root@host:/home/arm/kernel# tar xvjf linux-2.6.22.tar.bz2
$root@host:/home/arm/kernel# cd linux-2.6.22
$root@host:/home/arm/kernel/linux-2.6.22#
make ARCH=arm CROSS_COMPILE=arm-linux- menuconfig
其中menuconfig指定了配置界面,可用的还有config(全字符界面) xconfig(xwindow下的图形界面)。Ubuntu需要安装tk8.4以支持xconfig。另外需要将mawk卸载,安装gawk。(mawk有bug)
linux2.6的内核提供了对s3c2410的支持。在system中选上s3c2410系列就可以了。配置完毕退出保存。
$root@host:/home/arm/kernel/linux-2.6.22# cd include
$root@host:/home/arm/kernel/linux-2.6.22/include# cd linux
$root@host:/home/arm/kernel/linux-2.6.22/include/linux# ls version.h autoconf.h
version.h autoconf.h
这2个文件在后面的编译中会用到。如果没有,退到内目录下make version.h就可以了。
下面建立链接:
$root@host:/home/arm/kernel/linux-2.6.22/include# ln –s asm-arm asm
$root@host:/home/arm/kernel/linux-2.6.22/include# ln -s asm/arch-s3c2410 asm/arch
将内核头文件拷贝到最终安装目录下:
$root@host:/home/arm/kernel/linux-2.6.22/include# mkdir –p ${TARGET_PREFIX}/include
cp –r asm- ${TARGET_PREFIX}/include
$root@host:/home/arm/kernel/linux-2.6.22/include# cp –r linux ${TARGET_PREFIX}/include
$root@host:/home/arm/kernel/linux-2.6.22/include# cp –d asm ${TARGET_PREFIX}/include
至此内核头文件建立完毕。
2、 建立Binary utilities:
binutils是一些二进制工具的集合,其中常用的是as ,ar和ld。
$root@host:/home/arm/kernel/include# cd ${PRJROOT}/build-tools
$root@host:/home/arm/build-tools# tar xvjf binutils-2.18.tar.bz2
$root@host:/home/arm/build-tools# cd build-binutils
$root@host:/home/arm/build-tools/build-binutils#
patch –Np1 –i /home/arm/build-tools/patch/binutils-2.18*
$root@host:/home/arm/build-tools/build-binutils#
../binutils-2.18/configure --target=${TARGET} –prefix=${PREFIX}
$root@host:/home/arm/build-tools/build-binutils# make
$root@host:/home/arm/build-tools/build-binutils# make install
${PREFIX}/bin下应该生成一些以arm-linux开头的文件
$root@host:/home/arm/build-tools/build-binutils# ls ${PREFIX}/bin
3、 生成glibc头文件:
$root@host:/home/arm/build-tools/build-binutils# cd ..
$root@host:/home/arm/build-tools/# tar xvjf glibc-2.6.1.tar.bz2
$root@host:/home/arm/build-tools/#
tar xvzf glibc-ports-2.6.1.tar.gz --directory ./glibc-2.6.1/
$root@host:/home/arm/build-tools/# cd glibc-2.6.1
$root@host:/home/arm/build-tools/glibc-2.6.1# mv glibc-ports-2.6.1 ports –v
打上补丁:
$root@host:/home/arm/build-tools/glibc-2.6.1#
patch –Np1 –i /home/arm/build-tools/patch/glibc-2.6.1-*patch
$root@host:/home/arm/build-tools/glibc-2.6.1# cd ..
$root@host:/home/arm/build-tools/# cd build-glibc-headers
这里需要添加对NPTL线程库的支持:
$root@host:/home/arm/build-tools/build-glibc-headers#
echo “libc_cv_forced_unwind=yes”>>config.cache
echo “libc_cv_c_cleanup=yes”>>config.cache
echo “libc_cv_arm_tls=yes”>>config.cache
注:如果编译中出现”cannot compute long double size”,添加:
echo “ac_cv_sizeof_long_double=12”>>config.cache
$root@host:/home/arm/build-tools/build-glibc-headers#
../glibc-2.6.1/configure --host=${TARGET} --prefix=”/usr” --enable-add-ons
--with-headers=${TARGET_PREFIX}/include --cache-file=config.cache
$root@host:/home/arm/build-tools/build-glibc-headers#
make cross-compiling=yes install_root=${TARGET_PREFIX} prefix=””
install-headers
$root@host:/home/arm/build-tools/build-glibc-headers#
mkdir –p ${TARGET_PREFIX}/include/gnu
$root@host:/home/arm/build-tools/build-glibc-headers#
touch ${TARGET_PREFIX}/include/gnu/stubs.h
注:如果编译过程中出现找不到头文件的错误,可以根据错误提示的文件名用touch命令在相应目录下建立一个空文件,一般就可以编译通过了。
进入单片机查看更多内容>>
a.
b.
c.
d.
e.
f.
1、 生成内核头文件
$root@host:/home/arm/kernel# tar xvjf linux-2.6.22.tar.bz2
$root@host:/home/arm/kernel# cd linux-2.6.22
$root@host:/home/arm/kernel/linux-2.6.22#
make ARCH=arm CROSS_COMPILE=arm-linux- menuconfig
其中menuconfig指定了配置界面,可用的还有config(全字符界面) xconfig(xwindow下的图形界面)。Ubuntu需要安装tk8.4以支持xconfig。另外需要将mawk卸载,安装gawk。(mawk有bug)
linux2.6的内核提供了对s3c2410的支持。在system中选上s3c2410系列就可以了。配置完毕退出保存。
$root@host:/home/arm/kernel/linux-2.6.22# cd include
$root@host:/home/arm/kernel/linux-2.6.22/include# cd linux
$root@host:/home/arm/kernel/linux-2.6.22/include/linux# ls version.h autoconf.h
version.h autoconf.h
这2个文件在后面的编译中会用到。如果没有,退到内目录下make version.h就可以了。
下面建立链接:
$root@host:/home/arm/kernel/linux-2.6.22/include# ln –s asm-arm asm
$root@host:/home/arm/kernel/linux-2.6.22/include# ln -s asm/arch-s3c2410 asm/arch
将内核头文件拷贝到最终安装目录下:
$root@host:/home/arm/kernel/linux-2.6.22/include# mkdir –p ${TARGET_PREFIX}/include
$root@host:/home/arm/kernel/linux-2.6.22/include# cp –rd asm-arm ${TARGET_PREFIX}/include
$root@host:/home/arm/kernel/linux-2.6.22/include#cp –r asm- ${TARGET_PREFIX}/include
$root@host:/home/arm/kernel/linux-2.6.22/include# cp –r linux ${TARGET_PREFIX}/include
$root@host:/home/arm/kernel/linux-2.6.22/include# cp –d asm ${TARGET_PREFIX}/include
至此内核头文件建立完毕。
2、 建立Binary utilities:
binutils是一些二进制工具的集合,其中常用的是as ,ar和ld。
$root@host:/home/arm/kernel/include# cd ${PRJROOT}/build-tools
$root@host:/home/arm/build-tools# tar xvjf binutils-2.18.tar.bz2
$root@host:/home/arm/build-tools# cd build-binutils
$root@host:/home/arm/build-tools/build-binutils#
patch –Np1 –i /home/arm/build-tools/patch/binutils-2.18*
$root@host:/home/arm/build-tools/build-binutils#
../binutils-2.18/configure --target=${TARGET} –prefix=${PREFIX}
$root@host:/home/arm/build-tools/build-binutils# make
$root@host:/home/arm/build-tools/build-binutils# make install
${PREFIX}/bin下应该生成一些以arm-linux开头的文件
$root@host:/home/arm/build-tools/build-binutils# ls ${PREFIX}/bin
3、 生成glibc头文件:
$root@host:/home/arm/build-tools/build-binutils# cd ..
$root@host:/home/arm/build-tools/# tar xvjf glibc-2.6.1.tar.bz2
$root@host:/home/arm/build-tools/#
tar xvzf glibc-ports-2.6.1.tar.gz --directory ./glibc-2.6.1/
$root@host:/home/arm/build-tools/# cd glibc-2.6.1
$root@host:/home/arm/build-tools/glibc-2.6.1# mv glibc-ports-2.6.1 ports –v
打上补丁:
$root@host:/home/arm/build-tools/glibc-2.6.1#
patch –Np1 –i /home/arm/build-tools/patch/glibc-2.6.1-*patch
$root@host:/home/arm/build-tools/glibc-2.6.1# cd ..
$root@host:/home/arm/build-tools/# cd build-glibc-headers
这里需要添加对NPTL线程库的支持:
$root@host:/home/arm/build-tools/build-glibc-headers#
echo “libc_cv_forced_unwind=yes”>>config.cache
echo “libc_cv_c_cleanup=yes”>>config.cache
echo “libc_cv_arm_tls=yes”>>config.cache
注:如果编译中出现”cannot compute long double size”,添加:
echo “ac_cv_sizeof_long_double=12”>>config.cache
$root@host:/home/arm/build-tools/build-glibc-headers#
../glibc-2.6.1/configure --host=${TARGET} --prefix=”/usr” --enable-add-ons
--with-headers=${TARGET_PREFIX}/include --cache-file=config.cache
$root@host:/home/arm/build-tools/build-glibc-headers#
make cross-compiling=yes install_root=${TARGET_PREFIX} prefix=””
install-headers
$root@host:/home/arm/build-tools/build-glibc-headers#
mkdir –p ${TARGET_PREFIX}/include/gnu
$root@host:/home/arm/build-tools/build-glibc-headers#
touch ${TARGET_PREFIX}/include/gnu/stubs.h
注:如果编译过程中出现找不到头文件的错误,可以根据错误提示的文件名用touch命令在相应目录下建立一个空文件,一般就可以编译通过了。
相关文章
最新器件