Update for new BUILD_DIR and SRC_DIR variables
[hvlinux.git] / stage0 / pkg / gcc
index 24ee1ef..fab1a51 100644 (file)
@@ -1,47 +1,50 @@
 #!/bin/bash
 
-hvpatch()
-{
-    # Manually applying patches if specified
-    if [ -n "${GCC_PATCHES}" ]; then
-        for p in ${GCC_PATCHES}; do
-            apply_patch ${PACKAGE}-${p}.patch ${PACKAGE}
-        done
-    fi
-
-    case "${HVL_TARGET}" in
-        "x86")
-            apply_patch ${PACKAGE}-specs-1.patch ${PACKAGE}
-            ;;
-        "x86_64")
-            apply_patch ${PACKAGE}-pure64_specs-1.patch ${PACKAGE}
-           ;;
-    esac
-}
-
 hvconfig_pre()
 {
     export AR=ar
-    export LDFLAGS="-Wl,-rpath,/cross-tools/lib"
+    export LDFLAGS="-Wl,-rpath,${CROSS_TOOLS_DIR}/lib"
 
     # Common options for passes 1 & 2
-    CONFIGURE_OPTS="\
-        ${CONFIGURE_OPTS} \
+    # --with-local-prefix:
+    #   Remove /usr/local/include (default value) from gcc's include search
+    #   path. This is not absolutely essential, however, it helps to minimize
+    #   the influence of the host system.
+    # --with-native-system-header-dir=dirname
+    #   Must be an absolute directory (from within sysroot).
+    #   The compiler will search the sysroot directory within dirname for
+    #   native system headers rather than the default /usr/include.
+    #   For example, with:
+    #     --with-sysroot=/opt/toolchain
+    #     --with-native-system-header-dir=/tools/include
+    #   then GCC will search for system headers in:
+    #     /opt/toolchain/tools/include
+    CONFIGURE_OPTS=" \
+        --prefix=/cross-tools \
         --build=${CLFS_HOST} \
         --host=${CLFS_HOST} \
         --target=${CLFS_TARGET} \
         --with-sysroot=${CLFS} \
-        --with-local-prefix=/tools \
+        --with-local-prefix=${TOOLS_DIR} \
+        --with-native-system-header-dir=/tools/include \
         --disable-nls \
-        --with-mpfr=/cross-tools \
-        --with-gmp=/cross-tools \
-        --with-ppl=/cross-tools \
-        --with-cloog=/cross-tools \
-        --enable-cloog-backend=isl \
+        --with-mpfr=${CROSS_TOOLS_DIR} \
+        --with-gmp=${CROSS_TOOLS_DIR} \
+        --with-isl=${CROSS_TOOLS_DIR} \
+        --with-cloog=${CROSS_TOOLS_DIR} \
+        --with-mpc=${CROSS_TOOLS_DIR}
+        --with-system-zlib \
+        --enable-checking=release \
         --disable-multilib"
 
     if [ "x${HVLABEL}" = "x${GCC}-pass1" ]; then
-        CONFIGURE_OPTS="${CONFIGURE_OPTS} \
+        # --without-headers:
+        #   When building a cross-compiler and there are no system headers
+        #   for the target yet (they will be available once glibc is built).
+        # --with-newlib:
+        #   Tell the configuration utility not to use glibc, since it has not
+        #   yet been compiled for the target.
+        CONFIGURE_OPTS+=" \
             --disable-shared \
             --without-headers \
             --with-newlib \
@@ -49,34 +52,39 @@ hvconfig_pre()
             --disable-libgomp \
             --disable-libmudflap \
             --disable-libssp \
+            --disable-libatomic \
+            --disable-libitm \
+            --disable-libsanitizer \
+            --disable-libquadmath \
             --disable-threads \
+            --disable-target-zlib \
             --enable-languages=c"
+
+        # We will create a dummy limits.h so the build will not use the one
+        # provided by the host distro:
+        mkdir -p ${TOOLS_DIR}/include
+        touch ${TOOLS_DIR}/include/limits.h
     else
-        CONFIGURE_OPTS="${CONFIGURE_OPTS} \
+        CONFIGURE_OPTS+=" \
             --enable-shared \
+            --disable-static \
             --enable-languages=c,c++ \
             --enable-__cxa_atexit \
             --enable-c99 \
             --enable-long-long \
+            --enable-libstdcxx-time \
             --enable-threads=posix"
-    fi
-
-    cd ${LFS_TMP}/${PACKAGE}
-
-    # 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:
-    sed -e "s@\(^CROSS_SYSTEM_HEADER_DIR =\).*@\1 /tools/include@g" \
-        -i gcc/Makefile.in
+        cd ${SRC_DIR}
 
-    if [ "x${HVLABEL}" = "x${GCC}-pass1" ]; then
-        # We will create a dummy limits.h so the build will not use the one
-        # provided by the host distro:
-        touch /tools/include/limits.h
+        # Change the StartFile Spec to point to the correct library location:
+        echo -en '\n' >> gcc/config/linux.h
+        echo -en '#undef  STANDARD_STARTFILE_PREFIX_1\n' >> gcc/config/linux.h
+        echo -en '#define STANDARD_STARTFILE_PREFIX_1 "/tools/lib/"\n' >> \
+            gcc/config/linux.h
+        echo -en '#undef  STANDARD_STARTFILE_PREFIX_2\n' >> gcc/config/linux.h
+        echo -en '#define STANDARD_STARTFILE_PREFIX_2 ""\n' >> \
+            gcc/config/linux.h
     fi
 }
 
@@ -90,11 +98,11 @@ hvbuild()
 {
     if [ "x${HVLABEL}" = "x${GCC}-pass1" ]; then
         ${HVMAKE} all-gcc all-target-libgcc
-        ${HVMAKE} install-gcc install-target-libgcc
+        ${HVMAKE} DESTDIR=${LFS} install-gcc install-target-libgcc
     else
         ${HVMAKE} \
             AS_FOR_TARGET="${CLFS_TARGET}-as" \
             LD_FOR_TARGET="${CLFS_TARGET}-ld"
-        ${HVMAKE} install
+        ${HVMAKE} DESTDIR=${LFS} install
     fi
 }