Files
gcc/recipe.sh
T

119 lines
4.4 KiB
Bash

# This is the recipe.sh script. It is executed by BPM in a temporary directory when compiling a source package
# BPM Expects the source code to be extracted into the automatically created 'source' directory which can be accessed using $BPM_SOURCE
# BPM Expects the output files to be present in the automatically created 'output' directory which can be accessed using $BPM_OUTPUT
# The prepare function is executed in the root of the temp directory
# This function is used for putting downloaded files to the correct location or applying patches
prepare() {
cd "$BPM_SOURCE"
# Fix building with glibc-2.43
sed -i 's/char [*]q/const &/' libgomp/affinity-fmt.c
# Install libraries to /usr/lib instead of /usr/lib64
sed -e '/m64=/s/lib64/lib/' -i.orig gcc/config/i386/t-linux64
}
# The build function is executed in the source directory
# This function is used to compile the source code
build() {
mkdir build
cd build
../configure --prefix=/usr \
--libdir=/usr/lib \
--libexecdir=/usr/libexec \
--enable-default-pie \
--enable-default-ssp \
--enable-host-pie \
--disable-multilib \
--disable-fixincludes \
--disable-libssp \
--with-system-zlib \
--enable-languages=c,c++,fortran,objc,obj-c++,m2
make
# Make documentation
make -O -C $CHOST/libstdc++-v3/doc doc-man-doxygen
}
# The check function is executed in the source directory
# This function is used to run tests to verify the package has been compiled correctly
check() {
cd build
# Some tests are expected to fail. '|| true' will prevent the script from exiting if those fail
make -k check || true
# Get test results
"$BPM_SOURCE"/contrib/test_summary
}
_pick() {
local p="$1" f d; shift
for f; do
[ -d "$BPM_WORKDIR"/output_"$p" ] || { echo "Split package $p not found"; exit 1; }
d="$BPM_WORKDIR"/output_"$p"/"${f#$BPM_OUTPUT}"
mkdir -p "$(dirname "$d")"
mv "$f" "$d"
rmdir -p --ignore-fail-on-non-empty "$(dirname "$f")"
done
}
# The package function is executed in the source directory
# This function is used to move the compiled files into the output directory
package_gcc() {
cd build
make DESTDIR="$BPM_OUTPUT" install
# Symlink required by FHS
ln -sr /usr/bin/cpp "$BPM_OUTPUT"/usr/lib
# Create 'cc' symlinks which is required by some packages
ln -s gcc "$BPM_OUTPUT"/usr/bin/cc
ln -s gcc.1 "$BPM_OUTPUT"/usr/share/man/man1/cc.1
# Compatibility symlink to enable building programs with Link Time Optimizations (LTO)
mkdir -p "$BPM_OUTPUT"/usr/lib/bfd-plugins/
ln -sf ../../libexec/gcc/$(gcc -dumpmachine)/${BPM_PKG_VERSION}/liblto_plugin.so "$BPM_OUTPUT"/usr/lib/bfd-plugins/
# Move misplaced files
install -dm755 "$BPM_OUTPUT"/usr/share/gdb/auto-load/usr/lib
mv "$BPM_OUTPUT"/usr/lib/*gdb.py "$BPM_OUTPUT"/usr/share/gdb/auto-load/usr/lib
cd "$BPM_OUTPUT"
# Move runtime libraries into split package
for lib in libasan libatomic libgcc_s libgfortran libgomp libitm liblsan libobjc libquadmath libstdc++ libtsan libubsan; do
_pick gcc-libs usr/lib/"$lib"*
done
_pick gcc-libs usr/share/info/{libgomp,libitm,libquadmath}.info
_pick gcc-libs usr/share/locale/de/LC_MESSAGES/libstdc++.mo
_pick gcc-libs usr/share/locale/fr/LC_MESSAGES/libstdc++.mo
# Move fortran files to gcc-fortran package
_pick gcc-libs usr/bin/{gfortran,x86_64-pc-linux-gnu-gfortran}
_pick gcc-libs usr/lib/gcc/x86_64-pc-linux-gnu/${BPM_PKG_VERSION}/{finclude,libcaf_single.a}
_pick gcc-libs usr/lib/gcc/x86_64-pc-linux-gnu/${BPM_PKG_VERSION}/include/ISO_Fortran_binding.h
_pick gcc-libs usr/libexec/gcc/x86_64-pc-linux-gnu/${BPM_PKG_VERSION}/f951
_pick gcc-libs usr/share/info/gfortran.info
_pick gcc-libs usr/share/man/man1/gfortran.1
# Install package license
install -Dm644 "$BPM_SOURCE"/COPYING{,3}{,.LIB} -t "$BPM_OUTPUT"/usr/share/licenses/gcc/
}
package_gcc-libs() {
cd build
# Install libstdc++ man pages
make -C $CHOST/libstdc++-v3/doc DESTDIR="$BPM_OUTPUT" doc-install-man
# Install package license
install -Dm644 "$BPM_SOURCE"/{COPYING3,COPYING.RUNTIME} -t "$BPM_OUTPUT"/usr/share/licenses/gcc-libs/
}
package_gcc-fortran() {
# Install package license
install -Dm644 "$BPM_SOURCE"/{COPYING3,COPYING.RUNTIME} -t "$BPM_OUTPUT"/usr/share/licenses/gcc-fortran/
}