Linux From Scratch 5.1.1 / 2.toolchainを作成 1



toolchainの作成1(lfs-5.1.1-toolchain-1.sh)

Binutils のインストール - 第 1 段階

cd $LFS/sources
tar jxvf binutils-2.14.tar.bz2
mkdir binutils-build
cd binutils-build
../binutils-2.14/configure --prefix=/tools --disable-nls
make configure-host
make LDFLAGS="-all-static"
make install
make -C ld clean
make -C ld LDFLAGS="-all-static" LIB_PATH=/tools/lib

&color():Invalid color: #f00;
&color():Invalid color: #f00;

GCC のインストール 第1段階

cd $LFS/sources
tar jxvf gcc-core-3.3.3.tar.bz2
tar jxvf gcc-g++-3.3.3.tar.bz2
tar jxvf gcc-testsuite-3.3.3.tar.bz2
mkdir gcc-build
cd gcc-build
../gcc-3.3.3/configure --prefix=/tools \
--with-local-prefix=/tools \
--disable-nls --enable-shared \
--enable-languages=c
make BOOT_LDFLAGS="-static" bootstrap
make install
ln -s gcc /tools/bin/cc
cd ..
rm -rf gcc-build
rm -rf gcc-3.3.3 

Linux headers のインストール

tar jxvf linux-2.4.26.tar.bz2
cd linux-2.4.26
make mrproper
make include/linux/version.h
make symlinks
mkdir /tools/include/asm
cp include/asm/* /tools/include/asm
cp -R include/asm-generic /tools/include
cp -R include/linux /tools/include
cd ..
rm -rf linux-2.4.26

Glibc のインストール

cd $LFS/sources
tar jxvf glibc-2.3.3-lfs-5.1.tar.bz2
mkdir glibc-build
cd glibc-build
../glibc-2.3.3-lfs-5.1/configure --prefix=/tools \
    --disable-profile --enable-add-ons=linuxthreads \
    --with-binutils=/tools/bin --with-headers=/tools/include \
    --without-gd --without-cvs
make AUTOCONF=no
mkdir /tools/etc
touch /tools/etc/ld.so.conf
make install
make localedata/install-locales

Glibc の"閉じ込め"

cd $LFS/sources/binutils-build
make -C ld install
cd ..
SPECFILE=/tools/lib/gcc-lib/*/*/specs &&
sed -e 's@ /lib/ld-linux.so.2@ /tools/lib/ld-linux.so.2@g' \
    $SPECFILE > tempspecfile &&
mv -f tempspecfile $SPECFILE &&
unset SPECFILE
rm -f /tools/lib/gcc-lib/*/*/include/{pthread.h,bits/sigthread.h}
rm -rf binutils-build
rm -rf binutils-2.14
rm -rf glibc-build
rm -rf glibc-2.3.3-lfs-5.1 

完成度チェック

echo 'main(){}' > dummy.c
gcc dummy.c
readelf -l a.out | grep ': /tools'

すべてが正しく動いているなら、エラーはないはずで、最後のコマンドの出力結果は次のようになります。

[Requesting program interpreter: /tools/lib/ld-linux.so.2]
rm dummy.c a.out