2008年4月16日水曜日

build gcc for ARM

(1) gccのコンパイルの前に,codesourceryからダウンロードしたARM GNU/Linux の バイナリを展開し,ターゲット用のヘッダとライブラリ一式をホスト環境へコピーしておく。
$ bunzip2 -c arm-2008q1-126-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2 | tar xvf -
$ cd arm-2008q1
$ sudo cp -r arm-none-linux-gnueabi/libc /opt/codesourcery/arm-none-linux-gnueabi/libc

(2) gccのソースファイルを展開する。
$ bunzip2 -c gcc-2008q1-126.tar.bz2 | tar xf -

(3) binutilsの場合と同様に,pdf をインストールしないようあらかじめMakefile.inを修正しておく。
*** gcc-4.2/Makefile.in 2008-04-17 01:22:09.000000000 +0900
--- gcc-4.2/Makefile.in.orig 2008-04-17 01:21:51.000000000 +0900
***************
*** 2352,2358 ****
@r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(MAKE) $(RECURSE_FLAGS_TO_PASS) installdirs \
! install-host install-target install-html

.PHONY: install-host-nogcc
install-host-nogcc: \
--- 2352,2358 ----
@r=`${PWD_COMMAND}`; export r; \
s=`cd $(srcdir); ${PWD_COMMAND}`; export s; \
$(MAKE) $(RECURSE_FLAGS_TO_PASS) installdirs \
! install-host install-target install-html install-pdf

.PHONY: install-host-nogcc
install-host-nogcc: \

*** gcc-4.2/gcc/Makefile.in 2008-04-17 01:22:48.000000000 +0900
--- gcc-4.2/gcc/Makefile.in.orig 2008-04-17 01:22:25.000000000 +0900
***************
*** 3779,3785 ****
# Install the driver last so that the window when things are
# broken is small.
install: install-common $(INSTALL_HEADERS) $(INSTALL_LIBGCC) \
! install-cpp install-man install-info install-html \
install-@POSUB@ install-driver

# Handle cpp installation.
--- 3779,3785 ----
# Install the driver last so that the window when things are
# broken is small.
install: install-common $(INSTALL_HEADERS) $(INSTALL_LIBGCC) \
! install-cpp install-man install-info install-html install-pdf \
install-@POSUB@ install-driver

# Handle cpp installation.

(4) arm-2008q1-126-arm-none-linux-gnueabi.sh のbuild手順を参考に arm 用の gcc をコンパイルする。
$ mkdir -p BUILD/gcc-final
$ pushd BUILD/gcc-final
$ export AR_FOR_TARGET=arm-none-linux-gnueabi-ar
$ export NM_FOR_TARGET=arm-none-linux-gnueabi-nm
$ export OBJDUMP_FOR_TARGET=arm-none-linux-gnueabi-objdump
$ export STRIP_FOR_TARGET=arm-none-linux-gnueabi-strip
$ export PATH=/opt/codesourcery/bin:${PATH}
$ ../../gcc-4.2/configure \
--build=i686-apple-darwin9 --host=i686-apple-darwin9 \
--target=arm-none-linux-gnueabi --enable-threads --disable-libmudflap --disable-libssp \
--disable-libgomp --disable-libstdcxx-pch --with-gnu-as --with-gnu-ld --enable-languages=c,c++ \
--enable-shared --enable-symvers=gnu --enable-__cxa_atexit --disable-nls \
--prefix=/opt/codesourcery \
--with-sysroot=/opt/codesourcery/arm-none-linux-gnueabi/libc \
--with-build-sysroot=/opt/codesourcery/arm-none-linux-gnueabi/libc \
--enable-poison-system-directories \
--with-build-time-tools=/opt/codesourcery/arm-none-linux-gnueabi/bin \
--with-build-time-tools=/opt/codesourcery/arm-none-linux-gnueabi/bin 2>&1 |tee configure.out
$ sudo make -j4 LDFLAGS_FOR_TARGET=--sysroot=/opt/codesourcery/arm-none-linux-gnueabi/libc \
CPPFLAGS_FOR_TARGET=--sysroot=/opt/codesourcery/arm-none-linux-gnueabi/libc \
build_tooldir=/opt/codesourcery/arm-none-linux-gnueabi 2>&1 | tee make.out
$ make prefix=/opt/codesourcery exec_prefix=/opt/codesourcery \
libdir=/opt/codesourcery/lib \
htmldir=/opt/codesourcery/share/doc/arm-arm-none-linux-gnueabi/html \
pdfdir=/opt/codesourcery/share/doc/arm-arm-none-linux-gnueabi/pdf \
infodir=/opt/codesourcery/share/doc/arm-arm-none-linux-gnueabi/info \
mandir=/opt/codesourcery/share/doc/arm-arm-none-linux-gnueabi/man \
install 2>&1 |tee make_install.out
$ popd

これで /opt/codesourcery 以下にARM Linux用のクロスコンパイラ一式が整った。

0 件のコメント: