1.22. pass2-gcc-10.2.0

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


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

Additional source handling

The same version of gcc is used in several versions of LFS and uses different versions of libraries gmp, mpc.

src_postfetch()
{
    case ${LFS_VERSION} in
        10.1)
            gmp_version='6.2.1'
            mpc_version='1.2.1'
        ;;
        10.0)
            gmp_version='6.2.0'
            mpc_version='1.1.0'
        ;;
        *)
            gmp_version='6.2.0'
            mpc_version='1.1.0'
        ;;
    esac

    tar xf ${ANYSRCDIR}/mpfr-4.1.0.tar.xz
    mv mpfr-4.1.0 mpfr
    tar xf ${ANYSRCDIR}/gmp-${gmp_version}.tar.xz
    mv gmp-${gmp_version} gmp
    tar xf ${ANYSRCDIR}/mpc-${mpc_version}.tar.gz
    mv mpc-${mpc_version} mpc
}

Configuration

src_config()
{
    case $(uname -m) in
        x86_64)
            sed -e '/m64=/s/lib64/lib/' \
                -i.orig gcc/config/i386/t-linux64
        ;;
    esac

    mkdir build
    cd build
    mkdir -p ${LFS_TGT}/libgcc
    ln -s ../../../libgcc/gthr-posix.h ${LFS_TGT}/libgcc/gthr-default.h

    ../configure                                       \
        --build=$(../config.guess)                     \
        --host=${LFS_TGT}                              \
        --prefix=${PREFIX}                             \
        CC_FOR_TARGET=${LFS_TGT}-gcc                   \
        --with-build-sysroot=${LFS}                    \
        --enable-initfini-array                        \
        --disable-nls                                  \
        --disable-multilib                             \
        --disable-decimal-float                        \
        --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}

    ln -s gcc ${D}/usr/bin/cc
}

Links

url.lfs:
url.lfs.stage1: https://linuxfromscratch.org/lfs/view/10.1/chapter06/gcc-pass2.html