1.2. pass1-gcc-9.2.0

#!/bin/sh
# Copyright © 1999-2020 Gerard Beekmans
# Copyright © 2017-2020 Random Crew
# Distributed under the terms of MIT License.


MY_P="${P#pass1-}"
MY_PD="${MY_P}"

Additional source handling

src_postfetch()
{
    tar xf ${ANYSRCDIR}/mpfr-4.0.2.tar.xz
    mv mpfr-4.0.2 mpfr
    tar xf ${ANYSRCDIR}/gmp-6.2.0.tar.xz
    mv gmp-6.2.0 gmp
    tar xf ${ANYSRCDIR}/mpc-1.1.0.tar.gz
    mv mpc-1.1.0 mpc
}

Configuration

Add new rule to sed replacement:

    -e "s@/lib64@/lib@g" \

This is needed to set up the dynamic linker for use the single lib directory ./lib/ instead of both ./lib and ./lib64.

src_config()
{
    for file in gcc/config/{linux,i386/linux{,64}}.h
    do
        cp -u $file{,.orig}
        sed -e "s@/lib\(64\)\?\(32\)\?/ld@${PREFIX}&@g" \
            -e "s@/usr@${PREFIX}@g" \
            -e "s@/lib64@/lib@g" \
            $file.orig > $file
        echo "
    #undef STANDARD_STARTFILE_PREFIX_1
    #undef STANDARD_STARTFILE_PREFIX_2
    #define STANDARD_STARTFILE_PREFIX_1 \"${PREFIX}/lib/\"
    #define STANDARD_STARTFILE_PREFIX_2 \"\"" >> $file
        touch $file.orig
    done

    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=${PREFIX}                             \
        --with-glibc-version=2.11                      \
        --with-sysroot                                 \
        --with-newlib                                  \
        --without-headers                              \
        --with-local-prefix=${PREFIX}                  \
        --with-native-system-header-dir=${PREFIX}/include \
        --disable-nls                                  \
        --disable-shared                               \
        --disable-multilib                             \
        --disable-decimal-float                        \
        --disable-threads                              \
        --disable-libatomic                            \
        --disable-libgomp                              \
        --disable-libquadmath                          \
        --disable-libssp                               \
        --disable-libvtv                               \
        --disable-libstdcxx                            \
        --enable-languages=c,c++
}

Compilation

src_compile()
{
    make ${MAKEOPTS}
}

Installation

src_install()
{
    make install ${MAKEOPTS} DESTDIR=$D
}

Links

url.lfs:
url.lfs.stage1: https://linuxfromscratch.org/lfs/view/9.1/chapter05/gcc-pass1.html