]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
build: define RELEASE_YEAR with AC_SUBST
authorStefano Lattarini <stefano.lattarini@gmail.com>
Sun, 5 May 2013 18:16:25 +0000 (20:16 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Mon, 6 May 2013 10:23:20 +0000 (12:23 +0200)
Rather than reading it dynamically from the ChangeLog -- that,
remember, is only a dummy in a Git checkout!  To avoid risking
the definition to get out-of-sync, let's enhance the maintainer
target 'update-copyright' to update it automatically (the same
way it's done in the Automake build system).

* configure.ac (RELEASE_YEAR): New AC_SUBST'd variable.
* cfg.mk (update-release-year): New maintainer-specific target
to automatically update the value of that variable.
(update-copyright): Depend on the new target.
* bin/local.mk (RELEASE_YEAR): Drop definition.
(edit): Simplify quoting of $(RELEASE_YEAR).
* lib/Makefile.am (RELEASE_YEAR): Drop definition.
(m4sugar/version.m4): Simplify quoting of $(RELEASE_YEAR).

Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
bin/local.mk
cfg.mk
configure.ac
lib/Makefile.am

index 57983f82cdd3bdab5d3dbad1c8b29d84446f7f2e..ff7b2cfdbc12148124354827a842ffd88f035963 100644 (file)
@@ -38,10 +38,6 @@ EXTRA_DIST += \
 # Files that should be removed, but which Automake does not know.
 MOSTLYCLEANFILES += $(bin_SCRIPTS) bin/autoconf.in bin/*.tmp
 
-# Get the release year from ChangeLog.
-RELEASE_YEAR = \
-  `sed 's/^\([0-9][0-9][0-9][0-9]\).*/\1/;q' $(top_srcdir)/ChangeLog`
-
 ## ------------- ##
 ## The scripts.  ##
 ## ------------- ##
@@ -60,7 +56,7 @@ edit = sed \
        -e 's|@M4_DEBUGFILE[@]|$(M4_DEBUGFILE)|g' \
        -e 's|@M4_GNU[@]|$(M4_GNU)|g' \
        -e 's|@AWK[@]|$(AWK)|g' \
-       -e 's|@RELEASE_YEAR[@]|'$(RELEASE_YEAR)'|g' \
+       -e 's|@RELEASE_YEAR[@]|$(RELEASE_YEAR)|g' \
        -e 's|@VERSION[@]|$(VERSION)|g' \
        -e 's|@PACKAGE_NAME[@]|$(PACKAGE_NAME)|g' \
        -e 's|@configure_input[@]|Generated from $@.in; do not edit by hand.|g'
diff --git a/cfg.mk b/cfg.mk
index a57196e2c5bb999248331f860f2585534070427a..980eab97ff197f414bbb8e3fd3c4b6a5fc79f84e 100644 (file)
--- a/cfg.mk
+++ b/cfg.mk
@@ -123,6 +123,18 @@ update-copyright-env = \
   UPDATE_COPYRIGHT_USE_INTERVALS=1 \
   UPDATE_COPYRIGHT_MAX_LINE_LENGTH=72
 
+update-copyright: update-release-year
+update-release-year:
+       $(AM_V_GEN):; \
+       if test -n "$$UPDATE_COPYRIGHT_YEAR"; then \
+          current_year=$$UPDATE_COPYRIGHT_YEAR; \
+       else \
+         current_year=`date +%Y` && test -n "$$current_year" \
+           || { echo "$@: cannot get current year" >&2; exit 1; }; \
+       fi; \
+       sed -i "/^RELEASE_YEAR=/s/=.*$$/=$$current_year/" configure.ac
+.PHONY: update-release-year
+
 # Prevent incorrect NEWS edits.
 old_NEWS_hash = 8532b4ed4fb456eb71071a5cf8c258d4
 
index b3f3fa9c48663fe8c43fd0e4dc9549cb6c479876..91f6a74a8d62e12b0c811a54d7c7d70918b7b339 100644 (file)
@@ -27,6 +27,11 @@ AC_CONFIG_AUX_DIR([build-aux])
 
 AM_INIT_AUTOMAKE([1.11 dist-xz readme-alpha no-texinfo.tex std-options])
 
+# Keep this on a line of its own, since it must be found and processed
+# by the 'update-release-year' rule in our Makefile.
+RELEASE_YEAR=2013
+AC_SUBST([RELEASE_YEAR])
+
 AB_INIT
 
 # We use '/bin/sh -n script' to check that there are no syntax errors
index 1004622b3260852b2e0ca4c5f053399b4f709dc4..2b4c494dbdf641b8097f76c326b099737f042dea 100644 (file)
@@ -162,10 +162,6 @@ nodist_m4sugarlib_DATA = \
 
 CLEANFILES += $(nodist_m4sugarlib_DATA)
 
-# Get the release year from ../ChangeLog.
-RELEASE_YEAR = \
-  `sed 's/^\([0-9][0-9][0-9][0-9]\).*/\1/;q' $(top_srcdir)/ChangeLog`
-
 # The ':;' in the second line of the recipe works around a redirected
 # compound command bash exit status bug.
 m4sugar/version.m4: Makefile
@@ -182,7 +178,7 @@ m4sugar/version.m4: Makefile
          echo 'm4_define([m4_PACKAGE_STRING],    [$(PACKAGE_STRING)])' && \
          echo 'm4_define([m4_PACKAGE_BUGREPORT], [$(PACKAGE_BUGREPORT)])' && \
          echo 'm4_define([m4_PACKAGE_URL],       [$(PACKAGE_URL)])' && \
-         echo 'm4_define([m4_PACKAGE_YEAR],      ['$(RELEASE_YEAR)'])'; \
+         echo 'm4_define([m4_PACKAGE_YEAR],      [$(RELEASE_YEAR)])'; \
        } > $@-t
        mv $@-t $@