Sıfırdan Linux 3 - Linux API headers, glibc, libstdc, binutils(2), gcc(2)


Üçüncü yazıda kernel başlığını ekleyelim ve birkaç kitaplığı derleyelim.


Glibc için gerekli olan başlıkları ayarlayalım.


cd /mnt/lfs/sources
tar -Jxf linux-3.13.3.tar.xz
cd linux-3.13.3
make mrproper

make headers_check
make INSTALL_HDR_PATH=dest headers_install
cp -rv dest/include/* /tools/include
_____________________________________________________________________________

glibc-2.19 için

cd /mnt/lfs/sources
tar -Jxf glibc-2.19.tar.xz
cd glibc-2.19

if [ ! -r /usr/include/rpc/types.h ]; then
su -c 'mkdir -pv /usr/include/rpc'
su -c 'cp -v sunrpc/rpc/*.h /usr/include/rpc'
fi

Dışarda derlemek için

cd /mnt/lfs/sources
mkdir -v glibc-build
cd glibc-build

../glibc-2.19/configure --prefix=/tools --host=$LFS_TGT --build=$(../glibc-2.19/scripts/config.guess) --disable-profile --enable-kernel=2.6.32 --with-headers=/tools/include libc_cv_forced_unwind=yes libc_cv_ctors_header=yes libc_cv_c_cleanup=yes

make
make install

Test için

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

Çıktı olarak [Requesting program interpreter: /tools/lib/ld-linux.so.2] demeli.


rm -v dummy.c a.out
_____________________________________________________________________________

libstdc++-4.8.2 için

cd /mnt/lfs/sources
tar -xvjf gcc-4.8.2.tar.bz2
mkdir -pv gcc-build
cd gcc-build

../gcc-4.8.2/libstdc++-v3/configure --host=$LFS_TGT --prefix=/tools --disable-multilib --disable-shared --disable-nls --disable-libstdcxx-threads --disable-libstdcxx-pch --with-gxx-include-dir=/tools/$LFS_TGT/include/c++/4.8.2


make
make install
_____________________________________________________________________________

binutils'te ikinci tur

mkdir /mnt/lfs/sources/binutils-build2
cd /mnt/lfs/sources/binutils-build2

CC=$LFS_TGT-gcc AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib ../binutils-2.24/configure --prefix=/tools --disable-nls --with-lib-path=/tools/lib --with-sysroot

make
make install

make -C ld clean
make -C ld LIB_PATH=/usr/lib:/lib
cp -v ld/ld-new /tools/bin
_____________________________________________________________________________

gcc ikinci tur

cd /mnt/lfs/sources/gcc-4.8.2
cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
`dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/include-fixed/limits.h

for file in \
$(find gcc/config -name linux64.h -o -name linux.h -o -name sysv4.h)
do
cp -uv $file{,.orig}
sed -e 's@/lib\(64\)\?\(32\)\?/ld@/tools&@g' \
-e 's@/usr@/tools@g' $file.orig > $file
echo '
#undef STANDARD_STARTFILE_PREFIX_1
#undef STANDARD_STARTFILE_PREFIX_2
#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"
#define STANDARD_STARTFILE_PREFIX_2 ""' >> $file
touch $file.orig
done

Tekrar aynı kitaplıklar:

tar -Jxf ../mpfr-3.1.2.tar.xz
mv -v mpfr-3.1.2 mpfr
tar -Jxf ../gmp-5.1.3.tar.xz
mv -v gmp-5.1.3 gmp
tar -zxf ../mpc-1.0.2.tar.gz
mv -v mpc-1.0.2 mpc

Ayrı klasörde derlenecek:

mkdir ../gcc-build2
cd ../gcc-build2

CC=$LFS_TGT-gcc CXX=$LFS_TGT-g++ AR=$LFS_TGT-ar RANLIB=$LFS_TGT-ranlib ../gcc-4.8.2/configure --prefix=/tools --with-local-prefix=/tools --with-native-system-header-dir=/tools/include --enable-clocale=gnu --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-languages=c,c++ --disable-libstdcxx-pch --disable-multilib --disable-bootstrap --disable-libgomp --with-mpfr-include=$(pwd)/../gcc-4.8.2/mpfr/src --with-mpfr-lib=$(pwd)/mpfr/src/.libs

make
make install

 ln -sv gcc /tools/bin/cc

Test için

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

deyince çıktı: [Requesting program interpreter: /tools/lib/ld-linux.so.2] şeklinde olmalı.

rm -v dummy.c a.out

Kitapta 48. sayfaya ulaştık. Derlemeye devam.

Hiç yorum yok :

Yorum Gönder