# --- ROCK-COPYRIGHT-NOTE-BEGIN ---
# 
# This copyright note is auto-generated by ./scripts/Create-CopyPatch.
# Please add additional copyright information _after_ the line containing
# the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
# the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
# 
# ROCK Linux: rock-src/package/base/ccache/parse-config
# ROCK Linux is Copyright (C) 1998 - 2003 Clifford Wolf
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version. A copy of the GNU General Public
# License can be found at Documentation/COPYING.
# 
# Many people helped and are helping developing ROCK Linux. Please
# have a look at http://www.rocklinux.org/ and the Documentation/TEAM
# file for details.
# 
# --- ROCK-COPYRIGHT-NOTE-END ---


if [ "$ROCKCFG_PKG_CCACHE_USEIT" = 1 -a "`type -p ccache`" ] ; then
	unset ${!CCACHE_*}
	mkdir -p "$base/build/$ROCKCFG_ID/ccache${toolsdir#tools}"
	export CCACHE_DIR="$base/build/$ROCKCFG_ID/ccache${toolsdir#tools}"
	export CCACHE_DONT_STAT_COMPILER=1 CCACHE_NLEVELS=5

	var_insert KCC_WRAPPER_OTHERS ":" "ccache"
	var_insert GCC_WRAPPER_OTHERS ":" "ccache"

	eval "$( ccache -s | gawk 'NR == 1 { hit=$3; } NR == 2 { miss=$3; }
			END { if (hit+miss == 0) print "x=0.00";
			else printf "x=%.2f\n", hit*100 / (hit+miss);
			print "ccache_hit=" hit "; ccache_miss=" miss; }' )"
	echo_status "Compiler Cache enabled: $x% cache hits so `
			`far in ccache${toolsdir#tools}."

	ccache_print_status() {
		eval "$( ccache -s | gawk 'NR == 1 { hit=$3-'$ccache_hit'; }
			NR == 2 { miss=$3-'$ccache_miss'; }
			END { if (hit+miss == 0) print "x=0.00";
			else printf "x=%.2f\n", hit*100 / (hit+miss);
			print "ccache_hit=" hit "; ccache_miss=" miss; }' )"
		echo_status "Compiler Cache Hits while pkg build: $x% (`
			`$ccache_hit hits, $ccache_miss misses)"
	}

	hook_add finish 9 ccache_print_status
fi