add ccache wrapper
authorJohn Crispin <john@openwrt.org>
Wed, 6 Jun 2012 13:27:11 +0000 (13:27 +0000)
committerJohn Crispin <john@openwrt.org>
Wed, 6 Jun 2012 13:27:11 +0000 (13:27 +0000)
SVN-Revision: 32075

rules.mk
tools/ccache/Makefile
tools/ccache/files/ccache_cc [new file with mode: 0755]
tools/ccache/files/ccache_cxx [new file with mode: 0755]

index f6e748c4295c909f09dcd379d1eadd94b415394d..73a015e7a03bcc4b4225ba45b7524c2143e87907 100644 (file)
--- a/rules.mk
+++ b/rules.mk
@@ -188,8 +188,12 @@ INSTALL_DATA:=install -m0644
 INSTALL_CONF:=install -m0600
 
 ifneq ($(CONFIG_CCACHE),)
-  TARGET_CC:= ccache $(TARGET_CC)
-  TARGET_CXX:= ccache $(TARGET_CXX)
+  TARGET_CC_NOCACHE:=$(TARGET_CC)
+  TARGET_CXX_NOCACHE:=$(TARGET_CXX)
+  export TARGET_CC_NOCACHE
+  export TARGET_CXX_NOCACHE
+  TARGET_CC:= ccache_cc
+  TARGET_CXX:= ccache_cxx
   HOSTCC:= ccache $(HOSTCC)
 endif
 
index 9bc0b5901a5013bef55aefbd5e6438b54afb4010..8848fa5102b2500deaa5b3207bcf35a9bbfc64a2 100644 (file)
@@ -17,6 +17,11 @@ PKG_CAT:=zcat
 
 include $(INCLUDE_DIR)/host-build.mk
 
+define Host/Install/ccache
+       $(INSTALL_DIR) $(STAGING_DIR_HOST)/bin/
+       $(CP) ./files/* $(STAGING_DIR_HOST)/bin/
+endef
+
 ifneq ($(strip $(shell which ccache >/dev/null && echo found)),found)
   define Host/Compile
        $(MAKE) CC="$(HOSTCC_NOCACHE)" -C $(HOST_BUILD_DIR)
@@ -26,6 +31,10 @@ ifneq ($(strip $(shell which ccache >/dev/null && echo found)),found)
        -$(MAKE) -C $(HOST_BUILD_DIR) uninstall
        $(call Host/Clean/Default)
   endef
+  define Host/Install
+       $(call Host/Install/Default)
+       $(call Host/Install/ccache)
+  endef
 else
   define Host/Prepare
   endef
@@ -34,6 +43,7 @@ else
   define Host/Compile
   endef
   define Host/Install
+       $(call Host/Install/ccache)
   endef
   define Host/Clean
   endef
diff --git a/tools/ccache/files/ccache_cc b/tools/ccache/files/ccache_cc
new file mode 100755 (executable)
index 0000000..01c4ad4
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec ccache "${TARGET_CC_NOCACHE}" "$@"
diff --git a/tools/ccache/files/ccache_cxx b/tools/ccache/files/ccache_cxx
new file mode 100755 (executable)
index 0000000..cc60eb3
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+exec ccache "${TARGET_CXX_NOCACHE}" "$@"