418 lines
12 KiB
Bash
418 lines
12 KiB
Bash
#!/bin/bash
|
|
|
|
source vars.sh
|
|
|
|
echo "5.2. ""$BINUTILS"" - Pass 1"
|
|
tar xf "$BINUTILS".tar.xz &&
|
|
cd "$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 "$BINUTILS" &&
|
|
echo "Finished 5.2. ""$BINUTILS"" - Pass 1" >> build.log
|
|
|
|
echo "5.3. ""$GCC"" - Pass 1"
|
|
tar xf "$GCC".tar.xz &&
|
|
cd "$GCC" &&
|
|
tar -xf ../"$MPFR".tar.xz &&
|
|
mv -v "$MPFR" mpfr &&
|
|
tar -xf ../"$GMP".tar.xz &&
|
|
mv -v "$GMP" gmp &&
|
|
tar -xf ../"$MPC".tar.gz &&
|
|
mv -v "$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 "$GCC" &&
|
|
echo "Finished 5.3. ""$GCC"" - Pass 1" >> build.log
|
|
|
|
echo "5.4. ""$LINUX"" API Headers"
|
|
tar xf "$LINUX".tar.xz &&
|
|
cd "$LINUX" &&
|
|
make mrproper &&
|
|
make headers &&
|
|
find usr/include -type f ! -name '*.h' -delete &&
|
|
cp -rv usr/include $LFS/usr &&
|
|
cd .. &&
|
|
rm -rf "$LINUX"
|
|
|
|
echo "5.5. ""$GLIBC"""
|
|
tar xf "$GLIBC".tar.xz &&
|
|
cd "$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 ../"$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 "$GLIBC" &&
|
|
echo "Finished 5.5. ""$GLIBC""" >> build.log
|
|
|
|
echo "5.6. Libstdc++ from ""$GCC"""
|
|
tar xf "$GCC".tar.xz &&
|
|
cd "$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 "$GCC" &&
|
|
echo "Finished 5.6. Libstdc++ from ""$GCC""" >> build.log
|
|
|
|
echo "6.2. ""$M4"""
|
|
tar xf "$M4".tar.xz &&
|
|
cd "$M4" &&
|
|
./configure --prefix=/usr \
|
|
--host=$LFS_TGT \
|
|
--build=$(build-aux/config.guess) &&
|
|
make &&
|
|
make DESTDIR=$LFS install &&
|
|
cd .. &&
|
|
rm -rf "$M4" &&
|
|
echo "Finished 6.2. ""$M4""" >> build.log
|
|
|
|
echo '6.3. Ncurses-6.4'
|
|
tar xf ncurses-6.4.tar.gz &&
|
|
cd ncurses-6.4 &&
|
|
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 ncurses-6.4 &&
|
|
echo 'Finished 6.3. Ncurses-6.4' >> build.log
|
|
|
|
echo "6.4. ""$BASH"""
|
|
tar xf "$BASH".tar.gz &&
|
|
cd "$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 "$BASH" &&
|
|
echo "Finished 6.4. ""$BASH""" >> build.log
|
|
|
|
echo "6.5. ""$COREUTILS"""
|
|
tar xf "$COREUTILS".tar.xz &&
|
|
cd "$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 "$COREUTILS" &&
|
|
echo "Finished 6.5. ""$COREUTILS""" >> build.log
|
|
|
|
echo "6.6. "$DIFFUTILS""
|
|
tar xf "$DIFFUTILS".tar.xz &&
|
|
cd "$DIFFUTILS" &&
|
|
./configure --prefix=/usr --host=$LFS_TGT &&
|
|
make &&
|
|
make DESTDIR=$LFS install &&
|
|
cd .. &&
|
|
rm -rf "$DIFFUTILS" &&
|
|
echo "Finished 6.6. ""$DIFFUTILS""" >> build.log
|
|
|
|
echo "6.7. ""$FILE"""
|
|
tar xf "$FILE".tar.gz &&
|
|
cd "$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 "$FILE" &&
|
|
echo "Finished 6.7. ""$FILE""" >> build.log
|
|
|
|
echo "6.8. ""$FINDUTILS"""
|
|
tar xf "$FINDUTILS".tar.xz &&
|
|
cd "$FINDUTILS" &&
|
|
./configure --prefix=/usr \
|
|
--localstatedir=/var/lib/locate \
|
|
--host=$LFS_TGT \
|
|
--build=$(build-aux/config.guess) &&
|
|
|
|
make &&
|
|
make DESTDIR=$LFS install &&
|
|
cd .. &&
|
|
rm -rf "$FINDUTILS" &&
|
|
echo "Finished 6.8. ""$FINDUTILS""" >> build.log
|
|
|
|
echo "6.9. ""$GAWK"""
|
|
tar xf "$GAWK".tar.xz &&
|
|
cd "$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 "$GAWK" &&
|
|
echo "Finished 6.9. ""$GAWK""" >> build.log
|
|
|
|
echo "6.10. ""$GREP"""
|
|
tar xf "$GREP".tar.xz &&
|
|
cd "$GREP" &&
|
|
./configure --prefix=/usr \
|
|
--host=$LFS_TGT &&
|
|
make &&
|
|
make DESTDIR=$LFS install &&
|
|
cd .. &&
|
|
rm -rf "$GREP" &&
|
|
echo "Finished 6.10. ""$GREP""" >> build.log
|
|
|
|
echo "6.11. ""$GZIP"""
|
|
tar xf "$GZIP".tar.xz &&
|
|
cd "$GZIP" &&
|
|
./configure --prefix=/usr --host=$LFS_TGT &&
|
|
make &&
|
|
make DESTDIR=$LFS install &&
|
|
cd .. &&
|
|
rm -rf "$GZIP" &&
|
|
echo "Finished 6.11. ""$GZIP""" >> build.log
|
|
|
|
echo "6.12. ""$MAKE"""
|
|
tar xf "$MAKE".tar.gz &&
|
|
cd "$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 "$MAKE" &&
|
|
echo "Finished 6.12. ""$MAKE""" >> build.log
|
|
|
|
echo "6.13. ""$PATCH"""
|
|
tar xf "$PATCH".tar.xz &&
|
|
cd "$PATCH" &&
|
|
./configure --prefix=/usr \
|
|
--host=$LFS_TGT \
|
|
--build=$(build-aux/config.guess) &&
|
|
make &&
|
|
make DESTDIR=$LFS install &&
|
|
cd .. &&
|
|
rm -rf "$PATCH" &&
|
|
echo "Finished 6.13. ""$PATCH""" >> build.log
|
|
|
|
echo "6.14. ""$SED"""
|
|
tar xf "$SED".tar.xz &&
|
|
cd "$SED" &&
|
|
./configure --prefix=/usr \
|
|
--host=$LFS_TGT &&
|
|
make &&
|
|
make DESTDIR=$LFS install &&
|
|
cd .. &&
|
|
rm -rf "$SED" &&
|
|
echo "Finished 6.14. ""$SED""" >> build.log
|
|
|
|
echo "6.15. ""$TAR"""
|
|
tar xf "$TAR".tar.xz &&
|
|
cd "$TAR" &&
|
|
./configure --prefix=/usr \
|
|
--host=$LFS_TGT \
|
|
--build=$(build-aux/config.guess) &&
|
|
|
|
make &&
|
|
make DESTDIR=$LFS install &&
|
|
cd .. &&
|
|
rm -rf "$TAR" &&
|
|
echo "Finished 6.15. ""$TAR""" >> build.log
|
|
|
|
echo "6.16. ""$XZ"""
|
|
tar xf "$XZ".tar.xz &&
|
|
cd "$XZ" &&
|
|
./configure --prefix=/usr \
|
|
--host=$LFS_TGT \
|
|
--build=$(build-aux/config.guess) \
|
|
--disable-static \
|
|
--docdir=/usr/share/doc/"$XZ" &&
|
|
|
|
make &&
|
|
make DESTDIR=$LFS install &&
|
|
rm -v $LFS/usr/lib/liblzma.la &&
|
|
cd .. &&
|
|
rm -rf "$XZ" &&
|
|
echo "Finished 6.16. ""$XZ""" >> build.log
|
|
|
|
echo "6.17. ""$BINUTILS"" - Pass 2"
|
|
tar xf "$BINUTILS" &&
|
|
cd "$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 "$BINUTILS" &&
|
|
echo "Finished 6.17. ""$BINUTILS"" - Pass 2" >> build.log
|
|
|
|
echo "6.18. ""$GCC"" - Pass 2"
|
|
tar xf "$GCC" &&
|
|
cd "$GCC" &&
|
|
tar -xf ../"$MPFR".tar.xz &&
|
|
mv -v "$MPFR" mpfr &&
|
|
tar -xf ../"$GMP".tar.xz &&
|
|
mv -v "$GMP" gmp &&
|
|
tar -xf ../"$MPC".tar.gz &&
|
|
mv -v "$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 "$GCC" &&
|
|
echo "Finished 6.18. ""$GCC"" - Pass 2" >> build.log
|
|
|
|
echo "Continue chapter 7 p1 as the root user"
|