commit 0b09424017866d0f1d9dfff8cb54cedaf17b99aa
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Mon Nov 24 18:39:18 2014 +0100
Autotools: read git commit hash at compile time
Also do as cmake to avoid full recompilation when the hash changes.
diff --git a/config/lyxinclude.m4 b/config/lyxinclude.m4
index 6b8d7a5..95cb1f0 100644
--- a/config/lyxinclude.m4
+++ b/config/lyxinclude.m4
@@ -39,16 +39,6 @@ esac
AC_SUBST(lyx_devel_version)
])
-dnl If LyX is compiled from a git clone, find the HEAD commit hash
-dnl
-dnl
-AC_DEFUN([LYX_CHECK_GIT_COMMIT], [
-AC_MSG_CHECKING([for git commit hash])
-lyxgitcommit=`cd "$srcdir" && git log -1 --pretty=format:%H 2>/dev/null ||
true`
-test x$lyxgitcommit = x && lyxgitcommit="none"
-AC_MSG_RESULT($lyxgitcommit)
-])
-
dnl Define the option to set a LyX version on installed executables and
directories
dnl
diff --git a/configure.ac b/configure.ac
index e05681c..3b29b38 100644
--- a/configure.ac
+++ b/configure.ac
@@ -35,8 +35,6 @@ AM_INIT_AUTOMAKE([foreign dist-bzip2 no-define 1.8]
LYX_OBJECTS_LAYOUT)
m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
PACKAGE=$save_PACKAGE
-LYX_CHECK_GIT_COMMIT
-
# Allow to build some parts of the code as one big chunk
m4_define([ALLPARTS],[boost,client,insets,mathed,core,tex2lyx,frontend_qt])
AC_ARG_ENABLE(monolithic-build,
@@ -327,7 +325,6 @@ AC_DEFINE_UNQUOTED([PROGRAM_SUFFIX],
"${version_suffix}",[Program version suffix])
AC_DEFINE_UNQUOTED([LYX_DATE],"$LYX_DATE",[Date of release])
-AC_DEFINE_UNQUOTED([LYX_GIT_COMMIT_HASH], "$lyxgitcommit", [Git commit])
AC_DEFINE_UNQUOTED([VERSION_INFO],"$VERSION_INFO",[Full version info])
AC_DEFINE_UNQUOTED([LYX_DIR_VER],"$lyx_dir_ver",[Versioned env var for system
dir])
AC_DEFINE_UNQUOTED([LYX_USERDIR_VER],"$lyx_userdir_ver",[Versioned env var for
user dir])
diff --git a/src/Makefile.am b/src/Makefile.am
index dccf8d1..373c0b0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -11,7 +11,8 @@ endif
SUBDIRS = support frontends . $(CLIENT) tex2lyx
-EXTRA_DIST = pch.h \
+EXTRA_DIST = lyx_commit_hash.h.in \
+ pch.h \
CMakeLists.txt \
graphics/CMakeLists.txt \
insets/CMakeLists.txt \
@@ -302,6 +303,13 @@ HEADERFILESCORE = \
STANDALONEFILES = \
Layout.cpp
+.PHONY: lyx_commit_hash.h
+
+lyx_commit_hash.h:
+ $(AM_V_GEN)hash=`cd "$(top_srcdir)" && git log -1 --pretty=format:%H
2>/dev/null || echo none` ; \
+ sed s/@LYX_GIT_COMMIT_HASH@/$$hash/ "$(srcdir)"/lyx_commit_hash.h.in
>$@
+BUILT_SOURCES += lyx_commit_hash.h
+CLEANFILES += lyx_commit_hash.h
lyxcore.cpp:
@echo -e '$(SOURCEFILESCORE:%=\n#include "%")\n' > $@
@@ -336,7 +344,7 @@ BUILT_SOURCES += $(MOCEDFILES)
CLEANFILES += $(MOCEDFILES)
moc_%.cpp: %.h
- $(QT_MOC) $(MOCFLAG) -o $@ $<
+ $(AM_V_GEN)$(QT_MOC) $(MOCFLAG) -o $@ $<
liblyxcore_a_DEPENDENCIES = $(MOCEDFILES)
diff --git a/src/lyx_commit_hash.h.in b/src/lyx_commit_hash.h.in
new file mode 100644
index 0000000..26ae73b
--- /dev/null
+++ b/src/lyx_commit_hash.h.in
@@ -0,0 +1,16 @@
+/*
+ * \file lyx_commit_hash.h
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
+ *
+ * If LyX is compiled from a git clone, this should contain the HEAD
+ * commit hash.
+ */
+
+#ifndef _LYX_COMMIT_HASH_H
+#define _LYX_COMMIT_HASH_H
+
+#define LYX_GIT_COMMIT_HASH "@LYX_GIT_COMMIT_HASH@"
+
+#endif
+
diff --git a/src/version.cpp b/src/version.cpp
index 9b21d42..6701acc 100644
--- a/src/version.cpp
+++ b/src/version.cpp
@@ -10,11 +10,13 @@
*/
#include <config.h>
+
#if ! defined(LYX_DATE)
- #include <lyx_date.h>
+#include "lyx_date.h"
#endif
+
#if ! defined(LYX_GIT_COMMIT_HASH)
- #include <lyx_commit_hash.h>
+#include "lyx_commit_hash.h"
#endif
///