build: refresh the git description whenever something is recompiled

This fixes https://savannah.gnu.org/bugs/?47962 reported by Cody Taylor.
master
Benno Schulenberg 2016-05-20 12:59:57 +02:00
parent 6fda7a7057
commit 2ae490cd8f
5 changed files with 29 additions and 11 deletions

View File

@ -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

View File

@ -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 \

View File

@ -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

View File

@ -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 */

View File

@ -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. */