# This is the source.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 DOWNLOAD="https://ftpmirror.gnu.org/gcc/gcc-${BPM_PKG_VERSION}/gcc-${BPM_PKG_VERSION}.tar.xz" FILENAME="${DOWNLOAD##*/}" # The prepare function is executed in the root of the temp directory # This function is used for downloading files and putting them into the correct location prepare() { wget "$DOWNLOAD" tar -xvf "$FILENAME" --strip-components=1 -C "$BPM_SOURCE" } # The build function is executed in the source directory # This function is used to compile the source code build() { # Install libraries to /usr/lib instead of /usr/lib64 sed -e '/m64=/s/lib64/lib/' -i.orig gcc/config/i386/t-linux64 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-bootstrap \ --disable-fixincludes \ --with-system-zlib \ --enable-languages=c,c++,fortran,objc,obj-c++,m2 make } # 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 } # 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 # Move runtime libraries to gcc-libs package mkdir "$BPM_SOURCE"/output-gcc-libs install -d "$BPM_SOURCE"/output-gcc-libs/usr/lib install -d "$BPM_SOURCE"/output-gcc-libs/usr/share/{info,locale/de/LC_MESSAGES,locale/fr/LC_MESSAGES} for lib in libasan libatomic libgcc_s libgfortran libgomp libitm liblsan libobjc libquadmath libstdc++ libtsan libubsan; do mv "$BPM_OUTPUT"/usr/lib/"$lib"* -t "$BPM_SOURCE"/output-gcc-libs/usr/lib/ done mv "$BPM_OUTPUT"/usr/share/info/{libgomp,libitm,libquadmath}.info -t "$BPM_SOURCE"/output-gcc-libs/usr/share/info/ mv "$BPM_OUTPUT"/usr/share/locale/de/LC_MESSAGES/libstdc++.mo -t "$BPM_SOURCE"/output-gcc-libs/usr/share/locale/de/LC_MESSAGES/ mv "$BPM_OUTPUT"/usr/share/locale/fr/LC_MESSAGES/libstdc++.mo -t "$BPM_SOURCE"/output-gcc-libs/usr/share/locale/fr/LC_MESSAGES/ # Move fortran files to gcc-fortran package mkdir "$BPM_SOURCE"/output-gcc-fortran install -d "$BPM_SOURCE"/output-gcc-fortran/usr/bin install -d "$BPM_SOURCE"/output-gcc-fortran/usr/lib/gcc/x86_64-pc-linux-gnu/"${BPM_PKG_VERSION}"/include/ install -d "$BPM_SOURCE"/output-gcc-fortran/usr/libexec/gcc/x86_64-pc-linux-gnu/"${BPM_PKG_VERSION}"/ install -d "$BPM_SOURCE"/output-gcc-fortran/usr/share/{info,man/man1} mv "$BPM_OUTPUT"/usr/bin/{gfortran,x86_64-pc-linux-gnu-gfortran} -t "$BPM_SOURCE"/output-gcc-fortran/usr/bin/ mv "$BPM_OUTPUT"/usr/lib/gcc/x86_64-pc-linux-gnu/"${BPM_PKG_VERSION}"/{finclude,libcaf_single.a} -t "$BPM_SOURCE"/output-gcc-fortran/usr/lib/gcc/x86_64-pc-linux-gnu/"${BPM_PKG_VERSION}"/ mv "$BPM_OUTPUT"/usr/lib/gcc/x86_64-pc-linux-gnu/"${BPM_PKG_VERSION}"/include/ISO_Fortran_binding.h -t "$BPM_SOURCE"/output-gcc-fortran/usr/lib/gcc/x86_64-pc-linux-gnu/"${BPM_PKG_VERSION}"/include/ mv "$BPM_OUTPUT"/usr/libexec/gcc/x86_64-pc-linux-gnu/"${BPM_PKG_VERSION}"/f951 -t "$BPM_SOURCE"/output-gcc-fortran/usr/libexec/gcc/x86_64-pc-linux-gnu/"${BPM_PKG_VERSION}"/ mv "$BPM_OUTPUT"/usr/share/info/gfortran.info -t "$BPM_SOURCE"/output-gcc-fortran/usr/share/info/ mv "$BPM_OUTPUT"/usr/share/man/man1/gfortran.1 -t "$BPM_SOURCE"/output-gcc-fortran/usr/share/man/man1/ # Install package license install -Dm644 "$BPM_SOURCE"/COPYING{,3}{,.LIB} -t "$BPM_OUTPUT"/usr/share/licenses/gcc/ } package_gcc-libs() { # Replace 'output' directory with 'output-gcc-libs' rmdir "$BPM_OUTPUT" mv "$BPM_SOURCE"/output-gcc-libs "$BPM_OUTPUT" # Install package license install -Dm644 "$BPM_SOURCE"/{COPYING3,COPYING.RUNTIME} -t "$BPM_OUTPUT"/usr/share/licenses/gcc-libs/ } package_gcc-fortran() { # Replace 'output' directory with 'output-gcc-fortran' rmdir "$BPM_OUTPUT" mv "$BPM_SOURCE"/output-gcc-fortran "$BPM_OUTPUT" # Install package license install -Dm644 "$BPM_SOURCE"/{COPYING3,COPYING.RUNTIME} -t "$BPM_OUTPUT"/usr/share/licenses/gcc-fortran/ }