changeset 4194:3dc897731d3b

new option to enable ccache * configure.ac: New option, --with-ccache. Set and substitute MXE_TARGET variable. * Makefile.in (USE_CCACHE, MXE_TARGET): New substitutions. (prerequisites, ccache-links, all-targets): New targets. (all): Use recursive make invocations to build prerequisites before all other targets.
author John W. Eaton <jwe@octave.org>
date Mon, 29 Aug 2016 13:26:30 -0400
parents 32814edc00db
children 3262d92eff57
files Makefile.in configure.ac
diffstat 2 files changed, 48 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile.in	Mon Aug 29 12:02:46 2016 -0400
+++ b/Makefile.in	Mon Aug 29 13:26:30 2016 -0400
@@ -28,6 +28,9 @@
 # Set to "no" if doing a cross compile build.
 MXE_NATIVE_BUILD := @MXE_NATIVE_BUILD@
 
+# Set to "yes" to use ccache
+USE_CCACHE := @USE_CCACHE@
+
 # Set to "yes" to use the versions of GCC and binutils already
 # installed on your system (default is yes if doing native build).
 USE_SYSTEM_GCC := @USE_SYSTEM_GCC@
@@ -60,15 +63,11 @@
 ENABLE_DEVEL_TOOLS := @ENABLE_DEVEL_TOOLS@
 
 # Should match what config.guess prints for your system.
-# If cross compiling, you must set it manually.
+# If cross compiling, you must set it manually (defaults are set by configure).
 ifeq ($(MXE_NATIVE_BUILD),yes)
   TARGET := $(shell $(TOP_DIR)/tools/config.guess)
 else
-  ifeq ($(ENABLE_WINDOWS_64),yes)
-    TARGET := x86_64-w64-mingw32
-  else
-    TARGET := i686-w64-mingw32
-  endif
+  TARGET := @MXE_TARGET@
 endif
 BUILD_SYSTEM := $(shell $(TOP_DIR)/tools/config.guess)
 
@@ -252,6 +251,10 @@
 
 ENV_PATH := $(PATH)
 PATH := $(BUILD_TOOLS_PREFIX)/bin:$(PATH)
+ifeq ($(USE_CCACHE),yes)
+  PATH := $(BUILD_TOOLS_PREFIX)/bin/ccache:$(PATH)
+  CCACHE_LINKS_TARGET := ccache-links
+endif
 
 ENV_PKG_CONFIG_PATH := $(PKG_CONFIG_PATH)
 
@@ -507,7 +510,30 @@
 endif
 
 .PHONY: all
-all: $(TOP_DIR)/configure Makefile $(OCTAVE_TARGET)
+all:
+	$(MAKE) prerequisites
+	$(MAKE) all-targets
+
+.PHONY: prerequisites
+prerequisites: $(TOP_DIR)/configure Makefile $(CCACHE_LINKS_TARGET)
+
+.PHONY: ccache-links
+ccache-links:
+	@echo "creating ccache links"
+	@mkdir -p usr/bin/ccache && \
+	for f in gcc g++ gfortran; do \
+	  if test ! -e usr/bin/ccache/$(MXE_TOOL_PREFIX)$$f; then \
+	    ln -s /usr/bin/ccache usr/bin/ccache/$(MXE_TOOL_PREFIX)$$f; \
+	  fi; \
+	done && \
+	for f in gcc g++ gfortran; do \
+	  if test ! -e usr/bin/ccache/$$f; then \
+	    ln -s /usr/bin/ccache usr/bin/ccache/$$f; \
+	  fi; \
+	done
+
+.PHONY: all-targets
+all-targets: $(OCTAVE_TARGET)
 
 .PHONY: all-packages
 all-packages: $(PKGS)
--- a/configure.ac	Mon Aug 29 12:02:46 2016 -0400
+++ b/configure.ac	Mon Aug 29 13:26:30 2016 -0400
@@ -74,6 +74,12 @@
 esac
 AC_SUBST(PKG_DIR)
 
+USE_CCACHE=no
+AC_ARG_WITH([ccache],
+  [AS_HELP_STRING([--with-ccache], [use ccache (default: no)])],
+  [if test "$withval" = yes; then USE_CCACHE=yes; fi], [])
+AC_SUBST(USE_CCACHE)
+
 ENABLE_WINDOWS_64=no
 AC_ARG_ENABLE(windows-64,
   [AS_HELP_STRING([--enable-windows-64],
@@ -239,6 +245,15 @@
 MXE_ROOTDIR=`cd "$builddir"; pwd`
 AC_SUBST(MXE_ROOTDIR)
 
+if test "$MXE_NATIVE_BUILD" = no; then
+  if test "$ENABLE_WINDOWS_64" = yes; then
+    MXE_TARGET=x86_64-w64-mingw32
+  else
+    MXE_TARGET=i686-w64-mingw32
+  fi
+fi
+AC_SUBST(MXE_TARGET)
+
 AC_CONFIG_FILES([Makefile tools/set-mxe-env.sh])
 AC_CONFIG_FILES([tools/makeinst-script.sh], [chmod a+x tools/makeinst-script.sh])