制作工具链
优质
小牛编辑
130浏览
2023-12-01
此处工具链的制作基本上与 LFS 第五章相同,只是增删几个包、改动了一些配置选项、简化了几个包的安装动作、将几个补丁的功能用 sed 进行了替代、以及其它一些小变化等等,因此下面只列出命令而不进行任何说明。
( test ! -f $SRC/tmp.log ) && [ "`pwd`" = "$SRC" ] && tar -xf binutils-2.18.tar.bz2 && mkdir binutils-build && cd binutils-build && echo 'MAKEINFO = :' >> ../binutils-2.18/Makefile.in && CFLAGS="-O2 -fomit-frame-pointer -pipe -march=athlon-xp" LDFLAGS="-s" \ ../binutils-2.18/configure --prefix=/www --disable-nls --disable-rpath --disable-multilib --disable-shared --enable-static --disable-werror --without-gmp --without-mpfr --without-included-gettext --without-libiconv-prefix --without-libintl-prefix --with-pic && make all install tooldir=/www/ && cp ../binutils-2.18/include/libiberty.h /www/include && make clean-ld all-ld LIB_PATH=/www/lib tooldir=/www/ && cp ld/ld-new /www/bin/ && cd $SRC && rm */ && echo '1-binutils-pass1' >> $SRC/tmp.log && sync && tar -xf gcc-core-4.2.3.tar.bz2 && mkdir gcc-build && cd gcc-build && sed -r -i 's|^LDFLAGS(_FOR_TARGET)? =|& @LDFLAGS@|' ../gcc-4.2.3/Makefile.in && sed -i 's/install_to_$(INSTALL_DEST) //' ../gcc-4.2.3/libiberty/Makefile.in && sed -i -e's@\./fixinc\.sh@-c true@' -e'/^LIBGCC2_DEBUG_CFLAGS/d' ../gcc-4.2.3/gcc/Makefile.in && sed -i '/MULTILIB_OSDIRNAMES/d' ../gcc-4.2.3/gcc/config/i386/t-linux64 && CFLAGS="-O2 -fomit-frame-pointer -pipe -march=athlon-xp" LDFLAGS="-s" \ ../gcc-4.2.3/configure --prefix=/www --with-local-prefix=/www --enable-languages=c --enable-bootstrap --disable-nls --disable-rpath --disable-multilib --enable-shared=libgcc --enable-static=libgcc --disable-libgomp --disable-libmudflap --disable-libssp --enable-linux-futex --enable-threads=posix --enable-tls --disable-symvers --with-as=/www/bin/as --with-ld=/www/bin/ld --without-included-gettext --without-libiconv-prefix --without-libintl-prefix --without-gmp --without-mpfr --without-system-libunwind --without-system-zlib --with-pic --without-x && make bootstrap4 install LIBCFLAGS="-O2 -fomit-frame-pointer -pipe -march=athlon-xp" BOOT_CFLAGS="-O2 -fomit-frame-pointer -pipe -march=athlon-xp" BOOT_LDFLAGS="-s" && ln -sf gcc /www/bin/cc && INC=`gcc -print-file-name=include` && TOL=`gcc -print-file-name=install-tools` && rm $INC/* && cp $TOL/include/* $INC && cp $TOL/gsyslimits.h $INC/syslimits.h && unset INC TOL && cd $SRC && rm */ && echo '2-gcc-pass1' >> $SRC/tmp.log && sync && tar -xf linux-2.6.24.2.tar.bz2 && cd linux-2.6.24.2 && make distclean && make headers_check ARCH=x86 && make headers_install ARCH=x86 INSTALL_HDR_PATH=temp && cp -r temp/include/* /www/include/ && cd $SRC && rm */ && echo '3-kernel-headers' >> $SRC/tmp.log && sync && tar -xf glibc-2.6.1.tar.bz2 && mkdir glibc-build && cd glibc-build && find ../glibc-2.6.1 -name configure | xargs touch && LDFLAGS="`echo $LDFLAGS | sed 's/,--hash-style=gnu//'`" \ ../glibc-2.6.1/configure --prefix=/www --enable-add-ons=nptl --enable-shared --enable-kernel=2.6.22 --disable-oldest-abi --disable-profile --with-headers=/www/include --with-binutils=/www/bin --without-cvs --with-elf --without-gd --without-gmp --without-selinux --with-tls && echo 'MAKEINFO = :' >> configparms && make && ( make -k check 2> $SRC/tmp_glibc.log ; make install ) && cp --remove-destination /www/share/zoneinfo/UTC /www/etc/localtime && cd $SRC && rm */ && echo '4-glibc' >> $SRC/tmp.log && sync && mv /www/bin/{ld-new,ld} && gcc -dumpspecs | sed 's@/lib/ld-linux.so.2@/www/lib/ld-linux.so.2@g' > `dirname $(gcc -print-libgcc-file-name)`/specs && echo 'main(){}' > dummy.c && cc dummy.c && readelf -l a.out | fgrep '[Requesting program interpreter: /www/lib/ld-linux.so.2]' && rm dummy.c a.out && echo '5-Adjusting' >> $SRC/tmp.log && sync && tar -xf tcl8.4.18-src.tar.gz && cd tcl8.4.18/unix && ./configure --prefix=/www --enable-threads --enable-shared --enable-load --enable-gcc --disable-symbols --disable-64bit --disable-64bit-vis --disable-langinfo --disable-corefoundation --disable-dtrace --disable-framework --disable-man-symlinks --disable-man-compression --disable-man-suffix && make && make install install-private-headers && ln -sf tclsh8.4 /www/bin/tclsh && cd $SRC && rm */ && sync && tar -xf expect-5.43.0.tar.bz2 && cd expect-5.43 && patch $SRC/expect-5.43.0-spawn-2.patch && sed -i 's/STTY_BIN=.*/STTY_BIN=stty/g' configure{.in,} && ./configure --prefix=/www --enable-threads --enable-shared --enable-load --enable-gcc --with-tcl=/www/lib --with-tclinclude=/www/include --with-x=no --disable-symbols && make expect && make install SCRIPTS="" && cd $SRC && rm */ && sync && tar -xf dejagnu-1.4.4.tar.gz && cd dejagnu-1.4.4 && ./configure --prefix=/www && make install && cd $SRC && rm */ && echo '6-tcl-expect-dejagnu' >> $SRC/tmp.log && sync && tar -xf gcc-core-4.2.3.tar.bz2 && tar -xf gcc-testsuite-4.2.3.tar.bz2 && cd gcc-4.2.3 && sed -r -i 's|^LDFLAGS(_FOR_TARGET)? =|& @LDFLAGS@|' Makefile.in && sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in && sed -i -e's@\./fixinc\.sh@-c true@' -e'/^LIBGCC2_DEBUG_CFLAGS/d' gcc/Makefile.in && sed -i '/MULTILIB_OSDIRNAMES/d' gcc/config/i386/t-linux64 && echo '/* Remove /usr/include from end of include search path. */ #undef STANDARD_INCLUDE_DIR #define STANDARD_INCLUDE_DIR 0' | tee -a gcc/config/linux.h gcc/config/i386/linux{,64}.h && sed -i 's@/lib/ld.so@/www&@g' gcc/config/i386/gnu.h && sed -i 's@/lib/ld-linux.so.2@/www&@g' gcc/config/i386/linux{,64}.h && sed -i 's@/lib64/ld-linux-x86-64.so.2@/www&@g' gcc/config/i386/linux64.h && # sed -i '/LINK_SPEC/s/ "/&--hash-style=gnu /' gcc/config/i386/linux{,64}.h && mkdir ../gcc-build && cd ../gcc-build && ../gcc-4.2.3/configure --prefix=/www --with-local-prefix=/www --enable-languages=c --enable-bootstrap --disable-nls --disable-rpath --disable-multilib --enable-shared=libgcc --enable-static=libgcc --disable-libgomp --disable-libmudflap --disable-libssp --enable-linux-futex --enable-threads=posix --enable-tls --disable-symvers --with-as=/www/bin/as --with-ld=/www/bin/ld --without-included-gettext --without-libiconv-prefix --without-libintl-prefix --without-gmp --without-mpfr --without-system-libunwind --without-system-zlib --with-pic --without-x && make profiledbootstrap LIBCFLAGS="$CFLAGS" BOOT_CFLAGS="$CFLAGS" BOOT_LDFLAGS="$LDFLAGS" && ( make -k check | tee $SRC/tmp_gcc.log ; make install ) && INC=`gcc -print-file-name=include` && TOL=`gcc -print-file-name=install-tools` && rm $INC/* && cp $TOL/include/* $INC && cp $TOL/gsyslimits.h $INC/syslimits.h && unset INC TOL && cd $SRC && rm */ && sync && echo 'main(){}' > dummy.c && cc dummy.c && readelf -l a.out | fgrep '[Requesting program interpreter: /www/lib/ld-linux.so.2]' && rm dummy.c a.out && echo '7-gcc-pass2' >> $SRC/tmp.log && sync && tar -xf binutils-2.18.tar.bz2 && mkdir binutils-build && cd binutils-build && echo 'MAKEINFO = :' >> ../binutils-2.18/Makefile.in && CFLAGS="$CFLAGS -fno-inline-functions" \ ../binutils-2.18/configure --prefix=/www --with-lib-path=/www/lib --disable-nls --disable-rpath --disable-multilib --disable-shared --enable-static --disable-werror --without-gmp --without-mpfr --without-included-gettext --without-libiconv-prefix --without-libintl-prefix --with-pic && make all check install tooldir=/www/ && make clean-ld all-ld check-ld LIB_PATH=/lib:/usr/lib tooldir=/www/ && cp ld/ld-new /www/bin/ && cp ../binutils-2.18/include/libiberty.h /www/include/ && cd $SRC && rm */ && echo '8-binutils-pass2' >> $SRC/tmp.log && sync && tar -xf bash-3.2.tar.gz && cd bash-3.2 && patch $SRC/bash-3.2-fixes-7.patch && ./configure --prefix=/www --disable-minimal-config --disable-profiling --enable-static-link --disable-nls --disable-rpath --without-lispdir --without-afs --without-bash-malloc --without-gnu-malloc --without-curses --without-termcap --disable-install-termcap --with-installed-readline=no --without-purecov --without-purify --without-libiconv-prefix --without-included-gettext --without-libintl-prefix && make && cp bash /www/bin/ && ln -sf bash /www/bin/sh && cd $SRC && rm */ && echo '9-bash' >> $SRC/tmp.log && sync && tar -xf bzip2-1.0.4.tar.gz && cd bzip2-1.0.4 && make bzip2 CFLAGS="$CFLAGS -D_FILE_OFFSET_BITS=64" LDFLAGS="$LDFLAGS" && cp bzip2 /www/bin/ && ln -sf bzip2 /www/bin/bunzip2 && cd $SRC && rm */ && echo '10-bzip2' >> $SRC/tmp.log && sync && tar -xf coreutils-6.10.tar.gz && cd coreutils-6.10 && sed -i '/(setuid_root_mode)/s/(installed_su)/&;/' src/Makefile.in && ./configure --prefix=/www --enable-option-checking --disable-acl --disable-assert --disable-rpath --disable-nls --enable-install-program="arch,hostname,su" --without-libiconv-prefix --without-included-regex --without-libintl-prefix && make && make install install-root && cd $SRC && rm */ && echo '11-coreutils' >> $SRC/tmp.log && sync && tar -xf diffutils-2.8.1.tar.gz && cd diffutils-2.8.1 && ./configure --prefix=/www --disable-rpath --disable-nls --without-libiconv-prefix --without-included-regex --without-libintl-prefix && make && cp src/{cmp,diff} /www/bin/ && cd $SRC && rm */ && echo '12-diffutils' >> $SRC/tmp.log && sync && tar -xf findutils-4.2.33.tar.gz && cd findutils-4.2.33 && ./configure --prefix=/www --disable-id-cache --disable-debug --disable-leaf-optimisation --disable-d_type-optimization --disable-nls --disable-rpath --without-included-regex --without-libiconv-prefix --without-libintl-prefix && make && cp find/find xargs/xargs /www/bin/ && cd $SRC && rm */ && echo '13-findutils' >> $SRC/tmp.log && sync && tar -xf gawk-3.1.6.tar.bz2 && cd gawk-3.1.6 && ./configure --prefix=/www --disable-portals --enable-lint --enable-switch --enable-directories-fatal --disable-nls --disable-rpath --without-whiny-user-strftime --without-libiconv-prefix --without-libintl-prefix && make && cp gawk /www/bin/ && ln -sf gawk /www/bin/awk && cd $SRC && rm */ && echo '14-gawk' >> $SRC/tmp.log && sync && tar -xf grep-2.5.3.tar.bz2 && cd grep-2.5.3 && sed -i '/^SUBDIRS/s/doc//' Makefile.in && ./configure --prefix=/www --disable-perl-regexp --disable-nls --without-libiconv-prefix --without-included-gettext --without-included-regex --without-included-getopt && make && cp src/{,e,f}grep /www/bin/ && cd $SRC && rm */ && echo '15-grep' >> $SRC/tmp.log && sync && tar -xf gzip-1.3.12.tar.gz && cd gzip-1.3.12 && sed -i 's/futimens/gl_&/' gzip.c lib/utimens.{c,h} && ./configure --prefix=/www && make && cp gunzip gzip /www/bin/ && cd $SRC && rm */ && echo '16-gzip' >> $SRC/tmp.log && sync && tar -xf make-3.81.tar.bz2 && cd make-3.81 && ./configure --prefix=/www --disable-nls --disable-rpath --enable-job-server --without-libiconv-prefix --without-libintl-prefix --without-customs --without-dmalloc && make && cp make /www/bin/ && cd $SRC && rm */ && echo '17-make' >> $SRC/tmp.log && sync && tar -xf patch-2.5.4.tar.gz && cd patch-2.5.4 && ./configure --prefix=/www && make && cp patch /www/bin/ && cd $SRC && rm */ && echo '18-patch' >> $SRC/tmp.log && sync && tar -xf perl-5.8.8.tar.bz2 && cd perl-5.8.8 && sed -i -e's:/lib/libc.so.6:/www&:g' -e's:libc=/lib/$libc:libc=/www/lib/$libc:g' hints/linux.sh && echo 'locincpth="" ; loclibpth="" ; usrinc="/www/include" ; glibpth="/www/lib"' >> hints/linux.sh && sed -i 's/command /command[ -]/' makedepend.SH && ./configure.gnu --prefix=/www -Dstatic_ext='Data/Dumper Fcntl IO POSIX' && make && make install.perl && cd $SRC && rm */ && echo '19-perl' >> $SRC/tmp.log && sync && tar -xf sed-4.1.5.tar.gz && cd sed-4.1.5 && ./configure --prefix=/www --enable-i18n --enable-regex-tests --disable-html --disable-nls --without-included-regex --without-libiconv-prefix --without-included-gettext --without-libintl-prefix && make && cp sed/sed /www/bin/ && cd $SRC && rm */ && echo '20-sed' >> $SRC/tmp.log && sync && tar -xf tar-1.19.tar.bz2 && cd tar-1.19 && ./configure --prefix=/www --disable-rpath --disable-nls --disable-backup-scripts --without-included-regex --without-libiconv-prefix --without-libintl-prefix && make && cp src/tar /www/bin/ && cd $SRC && rm */ && echo '21-tar' >> $SRC/tmp.log && sync && tar -xf util-linux-2.12r.tar.bz2 && cd util-linux-2.12r && sed -i 's:/usr/include:/www/include:g' configure && sed -i 's|CPUOPT=.*|CPUOPT=|' MCONFIG && LDFLAGS="$LDFLAGS -static" ./configure && make -C lib && make -C mount mount umount && cp mount/{,u}mount /www/bin/ && cd $SRC && rm */ && echo '22-util-linux' >> $SRC/tmp.log && sync && tar -xf linux-2.6.24.2.tar.bz2 && cd linux-2.6.24.2 && make distclean && cp $SRC/linux-2.6.24-config.txt .config && chown -R nobody . && su -c'make silentoldconfig ARCH=x86' -s/www/bin/bash - nobody && echo 'cflags-y += -march=athlon-xp' | tee arch/x86/Makefile*.cpu && make ARCH=x86 V=0 CC="gcc -m32 $CFLAGS" LD="ld -m elf_i386 $kLDFLAGS" && cp arch/x86/boot/bzImage $LFS/boot/ && cd $SRC && rm */ && echo '23-linux' >> $SRC/tmp.log && sync && tar -xf iproute2-2.6.24-rc7.tar.bz2 && cd iproute2-2.6.24-rc7 && sed -i -e's|^SBINDIR=.*|SBINDIR=/www/bin|' -e's|^CONFDIR=.*|CONFDIR=/www/etc/iproute2|' -e's|^SUBDIRS=.*|SUBDIRS=lib ip|' -e's|$(KERNEL_INCLUDE)|/www/include|' Makefile && make CCOPTS="-D_GNU_SOURCE $CFLAGS" LDFLAGS="$LDFLAGS" && cp ip/ip /www/bin/ && cp -R etc/iproute2/ /www/etc/ && cd $SRC && rm */ && echo '24-iproute2' >> $SRC/tmp.log && sync && [ "`ldd /www/{bin,sbin}/* /www/lib/*{,/*{,/*{,/*{,/*}}}} | egrep ' => /(usr|lib)'`" = '' ] && rm /www/{sbin,info,man} /www/share/{info,man,zoneinfo} && ( strip --strip-debug /www/lib/*{,/*{,/*{,/*{,/*}}}} ; strip --strip-all /www/bin/* ; sync ) && echo 'tool-chain-finished!' >> $SRC/tmp.log && sync &&
到此,工具链制作完毕,可以通过查看 $SRC/tmp*.log 来了解制作过程是否顺利。如果没有很严重的错误,那么就可以准备下面的重启了。