Add constants for fast path resume copying
[coreboot.git] / util / crossgcc / buildgcc
index 891819137dc9eaba8396e5cd3da00407d04e56ba..d13e65d161452bd529fcc9ee1bf17ea335d27b70 100755 (executable)
@@ -126,6 +126,7 @@ myhelp()
        printf "    [-h|--help]                   print this help and exit\n"
        printf "    [-c|--clean]                  remove temporary files before build\n"
        printf "    [-t|--savetemps]              don't remove temporary files after build\n"
+       printf "    [-y|--ccache]                 Use ccache when building cross compiler\n"
        printf "    [-j|--jobs <num>]             run <num> jobs in parallel in make\n"
        printf "    [-p|--platform <platform>]    target platform to build cross compiler for\n"
        printf "                                  (defaults to $TARGETARCH)\n"
@@ -167,11 +168,11 @@ getopt - > /dev/null 2>/dev/null || gcc -o getopt getopt.c
 getoptbrand="`getopt -V | sed -e '1!d' -e 's,^\(......\).*,\1,'`"
 if [ "${getoptbrand}" = "getopt" ]; then
        # Detected GNU getopt that supports long options.
-       args=`getopt -l version,help,clean,directory:,platform:,jobs:,destdir:,savetemps,skip-gdb Vhcd:p:j:D:tG -- "$@"`
+       args=`getopt -l version,help,clean,directory:,platform:,jobs:,destdir:,savetemps,skip-gdb,ccache Vhcd:p:j:D:tGy -- "$@"`
        eval set "$args"
 else
        # Detected non-GNU getopt
-       args=`getopt Vhcd:p:j:D:tG $*`
+       args=`getopt Vhcd:p:j:D:tGy $*`
        set -- $args
 fi
 
@@ -192,6 +193,7 @@ while true ; do
                -j|--jobs)      shift; JOBS="-j $1"; shift;;
                -G|--gdb)       shift; SKIPGDB=0;;
                -S|--scripting) shift; SKIPPYTHON=0;;
+               -y|--ccache)    shift; USECCACHE=1;;
                --)             shift; break;;
                -*)             printf "Invalid option\n\n"; myhelp; exit 1;;
                *)              break;;
@@ -211,7 +213,9 @@ if [ $SKIPGDB -eq 1 ]; then
        fi
 fi
 if [ $SKIPPYTHON -eq 1 ]; then
+       PYTHON_ARCHIVE=""
        PYTHON_PACKAGE=""
+       EXPAT_ARCHIVE=""
        EXPAT_PACKAGE=""
 fi
 
@@ -323,6 +327,10 @@ if [ `uname` = "Darwin" ]; then
        fi
 fi
 
+if [ "$USECCACHE" = 1 ]; then
+       CC="ccache $CC"
+fi
+
 mkdir -p build-gmp build-mpfr build-mpc build-libelf build-binutils \
                build-gcc build-python build-expat
 if [ $SKIPGDB -eq 0 ]; then
@@ -335,7 +343,7 @@ printf "Building GMP ${GMP_VERSION} ... "
 (
        cd build-gmp
        rm -f .failed
-       ../${GMP_DIR}/configure --disable-shared --prefix=$TARGETDIR $OPTIONS \
+       CC="$CC" ../${GMP_DIR}/configure --disable-shared --prefix=$TARGETDIR $OPTIONS \
                || touch .failed
        $MAKE $JOBS || touch .failed
        $MAKE install DESTDIR=$DESTDIR || touch .failed
@@ -364,7 +372,7 @@ printf "Building MPFR ${MPFR_VERSION} ... "
        test `uname` = "Darwin" && CFLAGS="$CFLAGS -force_cpusubtype_ALL"
        cd build-mpfr
        rm -f .failed
-       ../${MPFR_DIR}/configure --disable-shared --prefix=$TARGETDIR \
+       CC="$CC" ../${MPFR_DIR}/configure --disable-shared --prefix=$TARGETDIR \
                --infodir=$TARGETDIR/info \
                --with-gmp=$DESTDIR$TARGETDIR CFLAGS="$HOSTCFLAGS" || \
                touch .failed
@@ -391,7 +399,7 @@ printf "Building MPC ${MPC_VERSION} ... "
        #test `uname` = "Darwin" && CFLAGS="$CFLAGS -force_cpusubtype_ALL"
        cd build-mpc
        rm -f .failed
-       ../${MPC_DIR}/configure --disable-shared --prefix=$TARGETDIR \
+       CC="$CC" ../${MPC_DIR}/configure --disable-shared --prefix=$TARGETDIR \
                --infodir=$TARGETDIR/info --with-mpfr=$DESTDIR$TARGETDIR \
                --with-gmp=$DESTDIR$TARGETDIR CFLAGS="$HOSTCFLAGS" || \
                touch .failed
@@ -413,7 +421,7 @@ printf "Building libelf ${LIBELF_VERSION} ... "
        cd build-libelf
        rm -f .failed
        echo "$HOSTCFLAGS"
-       CFLAGS="$HOSTCFLAGS" libelf_cv_elf_h_works=no \
+       CC="$CC" CFLAGS="$HOSTCFLAGS" libelf_cv_elf_h_works=no \
        ../${LIBELF_DIR}/configure --disable-shared --prefix=$TARGETDIR \
                --infodir=$TARGETDIR/info CFLAGS="$HOSTCFLAGS" || touch .failed
        $MAKE $JOBS || touch .failed
@@ -439,7 +447,7 @@ printf "Building binutils ${BINUTILS_VERSION} ... "
        # Now build binutils
        cd build-binutils
        rm -f .failed
-       ../binutils-${BINUTILS_VERSION}/configure --prefix=$TARGETDIR \
+       CC="$CC" ../binutils-${BINUTILS_VERSION}/configure --prefix=$TARGETDIR \
                --target=${TARGETARCH} --disable-werror --disable-nls \
                $USE_GOLD CFLAGS="$HOSTCFLAGS" || touch .failed
        $MAKE $JOBS || touch .failed
@@ -507,7 +515,7 @@ printf "Building Expat ${EXPAT_VERSION} ... "
        cd build-expat
        export PATH=$PATH:$DESTDIR$TARGETDIR/bin
        rm -f .failed
-       CFLAGS="$HOSTCFLAGS" ../${EXPAT_DIR}/configure --disable-shared \
+       CC="$CC" CFLAGS="$HOSTCFLAGS" ../${EXPAT_DIR}/configure --disable-shared \
                --prefix=$TARGETDIR --target=${TARGETARCH} || touch .failed
        $MAKE || touch .failed
        $MAKE install DESTDIR=$DESTDIR || touch .failed
@@ -529,7 +537,7 @@ printf "Building Python ${PYTHON_VERSION} ... "
        cd build-python
        export PATH=$PATH:$DESTDIR$TARGETDIR/bin
        rm -f .failed
-       CFLAGS="$HOSTCFLAGS" ../${PYTHON_DIR}/configure --prefix=$TARGETDIR \
+       CC="$CC" CFLAGS="$HOSTCFLAGS" ../${PYTHON_DIR}/configure --prefix=$TARGETDIR \
                --target=${TARGETARCH} || touch .failed
        $MAKE $JOBS || touch .failed
        $MAKE install DESTDIR=$DESTDIR || touch .failed
@@ -554,7 +562,7 @@ printf "Building GDB ${GDB_VERSION} ... "
        rm -f .failed
        LDFLAGS="-Wl,-rpath,\$\$ORIGIN/../lib/ -L$DESTDIR$TARGETDIR/lib \
                 -lpthread -ldl -lutil" \
-       CFLAGS="$HOSTCFLAGS -I$DESTDIR$TARGETDIR/include" \
+       CC="$CC" CFLAGS="$HOSTCFLAGS -I$DESTDIR$TARGETDIR/include" \
        ../gdb-${GDB_VERSION}/configure --prefix=$TARGETDIR \
                --target=${TARGETARCH} --disable-werror --disable-nls
        $MAKE $JOBS || touch .failed
@@ -575,7 +583,7 @@ printf "Building IASL ${IASL_VERSION} ... "
        export PATH=$PATH:$DESTDIR$TARGETDIR/bin
        rm -f .failed
        CFLAGS="$HOSTCFLAGS"
-       $MAKE || touch .failed
+       $MAKE CC="$CC" || touch .failed
        rm -f $DESTDIR$TARGETDIR/bin/iasl || touch .failed
        cp iasl $DESTDIR$TARGETDIR/bin || touch .failed
        if [ ! -f .failed ]; then touch .success; fi