From 6d3b3bfdb54d4bf497ab7928a9192bba5ca7bca5 Mon Sep 17 00:00:00 2001
From: Matthieu Schaller <matthieu.schaller@durham.ac.uk>
Date: Wed, 27 Apr 2016 16:08:20 +0100
Subject: [PATCH] Faster compilation

---
 .gitignore                      |  2 +-
 src/Makefile.am                 | 20 ++++++++++----------
 src/version.c                   |  3 +++
 src/{version.h.in => version.h} | 21 ++++++---------------
 src/version_string.h.in         | 32 ++++++++++++++++++++++++++++++++
 5 files changed, 52 insertions(+), 26 deletions(-)
 rename src/{version.h.in => version.h} (82%)
 create mode 100644 src/version_string.h.in

diff --git a/.gitignore b/.gitignore
index 277a14d0ce..92a1648315 100644
--- a/.gitignore
+++ b/.gitignore
@@ -11,7 +11,7 @@ config.sub
 ltmain.sh
 libtool
 
-src/version.h
+src/version_string.h
 swift*.tar.gz
 doc/doxyfile.stamp
 doc/html/
diff --git a/src/Makefile.am b/src/Makefile.am
index 65f093b014..57ca1e5974 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -36,7 +36,7 @@ endif
 include_HEADERS = space.h runner.h queue.h task.h lock.h cell.h part.h const.h \
     engine.h swift.h serial_io.h timers.h debug.h scheduler.h proxy.h parallel_io.h \
     common_io.h single_io.h multipole.h map.h tools.h partition.h clocks.h parser.h \
-    physical_constants.h physical_constants_cgs.h potentials.h
+    physical_constants.h physical_constants_cgs.h potentials.h version.h
 
 # Common source files
 AM_SOURCES = space.c runner.c queue.c task.c cell.c engine.c \
@@ -72,27 +72,27 @@ libswiftsim_mpi_la_CFLAGS = $(AM_CFLAGS) -DWITH_MPI $(METIS_INCS)
 libswiftsim_mpi_la_SHORTNAME = mpi
 
 
-# Versioning. If any sources change then update the version.h file with
+# Versioning. If any sources change then update the version_string.h file with
 # the current git revision and package version.
-# May have a checkout without a version.h file and no git command (tar/zip
+# May have a checkout without a version_string.h file and no git command (tar/zip
 # download), allow that, but make sure we know it.
-version.h: version.h.in $(AM_SOURCES) $(include_HEADERS) $(noinst_HEADERS)
+version_string.h: version_string.h.in $(AM_SOURCES) $(include_HEADERS) $(noinst_HEADERS)
 	if test "X$(GIT_CMD)" != "X"; then \
 	    GIT_REVISION=`$(GIT_CMD) describe --abbrev=8  --always --tags --dirty`; \
 	    GIT_BRANCH=`$(GIT_CMD) branch | sed -n 's/^\* \(.*\)/\1/p'`; \
 	    sed -e "s,@PACKAGE_VERSION\@,$(PACKAGE_VERSION)," \
 	        -e "s,@GIT_REVISION\@,$${GIT_REVISION}," \
-	        -e "s|@GIT_BRANCH\@|$${GIT_BRANCH}|" version.h.in > version.h; \
+	        -e "s|@GIT_BRANCH\@|$${GIT_BRANCH}|" version_string.h.in > version_string.h; \
 	else \
-	    if test ! -f version.h; then \
+	    if test ! -f version_string.h; then \
 	        sed -e "s,@PACKAGE_VERSION\@,$(PACKAGE_VERSION)," \
 	            -e "s,@GIT_REVISION\@,unknown," \
-		    -e "s,@GIT_BRANCH\@,unknown," version.h.in > version.h; \
+		    -e "s,@GIT_BRANCH\@,unknown," version_string.h.in > version_string.h; \
 	    fi; \
 	fi
 
-#  Make sure version.h is built first.
-BUILT_SOURCES = version.h
+#  Make sure version_string.h is built first.
+BUILT_SOURCES = version_string.h
 
 #  And distribute the built files.
-EXTRA_DIST = version.h version.h.in
+EXTRA_DIST = version_string.h version_string.h.in
diff --git a/src/version.c b/src/version.c
index 27841a1601..ab22c0d9ab 100644
--- a/src/version.c
+++ b/src/version.c
@@ -40,6 +40,9 @@
 /* This object's header. */
 #include "version.h"
 
+/* Local headers. */
+#include "version_string.h"
+
 /**
  * @brief Return the source code git revision
  *
diff --git a/src/version.h.in b/src/version.h
similarity index 82%
rename from src/version.h.in
rename to src/version.h
index 7824e06b99..4b6b38d220 100644
--- a/src/version.h.in
+++ b/src/version.h
@@ -2,33 +2,24 @@
  * This file is part of SWIFT.
  * Copyright (c) 2012 Matthieu Schaller (matthieu.schaller@durham.ac.uk).
  * Copyright (c) 2015 Peter W. Draper (p.w.draper@durham.ac.uk).
- * 
+ *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU Lesser General Public License as published
  * by the Free Software Foundation, either version 3 of the License, or
  * (at your option) any later version.
- * 
+ *
  * This program is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  * GNU General Public License for more details.
- * 
+ *
  * You should have received a copy of the GNU Lesser General Public License
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
- * 
+ *
  ******************************************************************************/
 #ifndef SWIFT_VERSION_H
 #define SWIFT_VERSION_H
 
-/**
- * @file version.h
- * @brief Package version, git revision sha and compiler info.
- */
-
-#define PACKAGE_VERSION "@PACKAGE_VERSION@"
-#define GIT_REVISION "@GIT_REVISION@"
-#define GIT_BRANCH "@GIT_BRANCH@"
-
 const char* package_description(void);
 const char* package_version(void);
 const char* git_revision(void);
@@ -36,8 +27,8 @@ const char* git_branch(void);
 const char* compiler_name(void);
 const char* compiler_version(void);
 const char* mpi_version(void);
-const char *hdf5_version(void);
-const char *metis_version(void);
+const char* hdf5_version(void);
+const char* metis_version(void);
 void greetings(void);
 
 #endif /* SWIFT_VERSION_H */
diff --git a/src/version_string.h.in b/src/version_string.h.in
new file mode 100644
index 0000000000..e4d62c7778
--- /dev/null
+++ b/src/version_string.h.in
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * This file is part of SWIFT.
+ * Copyright (c) 2012 Matthieu Schaller (matthieu.schaller@durham.ac.uk).
+ * Copyright (c) 2015 Peter W. Draper (p.w.draper@durham.ac.uk).
+ * 
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ * 
+ ******************************************************************************/
+#ifndef SWIFT_VERSION_STRING_H
+#define SWIFT_VERSION_STRING_H
+
+/**
+ * @file version_string.h
+ * @brief Package version, git revision sha and compiler info.
+ */
+
+#define PACKAGE_VERSION "@PACKAGE_VERSION@"
+#define GIT_REVISION "@GIT_REVISION@"
+#define GIT_BRANCH "@GIT_BRANCH@"
+
+#endif /* SWIFT_VERSION_STRING_H */
-- 
GitLab