From: Bastian M. <bma...@we...> - 2017-12-25 23:23:25
|
Forgot to reply to the list. > > On Monday, 25 December 2017 22:08:24 Bastian Märkisch wrote: > > > > Building from git tip fails to insert a valid date into > > > > the "last modified" field. This used to be pulled from the > > > > top of ChangeLog and inserted into timestamp.h but that > > > > mechanism does not track the date of git commits. > > > > > > That might do the trick: > > > git log -1 --format=%ci | cut -b-10 > > > > > > Bastian > > > > That looks promising. > > Can someone wrap that in the appropriate Makefile syntax to > > substitute for the rule currently in src/Makefile.am? > > > > timestamp.h: $(top_srcdir)/ChangeLog Makefile > > @echo Making $@ > > @echo "#ifndef GNUPLOT_TIMEBASE_H_INCLUDED" >$@t > > @echo "#define GNUPLOT_TIMEBASE_H_INCLUDED" >>$@t > > @head -1 $< | sed -e 's,\(^[0-9-]* \).*$$,const char gnuplot_date[] = "\1";,' >>$@t > > @echo "#endif /* GNUPLOT_TIMEBASE_H_INCLUDED */" >> $@t > > @if cmp -s $@ $@t; then rm -f $@t; else mv $@t $@; fi > > > > > > > > I suppose the dependency rule would become something like > > > > timestamp.h: $(top_srcdir)/.git/objects Makefile > > > > but how does one get "make" to track the change status of .git/objects ? > > > > Ethan > > > Pleae find below my attempt on a solution. Note that the dependency > "trick" is taken from > http://www.howtobuildsoftware.com/index.php/how-do/ceio/git-makefile-hook-track-branch-changes-from-a-makefile > > Bastian > > diff --git a/src/Makefile.am b/src/Makefile.am > index 0af79fe..9c57550 100644 > --- a/src/Makefile.am > +++ b/src/Makefile.am > @@ -105,11 +105,12 @@ endif > > DISTCLEANFILES = timestamp.h > BUILT_SOURCES = timestamp.h > -timestamp.h: $(top_srcdir)/ChangeLog Makefile > +git_current := $(shell cut -c6- $(top_srcdir)/.git/HEAD) > +timestamp.h: $(top_srcdir)/.git/${git_current} Makefile > @echo Making $@ > @echo "#ifndef GNUPLOT_TIMEBASE_H_INCLUDED" >$@t > @echo "#define GNUPLOT_TIMEBASE_H_INCLUDED" >>$@t > - @head -1 $< | sed -e 's,\(^[0-9-]* \).*$$,const char gnuplot_date[] = "\1";,' >>$@t > + @echo "const char gnuplot_date[] = \"`git log -1 --format=%ci | cut -b-11`\";" >>$@t > @echo "#endif /* GNUPLOT_TIMEBASE_H_INCLUDED */" >> $@t > @if cmp -s $@ $@t; then rm -f $@t; else mv $@t $@; fi > |