#!/bin/sh
-# First argument of this script is the package name
+set -o errexit
# Reading system configuration informations, functions and package versions.
source ../sysinfos
source ../functions
source ../packages-list
-# Saves CFLAGS and CXXFLAGS, and clears them.
-save_flags_no_optimizations
+PACKAGE=${1}
+shift
+CONFIGURE_OPTS=${*}
+
+# Manually applying patches
+apply_patch ${PACKAGE}-branch_update-1.patch ${PACKAGE}
+
+case "${HVL_TARGET}" in
+ "x86_64")
+ # Apply the following patch so that GCC links to /lib instead of /lib64:
+ apply_patch ${PACKAGE}-pure64-1.patch ${PACKAGE}
+ ;;
+esac
+
+cd ${LFS_TMP}/${PACKAGE}
# Applying a sed substitution that will suppress the installation of
# libiberty.a. We want to use the Binutils version of libiberty.a
-cd ${LFS_TMP}/${1} &&
-sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in &&
-
-# The bootstrap build performed in pass1 built GCC with the -fomit-frame-pointer
-# compiler flag. Non-bootstrap builds omit this flag by default, so the following sed
-# command is used in order to ensure consistent compiler builds.
-sed -i 's/^XCFLAGS =$/& -fomit-frame-pointer/' gcc/Makefile.in &&
-
-# Suppressing the running of the fixincludes script. */
-sed -i 's@\./fixinc\.sh@-c true@' gcc/Makefile.in &&
-
-# GCC provides a gccbug script which detects at compile time whether
-# mktemp is present, and hardcodes the result in a test. This will
-# cause the script to fall back to using less random names for temporary
-# files. We will be installing mktemp later, so the following sed will
-# simulate its presence:
-sed -i 's/@have_mktemp_command@/yes/' gcc/gccbug.in &&
-
-cd ${LFS_TMP}/${1}-build &&
-../${1}/configure \
+sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in
+
+cd ${LFS_TMP}/${PACKAGE}-build
+../${PACKAGE}/configure \
--prefix=/usr \
- --libexecdir=/usr/lib \
- --enable-shared \
- --enable-threads=posix \
- --enable-__cxa_atexit \
- --enable-clocale=gnu \
- --enable-languages=c,c++ \
- --disable-bootstrap &&
-make -j ${MAKEJOBS} &&
-make install &&
-ln -v -sf ../usr/bin/cpp /lib &&
-ln -v -sf gcc /usr/bin/cc &&
-
-# Performing compilation test...
-echo 'main(){}' > dummy.c &&
-cc dummy.c &&
-readelf -l a.out | grep ': /lib' 1> /dev/null 2>&1 &&
-rm dummy.c a.out &&
-
-# Restore original CFLAGS and CXXFLAGS values.
-restore_flags
-
-# Return last error
+ --sysconfdir=/etc \
+ ${CONFIGURE_OPTS}
+make
+make install
+ldconfig
+
+ln -svf ../usr/bin/cpp /lib
+ln -svf gcc /usr/bin/cc
+
exit $?