make only needs to read Makefile.incs once, thanks to the
[coreboot.git] / util / abuild / abuild
index 1e67685ffbb438e8a485d160fcc4c53908fc10e5..fbb801ec8288309271d8aac9d26f2d3527baa9da 100755 (executable)
@@ -18,7 +18,7 @@ ABUILD_DATE="January 29th, 2010"
 ABUILD_VERSION="0.9"
 
 # Where shall we place all the build trees?
-TARGET=$( pwd )/coreboot-builds
+TARGET=coreboot-builds
 XMLFILE=$( pwd )/abuild.xml
 
 # path to payload. Should be more generic
@@ -55,6 +55,9 @@ silent=
 # clang mode enabled by -sb option.
 scanbuild=false
 
+# use ccache
+ccache=false
+
 # stackprotect mode enabled by -ns option.
 stackprotect=false
 
@@ -174,6 +177,11 @@ function create_config
                        echo "CONFIG_DEFAULT_CONSOLE_LOGLEVEL=$loglevel" >> .config
                fi
 
+               if [ "$ccache" = "true" ]; then
+                       printf "(ccache enabled) "
+                       echo "CONFIG_CCACHE=y" >> .config
+               fi
+
                if [ "$scanbuild" = "true" ]; then
                        printf "(scan-build enabled) "
                        echo "CONFIG_SCANBUILD_ENABLE=y" >> .config
@@ -210,6 +218,16 @@ function create_buildenv
        MAINBOARD=$2
        CONFIG=$3
        create_config $VENDOR $MAINBOARD $CONFIG
+
+       # Allow simple "make" in the target directory
+       MAKEFILE=$TARGET/${VENDOR}_${MAINBOARD}/Makefile
+       echo "# autogenerated makefile" > $MAKEFILE
+       echo "TOP=$ROOT" >> $MAKEFILE
+       echo "OUT=$TARGET/${VENDOR}_${MAINBOARD}" >> $MAKEFILE
+       echo "coreboot.rom:" >> $MAKEFILE
+       echo "  cp config.build \$(TOP)/.config" >> $MAKEFILE
+       echo "  cd \$(TOP); \$(MAKE) oldconfig obj=\$(OUT)" >> $MAKEFILE
+       echo "  cd \$(TOP); \$(MAKE) obj=\$(OUT)" >> $MAKEFILE
 }
 
 function compile_target
@@ -485,6 +503,7 @@ function myhelp
        printf "    [-s|--silent]                 omit compiler calls in logs\n"
        printf "    [-ns|--nostackprotect]        use gcc -fno-stack-protector option\n"
        printf "    [-sb|--scan-build]            use clang's static analyzer\n"
+       printf "    [-y|--ccache]                 use ccache\n"
        printf "    [-C|--config]                 configure-only mode\n"
        printf "    [-l|--loglevel <num>]         set loglevel\n"
        printf "    [lbroot]                      absolute path to coreboot sources\n"
@@ -520,11 +539,11 @@ test "$ROOT" = "" && ROOT=$( cd ../..; pwd )
 getoptbrand="`getopt -V`"
 if [ "${getoptbrand:0:6}" == "getopt" ]; then
        # Detected GNU getopt that supports long options.
-       args=`getopt -l version,verbose,help,all,target:,broken,payloads:,test,cpus:,silent,xml,config,loglevel: Vvhat:bp:Tc:sxCl: -- "$@"`
+       args=`getopt -l version,verbose,help,all,target:,broken,payloads:,test,cpus:,silent,xml,config,loglevel:,ccache Vvhat:bp:Tc:sxCl:y -- "$@"`
        eval set "$args"
 else
        # Detected non-GNU getopt
-       args=`getopt Vvhat:bp:Tc:sxCl:o $*`
+       args=`getopt Vvhat:bp:Tc:sxCl:y $*`
        set -- $args
 fi
 
@@ -540,7 +559,7 @@ while true ; do
                -a|--all)       shift; buildall=true;;
                -b|--broken)    shift; buildbroken=true;;
                -r|--remove)    shift; remove=true; shift;;
-               -v|--verbose)   shift; verbose=true;;
+               -v|--verbose)   shift; verbose=true; silent='V=1';;
                -V|--version)   shift; myversion; exit 0;;
                -h|--help)      shift; myversion; myhelp; exit 0;;
                -p|--payloads)  shift; payloads="$1"; shift;;
@@ -549,6 +568,7 @@ while true ; do
                -s|--silent)    shift; silent="-s";;
                -ns|--nostackprotect) shift; stackprotect=true;;
                -sb|--scan-build) shift; scanbuild=true;;
+               -y|--ccache)    shift; ccache=true;;
                -C|--config)    shift; configureonly=1;;
                -l|--loglevel)  shift; loglevel="$1"; shift;;
                --)             shift; break;;