1.2. pass1-gcc-12.2.0

#!/bin/sh
# Copyright © 1999-2022 Gerard Beekmans
# Copyright © 2017-2022 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.1.0.tar.xz
    mv mpfr-4.1.0 mpfr
    tar xf ${ANYSRCDIR}/gmp-6.2.1.tar.xz
    mv gmp-6.2.1 gmp
    tar xf ${ANYSRCDIR}/mpc-1.2.1.tar.gz
    mv mpc-1.2.1 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

    ../configure                                       \
        --target=${LFS_TGT}                            \
        --prefix=${LFS}/${PASS1PREFIX}                   \
        --with-glibc-version=2.36                      \
        --with-sysroot=${LFS}                          \
        --with-newlib                                  \
        --without-headers                              \
        --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

$LFS_TGT-gcc is called not from default path, but explicitly from $D/$PREFIX. At the moment $LFS_TGT-gcc is not installed into the filesystem, as installation goes into D first.

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

    cd ..
    cat gcc/limitx.h gcc/glimits.h gcc/limity.h > \
        `dirname $( ${D}/${LFS}/${PASS1PREFIX}/bin/${LFS_TGT}-gcc \
        -print-libgcc-file-name )`/install-tools/include/limits.h
}

Links

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