[PATCH v3] Support building development version without git

Henri Menke <[email protected]>
Newsgroups gmane.comp.graphics.gnuplot.devel
Message-ID <[email protected]>
Currently building the development version requires git to be installed
to fetch the `last modified' date from the commit information.  This is
okay when building from a git clone, but fails when downloading a
snapshot that does not contain the .git directory.

To this end, I implemented a fallback that uses the last modification
time of the Makefile.am, which corresponds to the last commit date when
using a fresh checkout.  The old version had the advantage that
`timestamp.h' would only be rebuilt when changing the git branch.  If
git is not available, this logic fails of course.  Instead I made
`timestamp.h' a phony target, i.e. it will be rebuilt unconditionally
every time.  The disadvantage here is that this will also trigger a
rebuild of every file that depends on `timestamp.h' but as far as I can
see this is only `version.c'.
---
I've changed the commit format from %cs to %cd which is supported in
older git versions as well.  I'd like to avoid using %ci because this
requires an extra pipe to strip off the unnecessary time of day and
timezone information which makes the code even more ugly and unreadable.

 src/Makefile.am | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 1b0d8136e..0b261ea47 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -107,12 +107,12 @@ endif
 
 DISTCLEANFILES = timestamp.h
 BUILT_SOURCES = timestamp.h
-git_current := $(shell cut -c6- $(top_srcdir)/.git/HEAD)
-timestamp.h: $(top_srcdir)/.git/${git_current} Makefile
+.PHONY: timestamp.h
+timestamp.h: Makefile
 	@echo Making $@
 	@echo "#ifndef GNUPLOT_TIMEBASE_H_INCLUDED" >$@t
 	@echo "#define GNUPLOT_TIMEBASE_H_INCLUDED" >>$@t
-	@echo "const char gnuplot_date[] = \"`git --git-dir '$(top_srcdir)/.git' log -1 --format=%ci | cut -b-11`\";" >>$@t
+	@echo "const char gnuplot_date[] = \"`git --git-dir '$(top_srcdir)/.git' log -1 --date=short --format=%cd || stat -c '%.10y' Makefile.am`\";" >>$@t
 	@echo "#endif /* GNUPLOT_TIMEBASE_H_INCLUDED */" >> $@t
 	@if cmp -s $@ $@t; then rm -f $@t; else mv $@t $@; fi
 
-- 
2.27.0



_______________________________________________
gnuplot-beta mailing list
[email protected]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-beta
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.