From 0806363b57db10eba8db006899fb76fe8651590c Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Wed, 6 Mar 2024 23:05:51 -0800 Subject: [PATCH] Tell Autoconf to get the version from `ddclient.in` This avoids the need to maintain the same version string in two different places. --- .autom4te.cfg | 6 ++++++ Makefile.am | 1 + configure.ac | 11 ++++++++++- t/version.pl.in | 2 +- 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 .autom4te.cfg diff --git a/.autom4te.cfg b/.autom4te.cfg new file mode 100644 index 0000000..2e235ff --- /dev/null +++ b/.autom4te.cfg @@ -0,0 +1,6 @@ +# Disable autom4te cache to ensure that any change to ddclient.in triggers a +# rebuild of the configure script (which gets the version of ddclient from +# ddclient.in). See . +begin-language: "Autoconf-without-aclocal-m4" +args: --no-cache +end-language: "Autoconf-without-aclocal-m4" diff --git a/Makefile.am b/Makefile.am index a02bdb3..c43b540 100644 --- a/Makefile.am +++ b/Makefile.am @@ -76,6 +76,7 @@ generated_tests = \ TESTS = $(handwritten_tests) $(generated_tests) $(TESTS): ddclient EXTRA_DIST += $(handwritten_tests) \ + .autom4te.cfg \ t/lib/Devel/Autoflush.pm \ t/lib/Test/Builder.pm \ t/lib/Test/Builder/Formatter.pm \ diff --git a/configure.ac b/configure.ac index e60c85f..f65b8b3 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,14 @@ AC_PREREQ([2.63]) -AC_INIT([ddclient], [3.11.3_0]) +# Get the version from ddclient.in so that the same version string +# doesn't have to be maintained in two places. The m4_dquote macro is +# used instead of quote characters to ensure that the command is only +# run once. The command outputs quote characters to prevent +# incidental expansion (the m4_esyscmd macro does not quote the +# command output itself, so the command output is subject to +# expansion). +AC_INIT([ddclient], m4_dquote(m4_esyscmd([printf '[%s]' "$(./ddclient.in --version=short)"]))) +# Needed because of the above invocation of ddclient.in. +AC_SUBST([CONFIGURE_DEPENDENCIES], ['$(top_srcdir)/ddclient.in']) AC_CONFIG_SRCDIR([ddclient.in]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([m4]) diff --git a/t/version.pl.in b/t/version.pl.in index 42b1bb0..e7bd863 100644 --- a/t/version.pl.in +++ b/t/version.pl.in @@ -4,6 +4,6 @@ use version; SKIP: { eval { require Test::Warnings; } or skip($@, 1); } eval { require 'ddclient'; } or BAIL_OUT($@); -is(ddclient->VERSION(), version->parse('v@PACKAGE_VERSION@'), "version matches Autoconf config"); +is($ddclient::version, '@PACKAGE_VERSION@', "version matches version in Autoconf"); done_testing();