]> git.lyx.org Git - lyx.git/commitdiff
Autotools: read git commit hash at compile time
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 24 Nov 2014 17:39:18 +0000 (18:39 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 24 Nov 2014 21:00:21 +0000 (22:00 +0100)
Also do as cmake to avoid full recompilation when the hash changes.

config/lyxinclude.m4
configure.ac
src/Makefile.am
src/lyx_commit_hash.h.in [new file with mode: 0644]
src/version.cpp

index 6b8d7a5e184d22bbc635f61818fa7ee3c54fd345..95cb1f09aad3db6084b73431928fb12d8a112588 100644 (file)
@@ -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
index e05681c49d3ffb7e960d7cec18c3eff1f20bd152..3b29b38257c663413ab2e8a0ef63ca2b2c697be9 100644 (file)
@@ -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])
index dccf8d1de083877763b5b49cf5338b2bb030057e..373c0b074ca47044e1252adb6aee211a22932e60 100644 (file)
@@ -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 (file)
index 0000000..26ae73b
--- /dev/null
@@ -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
+
index 9b21d42a6bf56d142a8044058a2abd555582c1b9..6701accdf95180878a3cf816eb1e545d6229449b 100644 (file)
  */
 
 #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
 
 ///