+#!/bin/bash
+
+# Manually applying patches if specified
+if [ -n "${GCC_PATCHES}" ]; then
+ for p in ${GCC_PATCHES}; do
+ apply_patch ${1}-${p}.patch ${1}
+ done
+fi
+
+case "${HVL_TARGET}" in
+ *)
+ TARGET_CONFIGURE_OPTS="--with-ppl=/cross-tools \
+ --with-cloog=/cross-tools \
+ --disable-multilib"
+ ;;
+esac
+
+case "${HVL_TARGET}" in
+ "x86")
+ apply_patch ${1}-specs-1.patch ${1}
+ ;;
+ "x86_64")
+ apply_patch ${1}-pure64_specs-1.patch ${1}
+ ;;
+esac
+
+cd ${LFS_TMP}/${1}
+
+# Change the StartFile Spec to point to the correct library location:
+echo -en '#undef STANDARD_INCLUDE_DIR\n#define STANDARD_INCLUDE_DIR "/tools/include/"\n\n' >> gcc/config/linux.h
+echo -en '\n#undef STANDARD_STARTFILE_PREFIX_1\n#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"\n' >> gcc/config/linux.h
+echo -en '\n#undef STANDARD_STARTFILE_PREFIX_2\n#define STANDARD_STARTFILE_PREFIX_2 ""\n' >> gcc/config/linux.h
+
+# Alter gcc's C preprocessor's default include search path to use /tools only:
+cp -v gcc/Makefile.in{,.orig}
+sed -e "s@\(^CROSS_SYSTEM_HEADER_DIR =\).*@\1 /tools/include@g" \
+ gcc/Makefile.in.orig > gcc/Makefile.in