LFS 7.2手记(一)

            Preparing for the Build
             
groupadd lfs
useradd -s /bin/bash -g lfs -m -k /dev/null lfs
passwd lfs
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
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
 
mkdir -pv $LFS
mkdir -v $LFS/sources
cd $LFS/sources
tar xf ../lfs-packages-7.2.tar
 
for tarball in *.tar*
do
  tar xf "$tarball"
done
 
mkdir -v $LFS/tools
sudo ln -sv $LFS/tools /
 
            Constructing a Temporary System
         
echo $LFS
echo $LFS_TGT
echo $PATH
 
case $(uname -m) in
  x86_64) mkdir -v /tools/lib && ln -sv lib /tools/lib64 ;;
esac
 
    Binutils-2.22 - Pass 1
patch -Np1 -i ../binutils-2.22-build_fix-1.patch
mkdir -v ../binutils-build
cd ../binutils-build
 
../binutils-2.22/configure     \
    --prefix=/tools            \
    --with-sysroot=$LFS        \
    --with-lib-path=/tools/lib \
    --target=$LFS_TGT          \
    --disable-nls              \
    --disable-werror
make&&make install
 
    GCC-4.7.1 - Pass 1
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.tar.gz
mv -v mpc-1.0 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.1/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.1/mpfr/src \
    --with-mpfr-lib=$(pwd)/mpfr/src/.libs
     
make&&make install
ln -vs libgcc.a `$LFS_TGT-gcc -print-libgcc-file-name | sed 's/libgcc/&_eh/'`
 
    Linux-3.5.2 API Headers
make mrproper
make headers_check
make INSTALL_HDR_PATH=dest headers_install
cp -rv dest/include/* /tools/include
 
    Glibc-2.16.0
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
 
sed -i 's/ -lgcc_s//' Makeconfig
mkdir -v ../glibc-build
cd ../glibc-build
 
../glibc-2.16.0/configure                             \
      --prefix=/tools                                 \
      --host=$LFS_TGT                                 \
      --build=$(../glibc-2.16.0/scripts/config.guess) \
      --disable-profile                               \
      --enable-add-ons                                \
      --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-2.22 - Pass 2
patch -Np1 -i ../binutils-2.22-build_fix-1.patch
mkdir -v ../binutils-build
cd ../binutils-build
 
CC=$LFS_TGT-gcc            \
AR=$LFS_TGT-ar             \
RANLIB=$LFS_TGT-ranlib     \
../binutils-2.22/configure \
    --prefix=/tools        \
    --disable-nls          \
    --with-lib-path=/tools/lib
 
make&&make install
make -C ld clean
make -C ld LIB_PATH=/usr/lib:/lib
cp -v ld/ld-new /tools/bin
 
    GCC-4.7.1 - Pass 2
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
 
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.tar.gz
mv -v mpc-1.0 mpc
 
mkdir -v ../gcc-build
cd ../gcc-build
 
CC=$LFS_TGT-gcc \
AR=$LFS_TGT-ar                  \
RANLIB=$LFS_TGT-ranlib          \
../gcc-4.7.1/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.1/mpfr/src \
    --with-mpfr-lib=$(pwd)/mpfr/src/.libs
     
make&&make instll
ln -vs gcc /tools/bin/cc
 
    Tcl-8.5.12
cd unix
./configure --prefix=/tools
make&&make install
chmod -v u+w /tools/lib/libtcl8.5.so
make install-private-headers
ln -sv tclsh8.5 /tools/bin/tclsh
 
    Expect-5.45
cp -v configure{,.orig}
sed 's:/usr/local/bin:/bin:' configure.orig > configure
 
./configure --prefix=/tools --with-tcl=/tools/lib \
  --with-tclinclude=/tools/include
make&&make SCRIPTS="" install
 
    DejaGNU-1.5
./configure --prefix=/tools
make install
 
    Check-0.9.8
./configure --prefix=/tools
make&&make install
 
    Ncurses-5.9
./configure --prefix=/tools --with-shared \
    --without-debug --without-ada --enable-overwrite
make&&make install
 
    Bash-4.2
patch -Np1 -i ../bash-4.2-fixes-8.patch
./configure --prefix=/tools --without-bash-malloc
make&&make install
ln -vs bash /tools/bin/sh
 
    Bzip2-1.0.6
make&&make PREFIX=/tools install
 
    Coreutils-8.19
./configure --prefix=/tools --enable-install-program=hostname
make&&make install
 
    Diffutils-3.2
sed -i -e '/gets is a/d' lib/stdio.in.h
./configure --prefix=/tools
make&&make install
 
    File-5.11
./configure --prefix=/tools
make&&make install
 
    Findutils-4.4.2
./configure --prefix=/tools
make&&make install
 
    Gawk-4.0.1
./configure --prefix=/tools
make&&make install
 
    Gettext-0.18.1.1
sed -i -e '/gets is a/d' gettext-*/*/stdio.in.h
cd gettext-tools
EMACS="no" ./configure --prefix=/tools --disable-shared
 
make -C gnulib-lib
make -C src msgfmt
cp -v src/msgfmt /tools/bin
 
    Grep-2.14
./configure --prefix=/tools
make&&make install
 
    Gzip-1.5
./configure --prefix=/tools
make&&make install
 
    M4-1.4.16
sed -i -e '/gets is a/d' lib/stdio.in.h
./configure --prefix=/tools
make&&make install
 
    Make-3.82
./configure --prefix=/tools
make&&make install
 
    Patch-2.6.1
./configure --prefix=/tools
make&&make install
 
    Perl-5.16.1
patch -Np1 -i ../perl-5.16.1-libc-2.patch
sh Configure -des -Dprefix=/tools
make
cp -v perl cpan/podlators/pod2man /tools/bin
mkdir -pv /tools/lib/perl5/5.16.1
cp -Rv lib/* /tools/lib/perl5/5.16.1
 
    Sed-4.2.1
./configure --prefix=/tools
make&&make install
 
    Tar-1.26
sed -i -e '/gets is a/d' gnu/stdio.in.h
./configure --prefix=/tools
make&&make install
 
    Texinfo-4.13a
./configure --prefix=/tools
make&&make install
 
    Xz-5.0.4
./configure --prefix=/tools
make&&make install
 
        Stripping
strip --strip-debug /tools/lib/*
strip --strip-unneeded /tools/{,s}bin/*
rm -rf /tools/{,share}/{info,man,doc}
 
        Backup and have a rest
tar zcvf ../lfs-tools.tgz $LFS/tools
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值