LFS制作过程笔记
LFS (x86_64) 简要笔记
LFS 的工具链编译顺序
cross-binutils-> cross-gcc -> 内核头文件 -> cross-glibc -> binutils-final -> gcc-final(C/C++)
准备工作
export LFS=/mnt/lfs export SRC=/mnt/lfs/sources/ export BUILD=/mnt/lfs/sources/build mkdir -pv $BUILD mkdir -pv ${LFS}/tools ln -sv /mnt/clfs/tools /
添加LFS专用用户
groupadd clfs useradd -s /bin/bash -g lfs -m -k /dev/null clfs chown -v clfs:clfs $LFS/sources su - lfs
cat > ~/.bash_profile << "EOF" exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash EOF cat > ~/.bashrc << "EOF" set +h umask 022 export LC_ALL=POSIX export LFS=/mnt/lfs export PATH=/tools/bin:/bin:/usr/bin export SRC=/mnt/lfs/sources/ export BUILD=/mnt/lfs/sources/build export CROSS_HOST="x86_64-linux-gnu" export CROSS_TARGET="x86_64-regulus-linux-gnu" EOF source ~/.bash_profile
cross-binutils
mkdir binutils-build cd binutils-build ../binutils-2.23.1/configure \ --prefix=/tools \ --with-sysroot=$LFS \ --with-lib-path=/tools/lib \ --target=$LFS_TGT \ --disable-nls \ --disable-werror make -j32 case $(uname -m) in x86_64) mkdir -v /tools/lib && ln -sv lib /tools/lib64 ;; esac make install
--prefix=${CLFS}/tools 此项告诉配置脚本准备安装 Binutils 程序于 ${CLFS}/cross-tools 目录中。 --with-sysroot=$LFS 对于交叉编译,此项告诉编制系统到 $LFS 中寻找需要的目标系统库。 --with-lib-path=/tools/lib 此项指定要配置链接器使用的库路径。 --build=${CROSS_HOST} --host=${CROSS_HOST} --target=${CROSS_TARGET} --disable-nls 此项禁用国际化,因为国际化在临时工具中不需要。 --disable-werror 此项防止编制由于宿主的编译器的警告而停止。
cross-gcc
tar -Jxf ../../../mpfr-3.1.1.tar.xz mv -v mpfr-3.1.1 mpfr tar -Jxf ../../../gmp-5.0.5.tar.xz mv -v gmp-5.0.5 gmp tar -zxf ../../../mpc-1.0.1.tar.gz mv -v mpc-1.0.1 mpc 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 sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure mkdir -v ../gcc-build cd ../gcc-build ../gcc-4.7.2/configure \ --target=$LFS_TGT \ --prefix=/tools \ --with-sysroot=$LFS \ --with-newlib \ --without-headers \ --with-local-prefix=/tools \ --with-native-system-header-dir=/tools/include \ --disable-nls \ --disable-shared \ --disable-multilib \ --disable-decimal-float \ --disable-threads \ --disable-libmudflap \ --disable-libssp \ --disable-libgomp \ --disable-libquadmath \ --enable-languages=c \ --with-mpfr-include=$(pwd)/../gcc-4.7.2/mpfr/src \ --with-mpfr-lib=$(pwd)/mpfr/src/.libs make && make install ln -sv libgcc.a `$LFS_TGT-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/'`
Linux内核头文件
make mrproper make ARCH=x86_64 headers_check make ARCH=x86_64 INSTALL_HDR_PATH=dest headers_install cp -rv dest/include/* /tools/include find /tools/include -name .install -or -name ..install.cmd | xargs rm -fv
glibc(临时系统)
if [ ! -r /usr/include/rpc/types.h ]; then su -c 'mkdir -p /usr/include/rpc' su -c 'cp -v sunrpc/rpc/*.h /usr/include/rpc' fi cp -v Makeconfig{,.orig} sed -e 's/-lgcc_s//g' Makeconfig.orig > Makeconfig mkdir -v ../glibc-build cd ../glibc-build ../glibc-2.17/configure \ --prefix=/tools \ --host=$LFS_TGT \ --build=$CROSS-HOST \ --disable-profile \ --enable-kernel=2.6.25 \ --with-headers=/tools/include \ libc_cv_forced_unwind=yes \ libc_cv_ctors_header=yes \ libc_cv_c_cleanup=yes make make install
binutils(临时系统)
mkdir -v binutils-build cd binutils-build ../configure --build=$CROSS-TARGET --host=$CROSS-TARGET --target=$CROSS-TARGET --prefix=/tools --disable-nls --with-lib-path=/tools/lib make -j32 make install make -C ld LIB_PATH=/usr/lib:/lib CC=x86_64-regulus-linux-gnu-gcc cp -v ld/ld-new /tools/bin
gcc(临时系统)
cat gcc/limitx.h gcc/glimits.h gcc/limity.h > `dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/include-fixed/limits.h cp -v gcc/Makefile.in{,.tmp} sed 's/^T_CFLAGS =$/& -fomit-frame-pointer/' gcc/Makefile.in.tmp > gcc/Makefile.in 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 sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure mkdir -v ../gcc-build cd ../gcc-build ../gcc-4.7.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.7.2/mpfr/src \ --with-mpfr-lib=$(pwd)/mpfr/src/.libs make make install ln -sv libgcc.a `$LFS_TGT-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/'`
gmp-5.05
wget http://ftp.gnu.org/gnu/gmp/gmp-5.0.5.tar.bz2 tar -xvpf gmp-5.0.5.tar.bz2 cd gmp-5.0.5 CPPFLAGS=-fexceptions ./configure --prefix=${CLFS}/cross-tools --enable-cxx --disable-static make -j32 && make install
mpfr-3.1.1
wget http://www.mpfr.org/mpfr-3.1.1/mpfr-3.1.1.tar.xz tar -xvpf mpfr-3.1.1.tar.xz cd mpfr-3.1.1 LDFLAGS="-Wl,-rpath,/cross-tools/lib" ./configure --prefix=/cross-tools --enable-shared --disable-static --with-gmp=/cross-tools make && make install
mpc-1.0.1
wget http://www.multiprecision.org/mpc/download/mpc-1.0.1.tar.gz tar -xvpf mpc-1.0.1.tar.gz cd mpc-1.0.1 LDFLAGS="-Wl,-rpath,/cross-tools/lib" ./configure --prefix=/cross-tools --disable-static --with-gmp=/cross-tools --with-mpfr=/cross-tools make && make install
tcl8.5
tar -xzf $SRC/tcl8.5.13-src.tar.gz -C $BUILD && cd $BUILD/tcl8.5.13/unix && ./configure --prefix=/tools && make -j32 && make install && chmod -v u+w /tools/lib/libtcl8.5.so && make install-private-headers && ln -sv tclsh8.5 /tools/bin/tclsh && cd $BUILD
expect
tar -zxf $SRC/expect5.45.tar.gz -C $BUILD && cd $BUILD/expect5.45 && cp -v configure{,.orig} && sed 's:/usr/local/bin:/bin:' configure.orig > configure && ./configure --build=x86_64-regulus-linux-gnu --host=x86_64-regulus-linux-gnu --prefix=/tools --with-tcl=/tools/lib --with-tclinclude=/tools/include make && make SCRIPTS="" install && cd $BUILD
dejagnu
tar -zxf $SRC/dejagnu-1.5.tar.gz -C $BUILD cd $BUILD/dejagnu-1.5 ./configure --build=x86_64-regulus-linux-gnu --host=x86_64-regulus-linux-gnu --prefix=/tools make install
ncurses-5.9
tar -zxf $SRC/ncurses-5.9.tar.gz -C $BUILD cd $BUILD/ncurses-5.9/ ./configure --build=x86_64-regulus-linux-gnu --host=x86_64-regulus-linux-gnu --prefix=/tools --with-shared --without-debug --without-ada --enable-overwrite make make install
bash-4.2
tar -xzf $SRC/bash-4.2.tar.gz -C $BUILD cd $BUILD/bash-4.2/ patch -Np1 -i $SRC/bash-4.2-fixes-10.patch ./configure --build=x86_64-regulus-linux-gnu --host=x86_64-regulus-linux-gnu --prefix=/tools --without-bash-malloc make -j32 make install ln -vs bash /tools/bin/sh
Bzip2-1.0.6
tar -xzf $SRC/bzip2-1.0.6.tar.gz -C $BUILD cd $BUILD/bzip2-1.0.6 make make PREFIX=/tools install
coreutils-8.14
tar -xpf $SRC/coreutils-8.19.tar.bz2 -C $BUILD cd $BUILD/coreutils-8.19 ./configure --build=x86_64-regulus-linux-gnu --host=x86_64-regulus-linux-gnu --prefix=/tools --enable-install-program=hostname make -j32 make install cp -v src/su /tools/bin/su-tools
diffutils 3.2
tar -xvpf $SRC/diffutils-3.2.tar.bz2 -C $BUILD sed -i -e '/gets is a/d' lib/stdio.in.h cd $BUILD/diffutils-3.2 ./configure --build=x86_64-regulus-linux-gnu --host=x86_64-regulus-linux-gnu --prefix=/tools make make install
file-5.11
tar -zxf $SRC/file-5.11.tar.gz -C $BUILD cd $BUILD/file-5.11 ./configure --build=x86_64-regulus-linux-gnu --host=x86_64-regulus-linux-gnu --prefix=/tools make make install
findutils 4.4.2
tar -zxf $SRC/findutils-4.4.2.tar.gz -C $BUILD cd $BUILD/findutils-4.4.2 ./configure --build=x86_64-regulus-linux-gnu --host=x86_64-regulus-linux-gnu --prefix=/tools make make install
gawk 4.0.1
tar -xvpf $SRC/gawk-4.0.1.tar.xz -C $BUILD cd $BUILD/gawk-4.0.1 ./configure --build=x86_64-regulus-linux-gnu --host=x86_64-regulus-linux-gnu --prefix=/tools make make install
Gettext-0.18.1.1
tar -xzf $SRC/gettext-0.18.1.1.tar.gz -C $BUILD cd $BUILD/gettext-0.18.1.1/ sed -i -e '/gets is a/d' gettext-*/*/stdio.in.h cd gettext-tools EMACS="no" ./configure --build=x86_64-regulus-linux-gnu --host=x86_64-regulus-linux-gnu --prefix=/tools --disable-shared make -C gnulib-lib make -C src msgfmt cp -v src/msgfmt /tools/bin
Grep-2.14
tar -xvpf $SRC/grep-2.14.tar.xz -C $BUILD cd $BUILD/grep-2.14 ./configure --build=x86_64-regulus-linux-gnu --host=x86_64-regulus-linux-gnu --prefix=/tools make -j32 && make install
Gzip-1.4
tar -xzf $SRC/gzip-1.5.tar.xz -C $BUILD cd $BUILD/gzip-1.5 ./configure --build=x86_64-regulus-linux-gnu --host=x86_64-regulus-linux-gnu --prefix=/tools make -j32 && make install
M4-1.4.16
tar -xjf $SRC/m4-1.4.16.tar.bz2 -C $BUILD cd m4-1.4.16 sed -i -e '/gets is a/d' lib/stdio.in.h ./configure --build=x86_64-regulus-linux-gnu --host=x86_64-regulus-linux-gnu --prefix=/tools make -j32 && make install
Make-3.82
tar -xjf $SRC/make-3.82.tar.bz2 -C $BUILD cd $BUILD/make-3.82 ./configure --build=x86_64-regulus-linux-gnu --host=x86_64-regulus-linux-gnu --prefix=/tools make -j32 && make install
Patch-2.7.1
tar -xjf $SRC/patch-2.7.1.tar.bz2 -C $BUILD cd $BUILD/patch-2.7.1 ./configure --build=x86_64-regulus-linux-gnu --host=x86_64-regulus-linux-gnu --prefix=/tools make -j32 && make install
Perl-5.16.2
tar -zxf $SRC/perl-5.16.2.tar.bz2 -C $BUILD cd $BUILD/perl-5.16.2 patch -Np1 -i $SRC/perl-5.16.2-libc-1.patch sh Configure -des -Dprefix=/tools make -j32 cp -v perl cpan/podlators/pod2man /tools/bin mkdir -pv /tools/lib/perl5/5.16.2 cp -Rv lib/* /tools/lib/perl5/5.16.2
Sed-4.2.1
tar -xjf $SRC/sed-4.2.1.tar.bz2 -C $BUILD cd $BUILD/sed-4.2.1 ./configure --build=x86_64-regulus-linux-gnu --host=x86_64-regulus-linux-gnu --prefix=/tools make -j32 && make install
Tar-1.26
tar -xjf $SRC/tar-1.26.tar.bz2 -C $BUILD cd $BUILD/tar-1.26 sed -i -e '/gets is a/d' gnu/stdio.in.h ./configure --build=x86_64-regulus-linux-gnu --host=x86_64-regulus-linux-gnu --prefix=/tools make -j32 && make install
Texinfo-4.13a
tar -xzf $SRC/texinfo-4.13a.tar.gz -C $BUILD cd $BUILD/texinfo-4.13 ./configure --build=x86_64-regulus-linux-gnu --host=x86_64-regulus-linux-gnu --prefix=/tools make -j32 && make install
Xz-5.0.4
tar -xjf $SRC/xz-5.0.4.tar.bz2 -C $BUILD cd $BUILD/xz-5.0.4 ./configure --build=x86_64-regulus-linux-gnu --host=x86_64-regulus-linux-gnu --prefix=/tools make -j32 && make install
Stripping (可选)
strip --strip-debug /tools/lib/* strip --strip-unneeded /tools/{,s}bin/*
备份临时系统
chown -R root:root $LFS/tools cd /mnt/lfs/tools tar --numeric-owner -czvplf ${HOME}/lfs_chaintools.tar.gz *
真正的开始
Preparing Virtual Kernel File Systems
mkdir -v $LFS/{dev,proc,sys} mknod -m 600 $LFS/dev/console c 5 1 mknod -m 666 $LFS/dev/null c 1 3 mount -v --bind /dev $LFS/dev mount -vt devpts devpts $LFS/dev/pts mount -vt proc proc $LFS/proc mount -vt sysfs sysfs $LFS/sys if [ -h /dev/shm ]; then rm -f $LFS/dev/shm mkdir $LFS/dev/shm fi mount -vt tmpfs shm $LFS/dev/shm chroot "$LFS" /tools/bin/env -i \ HOME=/root \ TERM="$TERM" \ PS1='\u:\w\$ ' \ PATH=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \ /tools/bin/bash --login +h
建立目标系统文件目录结构
mkdir -pv /{bin,boot,etc/{opt,sysconfig},home,lib,mnt,opt,run} mkdir -pv /{media/{floppy,cdrom},sbin,srv,var} install -dv -m 0750 /root install -dv -m 1777 /tmp /var/tmp mkdir -pv /usr/{,local/}{bin,include,lib,sbin,src} mkdir -pv /usr/{,local/}share/{doc,info,locale,man} mkdir -v /usr/{,local/}share/{misc,terminfo,zoneinfo} mkdir -pv /usr/{,local/}share/man/man{1..8} for dir in /usr /usr/local; do ln -sv share/{man,doc,info} $dir done case $(uname -m) in x86_64) ln -sv lib /lib64 && ln -sv lib /usr/lib64 ;; esac mkdir -v /var/{log,mail,spool} ln -sv /run /var/run ln -sv /run/lock /var/lock mkdir -pv /var/{opt,cache,lib/{misc,locate},local}
ln -sv /tools/bin/{bash,cat,echo,pwd,stty} /bin ln -sv /tools/bin/perl /usr/bin ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib ln -sv /tools/lib/libstdc++.so{,.6} /usr/lib sed 's/tools/usr/' /tools/lib/libstdc++.la > /usr/lib/libstdc++.la ln -sv bash /bin/sh
touch /etc/mtab cat > /etc/passwd << "EOF" root:x:0:0:root:/root:/bin/bash bin:x:1:1:bin:/dev/null:/bin/false nobody:x:99:99:Unprivileged User:/dev/null:/bin/false EOF
cat > /etc/group << "EOF" root:x:0: bin:x:1: sys:x:2: kmem:x:3: tape:x:4: tty:x:5: daemon:x:6: floppy:x:7: disk:x:8: lp:x:9: dialout:x:10: audio:x:11: video:x:12: utmp:x:13: usb:x:14: cdrom:x:15: mail:x:34: nogroup:x:99: EOF
exec /tools/bin/bash --login +h touch /var/log/{btmp,lastlog,wtmp} chgrp -v utmp /var/log/lastlog chmod -v 664 /var/log/lastlog chmod -v 600 /var/log/btmp
Linux内核头文件
make mrproper make ARCH=x86_64 headers_check make ARCH=x86_64 INSTALL_HDR_PATH=dest headers_install cp -rv dest/include/* /tools/include find /tools/include -name .install -or -name ..install.cmd | xargs rm -fv
glibc 2.16
if [ ! -r /mnt/lfs/tools/include/rpc/types.h ]; then su -c 'mkdir -p /mnt/lfs/tools/include/rpc' su -c 'cp -v sunrpc/rpc/*.h /mnt/lfs/tools/include/rpc' fi sed -i 's/ -lgcc_s//' Makeconfig mkdir glibc-build cd glibc-build ../configure \ --build=x86_64-regulus-linux-gnu \ --host=x86_64-regulus-linux-gnu \ --prefix=/mnt/lfs/usr \ --disable-profile \ --enable-add-ons \ --enable-kernel=2.6.30 \ --with-headers=/mnt/lfs/usr/include \ libc_cv_forced_unwind=yes \ libc_cv_ctors_header=yes \ libc_cv_c_cleanup=yes
Zlib-1.2.7
binutils
mkdir binutils-build cd binutils-build ../configure \
--build=x86_64-linux-gnu \ --host=x86_64-regulus-linux-gnu \ --with-sysroot=/mnt/lfs \ --prefix=/mnt/lfs/usr \ --disable-nls \ --with-lib-path=/mnt/lfs/usr/lib
make -j32 make install
gcc
../gcc-4.7.2/configure --build=x86_64-regulus-linux-gnu \ --host=x86_64-regulus-linux-gnu \ --target=x86_64-regulus-linux-gnu \ --prefix=/usr \ --libexecdir=/usr/lib \ --enable-shared \ --enable-threads=posix \ --enable-__cxa_atexit \ --enable-clocale=gnu \ --enable-languages=c,c++ \ --disable-multilib \ --disable-bootstrap \ --with-system-zlib
6.1 install man-pages
tar -xvpf /sources/man-pages-3.35.tar.gz make install
6.2 install man-pages
tar -xjf $SRC/linux-3.0.4.tar.bz2 -C $BUILD cd $BUILD/linux-3.0.4 make mrproper make headers_check make INSTALL_HDR_PATH=dest headers_install find dest/include \( -name .install -o -name ..install.cmd \) -delete cp -rv dest/include/* /usr/include
6.11. Zlib-1.2.5
tar -xjf $SRC/zlib-1.2.5.tar.bz2 -C $BUILD cd $BUILD/zlib-1.2.5 sed -i 's/ifdef _LARGEFILE64_SOURCE/ifndef _LARGEFILE64_SOURCE/' zlib.h CFLAGS='-mstackrealign -fPIC -O3' ./configure --prefix=/usr make make install mv -v /usr/lib/libz.so.* /lib ln -sfv ../../lib/libz.so.1.2.5 /usr/lib/libz.so
6.12. File-5.09
tar -xvf $SRC/file-5.09.tar.gz -C $BUILD cd $BUILD/file-5.09 ./configure --prefix=/usr make make install
6.13. Binutils-2.21.1a
expect -c "spawn ls"
tar -xjf $SRC/binutils-2.21.1.tar.bz2 -C $BUILD cd $BUILD/binutils-2.21.1 rm -fv etc/standards.info sed -i.bak '/^INFO/s/standards.info //' etc/Makefile.in sed -i "/exception_defines.h/d" ld/testsuite/ld-elf/new.cc sed -i "s/-fvtable-gc //" ld/testsuite/ld-selective/selective.exp mkdir -v ../binutils-build cd ../binutils-build ../binutils-2.21.1/configure --prefix=/usr --enable-shared make tooldir=/usr make tooldir=/usr install cp -v ../binutils-2.21.1/include/libiberty.h /usr/include
6.14. GMP-5.0.2
tar -xjf $SRC/gmp-5.0.2.tar.bz2 -C $BUILD cd $BUILD/gmp-5.0.2 sed -i 's/np + dn, qn/& - dn/' mpn/generic/dcpi1_bdiv_q.c ./configure --prefix=/usr --enable-cxx --enable-mpbsd make make install mkdir -v /usr/share/doc/gmp-5.0.2 cp -v doc/{isa_abi_headache,configuration} doc/*.html \
/usr/share/doc/gmp-5.0.2
6.15. MPFR-3.1.0
tar -xjf $SRC/mpfr-3.1.0.tar.bz2 -C $BUILD cd $BUILD/mpfr-3.1.0 ./configure --prefix=/usr --enable-thread-safe --docdir=/usr/share/doc/mpfr-3.1.0 make make install make html make install-html
6.16. MPC-0.9
tar -xvf $SRC/mpc-0.9.tar.gz -C $BUILD cd $BUILD/mpc-0.9 ./configure --prefix=/usr make make install
6.17. GCC-4.6.1
tar -xvf $SRC/gcc-4.6.1.tar.bz2 -C $BUILD cd $BUILD/gcc-4.6.1
sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in case `uname -m` in
i?86) sed -i 's/^T_CFLAGS =$/& -fomit-frame-pointer/' \ gcc/Makefile.in ;;
esac sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in patch -Np1 -i $SRC/gcc-4.6.1-locale-1.patch mkdir -v ../gcc-build cd ../gcc-build ../gcc-4.6.1/configure --prefix=/usr \
--libexecdir=/usr/lib --enable-shared \ --enable-threads=posix --enable-__cxa_atexit \ --enable-clocale=gnu --enable-languages=c,c++ \ --disable-multilib --disable-bootstrap --with-system-zlib
make
- testing #####################
ulimit -s 16384 make -k check ../gcc-4.6.1/contrib/test_summary
- testing #####################
make install ln -sv ../usr/bin/cpp /lib ln -sv gcc /usr/bin/cc
- testing ######################
6.18. Sed-4.2.1
tar -xvf $SRC/sed-4.2.1.tar.bz2 -C $BUILD cd $BUILD/sed-4.2.1 ./configure --prefix=/usr --bindir=/bin --htmldir=/usr/share/doc/sed-4.2.1 make make html make install make -C doc install-html
Pkg-config-0.26
tar -xzf $SRC/pkg-config-0.26.tar.gz -C $BUILD cd $BUILD/pkg-config-0.26 ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var make make install
Bzip2-1.0.6
tar -xzf $SRC/bzip2-1.0.6.tar.gz -C $BUILD cd $BUILD/bzip2-1.0.6 patch -Np1 -i $SRC/bzip2-1.0.6-install_docs-1.patch sed -i 's@\(ln -s -f \)$(PREFIX)/bin/@\1@' Makefile make -f Makefile-libbz2_so make clean make make PREFIX=/usr install cp -v bzip2-shared /bin/bzip2 cp -av libbz2.so* /lib ln -sv ../../lib/libbz2.so.1.0 /usr/lib/libbz2.so rm -v /usr/bin/{bunzip2,bzcat,bzip2} ln -sv bzip2 /bin/bunzip2 ln -sv bzip2 /bin/bzcat
6.20. Ncurses-5.9
tar -xzf $SRC/ncurses-5.9.tar.gz -C $BUILD cd $BUILD/ncurses-5.9 ./configure --prefix=/usr --with-shared --without-debug --enable-widec make make install mv -v /usr/lib/libncursesw.so.5* /lib ln -sfv ../../lib/libncursesw.so.5 /usr/lib/libncursesw.so for lib in ncurses form panel menu ; do \
rm -vf /usr/lib/lib${lib}.so ; \ echo "INPUT(-l${lib}w)" >/usr/lib/lib${lib}.so ; \ ln -sfv lib${lib}w.a /usr/lib/lib${lib}.a ; \
done ln -sfv libncurses++w.a /usr/lib/libncurses++.a rm -vf /usr/lib/libcursesw.so echo "INPUT(-lncursesw)" >/usr/lib/libcursesw.so ln -sfv libncurses.so /usr/lib/libcurses.so ln -sfv libncursesw.a /usr/lib/libcursesw.a ln -sfv libncurses.a /usr/lib/libcurses.a mkdir -v /usr/share/doc/ncurses-5.9 cp -v -R doc/* /usr/share/doc/ncurses-5.9
Util-linux-2.20
tar -xjf $SRC/util-linux-2.20.tar.bz2 -C $BUILD cd $BUILD/util-linux-2.20
sed -e 's@etc/adjtime@var/lib/hwclock/adjtime@g' -i $(grep -rl '/etc/adjtime' .) mkdir -pv /var/lib/hwclock
./configure --enable-arch --enable-partx --enable-write make make install
6.22. E2fsprogs-1.41.14
tar -xzf $SRC/e2fsprogs-1.41.14.tar.gz -C $BUILD cd $BUILD/e2fsprogs-1.41.14 mkdir -v build cd build ../configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --with-root-prefix="" --enable-elf-shlibs --disable-libblkid --disable-libuuid --disable-uuidd --disable-fsck
make make install make install-libs chmod -v u+w /usr/lib/{libcom_err,libe2p,libext2fs,libss}.a
gunzip -v /usr/share/info/libext2fs.info.gz install-info --dir-file=/usr/share/info/dir /usr/share/info/libext2fs.info
6.23. Coreutils-8.14
tar -xvf $SRC/coreutils-8.14.tar.bz2 -C $BUILD cd $BUILD/coreutils-8.14 case `uname -m` in
i?86 | x86_64) patch -Np1 -i $SRC/coreutils-8.14-uname-1.patch ;;
esac patch -Np1 -i $SRC/coreutils-8.14-i18n-1.patch ./configure --prefix=/usr --enable-no-install-program=kill,uptime make make install mv -v /usr/bin/{cat,chgrp,chmod,chown,cp,date,dd,df,echo} /bin mv -v /usr/bin/{false,ln,ls,mkdir,mknod,mv,pwd,rm} /bin mv -v /usr/bin/{rmdir,stty,sync,true,uname} /bin mv -v /usr/bin/chroot /usr/sbin mv -v /usr/share/man/man1/chroot.1 /usr/share/man/man8/chroot.8 sed -i s/\"1\"/\"8\"/1 /usr/share/man/man8/chroot.8 mv -v /usr/bin/{head,sleep,nice,touch} /bin
6.24. Iana-Etc-2.30
tar -xjf $SRC/iana-etc-2.30.tar.bz2 -C $BUILD cd $BUILD/iana-etc-2.30 make make install
6.25. M4-1.4.16
tar -xjf $SRC/m4-1.4.16.tar.bz2 -C $BUILD cd $BUILD/m4-1.4.16 ./configure --prefix=/usr make make install
6.26. Bison-2.5
tar -xjf $SRC/bison-2.5.tar.bz2 -C $BUILD cd $BUILD/bison-2.5 ./configure --prefix=/usr echo '#define YYENABLE_NLS 1' >> lib/config.h make make install
6.27. Procps-3.2.8
tar -xzf $SRC/procps-3.2.8.tar.gz -C $BUILD cd $BUILD/procps-3.2.8 patch -Np1 -i $SRC/procps-3.2.8-fix_HZ_errors-1.patch patch -Np1 -i $SRC/procps-3.2.8-watch_unicode-1.patch sed -i -e 's@\*/module.mk@proc/module.mk ps/module.mk@' Makefile make make install
6.28. Grep-2.9
tar -xzf $SRC/grep-2.9.tar.bz2 -C $BUILD cd $BUILD/grep-2.9 sed -i 's/cp/#&/' tests/unibyte-bracket-expr ./configure --prefix=/usr --bindir=/bin make make install
6.29. Readline-6.2
tar -xvf $SRC/readline-6.2.tar.gz -C $BUILD cd $BUILD/readline-6.2 sed -i '/MV.*old/d' Makefile.in sed -i '/{OLDSUFF}/c:' support/shlib-install patch -Np1 -i $SRC/readline-6.2-fixes-1.patch ./configure --prefix=/usr --libdir=/lib make SHLIB_LIBS=-lncurses make install mv -v /lib/lib{readline,history}.a /usr/lib rm -v /lib/lib{readline,history}.so ln -sfv ../../lib/libreadline.so.6 /usr/lib/libreadline.so ln -sfv ../../lib/libhistory.so.6 /usr/lib/libhistory.so mkdir -v /usr/share/doc/readline-6.2 install -v -m644 doc/*.{ps,pdf,html,dvi} /usr/share/doc/readline-6.2
6.30. Bash-4.2
tar -xvf $SRC/bash-4.2.tar.gz -C $BUILD cd $BUILD/bash-4.2 patch -Np1 -i $SRC/bash-4.3-fixes-2.patch ./configure --prefix=/usr --bindir=/bin --htmldir=/usr/share/doc/bash-4.2 --without-bash-malloc \
--with-installed-readline
make make install
exec /bin/bash --login +h
6.31. Libtool-2.4
tar -xzf $SRC/libtool-2.4.tar.gz -C $BUILD cd $BUILD/libtool-2.4 ./configure --prefix=/usr make make install
6.32. GDBM-1.9.1
tar -xzf $SRC/gdbm-1.9.1.tar.gz -C $BUILD cd gdbm-1.9.1 ./configure --prefix=/usr --enable-libgdbm-compat make make install
6.33. Inetutils-1.8
tar -xvf $SRC/inetutils-1.8.tar.gz -C $BUILD cd $BUILD/inetutils-1.8 ./configure --prefix=/usr --libexecdir=/usr/sbin \
--localstatedir=/var --disable-ifconfig \ --disable-logger --disable-syslogd --disable-whois \ --disable-servers
make install make -C doc html make -C doc install-html docdir=/usr/share/doc/inetutils-1.8 mv -v /usr/bin/{hostname,ping,ping6} /bin mv -v /usr/bin/traceroute /sbin
6.34. Perl-5.14.2
tar -xvf $SRC/perl-5.14.2.tar.gz -C $BUILD cd $BUILD/perl-5.14.2
echo "127.0.0.1 localhost $(hostname)" > /etc/hosts
sed -i -e "s|BUILD_ZLIB\s*= True|BUILD_ZLIB = False|" \
-e "s|INCLUDE\s*= ./zlib-src|INCLUDE = /usr/include|" \ -e "s|LIB\s*= ./zlib-src|LIB = /usr/lib|" \ cpan/Compress-Raw-Zlib/config.in
sh Configure -des -Dprefix=/usr \
-Dvendorprefix=/usr \ -Dman1dir=/usr/share/man/man1 \ -Dman3dir=/usr/share/man/man3 \ -Dpager="/usr/bin/less -isR" \ -Duseshrplib
make make install
6.35. Autoconf-2.68
tar -xjf $SRC/autoconf-2.68.tar.bz2 -C $BUILD cd $BUILD/autoconf-2.68 ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var make make install
6.36. Automake-1.11.1
tar -xjf $SRC/automake-1.11.1.tar.bz2 -C $BUILD cd $BUILD/automake-1.11.1 ./configure --prefix=/usr --docdir=/usr/share/doc/automake-1.11.1 make make install
6.37. Diffutils-3.2
tar -xvf $SRC/diffutils-3.2.tar.bz2 -C $BUILD cd $BUILD/diffutils-3.2 ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var make make install
6.38. Gawk-4.0.0
tar -xjf $SRC/gawk-4.0.0.tar.bz2 -C $BUILD cd $BUILD/gawk-4.0.0 ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --libexecdir=/usr/lib make make install mkdir -v /usr/share/doc/gawk-4.0.0 cp -v doc/{awkforai.txt,*.{eps,pdf,jpg}} /usr/share/doc/gawk-4.0.0
6.39. Findutils-4.4.2
tar -xzf $SRC/findutils-4.4.2.tar.gz -C $BUILD cd $BUILD/findutils-4.4.2 ./configure --prefix=/usr --libexecdir=/usr/lib/findutils --localstatedir=/var/lib/locate make make install mv -v /usr/bin/find /bin sed -i 's/find:=${BINDIR}/find:=\/bin/' /usr/bin/updatedb
6.40. Flex-2.5.35
tar -xvf $SRC/flex-2.5.35.tar.bz2 -C $BUILD cd $BUILD/flex-2.5.35 patch -Np1 -i $SRC/flex-2.5.35-gcc44-1.patch ./configure --prefix=/usr make make install
ln -sv libfl.a /usr/lib/libl.a
cat > /usr/bin/lex << "EOF"
- !/bin/sh
- Begin /usr/bin/lex
exec /usr/bin/flex -l "$@"
- End /usr/bin/lex
EOF
chmod -v 755 /usr/bin/lex
- mkdir -v /usr/share/doc/flex-2.5.35
- cp -v doc/flex.pdf \
- /usr/share/doc/flex-2.5.35
6.41. Gettext-0.18.1.1
tar -xvf $SRC/gettext-0.18.1.1.tar.gz -C $BUILD cd $BUILD/gettext-0.18.1.1 ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var make make install
6.42. Groff-1.21
tar -xVf $SRC/groff-1.21.tar.gz -C $BUILD cd $BUILD/groff-1.21 PAGE=A4 ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var make make install ln -sv eqn /usr/bin/geqn ln -sv tbl /usr/bin/gtbl
6.43. GRUB-1.99
tar -xvf $SRC/grub-1.99.tar.gz -C $BUILD cd $BUILD/grub-1.99 ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var make make install
6.44. Gzip-1.4
tar -xzf $SRC/gzip-1.4.tar.gz -C $BUILD cd $BUILD/gzip-1.4 ./configure --prefix=/usr --bindir=/bin make make install mv -v /bin/{gzexe,uncompress,zcmp,zdiff,zegrep} /usr/bin mv -v /bin/{zfgrep,zforce,zgrep,zless,zmore,znew} /usr/bin
6.45. IPRoute2-2.6.39
tar -xvpf $SRC/iproute2-2.6.39.tar.gz -C $BUILD cd $BUILD/iproute2-2.6.39 sed -i '/^TARGETS/s@arpd@@g' misc/Makefile make DESTDIR= make DESTDIR= SBINDIR=/sbin MANDIR=/usr/share/man DOCDIR=/usr/share/doc/iproute2-2.6.39 install make install
6.46. Kbd-1.15.2
tar -xvf $SRC/kbd-1.15.3.tar.gz -C $BUILD cd $BUILD/kbd-1.15.3 patch -Np1 -i $SRC/kbd-1.15.2-backspace-1.patch ./configure --prefix=/usr --datadir=/lib/kbd make make install mv -v /usr/bin/{kbd_mode,loadkeys,openvt,setfont} /bin mkdir -v /usr/share/doc/kbd-1.15.3 cp -R -v doc/* /usr/share/doc/kbd-1.15.3
6.47. Less-444
tar -xzf $SRC/less-444.tar.gz -C $BUILD cd $BUILD/less-444 ./configure --prefix=/usr --sysconfdir=/etc make make install
6.48. Libpipeline-1.2.0
tar -xvf $SRC/libpipeline-1.2.0.tar.gz -C $BUILD cd $BUILD/libpipeline-1.2.0 ./configure CHECK_CFLAGS=-I/tools/include CHECK_LIBS="-L/tools/lib -lcheck" --prefix=/usr make make install
6.49. Make-3.82
tar -xjf $SRC/make-3.82.tar.bz2 -C $BUILD cd $BUILD/make-3.82 ./configure --prefix=/usr make make install
6.50. Xz-5.0.3
tar -xjf $SRC/xz-5.0.3.tar.bz2 -C $BUILD cd xz-5.0.3 ./configure --prefix=/usr --docdir=/usr/share/doc/xz-5.0.3 make make install
6.50. Xz-5.0.3
PKG_CONFIG=/tools/bin/true \
libpipeline_CFLAGS= \ libpipeline_LIBS='-lpipeline' \ ./configure --prefix=/usr --libexecdir=/usr/lib \ --docdir=/usr/share/doc/man-db-2.6.0.2 --sysconfdir=/etc \ --disable-setuid --with-browser=/usr/bin/lynx \ --with-vgrind=/usr/bin/vgrind --with-grap=/usr/bin/grap
6.51. Man-DB-2.6.0.2
- tar -xvf $SRC/man-db-2.6.0.2.tar.gz -C $BUILD
- cd $BUILD/man-db-2.6.0.2
- PKG_CONFIG=/tools/bin/true libpipeline_CFLAGS= libpipeline_LIBS='-lpipeline' ./configure --prefix=/usr --libexecdir=/usr/lib --docdir=/usr/share/doc/man-#db-2.6.0.2 --sysconfdir=/etc --disable-setuid --with-browser=/usr/bin/lynx --with-vgrind=/usr/bin/vgrind --with-grap=/usr/bin/grap
- make
- make install
6.52. Module-Init-Tools-3.16
tar -xvf $SRC/module-init-tools-3.16.tar.bz2 -C $BUILD cd $BUILD/module-init-tools-3.16 patch -Np1 -i $SRC/module-init-tools-3.16-man_pages-1.patch DOCBOOKTOMAN=/bin/true ./configure sed -i -e 's@../../configure@DOCBOOKTOMAN=/bin/true &@' tests/runtests ./tests/runtests DOCBOOKTOMAN=/bin/true ./configure --prefix=/ --enable-zlib-dynamic --mandir=/usr/share/man make make INSTALL=install install
6.53. Patch-2.6.1
tar -xjf $SRC/patch-2.6.1.tar.bz2 -C $BUILD cd $BUILD/patch-2.6.1 patch -Np1 -i $SRC/patch-2.6.1-test_fix-1.patch ./configure --prefix=/usr make make install
6.54. Psmisc-22.14
tar -xvf $SRC/psmisc-22.14.tar.gz -C $BUILD cd $BUILD/psmisc-22.14 ./configure --prefix=/usr make make install mv -v /usr/bin/fuser /bin mv -v /usr/bin/killall /bin
6.55. Shadow-4.1.4.3
tar -xvf $SRC/shadow-4.1.4.3.tar.bz2 -C $BUILD cd $BUILD/shadow-4.1.4.3 sed -i 's/groups$(EXEEXT) //' src/Makefile.in find man -name Makefile.in -exec sed -i 's/groups\.1 / /' {} \; sed -i 's/man_MANS = $(man_nopam) /man_MANS = /' man/ru/Makefile.in sed -i -e 's@#ENCRYPT_METHOD DES@ENCRYPT_METHOD SHA512@' -e 's@/var/spool/mail@/var/mail@' etc/login.defs ./configure --sysconfdir=/etc make make install mv -v /usr/bin/passwd /bin
6.56. Sysklogd-1.5
tar -xvf $SRC/sysklogd-1.5.tar.gz -C $BUILD cd $BUILD/sysklogd-1.5 make make BINDIR=/sbin install
cat > /etc/syslog.conf << "EOF"
- Begin /etc/syslog.conf
auth,authpriv.* -/var/log/auth.log
- .*;auth,authpriv.none -/var/log/sys.log
daemon.* -/var/log/daemon.log kern.* -/var/log/kern.log mail.* -/var/log/mail.log user.* -/var/log/user.log
- .emerg *
- End /etc/syslog.conf
EOF
6.56. Sysklogd-1.5
tar -xjf $SRC/sysvinit-2.88dsf.tar.bz2 -C $BUILD cd $BUILD/sysvinit-2.88dsf
sed -i 's@Sending processes@& configured via /etc/inittab@g' src/init.c sed -i -e 's/utmpdump wall/utmpdump/' -e '/= mountpoint/d' -e 's/mountpoint.1 wall.1//' src/Makefile make -C src make -C src install
cat > /etc/inittab << "EOF"
- Begin /etc/inittab
id:3:initdefault:
si::sysinit:/etc/rc.d/init.d/rc sysinit
l0:0:wait:/etc/rc.d/init.d/rc 0 l1:S1:wait:/etc/rc.d/init.d/rc 1 l2:2:wait:/etc/rc.d/init.d/rc 2 l3:3:wait:/etc/rc.d/init.d/rc 3 l4:4:wait:/etc/rc.d/init.d/rc 4 l5:5:wait:/etc/rc.d/init.d/rc 5 l6:6:wait:/etc/rc.d/init.d/rc 6
ca:12345:ctrlaltdel:/sbin/shutdown -t1 -a -r now
su:S016:once:/sbin/sulogin
1:2345:respawn:/sbin/agetty tty1 9600 2:2345:respawn:/sbin/agetty tty2 9600 3:2345:respawn:/sbin/agetty tty3 9600 4:2345:respawn:/sbin/agetty tty4 9600 5:2345:respawn:/sbin/agetty tty5 9600 6:2345:respawn:/sbin/agetty tty6 9600
- End /etc/inittab
EOF
6.58. Tar-1.26
tar -xjf $SRC/tar-1.26.tar.bz2 -C $BUILD cd $BUILD/tar-1.26 FORCE_UNSAFE_CONFIGURE=1 ./configure --prefix=/usr \
--bindir=/bin --libexecdir=/usr/sbin
make make install make -C doc install-html docdir=/usr/share/doc/tar-1.26
6.59. Texinfo-4.13a
tar -xvf $SRC/texinfo-4.13a.tar.gz -C $BUILD cd $BUILD/texinfo-4.13 ./configure --prefix=/usr make make install make TEXMF=/usr/share/texmf install-tex
cd /usr/share/info rm -v dir for f in * do install-info $f dir 2>/dev/null done
6.59. Texinfo-4.13a
tar -xvf $SRC/udev-173.tar.bz2 -C $BUILD cd $BUILD/udev-173 tar -xvf $SRC/udev-config-20100128.tar.bz2 tar -xvf $SRC/udev-173-testfiles.tar.bz2 --strip-components=1 install -dv /lib/{firmware,udev/devices/pts} mknod -m0666 /lib/udev/devices/null c 1 3 ./configure --prefix=/usr --sysconfdir=/etc --sbindir=/sbin \
--with-rootlibdir=/lib --libexecdir=/lib/udev \ --disable-hwdb --disable-introspection \ --disable-keymap --disable-gudev
make make install rmdir -v /usr/share/doc/udev cd udev-config-20100128 make install make install-doc
6.61. Vim-7.3
tar -xvpf $SRC/vim-7.3.tar.bz2 -C $BUILD cd $BUILD/vim73 ./configure --prefix=/usr --enable-multibyte make make install ln -sv vim /usr/bin/vi for L in /usr/share/man/{,*/}man1/vim.1; do
ln -sv vim.1 $(dirname $L)/vi.1
done
- ln -sv ../vim/vim73/doc /usr/share/doc/vim-7.3
cat > /etc/vimrc << "EOF"
" Begin /etc/vimrc
set nocompatible set backspace=2 syntax on if (&term == "iterm") || (&term == "putty")
set background=dark
endif
" End /etc/vimrc EOF
/etc/hosts
cat > /etc/hosts << "EOF"
- Begin /etc/hosts (no network card version)
127.0.0.1 buluoos.com localhost
- End /etc/hosts (no network card version)
EOF
/etc/hosts
echo "HOSTNAME=BuluoOS" > /etc/sysconfig/network
/etc/sysconfig/clock
cat > /etc/sysconfig/clock << "EOF"
- Begin /etc/sysconfig/clock
UTC=1
- Set this to any options you might need to give to hwclock,
- such as machine hardware clock type for Alphas.
CLOCKPARAMS=
- End /etc/sysconfig/clock
EOF
/etc/profile
cat > /etc/profile << "EOF"
- Begin /etc/profile
- export LANG=<ll>_<CC>.<charmap><@modifiers>
export LANG=zh_CN.UTF-8
- End /etc/profile
EOF
/etc/inputrc
cat > /etc/inputrc << "EOF"
- Begin /etc/inputrc
- Modified by Chris Lynn <[email protected]>
- Allow the command prompt to wrap to the next line
set horizontal-scroll-mode Off
- Enable 8bit input
set meta-flag On set input-meta On
- Turns off 8th bit stripping
set convert-meta Off
- Keep the 8th bit for display
set output-meta On
- none, visible or audible
set bell-style none
- All of the following map the escape sequence of the value
- contained in the 1st argument to the readline specific functions
"\eOd": backward-word "\eOc": forward-word
- for linux console
"\e[1~": beginning-of-line "\e[4~": end-of-line "\e[5~": beginning-of-history "\e[6~": end-of-history "\e[3~": delete-char "\e[2~": quoted-insert
- for xterm
"\eOH": beginning-of-line "\eOF": end-of-line
- for Konsole
"\e[H": beginning-of-line "\e[F": end-of-line
- End /etc/inputrc
EOF
/etc/fstab
cat > /etc/fstab << "EOF"
- Begin /etc/fstab
- file system mount-point type options dump fsck
- order
/dev/sda6 / <fff> defaults 1 1
- /dev/<yyy> swap swap pri=1 0 0
proc /proc proc defaults 0 0 sysfs /sys sysfs defaults 0 0 devpts /dev/pts devpts gid=4,mode=620 0 0 tmpfs /run tmpfs defaults 0 0
- End /etc/fstab
EOF
echo 7.3 > /etc/lfs-release
glibc-headers
if [ ! -r /tools/include/rpc/types.h ]; then su -c 'mkdir -p /tools/include/rpc' su -c 'cp -v sunrpc/rpc/*.h /tools/include/rpc' fi mkdir -v glibc-build cd glibc-build ../configure --prefix=/tools --build=x86_64-linux-gnu --host=x86_64-regulus-linux-gnu --with-headers=/tools/include make install-headers
参考文档
- 中文文档参考笔记 http://davidgao.github.com/LFSCN/
- LFS官方主页文档 http://www.linuxfromscratch.org/lfs/view/development/
后记
LFS好比给你的是一份菜谱,教你如何做成Linux From Strach这道菜,至于你如何从买菜,切菜到做菜,因人而异。等你这份菜谱上的菜都做的烂熟于心了,可能你开始想让Linux From Strach这道菜做的更加美味,那就全凭悟性与修为了!