宿主系统: ubuntu 14.04 64位
并下载 http://ftp.lfs-matrix.net/pub/lfs/lfs-packages/lfs-packages-7.7-systemd.tar
329M,这个是所有的源代码的打包
一.准备工作
1.
a.建立分区
-
cong@msi:/work$ sudo mkfs.ext4 /dev/sda5 #将/dev/sda5格式化为ext4
-
cong@msi:/work$ export LFS=/mnt/lfs #
-
cong@msi:/work$ sudo mkdir -pv $LFS # 建立挂载点
-
cong@msi:/work$ sudo mount -v -t ext4 /dev/sda5 $LFS # 将 /dev/<xxx> 挂载到 $LFS
b.建立lfs用户
-
cong@msi:/work$ sudo groupadd lfs
-
cong@msi:/work$ sudo useradd -s /bin/bash -g lfs -m -k /dev/null lfs
-
cong@msi:/work$ sudo passwd lfs
c.建立源码与编译的目录
-
cong@msi:/work$ mkdir -v $LFS/tools
-
cong@msi:/work$ mkdir -v $LFS/sources
-
-
cong@msi:/work$ sudo ln -sv /mnt/lfs/tools/ /
-
‘/tools’ -> ‘/mnt/lfs/tools/’
-
cong@msi:/work$ ls -l /
-
lrwxrwxrwx 1 root root 15 Jan 25 10:44 tools -> /mnt/lfs/tools/
d. 解压源码到sources目录
-
cong@msi:/work$ sudo tar czf ./lfs-packages-7.7-systemd.tar -C$LFS/sources
e.此时所有的操作都是在非lfs用户下进行的,一会就要切换到lfs用户了,这时需要把所有的文件owner都改为lfs
-
cong@msi:/mnt$ sudo chown lfs:lfs ./lfs -R
f.切换到lfs用户
-
cong@msi:/mnt/lfs$ sudo su - lfs
-
lfs@msi:~$ pwd #这是进入到了lfs的家目录
-
/home/lfs
2.设置环境
-
cat > ~/.bash_profile << "EOF"
-
exec env -i HOME=$HOME TERM=$TERM PS1='\u:\w\$ ' /bin/bash
-
EOF
-
-
cat > ~/.bashrc << "EOF"
-
set +h
-
umask 022
-
LFS=/mnt/lfs
-
LC_ALL=POSIX
-
LFS_TGT=$(uname -m)-lfs-linux-gnu
-
PATH=/tools/bin:/bin:/usr/bin
-
export LFS LC_ALL LFS_TGT PATH
-
EOF
不退出使环境生效
source ~/.bash_profile
退出重新登陆也可以使环境生效
sudo su - lfs 即可
二.源码编译
2.1 第一遍编译binutils-2.25
-
lfs@msi:/mnt/lfs/sources$ tar xf binutils-2.25.tar.bz2
-
lfs@msi:/mnt/lfs/sources$ mkdir -v binutils-build
-
mkdir: created directory './binutils-build'
-
lfs@msi:/mnt/lfs/sources$ cd binutils-build/
-
lfs@msi:/mnt/lfs/sources/binutils-build$ ../binutils-2.25/configure --prefix=/tools --with-sysroot=$LFS --with-lib-path=/tools/lib --target=$LFS_TGT --disable-nls --disable-werror
-
lfs@msi:/mnt/lfs/sources/binutils-build$ make
-
lfs@msi:/mnt/lfs/sources/binutils-build$ make install
a. ubuntu下编译时如果报WARNING: `makeinfo' is missing on your system.
说明texinfo没有装,安装 cong@msi:/work$ sudo apt-get install texinfo
注意: 这儿make时没有加-j8,是因为make -j8会报错
b.我的机子是64位的需要执行如下
-
lfs@msi:/mnt/lfs/sources/binutils-build$ mkdir -v /tools/lib
-
lfs@msi:/mnt/lfs/sources/binutils-build$ ln -sv /tools/lib /tools/lib64
建一个/tools/lib64的符号链接,如果不做这一步下面的2.5第2遍编译binutils时会报错:
cannot run C compiled programs
2.2 第一遍编译gcc-4.9.2
-
lfs@msi:/mnt/lfs/sources$ tar xf gcc-4.9.2.tar.bz2
-
lfs@msi:/mnt/lfs/sources$ cd gcc-4.9.2
-
lfs@msi:/mnt/lfs/sources/gcc-4.9.2$ tar xf ../mpfr-3.1.2.tar.xz
-
lfs@msi:/mnt/lfs/sources/gcc-4.9.2$ tar xf ../gmp-6.0.0a.tar.xz
-
lfs@msi:/mnt/lfs/sources/gcc-4.9.2$ tar xf ../mpc-1.0.2.tar.gz
-
lfs@msi:/mnt/lfs/sources/gcc-4.9.2$ mv mpfr-3.1.2/ mpfr
-
lfs@msi:/mnt/lfs/sources/gcc-4.9.2$ mv gmp-6.0.0/ gmp
-
lfs@msi:/mnt/lfs/sources/gcc-4.9.2$ mv mpc-1.0.2/ mpc
-
-
lfs@msi:/mnt/lfs/sources/gcc-4.9.2$ 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
-
lfs@msi:/mnt/lfs/sources/gcc-4.9.2$ sed -i '/k prot/agcc_cv_libc_provides_ssp=yes' gcc/configure
-
lfs@msi:/mnt/lfs/sources/gcc-4.9.2$ mkdir ../gcc-build
-
lfs@msi:/mnt/lfs/sources/gcc-4.9.2$ cd ../gcc-build/
-
lfs@msi:/mnt/lfs/sources/gcc-build$ ../gcc-4.9.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-libatomic \
-
--disable-libgomp \
-
--disable-libitm \
-
--disable-libquadmath \
-
--disable-libsanitizer \
-
--disable-libssp \
-
--disable-libvtv \
-
--disable-libcilkrts \
-
--disable-libstdc++-v3 \
-
--enable-languages=c,c++
-
lfs@msi:/mnt/lfs/sources/gcc-build$ make -j8 && make install
lfs@msi:/mnt/lfs/sources/gcc-build$ ls /tools
bin include lib libexec share x86_64-lfs-linux-gnu
2.3 安装 Linux API 头文件
-
lfs@msi:/mnt/lfs/sources$ tar xf linux-3.19.tar.xz
-
lfs@msi:/mnt/lfs/sources$ cd linux-3.19
-
lfs@msi:/mnt/lfs/sources/linux-3.19$ make mrproper
-
lfs@msi:/mnt/lfs/sources/linux-3.19$ make INSTALL_HDR_PATH=dest headers_install
-
lfs@msi:/mnt/lfs/sources/linux-3.19$ cp -rv dest/include/* /tools/include
2.4 安装Glibc
-
lfs@msi:/mnt/lfs/sources$ tar xf glibc-2.21.tar.xz
-
lfs@msi:/mnt/lfs/sources$ cd glibc-2.21
-
lfs@msi:/mnt/lfs/sources/glibc-2.21$ sed -e '/ia32/s/^/1:/' \
-
> -e '/SSE2/s/^1://' \
-
> -i sysdeps/i386/i686/multiarch/mempcpy_chk.S
-
lfs@msi:/mnt/lfs/sources/glibc-2.21$ mkdir -v ../glibc-build
-
mkdir: created directory '../glibc-build'
-
lfs@msi:/mnt/lfs/sources/glibc-2.21$ cd ../glibc-build/
-
lfs@msi:/mnt/lfs/sources/glibc-build$ ../glibc-2.21/configure \
-
> --prefix=/tools \
-
> --host=$LFS_TGT \
-
> --build=$(../glibc-2.21/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
-
lfs@msi:/mnt/lfs/sources/glibc-build$ make -j8 && make install
a. 注意:如果在configure时出现下面的错误,说明gawk没有装
-
configure: error:
-
*** These critical programs are missing or too old: gawk
-
*** Check the INSTALL file for required versions.
lfs@msi:/mnt/lfs/sources/glibc-build$ sudo apt-get install gawk
b.检查一下:
-
lfs@msi:/mnt/lfs/sources/glibc-build$ echo 'main(){}' > dummy.c
-
lfs@msi:/mnt/lfs/sources/glibc-build$ $LFS_TGT-gcc dummy.c
-
lfs@msi:/mnt/lfs/sources/glibc-build$ readelf -l a.out | grep ': /tools'
-
[Requesting program interpreter: /tools/lib64/ld-linux-x86-64.so.2]
2.5 第2遍编译binutils-2.25
-
lfs@msi:/mnt/lfs/sources/gcc-build$ rm -rf ../binutils-build/
-
lfs@msi:/mnt/lfs/sources/gcc-build$ mkdir ../binutils-build
-
lfs@msi:/mnt/lfs/sources/gcc-build$ cd ../binutils-build/
-
lfs@msi:/mnt/lfs/sources/binutils-build$ CC=$LFS_TGT-gcc \
-
> AR=$LFS_TGT-ar \
-
> RANLIB=$LFS_TGT-ranlib \
-
> ../binutils-2.25/configure \
-
> --prefix=/tools \
-
> --disable-nls \
-
> --disable-werror \
-
> --with-lib-path=/tools/lib \
-
> --with-sysroot
-
lfs@msi:/mnt/lfs/sources/binutils-build$ make -j8 && make install
a.注意,如果在confingure时报错cannot run C compiled programs,说明gcc没有安装好
我遇到的原因是,64位机子上没有lib64这个符号链接
2.5.1 编译ld
-
lfs@msi:/mnt/lfs/sources/binutils-build$ make -C ld clean
-
lfs@msi:/mnt/lfs/sources/binutils-build$ make -C ld LIB_PATH=/usr/lib:/lib
-
-
lfs@msi:/mnt/lfs/sources/binutils-build$ cp -v ld/ld-new /tools/bin/
-
'ld/ld-new' -> '/tools/bin/ld-new
2.6 第2遍编译gcc-4.9.2
-
lfs@msi:/mnt/lfs/sources/gcc-4.9.2$ 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
-
lfs@msi:/mnt/lfs/sources/gcc-4.9.2$ tar xf ../mpfr-3.1.2.tar.xz
-
lfs@msi:/mnt/lfs/sources/gcc-4.9.2$ tar xf ../gmp-6.0.0a.tar.xz
-
lfs@msi:/mnt/lfs/sources/gcc-4.9.2$ tar xf ../mpc-1.0.2.tar.gz
-
lfs@msi:/mnt/lfs/sources/gcc-4.9.2$ mv mpfr-3.1.2/ mpfr
-
lfs@msi:/mnt/lfs/sources/gcc-4.9.2$ mv gmp-6.0.0/ gmp
-
lfs@msi:/mnt/lfs/sources/gcc-4.9.2$ mv mpc-1.0.2/ mpc
-
lfs@msi:/mnt/lfs/sources/gcc-4.9.2$ cd ../gcc-build/
-
lfs@msi:/mnt/lfs/sources/gcc-build$ ls
-
lfs@msi:/mnt/lfs/sources/gcc-build$
-
lfs@msi:/mnt/lfs/sources/gcc-build$ CC=$LFS_TGT-gcc \
-
> CXX=$LFS_TGT-g++ \
-
> AR=$LFS_TGT-ar \
-
> RANLIB=$LFS_TGT-ranlib \
-
> ../gcc-4.9.2/configure \
-
> --prefix=/tools \
-
> --with-local-prefix=/tools \
-
> --with-native-system-header-dir=/tools/include \
-
> --enable-languages=c,c++ \
-
> --disable-libstdcxx-pch \
-
> --disable-multilib \
-
> --disable-bootstrap \
-
> --disable-libgomp
-
lfs@msi:/mnt/lfs/sources/gcc-build$ make -j8 && make install
a. 这儿没有cc,需要建立一个符号链接
lfs@msi:/mnt/lfs/sources/gcc-build$ ln -sv /tools/bin/gcc /tools/bin/cc
'/tools/bin/cc' -> '/tools/bin/gcc'
b. 测试一下工具链
-
lfs@msi:/mnt/lfs/sources/gcc-build$ echo 'main(){}' > dummy.c
-
lfs@msi:/mnt/lfs/sources/gcc-build$ cc dummy.c
-
lfs@msi:/mnt/lfs/sources/gcc-build$ readelf -l a.out | grep ': /tools'
-
[Requesting program interpreter: /tools/lib64/ld-linux-x86-64.so.2]
2.7 测试套件TCL
-
lfs@msi:/mnt/lfs/sources$ tar xf tcl8.6.3-src.tar.gz
-
lfs@msi:/mnt/lfs/sources$ cd tcl8.6.3/unix/
-
lfs@msi:/mnt/lfs/sources/tcl8.6.3/unix$ ./configure --prefix=/tools
-
-
lfs@msi:/mnt/lfs/sources/tcl8.6.3/unix$ make -j8 && make install
a.让库文件libtcl8.6.so可写
-
lfs@msi:/mnt/lfs/sources/tcl8.6.3/unix$ ls -l /tools/lib/libtcl8.6.so
-
-r-xr-xr-x 1 lfs lfs 1987632 Jan 26 11:47 /tools/lib/libtcl8.6.so
-
-
lfs@msi:/mnt/lfs/sources/tcl8.6.3/unix$ chmod -v u+w /tools/lib/libtcl8.6.so
-
mode of '/tools/lib/libtcl8.6.so' changed from 0555 (r-xr-xr-x) to 0755 (rwxr-xr-x)
-
-
lfs@msi:/mnt/lfs/sources/tcl8.6.3/unix$ ls -l /tools/lib/libtcl8.6.so
-
-rwxr-xr-x 1 lfs lfs 1987632 Jan 26 11:47 /tools/lib/libtcl8.6.so
b.安装头文件及创建符号连接
-
lfs@msi:/mnt/lfs/sources/tcl8.6.3/unix$ make install-private-headers
-
Installing private header files to /tools/include/
-
lfs@msi:/mnt/lfs/sources/tcl8.6.3/unix$ ln -sv /tools/bin/tclsh8.6 /tools/bin/tclsh
-
'/tools/bin/tclsh' -> '/tools/bin/tclsh8.6
2.8 expect
-
lfs@msi:/mnt/lfs/sources/tcl8.6.3/unix$ cd ../..
-
lfs@msi:/mnt/lfs/sources$
-
lfs@msi:/mnt/lfs/sources$ tar xf expect5.45.tar.gz
-
lfs@msi:/mnt/lfs/sources$ cd expect5.45
-
lfs@msi:/mnt/lfs/sources/expect5.45$ cp -v configure{,.orig}
-
'configure' -> 'configure.orig'
-
lfs@msi:/mnt/lfs/sources/expect5.45$ sed 's:/usr/local/bin:/bin:' configure.orig > configure
-
lfs@msi:/mnt/lfs/sources/expect5.45$ diff configure.orig configure
-
13411,13412c13411,13412
-
< if test -r /usr/local/bin/stty ; then
-
< STTY_BIN=/usr/local/bin/stty
-
---
-
> if test -r /bin/stty ; then
-
> STTY_BIN=/bin/stty
-
lfs@msi:/mnt/lfs/sources/expect5.45$ ./configure --prefix=/tools \
-
> --with-tcl=/tools/lib \
-
> --with-tclinclude=/tools/include
-
-
lfs@msi:/mnt/lfs/sources/expect5.45$ make -j8 && make SCRIPTS="" install
2.9 dejagnu
-
lfs@msi:/mnt/lfs/sources/expect5.45$ tar xf ../dejagnu-1.5.2.tar.gz -C../
-
lfs@msi:/mnt/lfs/sources/expect5.45$ cd ../dejagnu-1.5.2
-
lfs@msi:/mnt/lfs/sources/dejagnu-1.5.2$ ./configure --prefix=/tools
-
-
lfs@msi:/mnt/lfs/sources/dejagnu-1.5.2$ make -j8 && make install
2.10 check
-
lfs@msi:/mnt/lfs/sources/dejagnu-1.5.2$ tar xf ../check-0.9.14.tar.gz -C../
-
lfs@msi:/mnt/lfs/sources/dejagnu-1.5.2$ cd ../check-0.9.14
-
lfs@msi:/mnt/lfs/sources/check-0.9.14$ PKG_CONFIG= ./configure --prefix=/tools
-
lfs@msi:/mnt/lfs/sources/check-0.9.14$ make -j8 && make install
2.11 ncurses
-
lfs@msi:/mnt/lfs/sources/check-0.9.14$ tar xf ../ncurses-5.9.tar.gz -C..
-
lfs@msi:/mnt/lfs/sources/check-0.9.14$ cd ../ncurses-5.9
-
lfs@msi:/mnt/lfs/sources/ncurses-5.9$ ./configure --prefix=/tools \
-
> --with-shared \
-
> --without-debug \
-
> --without-ada \
-
> --enable-widec \
-
> --enable-overwrite
-
lfs@msi:/mnt/lfs/sources/ncurses-5.9$ make -j8 && make install
2.12 bash
-
lfs@msi:/mnt/lfs/sources/ncurses-5.9$ tar xf ../bash-4.3.30.tar.gz -C..
-
lfs@msi:/mnt/lfs/sources/ncurses-5.9$ cd ../bash-4.3.30
-
lfs@msi:/mnt/lfs/sources/bash-4.3.30$ ./configure --prefix=/tools --without-bash-malloc
-
lfs@msi:/mnt/lfs/sources/bash-4.3.30$ make -j8 && make install^C
-
lfs@msi:/mnt/lfs/sources/bash-4.3.30$ ln -sv /tools/bin/bash /tools/bin/sh
-
'/tools/bin/sh' -> '/tools/bin/bash
2.13 bzip2
-
lfs@msi:/mnt/lfs/sources/bash-4.3.30$ tar xf ../bzip2-1.0.6.tar.gz -C..
-
lfs@msi:/mnt/lfs/sources/bash-4.3.30$ cd ../bzip2-1.0.6
-
lfs@msi:/mnt/lfs/sources/bzip2-1.0.6$ ls
-
lfs@msi:/mnt/lfs/sources/bzip2-1.0.6$ make -j8
-
lfs@msi:/mnt/lfs/sources/bzip2-1.0.6$ make PREFIX=/tools install
2.14 coreutils
-
lfs@msi:/mnt/lfs/sources/bzip2-1.0.6$ tar xf ../coreutils-8.23.tar.xz -C ../
-
lfs@msi:/mnt/lfs/sources/bzip2-1.0.6$ cd ../coreutils-8.23
-
lfs@msi:/mnt/lfs/sources/coreutils-8.23$ ./configure --prefix=/tools --enable-install-program=hostnam
-
lfs@msi:/mnt/lfs/sources/coreutils-8.23$ make -j8 && make install
2.15 diffutils
-
lfs@msi:/mnt/lfs/sources/coreutils-8.23$ tar xf ../diffutils-3.3.tar.xz -C ..
-
lfs@msi:/mnt/lfs/sources/coreutils-8.23$ cd ../diffutils-3.3
-
lfs@msi:/mnt/lfs/sources/diffutils-3.3$ ./configure --prefix=/tools/
-
lfs@msi:/mnt/lfs/sources/diffutils-3.3$ make -j8 && make install
2.16 file
-
lfs@msi:/mnt/lfs/sources/diffutils-3.3$ tar xf ../file-5.22.tar.gz -C ..
-
lfs@msi:/mnt/lfs/sources/diffutils-3.3$ cd ../file-5.22
-
lfs@msi:/mnt/lfs/sources/file-5.22$
-
lfs@msi:/mnt/lfs/sources/file-5.22$ ./configure --prefix=/tools
-
lfs@msi:/mnt/lfs/sources/file-5.22$ make -j8 && make install
2.17 findutils
-
lfs@msi:/mnt/lfs/sources/file-5.22$ tar xf ../findutils-4.4.2.tar.gz -C ..
-
lfs@msi:/mnt/lfs/sources/file-5.22$ cd ../findutils-4.4.2
-
lfs@msi:/mnt/lfs/sources/findutils-4.4.2$ ./configure --prefix=/tools/
-
lfs@msi:/mnt/lfs/sources/findutils-4.4.2$
-
lfs@msi:/mnt/lfs/sources/findutils-4.4.2$ make -j8 && make install
2.18 gawk
-
lfs@msi:/mnt/lfs/sources/findutils-4.4.2$ tar xf ../gawk-4.1.1.tar.xz -C ..
-
lfs@msi:/mnt/lfs/sources/findutils-4.4.2$ cd ../gawk-4.1.1
-
lfs@msi:/mnt/lfs/sources/gawk-4.1.1$ ./configure --prefix=/tools
-
lfs@msi:/mnt/lfs/sources/gawk-4.1.1$ make -j8 && make install
2.19 gettext
-
lfs@msi:/mnt/lfs/sources/gawk-4.1.1$ tar xf ../gettext-0.19.4.tar.xz -C ..
-
lfs@msi:/mnt/lfs/sources/gawk-4.1.1$ cd ../gettext-0.19.4/gettext-tools/
-
lfs@msi:/mnt/lfs/sources/gettext-0.19.4/gettext-tools$
-
lfs@msi:/mnt/lfs/sources/gettext-0.19.4/gettext-tools$ EMACS="no" ./configure --prefix=/tools --disable-shared
-
lfs@msi:/mnt/lfs/sources/gettext-0.19.4/gettext-tools$ make -C gnulib-lib/
-
lfs@msi:/mnt/lfs/sources/gettext-0.19.4/gettext-tools$ make -C intl pluralx.c
-
lfs@msi:/mnt/lfs/sources/gettext-0.19.4/gettext-tools$ make -C src msgfmt
-
lfs@msi:/mnt/lfs/sources/gettext-0.19.4/gettext-tools$ make -C src msgmerge
-
lfs@msi:/mnt/lfs/sources/gettext-0.19.4/gettext-tools$ make -C src xgettext
-
lfs@msi:/mnt/lfs/sources/gettext-0.19.4/gettext-tools$ cp -v src/{msgfmt,msgmerge,xgettext} /tools/bin/
-
'src/msgfmt' -> '/tools/bin/msgfmt'
-
'src/msgmerge' -> '/tools/bin/msgmerge'
-
'src/xgettext' -> '/tools/bin/xgettext
2.20 grep
-
lfs@msi:/mnt/lfs/sources/gettext-0.19.4/gettext-tools$ tar xf ../../grep-2.21.tar.xz -C ../..
-
lfs@msi:/mnt/lfs/sources/gettext-0.19.4/gettext-tools$ cd ../../grep-2.21
-
lfs@msi:/mnt/lfs/sources/grep-2.21$ ./configure --prefix=/tools
-
lfs@msi:/mnt/lfs/sources/grep-2.21$ make -j8 && make install
2.21 gzip
-
lfs@msi:/mnt/lfs/sources/grep-2.21$ tar xf ../gzip-1.6.tar.xz -C ..
-
lfs@msi:/mnt/lfs/sources/grep-2.21$ cd ../gzip-1.6
-
lfs@msi:/mnt/lfs/sources/gzip-1.6$ ./configure --prefix=/tools
-
lfs@msi:/mnt/lfs/sources/gzip-1.6$ make -j8 && make install
2.22 m4
-
lfs@msi:/mnt/lfs/sources/gzip-1.6$ tar xf ../m4-1.4.17.tar.xz -C ..
-
lfs@msi:/mnt/lfs/sources/gzip-1.6$ cd ../m4-1.4.17
-
lfs@msi:/mnt/lfs/sources/m4-1.4.17$ ./configure --prefix=/tools
-
lfs@msi:/mnt/lfs/sources/m4-1.4.17$ make -j8 && make install
2.23 make
-
lfs@msi:/mnt/lfs/sources/m4-1.4.17$ tar xf ../make-4.1.tar.bz2 -C ../
-
lfs@msi:/mnt/lfs/sources/m4-1.4.17$ cd ../make-4.1
-
lfs@msi:/mnt/lfs/sources/make-4.1$ ./configure --prefix=/tools --without-guile
-
lfs@msi:/mnt/lfs/sources/make-4.1$ make -j8 && make install
2.24 patch
-
lfs@msi:/mnt/lfs/sources/make-4.1$ tar xf ../patch-2.7.4.tar.xz -C ../
-
lfs@msi:/mnt/lfs/sources/make-4.1$ cd ../patch-2.7.4
-
lfs@msi:/mnt/lfs/sources/patch-2.7.4$ ./configure --prefix=/tools/
-
lfs@msi:/mnt/lfs/sources/patch-2.7.4$ make -j8 && make install
2.25 perl
-
lfs@msi:/mnt/lfs/sources/patch-2.7.4$ tar xf ../perl-5.20.2.tar.bz2 -C ../
-
lfs@msi:/mnt/lfs/sources/patch-2.7.4$ cd ../perl-5.20.2
-
lfs@msi:/mnt/lfs/sources/perl-5.20.2$ sh Configure -des -Dprefix=/tools -Dlibs=-lm
-
lfs@msi:/mnt/lfs/sources/perl-5.20.2$ make -j8
-
lfs@msi:/mnt/lfs/sources/perl-5.20.2$ cp -v perl cpan/podlators/pod2man /tools/bin
-
'perl' -> '/tools/bin/perl'
-
'cpan/podlators/pod2man' -> '/tools/bin/pod2man'
-
lfs@msi:/mnt/lfs/sources/perl-5.20.2$ mkdir -pv /tools/lib/perl5/5.20.2
-
mkdir: created directory '/tools/lib/perl5'
-
mkdir: created directory '/tools/lib/perl5/5.20.2'
-
lfs@msi:/mnt/lfs/sources/perl-5.20.2$ cp -Rv lib/* /tools/lib/perl5/5.20.2
-
'lib/AnyDBM_File.pm' -> '/tools/lib/perl5/5.20.2/AnyDBM_File.pm
2.26 sed
-
lfs@msi:/mnt/lfs/sources/perl-5.20.2$ tar xf ../sed-4.2.2.tar.bz2 -C ..
-
lfs@msi:/mnt/lfs/sources/perl-5.20.2$ cd ../sed-4.2.2
-
lfs@msi:/mnt/lfs/sources/sed-4.2.2$ ./configure --prefix=/tools && make -j8 && make install
2.27 tar
-
lfs@msi:/mnt/lfs/sources/sed-4.2.2$ tar xf ../tar-1.28.tar.xz -C ..
-
lfs@msi:/mnt/lfs/sources/sed-4.2.2$ cd ../tar-1.28
-
lfs@msi:/mnt/lfs/sources/tar-1.28$ ./configure --prefix=/tools && make -j8 && make install
2.28 texinfo
-
lfs@msi:/mnt/lfs/sources/tar-1.28$ tar xf ../texinfo-5.2.tar.xz -C ../
-
lfs@msi:/mnt/lfs/sources/tar-1.28$ cd ../texinfo-5.2
-
lfs@msi:/mnt/lfs/sources/texinfo-5.2$ ./configure --prefix=/tools && make -j8 && make install
2.29 util-linux
-
lfs@msi:/mnt/lfs/sources/texinfo-5.2$ tar xf ../util-linux-2.26.tar.xz -C ..
-
lfs@msi:/mnt/lfs/sources/texinfo-5.2$ cd ../util-linux-2.26
-
lfs@msi:/mnt/lfs/sources/util-linux-2.26$ ./configure --prefix=/tools \
-
> --without-python \
-
> --disable-makeinstall-chown \
-
> --without-systemdsystemunitdir \
-
> PKG_CONFIG=""
-
lfs@msi:/mnt/lfs/sources/util-linux-2.26$ make -j8 && make install
2.30 xz
-
lfs@msi:/mnt/lfs/sources/util-linux-2.26$ tar xf ../xz-5.2.0.tar.xz -C ..
-
lfs@msi:/mnt/lfs/sources/util-linux-2.26$ cd ../xz-5.2.0
-
lfs@msi:/mnt/lfs/sources/xz-5.2.0$ ./configure --prefix=/tools && make -j8 && make install
2.31 清理
-
lfs@msi:/mnt/lfs/sources/xz-5.2.0$ cd /tools
-
lfs@msi:/tools$ du -hs -->清理之前1.2G
-
1.2G .
-
lfs@msi:/tools$ strip --strip-debug /tools/lib/*
-
lfs@msi:/tools$ du -hs
-
1.1G .
-
lfs@msi:/tools$ /usr/bin/strip --strip-unneeded /tools/{,s}bin
-
lfs@msi:/tools$ du -hs -->清理之后859M
-
859M .
删除多余的文档,这儿就不删了
但需要备份一下现在的tools目录
cong@msi:/mnt/lfs/tools$ sudo tar czf /work/lfs/tools_1412.tar.gz ./*
三.
3.1 配置chroot的环境
-
lfs@msi:/tools$ exit -->退出lfs用户
-
cong@msi:~$ sudo su - -->切换到root
-
root@msi:/mnt/lfs# echo $LFS -->重新export一个LFS变量
-
-
root@msi:/mnt/lfs# export LFS=/mnt/lfs
-
root@msi:/mnt/lfs# chown -R root:root $LFS/tools/
-
root@msi:/mnt/lfs# mkdir -pv $LFS/{dev,proc,sys,run}
-
root@msi:/mnt/lfs# mknod -m 600 $LFS/dev/console c 5 1
-
root@msi:/mnt/lfs# mknod -m 666 $LFS/dev/null c 1 3
-
-
root@msi:/mnt/lfs# mount -v --bind /dev/ $LFS/dev/
-
/dev on /mnt/lfs/dev type none (rw,bind)
-
root@msi:/mnt/lfs# mount -vt devpts devpts $LFS/dev/pts -o gid=5,mode=620
-
devpts on /mnt/lfs/dev/pts type devpts (rw,gid=5,mode=620)
-
root@msi:/mnt/lfs# mount -vt proc proc $LFS/proc
-
proc on /mnt/lfs/proc type proc (rw)
-
root@msi:/mnt/lfs# mount -vt sysfs sysfs $LFS/sys
-
sysfs on /mnt/lfs/sys type sysfs (rw)
-
root@msi:/mnt/lfs# mount -vt tmpfs tmpfs $LFS/run
-
tmpfs on /mnt/lfs/run type tmpfs (rw)
-
-
root@msi:/mnt/lfs# ls /mnt/lfs/dev/shm -l
-
lrwxrwxrwx 1 root root 8 1月 25 10:05 /mnt/lfs/dev/shm -> /run/shm
-
root@msi:/mnt/lfs# mkdir -pv $LFS/$(readlink $LFS/dev/shm)
-
mkdir: created directory ‘/mnt/lfs/run/shm’
3.2 chroot
-
root@msi:/mnt/lfs# 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
-
-
I have no name!:/# mkdir -pv /{bin,boot,etc/{opt,sysconfig},home,lib/firmware,mnt,opt}
-
I have no name!:/# mkdir -pv /{media/{floppy,cdrom},sbin,srv,var}
-
-
I have no name!:/# install -dv -m 0750 /root
-
install: creating directory '/root'
-
-
I have no name!:/# install -dv -m 1777 /tmp /var/tmp
-
install: creating directory '/tmp'
-
install: creating directory '/var/tmp'
-
-
-
I have no name!:/# mkdir -pv /usr/{,local/}{bin,include,lib,sbin,src}
-
I have no name!:/# mkdir -pv /usr/{,local/}share/{color,dict,doc,info,locale,man}
-
I have no name!:/# mkdir -v /usr/{,local/}share/{misc,terminfo,zoneinfo}
-
I have no name!:/# mkdir -v /usr/libexec
-
I have no name!:/# mkdir -pv /usr/{,local/}share/man/man{1..8}
-
I have no name!:/# ln -sv lib/ /lib64
-
'/lib64' -> 'lib/'
-
I have no name!:/# ln -sv lib /usr/lib64
-
'/usr/lib64' -> 'lib'
-
I have no name!:/# ln -sv lib /usr/local/lib64
-
'/usr/local/lib64' -> 'lib'
-
I have no name!:/# mkdir -v /var/{log,mail,spool}
-
I have no name!:/# ln -sv /run /var/run
-
I have no name!:/# ln -sv /run/lock /var/lock
-
I have no name!:/# mkdir -pv /var/{opt,cache,lib/{color,misc,locate},local}
-
-
I have no name!:/# ln -sv /tools/bin/{bash,cat,echo,pwd,stty} /bin
-
I have no name!:/# -sv /tools/bin/perl /usr/bin
-
I have no name!:/# ln -sv /tools/lib/libgcc_s.so{,.1} /usr/lib
-
I have no name!:/# ln -sv /tools/lib/libstdc++.so{,.6} /usr/lib
-
I have no name!:/# sed 's/tools/usr/' /tools/lib/libstdc++.la > /usr/lib/libstdc++.la
-
I have no name!:/# ln -sv bash /bin/sh
-
I have no name!:/# ln -sv /proc/self/mounts /etc/mtab
a.创建/etc/passwd文件
-
I have no name!:/# cat > /etc/passwd << "EOF"
-
> root:x:0:0:root:/root:/bin/bash
-
> bin:x:1:1:bin:/dev/null:/bin/false
-
> daemon:x:6:6:Daemon User:/dev/null:/bin/false
-
> messagebus:x:18:18:D-Bus Message Daemon User:/var/run/dbus:/bin/false
-
> systemd-bus-proxy:x:72:72:systemd Bus Proxy:/:/bin/false
-
> systemd-journal-gateway:x:73:73:systemd Journal Gateway:/:/bin/false
-
> systemd-journal-remote:x:74:74:systemd Journal Remote:/:/bin/false
-
> systemd-journal-upload:x:75:75:systemd Journal Upload:/:/bin/false
-
> systemd-network:x:76:76:systemd Network Management:/:/bin/false
-
> systemd-resolve:x:77:77:systemd Resolver:/:/bin/false
-
> systemd-timesync:x:78:78:systemd Time Synchronization:/:/bin/false
-
> nobody:x:99:99:Unprivileged User:/dev/null:/bin/false
-
> EOF
b.创建/etc/group文件
-
I have no name!:/# cat > /etc/group << "EOF"
-
> root:x:0:
-
> bin:x:1:daemon
-
> 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:
-
> adm:x:16:
-
> messagebus:x:18:
-
> systemd-journal:x:23:
-
> input:x:24:
-
> mail:x:34:
-
> systemd-bus-proxy:x:72:
-
> systemd-journal-gateway:x:73:
-
> systemd-journal-remote:x:74:
-
> systemd-journal-upload:x:75:
-
> systemd-network:x:76:
-
> systemd-resolve:x:77:
-
> systemd-timesync:x:78:
-
> nogroup:x:99:
-
> users:x:999:
-
> EOF
c.重新登陆之后
-
I have no name!:/# exec /tools/bin/bash --login +h
-
root:/#
-
root:/# touch /var/log/{btmp,lastlog,wtmp}
-
root:/# chgrp -v utmp /var/log/lastlog
-
changed group of '/var/log/lastlog' from root to utmp
-
root:/# chmod -v 664 /var/log/lastlog
-
mode of '/var/log/lastlog' changed from 0644 (rw-r--r--) to 0664 (rw-rw-r--)
-
root:/# chmod -v 600 /var/log/btmp
-
mode of '/var/log/btmp' changed from 0644 (rw-r--r--) to 0600 (rw-------)
3.3 linux-3.19 API头文件
-
root:/# cd sources/linux-3.19
-
root:/sources/linux-3.19# make mrproper
-
root:/sources/linux-3.19# make INSTALL_HDR_PATH=dest headers_install
-
root:/sources/linux-3.19# find dest/include \( -name .install -o -name ..install.cmd \) -delete
-
root:/sources/linux-3.19# cp -rv dest/include/* /usr/include
3.4 man-pages
-
root:/sources/linux-3.19# tar xf ../man-pages-3.79.tar.xz -C..
-
root:/sources/linux-3.19# cd ../man-pages-3.79
-
root:/sources/man-pages-3.79# make install
注意:在下面的编译之前需要先把以前解压的目录删掉,以免对现在造成影响
sudo find -maxdepth 1 -type d -exec rm -rf {} \;
3.5 glibc
-
root:/sources/man-pages-3.79# rm -rf ../glibc-2.21 ../glibc-build/
-
root:/sources/man-pages-3.79# tar xf ../glibc-2.21.tar.xz -C ..
-
root:/sources/man-pages-3.79# cd ../glibc-2.21
-
root:/sources/glibc-2.21# patch -Np1 -i ../glibc-2.21-fhs-1.patch
-
root:/sources/glibc-2.21# sed -e '/ia32/s/^/1:/' \
-
> -e '/SSE2/s/^1://' \
-
> -i sysdeps/i386/i686/multiarch/mempcpy_chk.S
-
root:/sources/glibc-2.21# mkdir -v ../glibc-build/
-
root:/sources/glibc-2.21# cd ../glibc-build/
-
root:/sources/glibc-build# ../glibc-2.21/configure \
-
> --prefix=/usr \
-
> --disable-profile \
-
> --enable-kernel=2.6.32 \
-
> --enable-obsolete-rpc
-
root:/sources/glibc-build# make -j8
-
root:/sources/glibc-build# make check
-
root:/sources/glibc-build# make install
a.安装nscd
-
root:/sources/glibc-build# cp -v ../glibc-2.21/nscd/nscd.conf /etc/
-
root:/sources/glibc-build# mkdir -pv /var/cache/nscd
-
-
root:/sources/glibc-build# install -v -Dm644 ../glibc-2.21/nscd/nscd.tmpfiles /usr/lib/tmpfiles.d/nscd.conf
-
install: creating directory '/usr/lib/tmpfiles.d'
-
'../glibc-2.21/nscd/nscd.tmpfiles' -> '/usr/lib/tmpfiles.d/nscd.conf'
-
-
root:/sources/glibc-build# install -v -Dm644 ../glibc-2.21/nscd/nscd.service /lib/systemd/system/nscd.service
-
install: creating directory '/lib/systemd'
-
install: creating directory '/lib/systemd/system'
-
'../glibc-2.21/nscd/nscd.service' -> '/lib/systemd/system/nscd.service
b.安装语言环境:
-
root:/sources/glibc-build# mkdir -pv /usr/lib/locale
-
mkdir: created directory '/usr/lib/locale'
-
root:/sources/glibc-build# localedef -i cs_CZ -f UTF-8 cs_CZ.UTF-8
-
root:/sources/glibc-build# localedef -i de_DE -f ISO-8859-1 de_DE
-
root:/sources/glibc-build# localedef -i de_DE@euro -f ISO-8859-15 de_DE@euro
-
root:/sources/glibc-build# localedef -i de_DE -f UTF-8 de_DE.UTF-8
-
root:/sources/glibc-build# localedef -i en_GB -f UTF-8 en_GB.UTF-8
-
root:/sources/glibc-build# localedef -i en_HK -f ISO-8859-1 en_HK
-
root:/sources/glibc-build# localedef -i en_PH -f ISO-8859-1 en_PH
-
root:/sources/glibc-build# localedef -i en_US -f ISO-8859-1 en_US
-
root:/sources/glibc-build# localedef -i en_US -f UTF-8 en_US.UTF-8
-
root:/sources/glibc-build# localedef -i es_MX -f ISO-8859-1 es_MX
-
root:/sources/glibc-build# localedef -i fa_IR -f UTF-8 fa_IR
-
root:/sources/glibc-build# localedef -i fr_FR -f ISO-8859-1 fr_FR
-
root:/sources/glibc-build# localedef -i fr_FR@euro -f ISO-8859-15 fr_FR@euro
-
root:/sources/glibc-build# localedef -i fr_FR -f UTF-8 fr_FR.UTF-8
-
root:/sources/glibc-build# localedef -i it_IT -f ISO-8859-1 it_IT
-
root:/sources/glibc-build# localedef -i it_IT -f UTF-8 it_IT.UTF-8
-
root:/sources/glibc-build# localedef -i ja_JP -f EUC-JP ja_JP
-
root:/sources/glibc-build# localedef -i ru_RU -f KOI8-R ru_RU.KOI8-R
-
root:/sources/glibc-build# localedef -i ru_RU -f UTF-8 ru_RU.UTF-8
-
root:/sources/glibc-build# localedef -i tr_TR -f UTF-8 tr_TR.UTF-8
-
root:/sources/glibc-build# localedef -i zh_CN -f GB18030 zh_CN.GB18030
-
root:/sources/glibc-build# cat /etc/nscd.conf ^C
-
root:/sources/glibc-build# cat > /etc/nsswitch.conf << "EOF"
-
> # Begin /etc/nsswitch.conf
-
>
-
> passwd: files
-
> group: files
-
> shadow: files
-
>
-
> hosts: files dns myhostname
-
> networks: files
-
>
-
> protocols: files
-
> services: files
-
> ethers: files
-
> rpc: files
-
>
-
> # End /etc/nsswitch.conf
-
> EOF
-
-
-
root:/sources/glibc-build# tar xf ../tzdata2015a.tar.gz
-
root:/sources/glibc-build# ZONEINFO=/usr/share/zoneinfo
-
root:/sources/glibc-build# mkdir -pv $ZONEINFO/{posix,right}
-
mkdir: created directory '/usr/share/zoneinfo/posix'
-
mkdir: created directory '/usr/share/zoneinfo/right'
-
root:/sources/glibc-build# for tz in etcetera southamerica northamerica europe africa antarctica \
-
> asia australasia backward pacificnew systemv; do
-
> zic -L /dev/null -d $ZONEINFO -y "sh yearistype.sh" ${tz}
-
> zic -L /dev/null -d $ZONEINFO/posix -y "sh yearistype.sh" ${tz}
-
> zic -L leapseconds -d $ZONEINFO/right -y "sh yearistype.sh" ${tz}
-
> done
-
root:/sources/glibc-build# cp -v zone.tab zone1970.tab iso3166.tab $ZONEINFO
-
'zone.tab' -> '/usr/share/zoneinfo/zone.tab'
-
'zone1970.tab' -> '/usr/share/zoneinfo/zone1970.tab'
-
'iso3166.tab' -> '/usr/share/zoneinfo/iso3166.tab'
-
root:/sources/glibc-build# zic -d $ZONEINFO -p America/New_York
-
root:/sources/glibc-build# unset ZONEINFO
-
root:/sources/glibc-build# tzselect
-
-
-
root:/sources/glibc-build# ln -sfv /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
-
'/etc/localtime' -> '/usr/share/zoneinfo/Asia/Shanghai
c.配置动态加载器
-
root:/sources/glibc-build# cat > /etc/ld.so.conf << "EOF"
-
> # Begin /etc/ld.so.conf
-
> /usr/local/lib
-
> /opt/lib
-
>
-
> EOF
-
root:/sources/glibc-build#
-
root:/sources/glibc-build#
-
root:/sources/glibc-build#
-
root:/sources/glibc-build#
-
root:/sources/glibc-build# cat >> /etc/ld.so.conf << "EOF"
-
> # Add an include directory
-
> include /etc/ld.so.conf.d/*.conf
-
>
-
> EOF
-
root:/sources/glibc-build# cat /etc/ld.so.conf
-
# Begin /etc/ld.so.conf
-
/usr/local/lib
-
/opt/lib
-
-
# Add an include directory
-
include /etc/ld.so.conf.d/*.conf
-
-
root:/sources/glibc-build# mkdir -pv /etc/ld.so.conf.d
-
mkdir: created directory '/etc/ld.so.conf.d
3.6 调整工具链
-
root:/sources/glibc-build# mv -v /tools/bin/{ld,ld-old}
-
'/tools/bin/ld' -> '/tools/bin/ld-old'
-
-
root:/sources/glibc-build# mv -v /tools/$(gcc -dumpmachine)/bin/{ld,ld-old}
-
'/tools/x86_64-unknown-linux-gnu/bin/ld' -> '/tools/x86_64-unknown-linux-gnu/bin/ld-old'
-
-
root:/sources/glibc-build# mv -v /tools/bin/{ld-new,ld}
-
'/tools/bin/ld-new' -> '/tools/bin/ld'
-
-
root:/sources/glibc-build# ln -sv /tools/bin/ld /tools/$(gcc -dumpmachine)/bin/ld
-
'/tools/x86_64-unknown-linux-gnu/bin/ld' -> '/tools/bin/ld'
-
-
root:/sources/glibc-build# gcc -dumpspecs | sed -e 's@/tools@@g' \
-
-e '/\*startfile_prefix_spec:/{n;s@.*@/usr/lib/ @}' \
-
-e '/\*cpp:/{n;s@$@ -isystem /usr/include@}' > \
-
`dirname $(gcc --print-libgcc-file-name)`/specs -->创建spec文件
b.测试工具链
-
root:/sources/glibc-build# echo 'main(){}' > dummy.c
-
root:/sources/glibc-build# cc dummy.c -v -Wl,--verbose &> dummy.log
-
root:/sources/glibc-build# readelf -l a.out | grep ': /lib'
-
[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
-
root:/sources/glibc-build# grep -o '/usr/lib.*/crt[1in].*succeeded' dummy.log
-
/usr/lib/../lib64/crt1.o succeeded
-
/usr/lib/../lib64/crti.o succeeded
-
/usr/lib/../lib64/crtn.o succeeded
-
root:/sources/glibc-build# grep -B1 '^ /usr/include' dummy.log
-
#include <...> search starts here:
-
/usr/include
-
root:/sources/glibc-build# grep 'SEARCH.*/usr/lib' dummy.log |sed 's|; |\n|g'
-
SEARCH_DIR("=/tools/x86_64-unknown-linux-gnu/lib64")
-
SEARCH_DIR("/usr/lib")
-
SEARCH_DIR("/lib")
-
SEARCH_DIR("=/tools/x86_64-unknown-linux-gnu/lib");
-
root:/sources/glibc-build# grep "/lib.*/libc.so.6 " dummy.log
-
attempt to open /lib64/libc.so.6 succeeded
-
root:/sources/glibc-build# grep found dummy.log
-
found ld-linux-x86-64.so.2 at /lib64/ld-linux-x86-64.so.2
-
root:/sources/glibc-build# rm -v dummy.c a.out dummy.log
-
removed 'dummy.c'
-
removed 'a.out'
-
removed 'dummy.log
我这儿是64位的,输出与文档是不一样的
3.7 zlib
-
root:/sources/zlib-1.2.8# ./configure --prefix=/usr
-
root:/sources/zlib-1.2.8# make -j8
-
root:/sources/zlib-1.2.8# make check
-
root:/sources/zlib-1.2.8# make install
-
root:/sources/zlib-1.2.8# mv -v /usr/lib/libz.so.* /lib
-
'/usr/lib/libz.so.1' -> '/lib/libz.so.1'
-
'/usr/lib/libz.so.1.2.8' -> '/lib/libz.so.1.2.8'
-
root:/sources/zlib-1.2.8#
-
root:/sources/zlib-1.2.8# ln -sfv ../../lib/$(readlink /usr/lib/libz.so) /usr/lib/libz.so
-
'/usr/lib/libz.so' -> '../../lib/libz.so.1.2.8
3.8 file-5.22
-
root:/sources/zlib-1.2.8# tar xf ../file-5.22.tar.gz -C ..
-
root:/sources/zlib-1.2.8# cd ../file-5.22
-
root:/sources/file-5.22# ./configure --prefix=/usr/ && make -j8 && make check && make install
3.9 binutils
-
root:/sources/file-5.22# expect -c "spawn ls"
-
spawn ls
-
root:/sources/file-5.22# tar xf ../binutils-2.25.tar.bz2 -C ..
-
root:/sources/file-5.22# mkdir -pv ../binutils-build
-
mkdir: created directory '../binutils-build'
-
root:/sources/file-5.22# cd ../binutils-build/
-
root:/sources/binutils-build# ../binutils-2.25/configure --prefix=/usr \
-
> --enable-shared \
-
> --disable-werror
-
root:/sources/binutils-build# make tooldir=/usr -j8
-
root:/sources/binutils-build# make -k check
-
root:/sources/binutils-build# make tooldir=/usr install
3.10 gmp
-
root:/sources/binutils-build# tar xf ../gmp-6.0.0a.tar.xz -C..
-
root:/sources/binutils-build# cd ../gmp-6.0.0
-
root:/sources/gmp-6.0.0# ./configure --prefix=/usr \
-
> --enable-cxx \
-
> --docdir=/usr/share/doc/gmp-6.0.0a
-
root:/sources/gmp-6.0.0# make -j8
-
root:/sources/gmp-6.0.0# make html
-
-
root:/sources/gmp-6.0.0# make check 2>&1 | tee gmp-check-log
-
-
root:/sources/gmp-6.0.0# awk '/tests passed/{total+=$2} ; END{print total}' gmp-check-log
-
188
-
root:/sources/gmp-6.0.0# make install
-
root:/sources/gmp-6.0.0# make install-html
3.11 mpfr
-
root:/sources/gmp-6.0.0# tar xf ../mpfr-3.1.2.tar.xz -C ..
-
root:/sources/gmp-6.0.0# cd ../mpfr-3.1.2
-
root:/sources/mpfr-3.1.2# patch -Np1 -i ../mpfr-3.1.2-upstream_fixes-3.patch
-
root:/sources/mpfr-3.1.2# ./configure --prefix=/usr \
-
> --enable-thread-safe \
-
> --docdir=/usr/share/doc/mpfr-3.1.2
-
root:/sources/mpfr-3.1.2# make -j8
-
root:/sources/mpfr-3.1.2# make html
-
root:/sources/mpfr-3.1.2# make check
-
root:/sources/mpfr-3.1.2# make install
-
root:/sources/mpfr-3.1.2# make install-html
3.12 mpc
-
root:/sources/mpfr-3.1.2# tar xf ../mpc-1.0.2.tar.gz -C ..
-
root:/sources/mpfr-3.1.2# cd ../mpc-1.0.2
-
root:/sources/mpc-1.0.2# ./configure --prefix=/usr --docdir=/usr/share/doc/mpc-1.0.2
-
root:/sources/mpc-1.0.2# make -j8
-
root:/sources/mpc-1.0.2# make html
-
root:/sources/mpc-1.0.2# make install
-
root:/sources/mpc-1.0.2# make install-html
3.13 gcc-4.9.2
TMD 写了这么多一个,在提交时报个错全没有了!TMD
TMD TMD
TMD
3.**
最后改grub.cfg的时候,因为我这是在ubuntu系统之下本身就有了grub的引导
所以这儿就没有必要运行grub-install了只需要修改一下grub.cfg文件就可以了
在宿主机子上添加如下即可:
-
cong@msi:~$ sudo vi /boot/grub/grub.cfg
-
menuentry "LFS_Cong Linux 3.19-lfs-7.7-systemd"{
-
insmod gzio
-
insmod part_msdos
-
insmod ext2
-
set root='hd0,msdos5'
-
linux /boot/vmlinuz-3.19-lfs-7.7-systemd root=/dev/sda5 ro
-
}
set root
='hd0
,msdos5
' -->/dev/sda5是LFS的分区
这样就完成了LFS系统的引导了。
阅读(2305) | 评论(0) | 转发(0) |