From aab02e5a27249b1a35f9a4ccce66219b77785396 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sat, 17 Oct 2020 12:11:47 +0100 Subject: [PATCH 1/8] Use BUILT_SOURCES make mechanism as intended --- tests/Makefile.am | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 65c6b8117..a91cfaa02 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -98,17 +98,18 @@ testloc.sh: echo './testloc EM79UT96LW 5' > testloc.sh chmod +x ./testloc.sh -# If we have a .git directory then we will generate the hamlibdate.h +# If we have a .git directory then we will generate the hamlibdate.h # file. If not, then copy the placeholder. Either way copy the result -# to the build directory for inclusion in compiles, which avoids race -# conditions with parallel builds. -hamlibdatetime.h: FORCE +# to the sources directory if it is different for inclusion in +# distribution tarballs, which avoids race conditions with parallel +# builds. +hamlibdatetime.h: Makefile echo "SHA=$(SHA)" - test ! -x $(top_srcdir)/.git || echo "/* This date time is from the last non-merge commit to Hamlib. */" > $(top_srcdir)/tests/hamlibdatetime.h - test ! -x $(top_srcdir)/.git || echo "#define HAMLIBDATETIME "\"$$(TZ=UTC git --git-dir=$(top_srcdir)/.git log --no-merges --date='format-local:%a %b %d %H:%M:%S %Y %z SHA=' --format='%cd' -n 1)$$(git --git-dir=$(top_srcdir)/.git log --no-merges | grep commit | head -n 1 | cut -c8-13)\" >> $(top_srcdir)/tests/hamlibdatetime.h - test -f $(top_srcdir)/tests/hamlibdatetime.h || cp $(top_srcdir)/tests/hamlibdatetime.h.in $(top_srcdir)/tests/hamlibdatetime.h - test $(top_srcdir) == $(top_builddir) || cp $(top_srcdir)/tests/hamlibdatetime.h $(top_builddir)/tests/; - -FORCE: ; + if test -x $(top_srcdir)/.git ; then \ + echo "/* This date time is from the last non-merge commit to Hamlib. */" > $@ ;\ + echo "#define HAMLIBDATETIME "\"$$(TZ=UTC git --git-dir=$(top_srcdir)/.git log --no-merges --date='format-local:%a %b %d %H:%M:%S %Y %z SHA=' --format='%cd' -n 1)$$(git --git-dir=$(top_srcdir)/.git log --no-merges | grep commit | head -n 1 | cut -c8-13)\" >> $@ ;\ + cp $@ $(top_srcdir)/tests/$(@F) ;\ + fi + test -f $(top_srcdir)/tests/$(@F) || cp $(top_srcdir)/tests/$(@F).in $(top_srcdir)/tests/$(@F) CLEANFILES = testrig.sh testfreq.sh testbcd.sh testloc.sh From 93560bf6824bd05585df0b94976e138f327f3ca7 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sat, 17 Oct 2020 12:25:40 +0100 Subject: [PATCH 2/8] Fix rebuild dependency --- tests/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Makefile.am b/tests/Makefile.am index a91cfaa02..a7061733c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -111,5 +111,6 @@ hamlibdatetime.h: Makefile cp $@ $(top_srcdir)/tests/$(@F) ;\ fi test -f $(top_srcdir)/tests/$(@F) || cp $(top_srcdir)/tests/$(@F).in $(top_srcdir)/tests/$(@F) + test -f $@ || cp $(top_srcdir)/tests/$(@F).in $@ CLEANFILES = testrig.sh testfreq.sh testbcd.sh testloc.sh From c8a30f2ef3e1081cc589ae3b1302320c1674195d Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sat, 17 Oct 2020 12:30:08 +0100 Subject: [PATCH 3/8] Build hamlibdatetime.h every time --- tests/Makefile.am | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index a7061733c..75575343e 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -103,7 +103,7 @@ testloc.sh: # to the sources directory if it is different for inclusion in # distribution tarballs, which avoids race conditions with parallel # builds. -hamlibdatetime.h: Makefile +hamlibdatetime.h: FORCE echo "SHA=$(SHA)" if test -x $(top_srcdir)/.git ; then \ echo "/* This date time is from the last non-merge commit to Hamlib. */" > $@ ;\ @@ -113,4 +113,6 @@ hamlibdatetime.h: Makefile test -f $(top_srcdir)/tests/$(@F) || cp $(top_srcdir)/tests/$(@F).in $(top_srcdir)/tests/$(@F) test -f $@ || cp $(top_srcdir)/tests/$(@F).in $@ +FORCE: + CLEANFILES = testrig.sh testfreq.sh testbcd.sh testloc.sh From d866d4dc3307be14cb5bf20b08c899aef06d399a Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sat, 17 Oct 2020 13:25:35 +0100 Subject: [PATCH 4/8] Force copy over existing --- tests/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 75575343e..7bc3fc10c 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -108,10 +108,10 @@ hamlibdatetime.h: FORCE if test -x $(top_srcdir)/.git ; then \ echo "/* This date time is from the last non-merge commit to Hamlib. */" > $@ ;\ echo "#define HAMLIBDATETIME "\"$$(TZ=UTC git --git-dir=$(top_srcdir)/.git log --no-merges --date='format-local:%a %b %d %H:%M:%S %Y %z SHA=' --format='%cd' -n 1)$$(git --git-dir=$(top_srcdir)/.git log --no-merges | grep commit | head -n 1 | cut -c8-13)\" >> $@ ;\ - cp $@ $(top_srcdir)/tests/$(@F) ;\ + cp -f $@ $(top_srcdir)/tests/$(@F) ;\ fi test -f $(top_srcdir)/tests/$(@F) || cp $(top_srcdir)/tests/$(@F).in $(top_srcdir)/tests/$(@F) - test -f $@ || cp $(top_srcdir)/tests/$(@F).in $@ + test -f $@ || cp $(top_srcdir)/tests/$(@F) $@ FORCE: From d81a027063a33444ffcf7207ca085151f2471346 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sat, 17 Oct 2020 13:32:49 +0100 Subject: [PATCH 5/8] Minimize rebuilding --- tests/Makefile.am | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 7bc3fc10c..a012d78a5 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -106,9 +106,12 @@ testloc.sh: hamlibdatetime.h: FORCE echo "SHA=$(SHA)" if test -x $(top_srcdir)/.git ; then \ - echo "/* This date time is from the last non-merge commit to Hamlib. */" > $@ ;\ - echo "#define HAMLIBDATETIME "\"$$(TZ=UTC git --git-dir=$(top_srcdir)/.git log --no-merges --date='format-local:%a %b %d %H:%M:%S %Y %z SHA=' --format='%cd' -n 1)$$(git --git-dir=$(top_srcdir)/.git log --no-merges | grep commit | head -n 1 | cut -c8-13)\" >> $@ ;\ - cp -f $@ $(top_srcdir)/tests/$(@F) ;\ + echo "/* This date time is from the last non-merge commit to Hamlib. */" > $@.tmp ;\ + echo "#define HAMLIBDATETIME "\"$$(TZ=UTC git --git-dir=$(top_srcdir)/.git log --no-merges --date='format-local:%a %b %d %H:%M:%S %Y %z SHA=' --format='%cd' -n 1)$$(git --git-dir=$(top_srcdir)/.git log --no-merges | grep commit | head -n 1 | cut -c8-13)\" >> $@.tmp ;\ + if test $$(diff $@.tmp $@) ; then \ + mv $@.tmp $@ ;\ + cp -f $@ $(top_srcdir)/tests/$(@F) ;\ + fi \ fi test -f $(top_srcdir)/tests/$(@F) || cp $(top_srcdir)/tests/$(@F).in $(top_srcdir)/tests/$(@F) test -f $@ || cp $(top_srcdir)/tests/$(@F) $@ From e149c9980f5d08b3d56fed2937c8a1191d75df4b Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sat, 17 Oct 2020 13:35:16 +0100 Subject: [PATCH 6/8] Correct use of sh if --- tests/Makefile.am | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index a012d78a5..97234e6e6 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -108,8 +108,8 @@ hamlibdatetime.h: FORCE if test -x $(top_srcdir)/.git ; then \ echo "/* This date time is from the last non-merge commit to Hamlib. */" > $@.tmp ;\ echo "#define HAMLIBDATETIME "\"$$(TZ=UTC git --git-dir=$(top_srcdir)/.git log --no-merges --date='format-local:%a %b %d %H:%M:%S %Y %z SHA=' --format='%cd' -n 1)$$(git --git-dir=$(top_srcdir)/.git log --no-merges | grep commit | head -n 1 | cut -c8-13)\" >> $@.tmp ;\ - if test $$(diff $@.tmp $@) ; then \ - mv $@.tmp $@ ;\ + if $$(diff $@.tmp $@) ; then \ + mv -f $@.tmp $@ ;\ cp -f $@ $(top_srcdir)/tests/$(@F) ;\ fi \ fi From 2c5aaff0c44b072ebc2bc704d5b6ddd94bc39165 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sat, 17 Oct 2020 17:17:37 +0100 Subject: [PATCH 7/8] Another attempt at a reliable SCS version header generation --- tests/Makefile.am | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/tests/Makefile.am b/tests/Makefile.am index 97234e6e6..35fc4a7dd 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -4,7 +4,7 @@ # AUTOMAKE_OPTIONS = dejagnu # DEJATOOL = testfreq testbcd testloc rigctl -BUILT_SOURCES = hamlibdatetime.h +BUILT_SOURCES = $(builddir)/hamlibdatetime.h DISTCLEANFILES = rigctl.log rigctl.sum testbcd.log testbcd.sum hamlibdatetime.h @@ -28,7 +28,7 @@ rigsmtr_SOURCES = rigsmtr.c rigmem_SOURCES = rigmem.c memsave.c memload.c memcsv.c sprintflst.c sprintflst.h # include generated include files ahead of any in sources -rigctl_CPPFLAGS = -I$(top_builddir)/tests -I$(top_srcdir) $(AM_CPPFLAGS) +rigctl_CPPFLAGS = -I$(builddir)/tests -I$(srcdir) $(AM_CPPFLAGS) # all the programs need this LDADD = $(top_builddir)/src/libhamlib.la $(top_builddir)/lib/libmisc.la $(DL_LIBS) @@ -99,23 +99,26 @@ testloc.sh: chmod +x ./testloc.sh # If we have a .git directory then we will generate the hamlibdate.h -# file. If not, then copy the placeholder. Either way copy the result -# to the sources directory if it is different for inclusion in -# distribution tarballs, which avoids race conditions with parallel -# builds. +# file and replace it if it is different. Fall back to a copy of a +# generic hamlibdatetime.h.in in the source tree. Build looks in build +# directory before the source directory for the hamlibdatetime.h +# header. hamlibdatetime.h: FORCE - echo "SHA=$(SHA)" - if test -x $(top_srcdir)/.git ; then \ - echo "/* This date time is from the last non-merge commit to Hamlib. */" > $@.tmp ;\ - echo "#define HAMLIBDATETIME "\"$$(TZ=UTC git --git-dir=$(top_srcdir)/.git log --no-merges --date='format-local:%a %b %d %H:%M:%S %Y %z SHA=' --format='%cd' -n 1)$$(git --git-dir=$(top_srcdir)/.git log --no-merges | grep commit | head -n 1 | cut -c8-13)\" >> $@.tmp ;\ - if $$(diff $@.tmp $@) ; then \ - mv -f $@.tmp $@ ;\ - cp -f $@ $(top_srcdir)/tests/$(@F) ;\ - fi \ + @if test -x $(top_srcdir)/.git ; then \ + echo "/* This date time is from the last non-merge commit to Hamlib. */" > $(builddir)/$(@F).tmp ;\ + echo "#define HAMLIBDATETIME "\"$$(TZ=UTC git --git-dir=$(top_srcdir)/.git log --no-merges --date='format-local:%a %b %d %H:%M:%S %Y %z SHA=' --format='%cd' -n 1)$$(git --git-dir=$(top_srcdir)/.git log --no-merges | grep commit | head -n 1 | cut -c8-13)\" >> $(builddir)/$(@F).tmp ;\ + diff -qN $(builddir)/$(@F).tmp $(builddir)/$(@F) ; test $$? -eq 0 || { echo "Generating SCS header \"$(builddir)/$(@F)\"" ; mv -f $(builddir)/$(@F).tmp $(builddir)/$(@F) ; } ;\ + else \ + test -f $(srcdir)/$(@F) || cp $(srcdir)/$(@F).in $(srcdir)/$(@F) ;\ fi - test -f $(top_srcdir)/tests/$(@F) || cp $(top_srcdir)/tests/$(@F).in $(top_srcdir)/tests/$(@F) - test -f $@ || cp $(top_srcdir)/tests/$(@F) $@ FORCE: +# If we are making a distribution out-of-source and we have generated +# a hamlibdatetime.h; then copy it to the tests directory of the +# source tarball so that downstream builds pick up the version +# information we know about. +dist-hook: + test ./ -ef $(srcdir)/ || test ! -f hamlibdatetime.h || cp -f hamlibdatetime.h $(srcdir)/ + CLEANFILES = testrig.sh testfreq.sh testbcd.sh testloc.sh From 25851f74e13cc21056847b69576450a80812430d Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Sat, 17 Oct 2020 21:23:33 +0100 Subject: [PATCH 8/8] Remove temporary file --- tests/Makefile.am | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/Makefile.am b/tests/Makefile.am index 35fc4a7dd..077f41385 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -108,6 +108,7 @@ hamlibdatetime.h: FORCE echo "/* This date time is from the last non-merge commit to Hamlib. */" > $(builddir)/$(@F).tmp ;\ echo "#define HAMLIBDATETIME "\"$$(TZ=UTC git --git-dir=$(top_srcdir)/.git log --no-merges --date='format-local:%a %b %d %H:%M:%S %Y %z SHA=' --format='%cd' -n 1)$$(git --git-dir=$(top_srcdir)/.git log --no-merges | grep commit | head -n 1 | cut -c8-13)\" >> $(builddir)/$(@F).tmp ;\ diff -qN $(builddir)/$(@F).tmp $(builddir)/$(@F) ; test $$? -eq 0 || { echo "Generating SCS header \"$(builddir)/$(@F)\"" ; mv -f $(builddir)/$(@F).tmp $(builddir)/$(@F) ; } ;\ + rm -f $(builddir)/$(@F).tmp ;\ else \ test -f $(srcdir)/$(@F) || cp $(srcdir)/$(@F).in $(srcdir)/$(@F) ;\ fi