======================================================================
HOST 시스템 환경
autoconf 2.13
automake 1.11.1
texinfo-4.6
GCC : 4.1.3 or 4.4.3 (sudo apt-get install gcc-4.1)
gettext (sudo apt-get install gettext)
gawk (sudo apt-get install gawk)

======================================================================
BUILD 시스템 build_root 설정
export XTARGET=arm-linux  or  export XTARGET=arm-unknown-linux-gnueabi
export XBUILDSRC=path/to/src/root ($HOME/workspace/x-tool/src)
export XBUILDROOT=path/to/build-install/root ($HOME/workspace/x-tool/usr)
======================================================================

[[[[[ KERNEL HEADER or KERNEL LIBC HEADER ]]]]] - linux-2.6.25이후, chipset별 header 위치가 다름.
glibc를 빌드할때 include/asm-$ARCH(asm), include/asm-generic, include/linux 폴더의 헤더가 필요함
cd $XSRCROOT
w get ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.25.tar.gz
tar xzvf linux-2.6.25.tar.gz
ln -s linux-2.6.25 linux

-----------------------------------------------------------------
Kernel Config.
arm.config or eabi_arm.config



mv arm.config $XBUILDSRC/linux/.config
// config 중, system type, architecture를 확인해야 한다.
cd linux
make ARCH=arm menuconfig or make ARCH=arm oldconfig
-----------------------------------------------------------------
or
// config 중, system type, architecture를 확인해야 한다.
make ARCH=arm versatile_defconfig
make ARCH=arm menuconfig
-----------------------------------------------------------------

// toolchain이 참조할 헤더 구조를 만들어준다.
make ARCH=arm include/asm include/linux/version.h include/asm-arm/.arch
==> 이후 버전의 리눅스 커널은 headers_install 명령을 사용하면 되는데 참조할 헤더의 위치는 지정(INSTALL_HDR_DIR??)할 수도 있고 default로 linux/usr/include 일 것이다.
(make ARCH=arm headers_install)

#cd include
#ln -s asm-arm asm
======================================================================

cd $XBUILDSRC
[[[[[ BINUTIL ]]]]] - binutil-2.19.1
w get ftp://ftp.gnu.org/gnu/binutils/binutils-2.19.1.tar.gz
tar xzvf binutils-2.19.1.tar.gz
- ARM 패치
binutils-2.19.arm.patch



cd binutil-2.19.1
cat ../binutils-2.19.arm.patch | patch -p1
mkdir buildx & cd buildx
../configure --target=$XTARGET --prefix=$XBUILDROOT
make & make install

// lib 링크 변경
cd $XBUILDROOT/$XTARGET
mv lib lib.bak
ln ../lib lib
==> 이거 안하면 GCC cross-compiler 빌드시에 glibc 라이브러리를 못찾음

## 추가사항
[2011.06.30]
- 2.21버전에는 위의 arm patch가 들어가 있음
- gas/config/tc-arm.c : 'firsttype$defined' may be used uninitialized in this function ==> configure 옵션에 --diasble-werror 추가해서 임시 처리함


======================================================================

[[[[[ BOOTSTRAP GCC ]]]]] - gcc-4.4.3
cd $XBUILDSRC
w get ftp://ftp.gnu.org/gnu/gcc/gcc-4.4.3/gcc-4.4.3.tar.gz
tar xzvf gcc-4.4.3.tar.gz
mv gcc-4.4.3 gcc-4.4.3-bootstrap
cd gcc-4.4.3-bootstrap
// gcc source modify
perl -pi -e 's/^(TARGET_LIBGCC2_CFLAGS.*)/$1 -Dinhibit_libc -D__gthr_posix_h/' gcc/config/arm/t-linux
echo 'T_CFLAGS = -Dinhibit_libc -D__gthr_posix_h' >> gcc/config/arm/t-linux

// bootstrap gcc configure
gccpatch_libgcc_mvars.patch



cat ../gccpatch_libgcc-mvars.patch | patch -p0

gccpatch_130-cross-compile.patch



cat ../gccpatch_130-cross-compile.patch | patch -p1

gcc4.x 빌드를 위해 GMP, MPFR이 필요함
sudo apt-get install libgmp3-dev
sudo apt-get install libmpfr-dev

mkdir buildx & cd buildx

// arm-linux
../configure --target=$XTARGET --prefix=$XBUILDROOT --disable-multilib --with-newlib --disable-nls --disable-threads --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c --disable-shared --without-headers --disable-libmudflap --disable-libssp --disable-libgomp

or

// arm-eabi
../configure --target=$XTARGET --prefix=$XBUILDROOT --disable-multilib --with-newlib --disable-nls --disable-threads --enable-symvers=gnu --enable-__cxa_atexit --enable-languages=c --disable-shared --with-float=soft --enable-cxx-flags=-msoft-float --without-headers --disable-libmudflap --disable-libssp --disable-libgomp

make & make install

## 추가사항
[2011.06.30]
- 4.6.0 버전 : sudo apt-get install libmpc-dev
                     --disable-libquadmath : GCC_EXECUTABLE 어쩌고 에러

======================================================================

[[[[[ GLIBC ]]]]] - glibc-2.10.1, glibc-ports-2.10.1
cd $XBUILDSRC
w get ftp://ftp.gnu.org/gnu/glibc/glibc-2.10.1.tar.gz
w get ftp://ftp.gnu.org/gnu/glibc/glibc-ports-2.10.1.tar.gz

mv glibc-ports-2.10.1 ./glibc-2.10.1
mv glibc-2.10.1/glibc-ports-2.10.1 glibc-2.10.1/ports

cd glibc-2.10.1
Makeconfig에서 -lgcc_eh 부분 제거

export PATH=$XBUILDROOT/bin:$PATH

mkdir buildx & cd buildx
// glibc configure
echo "libc_cv_forced_unwind=yes" > config.cache
echo "libc_cv_c_cleanup=yes"    >> config.cache

##추가사항
[2011.06.30]
(glibc-2.13 테스트) echo "libc_cv_asm_cfi_directive_sections=yes" >> config.cache

//arm-linux
CC=$XTARGET-gcc AR=$XTARGET-ar RANLIB=$XTARGET-ranlib ../configure --prefix=$XBUILDROOT --build=i686-pc-linux-gnu --host=$XTARGET --without-cvs --disable-profile --disable-debug --without-gd --enable-shared --enable-add-ons=ports,nptl --with-headers=$XBUILDSRC/linux/include --includedir=$XBUILDROOT/$XTARGET/include --disable-sanity-checks --cache-file=config.cache

or

//arm-eabi
CC=$XTARGET-gcc AR=$XTARGET-ar RANLIB=$XTARGET-ranlib ../configure --prefix=$XBUILDROOT --build=i686-pc-linux-gnu --host=$XTARGET --without-cvs --disable-profile --disable-debug --without-gd --enable-shared --enable-add-ons=ports,nptl --with-headers=$XBUILDSRC/linux/usr/include --with-tls --with-__thread --includedir=$XBUILDROOT/$XTARGET/include --disable-sanity-checks --cache-file=config.cache

make & make install


## 추가사항
[2011.06.30]
2.13버전 컴파일시에 .cfi_sections 관련 에러 ==> http://www.uclibc.org/downloads/ChangeLog-0.9.31_0.9.32
신규 pseudo op를 지원하지 않는 binutil을 사용하면 에러(ex.cfi_section)나므로 최신 binutil을 사용할 것



======================================================================

[[[[[ GCC CROSS COMPILER ]]]]]
cd $XBUILDSRC
w get ftp://ftp.gnu.org/gnu/gcc/gcc-4.4.3/gcc-4.4.3.tar.gz
tar xzvf gcc-4.4.3.tar.gz
mv gcc-4.4.3 gcc-4.4.3-cross
cd gcc-4.4.3-cross
mkdir buildx & cd buildx
// gcc configure

//arm-linux
../configure --target=$XTARGET --prefix=$XBUILDROOT --disable-nls --enable-__cxa_atexit --enable-languages=c,c++,fortran,objc --enable-c99 --enable-long-long --enable-shared --enable-multilib --with-headers=$XBUILDSRC/linux/include

or

//arm-eabi
../configure --target=$XTARGET --prefix=$XBUILDROOT --disable-nls --enable-__cxa_atexit --enable-languages=c,c++,fortran,objc --enable-c99 --enable-long-long --enable-shared --enable-multilib --with-float=soft --enable-cxx-flags=-msoft-float --with-headers=$XBUILDSRC/linux/usr/include

gcc의 --with-header configure 옵션은 해당 경로의 헤더를 prefix/target 하위의 sys-include 폴더($XBUILDROOT/$XTARGET/sys-include)를 생성하고 거기에 복사하도록 작동한다

make & make install

## 추가사항
[2011.07.04]
4.6.1버전 - --with-system-zlib configure 추가


Toolchain을 이용해 컴파일 시, 실제 타겟 architecture에 맞게 컴파일 옵션을 주어야한다.
==> 참조문서
ex. $XTARGET-gcc -march=armv6k -o hello hello.c




2010/08/31 18:31 2010/08/31 18:31
Posted by scott

트랙백 주소 :: 이 글에는 트랙백을 보낼 수 없습니다