1.代碼結構為:
setup ---》 源代碼壓縮包
src ---》源碼
binutils-2.24 gcc-4.7.1 gdb-7.6.2 glibc-2.18
build --》 編譯目錄
:~/code/cross-compile$ ls build/
binutils gcc gdb glibc
kernel ----》 內核代碼:
~/code/cross-compile/kernel$ ls
linux-3.10
2.編譯 binutils
在build/binutils 下,執行命令:
。./。./src/binutils-2.24/configure --target=mipsel-linux-gnueabi --prefix=/home/charles/code/cross-compile/embedded-toolchain/cross-tools --with-sysroot=/home/charles/code/cross-compile/embedded-toolchain
然后,執行 make, make install 安裝
3. 編譯 GCC stage 1
在 build/gcc目錄下,執行
AR=ar LDFLAGS=“-Wl,-rpath=/home/charles/code/cross-compile/embedded-toolchain/cross-tools/lib” 。./。./src/gcc-4.7.1/configure --prefix=/home/charles/code/cross-compile/embedded-toolchain/cross-tools --target=mipsel-linux-gnueabi --with-sysroot=/home/charles/code/cross-compile/embedded-toolchain --with-gmp=/usr/local --with-mpfr=/usr/local --with-ppl=/usr/local --with-newlib --without-headers --disable-multilib --disable-nls --disable-decimal-float --disable-libgomp --disable-libmudflap --disable-libssp --disable-shared --disable-threads --enable-languages=c --with-float=soft --with-arch=mips32r2 --with-tune=mips32r2
然后,
make all-gcc all-target-libgcc
make install-gcc install-target-libgcc
4. 安裝內核頭文件
進入到內核代碼目錄,
執行命令:
ARCH=mips make mrproper
ARCH=mips make headers_check
ARCH=mips CROSS_COMPILE=mipsel-gcc-linux-gnueabi make INSTALL_HDR_PATH=/home/charles/code/cross-compile/embedded-toolchain/usr headers_install
find /home/charles/code/cross-compile/embedded-toolchain/usr/include/ -name “.install” -or -name “。.install.cmd” | xargs rm -fv ;\
5. 編譯 GLIBC
進入到 build/glibc,執行
BUILD_CC=gcc CC=mipsel-linux-gnueabi-gcc AR=mipsel-linux-gnueabi-ar RANLIB=mipsel-linux-gnueabi-ranlib 。./。./src/glibc-2.18/configure --prefix=/usr --host=mipsel-linux --enable-add-ons --with-fp=no libc_cv_forced_unwind=yes libc_cv_c_cleanup=yes libc_cv_ctors_header=yes --with-tune=mips32r2 --with-arch=mips32r2 --with-headers=/home/charles/code/cross-compile/embedded-toolchain/usr/include
把步驟3生成的mipsel gcc 加入到 path:
export PATH=$PATH:/home/charles/code/cross-compile/embedded-toolchain/cross-tools/bin
執行
make
make install install_root=/home/charles/code/cross-compile/embedded-toolchain
6.編譯最后的GCC
AR=ar LDFLAGS=“-Wl,-rpath=/home/charles/code/cross-compile/embedded-toolchain/cross-tools/lib” 。./。./src/gcc-4.7.1/configure --prefix=/home/charles/code/cross-compile/embedded-toolchain/cross-tools --target=mipsel-linux-gnueabi --with-sysroot=/home/charles/code/cross-compile/embedded-toolchain --with-gmp=/usr/local --with-mpfr=/usr/local --with-ppl=/usr/local --disable-multilib --disable-libssp --disable-nls --disable-libstdcxx-pch --with-arch=mips32r2 --with-tune=mips32r2 --enable-languages=c,c++ --with-float=soft --with-mips-plt --disable-libgomp --disable-libmudflap --enable-poison-system-directories --enable-symvers=gnu --enable-long-long --enable-threads --enable-shared --enable-lto --enable-__cxa_atexit --with-gnu-as --with-gnu-ld
再執行
make all-gcc -j10 -i -k
make all-target-libgcc
make install-gcc
make install-target-libgcc
make
make install
最后,看一下生成的gcc的信息:
。/mipsel-linux-gnueabi-gcc -v
Using built-in specs.
COLLECT_GCC=。/mipsel-linux-gnueabi-gcc
COLLECT_LTO_WRAPPER=/home/charles/toolchain/embedded-toolchain/cross-tools/bin/。./libexec/gcc/mipsel-linux-gnueabi/4.7.1/lto-wrapper
Target: mipsel-linux-gnueabi
Configured with: 。./。./src/gcc-4.7.1/configure --prefix=/home/charles/code/cross-compile/embedded-toolchain/cross-tools --target=mipsel-linux-gnueabi --with-sysroot=/home/charles/code/cross-compile/embedded-toolchain --with-gmp=/usr/local --with-mpfr=/usr/local --with-ppl=/usr/local --disable-multilib --disable-libssp --disable-nls --disable-libstdcxx-pch --with-float=soft --with-arch=mips32r2 --with-tune=mips32r2 --enable-languages=c,c++ --with-float=soft --with-mips-plt --disable-libgomp --disable-libmudflap --enable-poison-system-directories --enable-symvers=gnu --enable-long-long --enable-threads --enable-shared --enable-lto --enable-__cxa_atexit --with-gnu-as --with-gnu-ld
Thread model: posix
gcc version 4.7.1 (GCC)
-
Linux
+關注
關注
87文章
11296瀏覽量
209357 -
開發工具鏈
+關注
關注
0文章
12瀏覽量
1588
發布評論請先 登錄
相關推薦
評論