lfs-auto/chap5-6.sh

552 lines
16 KiB
Bash

#!/bin/bash
source vars.sh
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Starting 5.2. ""$LFS_BINUTILS"" - Pass 1" >> build.log
tar xf "$LFS_BINUTILS".tar.xz &&
cd "$LFS_BINUTILS" &&
mkdir -v build &&
cd build &&
../configure --prefix=$LFS/tools \
--with-sysroot=$LFS \
--target=$LFS_TGT \
--disable-nls \
--enable-gprofng=no \
--disable-werror &&
make &&
make install &&
cd ../.. &&
rm -rf "$LFS_BINUTILS" &&
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Finished 5.2. ""$LFS_BINUTILS"" - Pass 1" >> build.log
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Starting 5.3. ""$LFS_GCC"" - Pass 1" >> build.log
tar xf "$LFS_GCC".tar.xz &&
cd "$LFS_GCC" &&
tar -xf ../"$LFS_MPFR".tar.xz &&
mv -v "$LFS_MPFR" mpfr &&
tar -xf ../"$LFS_GMP".tar.xz &&
mv -v "$LFS_GMP" gmp &&
tar -xf ../"$LFS_MPC".tar.gz &&
mv -v "$LFS_MPC" mpc &&
case $(uname -m) in
x86_64)
sed -e '/m64=/s/lib64/lib/' \
-i.orig gcc/config/i386/t-linux64
;;
esac &&
mkdir -v build &&
cd build &&
../configure \
--target=$LFS_TGT \
--prefix=$LFS/tools \
--with-glibc-version=2.37 \
--with-sysroot=$LFS \
--with-newlib \
--without-headers \
--enable-default-pie \
--enable-default-ssp \
--disable-nls \
--disable-shared \
--disable-multilib \
--disable-threads \
--disable-libatomic \
--disable-libgomp \
--disable-libquadmath \
--disable-libssp \
--disable-libvtv \
--disable-libstdcxx \
--enable-languages=c,c++ &&
make &&
make install &&
cd .. &&
cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
`dirname $($LFS_TGT-gcc -print-libgcc-file-name)`/install-tools/include/limits.h &&
cd .. &&
rm -rf "$LFS_GCC" &&
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Finished 5.3. ""$LFS_GCC"" - Pass 1" >> build.log
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Starting 5.4. ""$LFS_LINUX"" API Headers" >> build.log
tar xf "$LFS_LINUX".tar.xz &&
cd "$LFS_LINUX" &&
make mrproper &&
make headers &&
find usr/include -type f ! -name '*.h' -delete &&
cp -rv usr/include $LFS/usr &&
cd .. &&
rm -rf "$LFS_LINUX" &&
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Finished 5.4. ""$LFS_LINUX"" API Headers" >> build.log
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Starting 5.5. ""$LFS_GLIBC""" >> build.log
tar xf "$LFS_GLIBC".tar.xz &&
cd "$LFS_GLIBC" &&
case $(uname -m) in
i?86) ln -sfv ld-linux.so.2 $LFS/lib/ld-lsb.so.3
;;
x86_64) ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64
ln -sfv ../lib/ld-linux-x86-64.so.2 $LFS/lib64/ld-lsb-x86-64.so.3
;;
esac &&
patch -Np1 -i ../"$LFS_GLIBC"-fhs-1.patch &&
mkdir -v build &&
cd build &&
echo "rootsbindir=/usr/sbin" > configparms &&
../configure \
--prefix=/usr \
--host=$LFS_TGT \
--build=$(../scripts/config.guess) \
--enable-kernel=3.2 \
--with-headers=$LFS/usr/include \
libc_cv_slibdir=/usr/lib &&
make &&
make DESTDIR=$LFS install &&
sed '/RTLDLIST=/s@/usr@@g' -i $LFS/usr/bin/ldd &&
echo 'At this point, it is imperative to stop and ensure that the basic functions (compiling and linking) of the new toolchain are working as expected.'
echo 'int main(){}' | $LFS_TGT-gcc -xc -
readelf -l a.out | grep ld-linux
echo 'If everything is working correctly, there should be no errors, and the output of the last command will be of the form: [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]'
sleep 10
rm -v a.out &&
$LFS/tools/libexec/gcc/$LFS_TGT/12.2.0/install-tools/mkheaders &&
cd ../.. &&
rm -rf "$LFS_GLIBC" &&
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Finished 5.5. ""$LFS_GLIBC""" >> build.log
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Starting 5.6. Libstdc++ from ""$LFS_GCC""" >> build.log
tar xf "$LFS_GCC".tar.xz &&
cd "$LFS_GCC" &&
mkdir -v build &&
cd build &&
../libstdc++-v3/configure \
--host=$LFS_TGT \
--build=$(../config.guess) \
--prefix=/usr \
--disable-multilib \
--disable-nls \
--disable-libstdcxx-pch \
--with-gxx-include-dir=/tools/$LFS_TGT/include/c++/12.2.0 &&
make &&
make DESTDIR=$LFS install &&
rm -v $LFS/usr/lib/lib{stdc++,stdc++fs,supc++}.la &&
cd ../.. &&
rm -rf "$LFS_GCC" &&
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Finished 5.6. Libstdc++ from ""$LFS_GCC""" >> build.log
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Starting 6.2. ""$LFS_M4""" >> build.log
tar xf "$LFS_M4".tar.xz &&
cd "$LFS_M4" &&
./configure --prefix=/usr \
--host=$LFS_TGT \
--build=$(build-aux/config.guess) &&
make &&
make DESTDIR=$LFS install &&
cd .. &&
rm -rf "$LFS_M4" &&
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Finished 6.2. ""$LFS_M4""" >> build.log
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Starting 6.3. ""$LFS_NCURSES""" >> build.log
tar xf "$LFS_NCURSES".tar.gz &&
cd "$LFS_NCURSES" &&
sed -i s/mawk// configure &&
mkdir build &&
pushd build
../configure
make -C include
make -C progs tic
popd
./configure --prefix=/usr \
--host=$LFS_TGT \
--build=$(./config.guess) \
--mandir=/usr/share/man \
--with-manpage-format=normal \
--with-shared \
--without-normal \
--with-cxx-shared \
--without-debug \
--without-ada \
--disable-stripping \
--enable-widec &&
make &&
make DESTDIR=$LFS TIC_PATH=$(pwd)/build/progs/tic install &&
echo "INPUT(-lncursesw)" > $LFS/usr/lib/libncurses.so &&
cd .. &&
rm -rf "$LFS_NCURSES" &&
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Finished 6.3. ""$LFS_NCURSES""" >> build.log
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Starting 6.4. ""$LFS_BASH""" >> build.log
tar xf "$LFS_BASH".tar.gz &&
cd "$LFS_BASH" &&
./configure --prefix=/usr \
--build=$(sh support/config.guess) \
--host=$LFS_TGT \
--without-bash-malloc &&
make &&
make DESTDIR=$LFS install &&
ln -sv bash $LFS/bin/sh &&
cd .. &&
rm -rf "$LFS_BASH" &&
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Finished 6.4. ""$LFS_BASH""" >> build.log
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Starting 6.5. ""$LFS_COREUTILS""" >> build.log
tar xf "$LFS_COREUTILS".tar.xz &&
cd "$LFS_COREUTILS" &&
./configure --prefix=/usr \
--host=$LFS_TGT \
--build=$(build-aux/config.guess) \
--enable-install-program=hostname \
--enable-no-install-program=kill,uptime &&
make &&
make DESTDIR=$LFS install &&
mv -v $LFS/usr/bin/chroot $LFS/usr/sbin &&
mkdir -pv $LFS/usr/share/man/man8 &&
mv -v $LFS/usr/share/man/man1/chroot.1 $LFS/usr/share/man/man8/chroot.8 &&
sed -i 's/"1"/"8"/' $LFS/usr/share/man/man8/chroot.8 &&
cd .. &&
rm -rf "$LFS_COREUTILS" &&
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Finished 6.5. ""$LFS_COREUTILS""" >> build.log
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Starting 6.6. ""$LFS_DIFFUTILS""" >> build.log
tar xf "$LFS_DIFFUTILS".tar.xz &&
cd "$LFS_DIFFUTILS" &&
./configure --prefix=/usr --host=$LFS_TGT &&
make &&
make DESTDIR=$LFS install &&
cd .. &&
rm -rf "$LFS_DIFFUTILS" &&
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Finished 6.6. ""$LFS_DIFFUTILS""" >> build.log
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Starting 6.7. ""$LFS_FILE""" >> build.log
tar xf "$LFS_FILE".tar.gz &&
cd "$LFS_FILE" &&
mkdir build &&
pushd build
../configure --disable-bzlib \
--disable-libseccomp \
--disable-xzlib \
--disable-zlib
make
popd
./configure --prefix=/usr --host=$LFS_TGT --build=$(./config.guess) &&
make FILE_COMPILE=$(pwd)/build/src/file &&
make DESTDIR=$LFS install &&
rm -v $LFS/usr/lib/libmagic.la &&
cd .. &&
rm -rf "$LFS_FILE" &&
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Finished 6.7. ""$LFS_FILE""" >> build.log
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Starting 6.8. ""$LFS_FINDUTILS""" >> build.log
tar xf "$LFS_FINDUTILS".tar.xz &&
cd "$LFS_FINDUTILS" &&
./configure --prefix=/usr \
--localstatedir=/var/lib/locate \
--host=$LFS_TGT \
--build=$(build-aux/config.guess) &&
make &&
make DESTDIR=$LFS install &&
cd .. &&
rm -rf "$LFS_FINDUTILS" &&
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Finished 6.8. ""$LFS_FINDUTILS""" >> build.log
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Starting 6.9. ""$LFS_GAWK""" >> build.log
tar xf "$LFS_GAWK".tar.xz &&
cd "$LFS_GAWK" &&
sed -i 's/extras//' Makefile.in &&
./configure --prefix=/usr \
--host=$LFS_TGT \
--build=$(build-aux/config.guess) &&
make &&
make DESTDIR=$LFS install &&
cd .. &&
rm -rf "$LFS_GAWK" &&
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Finished 6.9. ""$LFS_GAWK""" >> build.log
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Starting 6.10. ""$LFS_GREP""" >> build.log
tar xf "$LFS_GREP".tar.xz &&
cd "$LFS_GREP" &&
./configure --prefix=/usr \
--host=$LFS_TGT &&
make &&
make DESTDIR=$LFS install &&
cd .. &&
rm -rf "$LFS_GREP" &&
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Finished 6.10. ""$LFS_GREP""" >> build.log
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Starting 6.11. ""$LFS_GZIP""" >> build.log
tar xf "$LFS_GZIP".tar.xz &&
cd "$LFS_GZIP" &&
./configure --prefix=/usr --host=$LFS_TGT &&
make &&
make DESTDIR=$LFS install &&
cd .. &&
rm -rf "$LFS_GZIP" &&
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Finished 6.11. ""$LFS_GZIP""" >> build.log
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Starting 6.12. ""$LFS_MAKE""" >> build.log
tar xf "$LFS_MAKE".tar.gz &&
cd "$LFS_MAKE" &&
sed -e '/ifdef SIGPIPE/,+2 d' \
-e '/undef FATAL_SIG/i FATAL_SIG (SIGPIPE);' \
-i src/main.c &&
./configure --prefix=/usr \
--without-guile \
--host=$LFS_TGT \
--build=$(build-aux/config.guess) &&
make &&
make DESTDIR=$LFS install &&
cd .. &&
rm -rf "$LFS_MAKE" &&
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Finished 6.12. ""$LFS_MAKE""" >> build.log
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Starting 6.13. ""$LFS_PATCH""" >> build.log
tar xf "$LFS_PATCH".tar.xz &&
cd "$LFS_PATCH" &&
./configure --prefix=/usr \
--host=$LFS_TGT \
--build=$(build-aux/config.guess) &&
make &&
make DESTDIR=$LFS install &&
cd .. &&
rm -rf "$LFS_PATCH" &&
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Finished 6.13. ""$LFS_PATCH""" >> build.log
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Starting 6.14. ""$LFS_SED""" >> build.log
tar xf "$LFS_SED".tar.xz &&
cd "$LFS_SED" &&
./configure --prefix=/usr \
--host=$LFS_TGT &&
make &&
make DESTDIR=$LFS install &&
cd .. &&
rm -rf "$LFS_SED" &&
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Finished 6.14. ""$LFS_SED""" >> build.log
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Starting 6.15. ""$LFS_TAR""" >> build.log
tar xf "$LFS_TAR".tar.xz &&
cd "$LFS_TAR" &&
./configure --prefix=/usr \
--host=$LFS_TGT \
--build=$(build-aux/config.guess) &&
make &&
make DESTDIR=$LFS install &&
cd .. &&
rm -rf "$LFS_TAR" &&
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Finished 6.15. ""$LFS_TAR""" >> build.log
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Starting 6.16. ""$LFS_XZ""" >> build.log
tar xf "$LFS_XZ".tar.xz &&
cd "$LFS_XZ" &&
./configure --prefix=/usr \
--host=$LFS_TGT \
--build=$(build-aux/config.guess) \
--disable-static \
--docdir=/usr/share/doc/"$LFS_XZ" &&
make &&
make DESTDIR=$LFS install &&
rm -v $LFS/usr/lib/liblzma.la &&
cd .. &&
rm -rf "$LFS_XZ" &&
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Finished 6.16. ""$LFS_XZ""" >> build.log
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Starting 6.17. ""$LFS_BINUTILS"" - Pass 2" >> build.log
tar xf "$LFS_BINUTILS".tar.xz &&
cd "$LFS_BINUTILS" &&
sed '6009s/$add_dir//' -i ltmain.sh &&
mkdir -v build &&
cd build &&
../configure \
--prefix=/usr \
--build=$(../config.guess) \
--host=$LFS_TGT \
--disable-nls \
--enable-shared \
--enable-gprofng=no \
--disable-werror \
--enable-64-bit-bfd &&
make &&
make DESTDIR=$LFS install &&
rm -v $LFS/usr/lib/lib{bfd,ctf,ctf-nobfd,opcodes}.{a,la} &&
cd ../.. &&
rm -rf "$LFS_BINUTILS" &&
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Finished 6.17. ""$LFS_BINUTILS"" - Pass 2" >> build.log
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Starting 6.18. ""$LFS_GCC"" - Pass 2" >> build.log
tar xf "$LFS_GCC".tar.xz &&
cd "$LFS_GCC" &&
tar -xf ../"$LFS_MPFR".tar.xz &&
mv -v "$LFS_MPFR" mpfr &&
tar -xf ../"$LFS_GMP".tar.xz &&
mv -v "$LFS_GMP" gmp &&
tar -xf ../"$LFS_MPC".tar.gz &&
mv -v "$LFS_MPC" mpc &&
case $(uname -m) in
x86_64)
sed -e '/m64=/s/lib64/lib/' -i.orig gcc/config/i386/t-linux64
;;
esac &&
sed '/thread_header =/s/@.*@/gthr-posix.h/' \
-i libgcc/Makefile.in libstdc++-v3/include/Makefile.in &&
mkdir -v build &&
cd build &&
../configure \
--build=$(../config.guess) \
--host=$LFS_TGT \
--target=$LFS_TGT \
LDFLAGS_FOR_TARGET=-L$PWD/$LFS_TGT/libgcc \
--prefix=/usr \
--with-build-sysroot=$LFS \
--enable-default-pie \
--enable-default-ssp \
--disable-nls \
--disable-multilib \
--disable-libatomic \
--disable-libgomp \
--disable-libquadmath \
--disable-libssp \
--disable-libvtv \
--enable-languages=c,c++ &&
make &&
make DESTDIR=$LFS install &&
ln -sv gcc $LFS/usr/bin/cc &&
cd ../.. &&
rm -rf "$LFS_GCC" &&
CURRENT_DATE_TIME=$(date +"%Y-%m-%d %T")
echo "$CURRENT_DATE_TIME" >> build.log
echo "Finished 6.18. ""$LFS_GCC"" - Pass 2" >> build.log
echo "Enter the chroot environment as the root user:"
echo "bash chroot.sh"