Add support to build with ccache in the build system

Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de>
Acked-by: Stefan Reinauer <stepan@coresystems.de>


git-svn-id: svn://svn.coreboot.org/coreboot/trunk@5297 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
diff --git a/util/abuild/abuild b/util/abuild/abuild
index 5aeca0f..d982835 100755
--- a/util/abuild/abuild
+++ b/util/abuild/abuild
@@ -55,6 +55,9 @@
 # clang mode enabled by -sb option.
 scanbuild=false
 
+# use ccache
+ccache=false
+
 # stackprotect mode enabled by -ns option.
 stackprotect=false
 
@@ -174,6 +177,11 @@
 			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
@@ -495,6 +503,7 @@
 	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"
@@ -530,11 +539,11 @@
 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
 
@@ -559,6 +568,7 @@
 		-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;;
diff --git a/util/romcc/romcc.c b/util/romcc/romcc.c
index aee8696..b7c7a01 100644
--- a/util/romcc/romcc.c
+++ b/util/romcc/romcc.c
@@ -24968,10 +24968,14 @@
 	state.errout = stderr;
 	state.dbgout = stdout;
 	/* Remember the output filename */
-	state.output    = fopen(state.compiler->ofilename, "w");
-	if (!state.output) {
-		error(&state, 0, "Cannot open output file %s\n",
-			state.compiler->ofilename);
+	if ((state.compiler->flags & COMPILER_PP_ONLY) && (strcmp("auto.inc",state.compiler->ofilename) == 0)) {
+		state.output    = stdout;
+	} else {
+		state.output    = fopen(state.compiler->ofilename, "w");
+		if (!state.output) {
+			error(&state, 0, "Cannot open output file %s\n",
+				state.compiler->ofilename);
+		}
 	}
 	/* Make certain a good cleanup happens */
 	exit_state = &state;
@@ -25146,6 +25150,12 @@
 			else if (strncmp(argv[1], "-m", 2) == 0) {
 				result = arch_encode_flag(&arch, argv[1]+2);
 			}
+			else if (strncmp(argv[1], "-c", 2) == 0) {
+				result = 0;
+			}
+			else if (strncmp(argv[1], "-S", 2) == 0) {
+				result = 0;
+			}
 			else if (strncmp(argv[1], "-include", 10) == 0) {
 				struct filelist *old_head = include_filelist;
 				include_filelist = malloc(sizeof(struct filelist));