]> git.draconx.ca Git - cdecl99.git/commitdiff
Generate ChangeLog from git at packaging time.
authorNick Bowler <nbowler@draconx.ca>
Tue, 23 Feb 2021 05:39:30 +0000 (00:39 -0500)
committerNick Bowler <nbowler@draconx.ca>
Tue, 23 Feb 2021 05:39:30 +0000 (00:39 -0500)
Import the gitlog-to-changelog script from gnulib and add rules to
generate an up-to-date changelog from the git history, if available,
when running 'make dist'.

The ChangeLog is otherwise taken from srcdir as usual, so that
modified versions can be prepared from a release tarball without
requiring the full git history.  In this scenario, the ChangeLog
would have to be manually edited.

In case the ChangeLog generation fails, a distcheck-hook is added
to hopefully catch issues before releasing tarballs with a broken
ChangeLog.

.gitignore
ChangeLog [new file with mode: 0644]
Makefile.am
m4/gnulib-cache.m4

index 735368eb75e5701d8e6d67f738d6c22d04761912..dafb638b40ef72738f082bba85129dd26228942f 100644 (file)
@@ -15,6 +15,7 @@
 /configure
 /depcomp
 /exported.sh
+/gitlog-to-changelog
 /install-sh
 /lib
 /libtool
diff --git a/ChangeLog b/ChangeLog
new file mode 100644 (file)
index 0000000..4e0b7e7
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1 @@
+Stub changelog, see the git history for changes.
index 01ff0a62e5c3f9bec551629150dd191f17f46751..4bdc88cad94c1d7280de28bc34066edea4aad790 100644 (file)
@@ -149,6 +149,39 @@ unfuck-distdir:
        find '$(distdir)' -type f -exec chmod u+w {} +
 .PHONY: unfuck-distdir
 
+GITLOG_FLAGS = --format='%s%n%n%b%n'
+
+dist-hook: generate-changelog
+generate-changelog: unfuck-distdir
+       -: "$${GIT_DIR=$(top_srcdir)/.git}"; \
+         export GIT_DIR; test -d "$$GIT_DIR" || exit 0; \
+         $(top_srcdir)/gitlog-to-changelog $(GITLOG_FLAGS) \
+           >'$(distdir)/ChangeLog.gen' && \
+         mv -f '$(distdir)/ChangeLog.gen' '$(distdir)/ChangeLog'
+       rm -f '$(distdir)/ChangeLog.gen'
+.PHONY: generate-changelog
+
+GENERIC_V   = $(GENERIC_V_@AM_V@)
+GENERIC_V_  = $(GENERIC_V_@AM_DEFAULT_V@)
+GENERIC_V_0 = @printf '%2.0s%$(DX_ALIGN_V)s %s\n'
+
+TEST_DISTRIBUTION = false
+TEST_DISTRIBUTION_OR_ERROR = if $(TEST_DISTRIBUTION); \
+  then echo 'Proceeding anyway...'; \
+  else echo 'Run $(MAKE) TEST_DISTRIBUTION=true to ignore this failure.'; \
+       false; \
+  fi
+
+distcheck-hook:
+       $(GENERIC_V) : 'CHECK   ' ChangeLog; \
+         $(AWK) '/^Stub/ { print FILENAME ":" NR ":", $$0; exit 1 }' \
+           $(distdir)/ChangeLog || { \
+             echo 'ERROR: *** Packaged ChangeLog was not properly generated from git log.'; \
+             echo '       *** The source version was used instead, but this appears to'; \
+             echo '       *** be the stub from a git checkout.  The "git" and "perl"'; \
+             echo '       *** programs are required for ChangeLog generation to work.'; \
+             $(TEST_DISTRIBUTION_OR_ERROR); } >&2
+
 # Supporting rules for bison/flex.
 
 BISON_V   = $(BISON_V_@AM_V@)
index 5faa6b6c3576d33731b44025924ae0ef54148d9f..5223b7d74d14d07f8ebb65c52772bc35153c498d 100644 (file)
@@ -41,6 +41,7 @@
 #  --no-vc-files \
 #  getopt-gnu \
 #  gettext-h \
+#  gitlog-to-changelog \
 #  localcharset \
 #  lock \
 #  readline \
@@ -52,6 +53,7 @@ gl_LOCAL_DIR([])
 gl_MODULES([
   getopt-gnu
   gettext-h
+  gitlog-to-changelog
   localcharset
   lock
   readline