[PATCH 09/19] Introduce a cache of the configuration
Thiago Macieira
thiago at macieira.org
Mon Apr 22 23:48:15 PDT 2013
You may have noticed that running make is a little slow. Every time
that it is loaded, it will try to detect everything again. So,
instead, save the output and reload it the next time.
This is implemented by adding a rule that (re-)creates the
config.cache file, which is included by make. If the file doesn't
exist yet, make will first run the rule which creates it, then reload
itself.
You can also cause it to reconfigure by running "make configure".
Signed-off-by: Thiago Macieira <thiago at macieira.org>
---
.gitignore | 1 +
Configure.mk | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
Rules.mk | 3 +++
3 files changed, 52 insertions(+)
diff --git a/.gitignore b/.gitignore
index 54650bc..b62d898 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,3 +22,4 @@ Documentation/user-manual.pdf
Documentation/user-manual.text
packaging/windows/subsurface.nsi
packaging/macos/Info.plist
+config.cache
diff --git a/Configure.mk b/Configure.mk
index f9b9e06..fa04a44 100644
--- a/Configure.mk
+++ b/Configure.mk
@@ -1,5 +1,6 @@
# -*- Makefile -*-
# This file contains the detection rules
+all:
PKGCONFIG=pkg-config
XML2CONFIG=xml2-config
@@ -8,6 +9,11 @@ QMAKE=qmake
MOC=moc
UIC=uic
+CONFIGFILE = config.cache
+ifeq ($(CONFIGURING),1)
+
+# Detect the target system
+# Ask the compiler what OS it's producing files for
UNAME := $(shell $(CC) -dumpmachine 2>&1 | grep -E -o "linux|darwin|win|gnu|kfreebsd")
# find libdivecomputer
@@ -110,3 +116,45 @@ ZIPFLAGS = $(strip $(shell $(PKGCONFIG) --cflags libzip 2> /dev/null))
LIBSQLITE3 = $(shell $(PKGCONFIG) --libs sqlite3 2> /dev/null)
SQLITE3FLAGS = $(strip $(shell $(PKGCONFIG) --cflags sqlite3))
+
+# Write the configure file
+all: configure
+configure $(CONFIGURE): Configure.mk
+ @echo "\
+ CONFIGURED = 1 \\\
+ UNAME = $(UNAME) \\\
+ LIBDIVECOMPUTERDIR = $(LIBDIVECOMPUTERDIR) \\\
+ LIBDIVECOMPUTERCFLAGS = $(LIBDIVECOMPUTERCFLAGS) \\\
+ LIBDIVECOMPUTER = $(LIBDIVECOMPUTER) \\\
+ LIBQT = $(LIBQT) \\\
+ QTCXXFLAGS = $(QTCXXFLAGS) \\\
+ LIBGTK = $(LIBGTK) \\\
+ GTKCFLAGS = $(GTKCFLAGS) \\\
+ LIBGCONF2 = $(LIBGCONF2) \\\
+ GCONF2CFLAGS = $(GCONF2CFLAGS) \\\
+ GTK_MAC_BUNDLER = $(GTK_MAC_BUNDLER) \\\
+ LIBXML2 = $(LIBXML2) \\\
+ LIBXSLT = $(LIBXSLT) \\\
+ XML2CFLAGS = $(XML2CFLAGS) \\\
+ GLIB2CFLAGS = $(GLIB2CFLAGS) \\\
+ XSLCFLAGS = $(XSLCFLAGS) \\\
+ OSMGPSMAPFLAGS = $(OSMGPSMAPFLAGS) \\\
+ LIBOSMGPSMAP = $(LIBOSMGPSMAP) \\\
+ LIBSOUPCFLAGS = $(LIBSOUPCFLAGS) \\\
+ LIBSOUP = $(LIBSOUP) \\\
+ LIBZIP = $(LIBZIP) \\\
+ ZIPFLAGS = $(ZIPFLAGS) \\\
+ LIBSQLITE3 = $(LIBSQLITE3) \\\
+ SQLITE3FLAGS = $(SQLITE3FLAGS) \\\
+ " | sed 's,\\,\n,g' > $(CONFIGFILE)
+
+else
+configure $(CONFIGFILE): Configure.mk
+ @test -e $(CONFIGFILE) && echo Reconfiguring.. || echo Configuring...
+ @$(MAKE) CONFIGURING=1 configure
+ @echo Done
+
+-include $(CONFIGFILE)
+endif
+
+.PHONY: configure all
diff --git a/Rules.mk b/Rules.mk
index 59e73e1..5374e06 100644
--- a/Rules.mk
+++ b/Rules.mk
@@ -197,4 +197,7 @@ clean:
$(VERSION_FILE) qt-ui/*.moc qt-ui/ui_*.h
rm -rf share .dep
+confclean: clean
+ rm -f $(CONFIGFILE)
+
-include $(DEPS)
--
1.7.11.7
More information about the subsurface
mailing list