]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Makefile/version: use version/date from .git if possible.
authorNeilBrown <neilb@suse.de>
Tue, 25 Jun 2013 06:27:05 +0000 (16:27 +1000)
committerNeilBrown <neilb@suse.de>
Tue, 25 Jun 2013 06:27:05 +0000 (16:27 +1000)
If being built from a git tree, use the version and date
information from the top commit rather than the hard-coded
values.

Signed-off-by: NeilBrown <neilb@suse.de>
Makefile
ReadMe.c
makedist

index 043bcea7d00305df1918a204d0491438c2267a50..76dce90876845d6a0bf86b72641dcc7d9b02e3de 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -80,6 +80,12 @@ DIRFLAGS += -DMDMON_DIR=\"$(MDMON_DIR)\"
 DIRFLAGS += -DFAILED_SLOTS_DIR=\"$(FAILED_SLOTS_DIR)\"
 CFLAGS = $(CWFLAGS) $(CXFLAGS) -DSendmail=\""$(MAILCMD)"\" $(CONFFILEFLAGS) $(DIRFLAGS)
 
+VERSION = $(shell [ -d .git ] && git describe HEAD | sed 's/mdadm-//')
+VERS_DATE = $(shell [ -d .git ] && date --date="`git log -n1 --format=format:%cd --date=short`" '+%0dth %B %Y' | sed -e 's/1th/1st/' -e 's/2th/2nd/' -e 's/11st/11th/' -e 's/12nd/12th/')
+DVERS = $(if $(VERSION),-DVERSION=\"$(VERSION)\",)
+DDATE = $(if $(VERS_DATE),-DVERS_DATE="\"$(VERS_DATE)\"",)
+CFLAGS += $(DVERS) $(DDATE)
+
 # The glibc TLS ABI requires applications that call clone(2) to set up
 # TLS data structures, use pthreads until mdmon implements this support
 USE_PTHREADS = 1
index cb0678ab97f8cec9af7d852a8b06252830d5c565..51a6482a1bee9e70d3cc867bacb1bd1360735736 100644 (file)
--- a/ReadMe.c
+++ b/ReadMe.c
 
 #include "mdadm.h"
 
-char Version[] = Name " - v3.2.5 - 18th May 2012\n";
+#ifndef VERSION
+#define VERSION "3.2.5"
+#endif
+#ifndef VERS_DATE
+#define VERS_DATE "18th May 2012"
+#endif
+char Version[] = Name " - v" VERSION " - " VERS_DATE "\n";
 
 /*
  * File: ReadMe.c
index 6b61eb97d34382a6452fefccd82ca8676cff84ba..2f639d8dd7424f68128f68f7eeb16050168d9ca8 100755 (executable)
--- a/makedist
+++ b/makedist
@@ -14,8 +14,8 @@ then :
 else echo $target is not a directory
      exit 2
 fi
-set `grep '^char Version' ReadMe.c `
-version=`echo $7 | sed 's/v//'`
+set `grep '^#define VERSION' ReadMe.c `
+version=`echo $7 | sed -e 's/"//g'`
 grep "^.TH MDADM 8 .. v$version" mdadm.8.in > /dev/null 2>&1 ||
  {
    echo mdadm.8.in does not mention version $version.