From 6e4f8128fe078a3e54f5c92d27c31acc7b8f9fd8 Mon Sep 17 00:00:00 2001 From: Philipp Takacs Date: Sun, 4 Sep 2016 14:12:00 +0200 Subject: [PATCH] redesign version string Now we have two version nummbers one for the tool and one for the lib. Also the version number is changed everytime the object is rebuild. --- Makefile.in | 6 +++--- VERSION | 2 +- config/Makefile.in | 9 +-------- config/version.sh | 18 ------------------ h/mh.h | 4 ++-- man/Makefile.in | 5 +++-- sbr/Makefile.in | 12 ++++++++---- sbr/print_version.c | 5 ++++- sbr/version.c | 3 +++ uip/Makefile.in | 4 +++- uip/ali.c | 2 ++ uip/anno.c | 2 ++ uip/ap.c | 2 ++ uip/burst.c | 2 ++ uip/comp.c | 1 + uip/dist.c | 1 + uip/dp.c | 2 ++ uip/flist.c | 2 ++ uip/fmtdump.c | 2 ++ uip/folder.c | 2 ++ uip/forw.c | 2 ++ uip/inc.c | 2 ++ uip/mark.c | 2 ++ uip/mhbuild.c | 1 + uip/mhl.c | 2 ++ uip/mhlist.c | 1 + uip/mhmail.c | 2 ++ uip/mhparam.c | 6 ++++-- uip/mhpath.c | 2 ++ uip/mhshow.c | 1 + uip/mhstore.c | 1 + uip/mhtest.c | 1 + uip/new.c | 2 ++ uip/packf.c | 1 + uip/pick.c | 2 ++ uip/prompter.c | 1 + uip/rcvdist.c | 2 ++ uip/rcvpack.c | 1 + uip/rcvstore.c | 1 + uip/refile.c | 2 ++ uip/repl.c | 2 ++ uip/rmf.c | 2 ++ uip/rmm.c | 1 + uip/scan.c | 1 + uip/send.c | 1 + uip/slocal.c | 1 + uip/sortm.c | 2 ++ uip/spost.c | 1 + uip/whatnow.c | 2 ++ uip/whom.c | 1 + version.sh | 33 +++++++++++++++++++++++++++++++++ 51 files changed, 126 insertions(+), 42 deletions(-) delete mode 100755 config/version.sh create mode 100644 sbr/version.c create mode 100755 version.sh diff --git a/Makefile.in b/Makefile.in index f93359d..465beda 100644 --- a/Makefile.in +++ b/Makefile.in @@ -2,15 +2,15 @@ # Makefile for top level of mmh distribution # -# mmh version -VERSION = @VERSION@ - SHELL = /bin/sh @SET_MAKE@ srcdir = @srcdir@ VPATH = @srcdir@ +# mmh version +VERSION = `sed q $(srcdir)/VERSION` + # ========== USER CONFIGURATION SECTION ========== # # If `make' is executed in the directory containing this Makefile, diff --git a/VERSION b/VERSION index 52c4325..be58634 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.3+dev +0.3 diff --git a/config/Makefile.in b/config/Makefile.in index 47f9125..16af151 100644 --- a/config/Makefile.in +++ b/config/Makefile.in @@ -2,9 +2,6 @@ # Makefile for config subdirectory # -# nmh version -VERSION = @VERSION@ - SHELL = /bin/sh top_srcdir = @top_srcdir@ @@ -42,15 +39,12 @@ COMPILE2 = $(CC) -c $(DEFS) $(CONFIGDEFS) $(INCLUDES) $(CFLAGS) SRCS = config.c # object files -OBJS = config.o version.o +OBJS = config.o # ========= DEPENDENCIES FOR BUILDING ========== all: $(OBJS) -version.c: - ${srcdir}/version.sh $(VERSION) > version.c - config.o: config.c $(COMPILE2) $(srcdir)/config.c @@ -66,7 +60,6 @@ mostlyclean: rm -f *.o *~ clean: mostlyclean - rm -f version.c distclean: clean rm -f Makefile diff --git a/config/version.sh b/config/version.sh deleted file mode 100755 index 6396306..0000000 --- a/config/version.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh -# -# version.sh -- script to create version string(s) for mmh. -# -# You need to pass the script the version number to use. -# - -if [ -z "$1" ]; then - echo "usage: version.sh VERSION" 1>&2 - exit 1 -fi - -VERSION=$1 - -git_info="$(git show --pretty'=format: [%h -- %cD]' HEAD | head -n1)" - -echo "char *version_str = \"mmh-${VERSION}${git_info}\";" -echo "char *version_num = \"mmh-$VERSION\";" diff --git a/h/mh.h b/h/mh.h index e1795ca..53b301e 100644 --- a/h/mh.h +++ b/h/mh.h @@ -304,8 +304,8 @@ extern char *seq_unseen; extern char *seq_neg; extern char *trashfolder; extern char *usequence; -extern char *version_num; -extern char *version_str; +extern char *version; +extern char *lib_version; extern char *whatnowproc; #include diff --git a/man/Makefile.in b/man/Makefile.in index abfcd41..49b2600 100644 --- a/man/Makefile.in +++ b/man/Makefile.in @@ -2,7 +2,6 @@ # Makefile for man subdirectory # -VERSION = @VERSION@ DATE = @DATE@ SHELL = /bin/sh @@ -11,6 +10,8 @@ top_srcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = @srcdir@ +VERSION = `$(top_srcdir)/version.sh $(top_srcdir)` + prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ @@ -87,7 +88,7 @@ $(MAN1) $(MAN5) $(MAN7) $(MAN8): man.sed # create the sed file for building man pages man.sed: Makefile titles @echo 's,%nmhwarning%,THIS FILE HAS BEEN AUTOMATICALLY GENERATED. DO NOT EDIT.,g' > $@ - @echo 's,%nmhversion%,mmh-$(VERSION),g' >> $@ + @echo 's,%nmhversion%,'$(VERSION)',g' >> $@ @echo 's,%nmhdate%,$(DATE),g' >> $@ @echo 's,%bindir%,$(bindir),g' >> $@ @echo 's,%etcdir%,$(etcdir),g' >> $@ diff --git a/sbr/Makefile.in b/sbr/Makefile.in index f60bd9a..a9fa2d4 100644 --- a/sbr/Makefile.in +++ b/sbr/Makefile.in @@ -8,6 +8,8 @@ top_srcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = @srcdir@ +VERSION = `$(top_srcdir)/version.sh $(top_srcdir)` + prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ @@ -33,7 +35,7 @@ LINTFLAGS = @LINTFLAGS@ COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CFLAGS) -LOCALLIBS = ../config/version.o ../config/config.o +LOCALLIBS = ../config/config.o .SUFFIXES: .SUFFIXES: .c .o @@ -94,14 +96,16 @@ dtimep.c: dtimep.lex pidstatus.o: sigmsg.h -libmh.a: $(OBJS) $(LOCALLIBS) +libmh.a: $(OBJS) $(LOCALLIBS) version.c rm -f $@ + $(COMPILE) -DVERSION="\"$(VERSION)\"" -o version.o $(srcdir)/version.c if test x$(LIBTOOL) != x -a x$(GNU_LIBTOOL) = x ; then \ - $(LIBTOOL) -static -c -o libmh.a $(OBJS) $(LOCALLIBS) ; \ + $(LIBTOOL) -static -c -o libmh.a $(OBJS) $(LOCALLIBS) version.o; \ else \ - ar cr libmh.a `$(LORDER) $(OBJS) $(LOCALLIBS) | $(TSORT) 2>/dev/null` ; \ + ar cr libmh.a `$(LORDER) $(OBJS) $(LOCALLIBS) version.o | $(TSORT) 2>/dev/null` ; \ $(RANLIB) libmh.a ; \ fi + rm -f version.o install: diff --git a/sbr/print_version.c b/sbr/print_version.c index 8361c66..7223390 100644 --- a/sbr/print_version.c +++ b/sbr/print_version.c @@ -12,5 +12,8 @@ void print_version(char *invo_name) { - printf("%s -- %s\n", invo_name, version_str); + printf("%s -- %s\n", invo_name, version); + if (strcmp(version, lib_version)!=0) { + printf("libversion: %s\n", lib_version); + } } diff --git a/sbr/version.c b/sbr/version.c new file mode 100644 index 0000000..42917c5 --- /dev/null +++ b/sbr/version.c @@ -0,0 +1,3 @@ +#include + +char *lib_version = VERSION; diff --git a/uip/Makefile.in b/uip/Makefile.in index d7cad06..e7e7b46 100644 --- a/uip/Makefile.in +++ b/uip/Makefile.in @@ -8,6 +8,8 @@ top_srcdir = @top_srcdir@ srcdir = @srcdir@ VPATH = @srcdir@ +VERSION = `$(top_srcdir)/version.sh $(top_srcdir)` + prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ @@ -31,7 +33,7 @@ LINTFLAGS = @LINTFLAGS@ TERMLIB = @TERMLIB@ LEXLIB = @LEXLIB@ -COMPILE = $(CC) -c $(DEFS) $(INCLUDES) $(CFLAGS) +COMPILE = $(CC) -c $(DEFS) -DVERSION="\"$(VERSION)\"" $(INCLUDES) $(CFLAGS) LINK = $(CC) $(LDFLAGS) -o $@ LN = ln diff --git a/uip/ali.c b/uip/ali.c index 9ab6515..d4c6c7f 100644 --- a/uip/ali.c +++ b/uip/ali.c @@ -40,6 +40,8 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; + static int pos = 1; extern struct aka *akahead; diff --git a/uip/anno.c b/uip/anno.c index 9e287be..33d2b49 100644 --- a/uip/anno.c +++ b/uip/anno.c @@ -53,6 +53,8 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; + /* ** static prototypes */ diff --git a/uip/ap.c b/uip/ap.c index 9d35601..41eae6a 100644 --- a/uip/ap.c +++ b/uip/ap.c @@ -31,6 +31,8 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; + static struct format *fmt; static int dat[5]; diff --git a/uip/burst.c b/uip/burst.c index a68420a..12d1f9d 100644 --- a/uip/burst.c +++ b/uip/burst.c @@ -25,6 +25,8 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; + static char delim3[] = "-------"; struct smsg { diff --git a/uip/comp.c b/uip/comp.c index c34ce43..75bbf86 100644 --- a/uip/comp.c +++ b/uip/comp.c @@ -31,6 +31,7 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; int main(int argc, char **argv) diff --git a/uip/dist.c b/uip/dist.c index d74e498..1d5c3aa 100644 --- a/uip/dist.c +++ b/uip/dist.c @@ -31,6 +31,7 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; int main(int argc, char **argv) diff --git a/uip/dp.c b/uip/dp.c index 3a01995..70162b2 100644 --- a/uip/dp.c +++ b/uip/dp.c @@ -26,6 +26,8 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; + static struct format *fmt; static int dat[5]; diff --git a/uip/flist.c b/uip/flist.c index 63fcb0f..73ad5f2 100644 --- a/uip/flist.c +++ b/uip/flist.c @@ -60,6 +60,8 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; + struct Folder { char *name; /* name of folder */ int priority; diff --git a/uip/fmtdump.c b/uip/fmtdump.c index d75849b..419d8ee 100644 --- a/uip/fmtdump.c +++ b/uip/fmtdump.c @@ -23,6 +23,8 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; + /* for assignlabel */ static struct format *lvec[128]; static int lused = 0; diff --git a/uip/folder.c b/uip/folder.c index 3e3cd76..b7cdfe5 100644 --- a/uip/folder.c +++ b/uip/folder.c @@ -64,6 +64,8 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; + static int fshort = 0; /* output only folder names */ static int fcreat = 0; /* should we ask to create new folders? */ static int fpack = 0; /* are we packing the folder? */ diff --git a/uip/forw.c b/uip/forw.c index d8d69f7..e00ae0e 100644 --- a/uip/forw.c +++ b/uip/forw.c @@ -44,6 +44,8 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; + static char drft[BUFSIZ]; static struct msgs *mp = NULL; diff --git a/uip/inc.c b/uip/inc.c index 08aa533..e31c6a6 100644 --- a/uip/inc.c +++ b/uip/inc.c @@ -74,6 +74,8 @@ static struct swit switches[] = { { NULL, 0 }, }; +char *version=VERSION; + /* ** This is an attempt to simplify things by putting all the ** privilege ops into macros. diff --git a/uip/mark.c b/uip/mark.c index 1e57d1c..72b6d8e 100644 --- a/uip/mark.c +++ b/uip/mark.c @@ -40,6 +40,8 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; + /* ** static prototypes */ diff --git a/uip/mhbuild.c b/uip/mhbuild.c index 6ed6037..a233c68 100644 --- a/uip/mhbuild.c +++ b/uip/mhbuild.c @@ -45,6 +45,7 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; /* ** Directory to place tmp files. This must diff --git a/uip/mhl.c b/uip/mhl.c index c089d8e..a84703b 100644 --- a/uip/mhl.c +++ b/uip/mhl.c @@ -61,6 +61,8 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; + #define NOCOMPONENT 0x000001 /* don't show component name */ #define UPPERCASE 0x000002 /* display in all upper case */ #define CENTER 0x000004 /* center line */ diff --git a/uip/mhlist.c b/uip/mhlist.c index c9194cc..7056db5 100644 --- a/uip/mhlist.c +++ b/uip/mhlist.c @@ -40,6 +40,7 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; /* mhparse.c */ extern char *tmp; /* directory to place temp files */ diff --git a/uip/mhmail.c b/uip/mhmail.c index 06630b3..4215ecf 100644 --- a/uip/mhmail.c +++ b/uip/mhmail.c @@ -32,6 +32,8 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; + static char tmpfil[BUFSIZ]; /* diff --git a/uip/mhparam.c b/uip/mhparam.c index 29d4170..2c61e60 100644 --- a/uip/mhparam.c +++ b/uip/mhparam.c @@ -28,6 +28,8 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; + struct proc { char *p_name; char **p_field; @@ -41,8 +43,8 @@ char *empty = ""; */ static struct proc procs [] = { { "#--Version--", &empty }, - { "version", &version_num }, - { "version-str", &version_str }, + { "version", &version }, + { "lib-version", &lib_version }, { "#--Path-and-File-Names--", &empty }, { "mypath", &mypath }, diff --git a/uip/mhpath.c b/uip/mhpath.c index 0fe638c..31e0722 100644 --- a/uip/mhpath.c +++ b/uip/mhpath.c @@ -20,6 +20,8 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; + int main(int argc, char **argv) { diff --git a/uip/mhshow.c b/uip/mhshow.c index e39bf65..be9cd45 100644 --- a/uip/mhshow.c +++ b/uip/mhshow.c @@ -42,6 +42,7 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; /* mhparse.c */ extern char *tmp; /* directory to place temp files */ diff --git a/uip/mhstore.c b/uip/mhstore.c index 596df72..47b7c02 100644 --- a/uip/mhstore.c +++ b/uip/mhstore.c @@ -40,6 +40,7 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; /* mhparse.c */ extern char *tmp; /* directory to place temp files */ diff --git a/uip/mhtest.c b/uip/mhtest.c index cecf2ee..d4bf6a6 100644 --- a/uip/mhtest.c +++ b/uip/mhtest.c @@ -42,6 +42,7 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; /* mhparse.c */ extern char *tmp; /* directory to place temp files */ diff --git a/uip/new.c b/uip/new.c index efbea04..9763376 100644 --- a/uip/new.c +++ b/uip/new.c @@ -33,6 +33,8 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; + static enum { NEW, FNEXT, FPREV, UNSEEN } run_mode = NEW; /* diff --git a/uip/packf.c b/uip/packf.c index a8c2c42..fe1102c 100644 --- a/uip/packf.c +++ b/uip/packf.c @@ -23,6 +23,7 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; int main(int argc, char **argv) diff --git a/uip/pick.c b/uip/pick.c index 7d9c086..4cb33fb 100644 --- a/uip/pick.c +++ b/uip/pick.c @@ -70,6 +70,8 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; + /* ** static prototypes */ diff --git a/uip/prompter.c b/uip/prompter.c index ea17b91..7f71e02 100644 --- a/uip/prompter.c +++ b/uip/prompter.c @@ -38,6 +38,7 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; volatile sig_atomic_t wtuser = 0; volatile sig_atomic_t sigint = 0; diff --git a/uip/rcvdist.c b/uip/rcvdist.c index d08058b..af3fc10 100644 --- a/uip/rcvdist.c +++ b/uip/rcvdist.c @@ -26,6 +26,8 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; + static char backup[BUFSIZ] = ""; static char drft[BUFSIZ] = ""; static char tmpfil[BUFSIZ] = ""; diff --git a/uip/rcvpack.c b/uip/rcvpack.c index bd6bacb..b4e37bd 100644 --- a/uip/rcvpack.c +++ b/uip/rcvpack.c @@ -22,6 +22,7 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; int main(int argc, char **argv) diff --git a/uip/rcvstore.c b/uip/rcvstore.c index 83c5150..33f8f3b 100644 --- a/uip/rcvstore.c +++ b/uip/rcvstore.c @@ -43,6 +43,7 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; /* ** name of temporary file to store incoming message diff --git a/uip/refile.c b/uip/refile.c index 182f315..682f66a 100644 --- a/uip/refile.c +++ b/uip/refile.c @@ -31,6 +31,8 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; + static char maildir[BUFSIZ]; struct st_fold { diff --git a/uip/repl.c b/uip/repl.c index 8a40543..b2adebf 100644 --- a/uip/repl.c +++ b/uip/repl.c @@ -60,6 +60,8 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; + static struct swit ccswitches[] = { #define CTOSW 0 { "to", 0 }, diff --git a/uip/rmf.c b/uip/rmf.c index e435a27..273477e 100644 --- a/uip/rmf.c +++ b/uip/rmf.c @@ -25,6 +25,8 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; + /* ** static prototypes */ diff --git a/uip/rmm.c b/uip/rmm.c index 99820e9..5059383 100644 --- a/uip/rmm.c +++ b/uip/rmm.c @@ -24,6 +24,7 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; int main(int argc, char **argv) diff --git a/uip/scan.c b/uip/scan.c index a735b31..018cd9c 100644 --- a/uip/scan.c +++ b/uip/scan.c @@ -30,6 +30,7 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; int main(int argc, char **argv) diff --git a/uip/send.c b/uip/send.c index eac15ae..d7691db 100644 --- a/uip/send.c +++ b/uip/send.c @@ -73,6 +73,7 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; int main(int argc, char **argv) diff --git a/uip/slocal.c b/uip/slocal.c index 9306f94..df0dc7f 100644 --- a/uip/slocal.c +++ b/uip/slocal.c @@ -72,6 +72,7 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; static int globbed = 0; /* have we built "vars" table yet? */ static int parsed = 0; /* have we built header field table yet */ diff --git a/uip/sortm.c b/uip/sortm.c index ff69bc9..c56a401 100644 --- a/uip/sortm.c +++ b/uip/sortm.c @@ -41,6 +41,8 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; + struct smsg { int s_msg; time_t s_clock; diff --git a/uip/spost.c b/uip/spost.c index 505b94c..39d8ada 100644 --- a/uip/spost.c +++ b/uip/spost.c @@ -39,6 +39,7 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; /* flags for headers->flags */ #define HNOP 0x0000 /* just used to keep .set around */ diff --git a/uip/whatnow.c b/uip/whatnow.c index 45671ed..be046ac 100644 --- a/uip/whatnow.c +++ b/uip/whatnow.c @@ -32,6 +32,8 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; + /* ** Options at the "whatnow" prompt */ diff --git a/uip/whom.c b/uip/whom.c index 7486dd8..64ec7c9 100644 --- a/uip/whom.c +++ b/uip/whom.c @@ -37,6 +37,7 @@ static struct swit switches[] = { { NULL, 0 } }; +char *version=VERSION; #define NFILES 32 diff --git a/version.sh b/version.sh new file mode 100755 index 0000000..9c868de --- /dev/null +++ b/version.sh @@ -0,0 +1,33 @@ +#!/bin/sh +# +# version.sh -- script to create version string(s) for mmh. +# +# You can pass the top soucre directory to the script. +# + +if [ -d "$1" ] +then + cd "$1" +fi + +if [ ! -f VERSION ] +then + echo "No version file found" 1>&2 + echo "usage: $0 [mmh-sourcedir]" 1>&2 + exit 1 +fi + +version="`sed q VERSION`" + +git_info="" + +if [ -d ".git" ]; then + current=`git log -n 1 --pretty=format:+%h HEAD` + release=`git log -n 1 --pretty=format:+%h "mmh-$version"` + if [ "$current" != "$release" ] + then + git_info="$current" + fi +fi + +echo mmh-"$version""$git_info" -- 1.7.10.4