commit 2ae490cd8f106fe0e6e9078d6697878954167015
parent 6fda7a705700db7b356e9c4636a9754e9952fde8
Author: Benno Schulenberg <bensberg@justemail.net>
Date: Fri, 20 May 2016 12:59:57 +0200
build: refresh the git description whenever something is recompiled
This fixes https://savannah.gnu.org/bugs/?47962 reported by Cody Taylor.
Diffstat:
5 files changed, 29 insertions(+), 11 deletions(-)
diff --git a/configure.ac b/configure.ac
@@ -708,16 +708,16 @@ AM_CONDITIONAL(GROFF_HTML, test x$groff_html_support = xyes)
AC_CHECK_PROG(haveit, makeinfo, yes, no)
AM_CONDITIONAL(HAVE_MAKEINFO, test x$haveit = xyes)
+# Check whether this is a git repository.
AC_MSG_CHECKING([whether building from git])
if test -d .git ; then
AC_MSG_RESULT([yes])
- AC_PATH_PROG([GIT], [git])
- REVISION=`($GIT rev-parse --is-inside-work-tree >/dev/null 2>&1) && ($GIT rev-parse --short HEAD)`
- AC_SUBST(REVISION)
- AC_DEFINE_UNQUOTED([REVISION],"${REVISION}","Setting REVISION in config.h.")
+ from_git=yes
else
AC_MSG_RESULT([no])
+ from_git=no
fi
+AM_CONDITIONAL(BUILDING_FROM_GIT, test x$from_git = xyes)
AC_CONFIG_FILES([
Makefile
diff --git a/src/Makefile.am b/src/Makefile.am
@@ -1,5 +1,21 @@
AM_CPPFLAGS = -DLOCALEDIR=\"$(localedir)\" -DSYSCONFDIR=\"$(sysconfdir)\"
+if BUILDING_FROM_GIT
+SOMETHING = "REVISION \"$(shell git describe --tags 2>/dev/null)\""
+else
+SOMETHING = "NOTHING \"from tarball\""
+endif
+
+nano.o: revision.h
+winio.o: revision.h
+
+revision.h: update_revision
+ @[ -f $@ ] || touch $@
+ @echo "#define $(SOMETHING)" | cmp -s $@ - || \
+ echo "#define $(SOMETHING)" > $@
+
+.PHONY: update_revision
+
bin_PROGRAMS = nano
nano_SOURCES = browser.c \
chars.c \
diff --git a/src/nano.c b/src/nano.c
@@ -21,6 +21,7 @@
**************************************************************************/
#include "proto.h"
+#include "revision.h"
#include <stdio.h>
#include <stdarg.h>
@@ -918,7 +919,7 @@ void usage(void)
void version(void)
{
#ifdef REVISION
- printf(" nano from git, commit %s (after %s)\n", REVISION, VERSION);
+ printf(" nano from git, %s\n", REVISION);
#else
printf(_(" nano, version %s\n"), VERSION);
#endif
diff --git a/src/nano.h b/src/nano.h
@@ -604,10 +604,4 @@ enum
/* The largest size_t number that doesn't have the high bit set. */
#define HIGHEST_POSITIVE ((~(size_t)0) >> 1)
-#ifdef REVISION
-#define BRANDING PACKAGE_VERSION"-git "REVISION
-#else
-#define BRANDING PACKAGE_STRING
-#endif
-
#endif /* !NANO_H */
diff --git a/src/winio.c b/src/winio.c
@@ -21,6 +21,7 @@
**************************************************************************/
#include "proto.h"
+#include "revision.h"
#include <stdio.h>
#include <stdarg.h>
@@ -28,6 +29,12 @@
#include <unistd.h>
#include <ctype.h>
+#ifdef REVISION
+#define BRANDING REVISION
+#else
+#define BRANDING PACKAGE_STRING
+#endif
+
static int *key_buffer = NULL;
/* The keystroke buffer, containing all the keystrokes we
* haven't handled yet at a given point. */