免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1076 | 回复: 0
打印 上一主题 下一主题

编译toolchain arm-linux-gcc 3.3.2脚本解释 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-06-17 23:04 |只看该作者 |倒序浏览

这里给出建立toolchain.3.3.2的脚本(注意,必须先设置内核头文件,如上所述):
gcc-3.3.2.tar.bz2
glibc-2.3.2.tar.bz2,
binutils-head.tar.bz2,
glibc-linuxthreads-2.3.2.tar.bz2
这里是host:i386,target:arm

#!/bin/sh -e

set -v

build_binutils=yes
build_bootstrap=yes
build_glibc=yes

#  With thanks to erik mouw, jeff sutherland, and many others
PREFIX=/usr/local/arm/3.3.2     #建立的toolchain的位置,可根据需要自己设定
HOST=i686-pc-linux-gnu           #host类型
#KERNEL=/work/kernel.h3900
KERNEL=YourKernel目录         #这里要注意,不然找不到配置头文件
TGT=arm-linux
DNLD=/work/gcc-downloads      #放置建立toolchain所需要的工具包,把工具包搞到里面去
BLD=/work/arm                 #建立toolchain的编译工作目录
#GCC=gcc-3.3-cvs
GCC=gcc-3.3.2                    #这几个指定工具包的版本
GLIBC=glibc-2.3.2
GLIBC_THREADS=glibc-linuxthreads-2.3.2
BINUTILS=binutils-head

if [ "x$build_bootstrap" = "xyes" ] ; then
[ -d $PREFIX ] && rm -rf $PREFIX/*
fi

mkdir -p $PREFIX $BLD
pushd $BLD
export PATH=${PREFIX}/bin:$PATH
echo "Versions" > ${PREFIX}/VERSIONS
echo "  $GCC" >> ${PREFIX}/VERSIONS
echo "  $GLIBC" >> ${PREFIX}/VERSIONS
echo "  $BINUTILS" >> ${PREFIX}/VERSIONS

# binutils
if [ "x$build_binutils" = "xyes" ] ; then
echo "Tool chain binutils configuration:" >> ${PREFIX}/VERSIONS
echo "../${BINUTILS}/configure --target=$TGT --prefix=$PREFIX --host=$HOST" >> ${PREFIX}/VERSIONS
echo "" >> ${PREFIX}/VERSIONS
rm -rf $BINUTILS ${BINUTILS}-bld
tar jxf ${DNLD}/${BINUTILS}.tar.bz2
mkdir -p ${BINUTILS}-bld
cd ${BINUTILS}-bld
../${BINUTILS}/configure --target=$TGT --prefix=$PREFIX --host=$HOST || exit 1
make || exit 1
make install || exit 1
cd ..
rm -rf $BINUTILS ${BINUTILS}-bld
fi
export PATH=$PREFIX/bin:$PATH

# bootstrap compiler
if [ "x$build_bootstrap" = "xyes" ] ; then
rm -rf $GCC ${GCC}-bld
tar jxf ${DNLD}/${GCC}.tar.bz2
mkdir -p ${GCC}-bld
perl -pi -e 's/^(TARGET_LIBGCC2_CFLAGS.*)/$1 -Dinhibit_libc -D__gthr_posix_h/' ${GCC}/gcc/config/arm/t-linux
echo 'T_CFLAGS = -Dinhibit_libc -D__gthr_posix_h' >> ${GCC}/gcc/config/arm/t-linux
cd ${GCC}-bld
../${GCC}/configure --target=$TGT --prefix=$PREFIX --host=$HOST --with-cpu=strongarm1100 --with-headers=$KERNEL/include --disable-shared --disable-threads --enable-languages="c" || exit 1
make || exit 1
make install || exit 1
cd ..
rm -rf $GCC ${GCC}-bld
fi

# glibc
if [ "x$build_glibc" = "xyes" ] ; then
echo "Tool chain glibc configuration:" >> ${PREFIX}/VERSIONS
echo "../${GLIBC}/configure --host=$TGT --build=$HOST --with-headers=$KERNEL/include --enable-add-ons=linuxthreads --enable-shared --prefix=$PREFIX" >> ${PREFIX}/VERSIONS
echo "" >> ${PREFIX}/VERSIONS
rm -rf $GLIBC ${GLIBC}-bld
tar jxf ${DNLD}/${GLIBC}.tar.bz2
tar -C $GLIBC -jxf ${DNLD}/${GLIBC_THREADS}.tar.bz2
pushd ${BLD}/${GLIBC}
export CC=arm-linux-gcc
( cat

sed -e '/*** BUG/d' ${PREFIX}/lib/libc.so > ${PREFIX}/lib/libc.so.new
mv -f ${PREFIX}/lib/libc.so.new -f ${PREFIX}/lib/libc.so
sed -e '/*** BUG/d' ${PREFIX}/lib/libpthread.so > ${PREFIX}/lib/libpthread.so.new
mv -f ${PREFIX}/lib/libpthread.so.new -f ${PREFIX}/lib/libpthread.so
# complete compiler
echo "Tool chain gcc configuration" >> ${PREFIX}/VERSIONS
echo "../${GCC}/configure --target=arm-linux --with-cpu=strongarm1100 --prefix=$PREFIX $HOST --with-headers=$KERNEL/include --enable-threads=pthreads --enable-shared --enable-static --enable-languages=c,c++" >> ${PREFIX}/VERSIONS
echo "" >> ${PREFIX}/VERSIONS
tar jmxf ${DNLD}/${GCC}.tar.bz2
mkdir -p ${GCC}-bld
#perl -pi -e 's/int namelen/unsigned int namelen/' ${GCC}/libjava/java/net/natInetAddress.cc
cd ${GCC}-bld
../${GCC}/configure --target=$TGT --with-cpu=strongarm1100 --prefix=$PREFIX $HOST --with-headers=$KERNEL/include --enable-threads=pthreads --enable-shared --enable-static --enable-languages="c,c++" || exit 1
make || exit 1
make install || exit 1
cd ..
rm -rf $GCC ${GCC}-bld
pushd ${PREFIX}/lib
find ../${TGT}/lib -name "lib*" -type f -exec ln -sf {} . \;

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/15906/showart_129350.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP