summaryrefslogtreecommitdiff
path: root/t/backcompat2.sh
diff options
context:
space:
mode:
authorStefano Lattarini <stefano.lattarini@gmail.com>2012-08-24 10:47:17 +0200
committerStefano Lattarini <stefano.lattarini@gmail.com>2012-08-24 11:42:41 +0200
commit2abe18335cffce365cbe09bdc1d0315f5ed8f24d (patch)
treeb12884139c48a64958446b165b7fcf33dc9174ff /t/backcompat2.sh
parentc6cc38027572445a25d749db99473f82521cc79e (diff)
downloadautomake-2abe18335cffce365cbe09bdc1d0315f5ed8f24d.tar.gz
AM_INIT_AUTOMAKE: allow obsolescent two-args invocation once again
This partially reverts commit 'v1.12-67-ge186355' of 2012-05-25, "init: obsolete usages of AM_INIT_AUTOMAKE not supported anymore" Some users still need to be able to define the version number for their package dynamically, at configure runtime. Their user case is that, for development snapshots, they want to be able to base the complete version of the package on the VCS revision ID (mostly Git or Mercurial). They could of course do so by specifying such version dynamically in their call to AC_INIT, as is done by several GNU packages. But then they would need to regenerate and re-run the configure script before each snapshot, which might be very time-consuming for complex packages, to the point of slowing down and even somewhat impeding development. The situation should truly be solved in Autoconf, by allowing a way to specify the version dynamically in a way that doesn't force the configure script to be regenerated and re-run every time the package version changes. But until Autoconf has been improved to allow this, Automake will have to support the obsolescent two-arguments invocation for AM_INIT_AUTOMAKE, to avoid regressing the suboptimal but working solution for the use case described above. See also: <http://lists.gnu.org/archive/html/automake/2012-08/msg00025.html> * NEWS: Update. * m4/init.m4 (AM_INIT_AUTOMAKE): Support once again invocation with two or three arguments. * t/aminit-moreargs-no-more.sh: Renamed ... * t/aminit-moreargs-deprecated.sh: ... like this, and updated. * t/nodef.sh: Recovered test, with minor adjustments. * t/backcompat.sh: Likewise. * t/backcompat2.sh: Likewise. * t/backcompat3.sh: Likewise. * t/backcompat6.sh: Likewise. * t/list-of-tests.mk: Adjust. Suggested-by: Bob Friesenhahn n<bfriesen@simple.dallas.tx.us> Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Diffstat (limited to 't/backcompat2.sh')
-rwxr-xr-xt/backcompat2.sh73
1 files changed, 73 insertions, 0 deletions
diff --git a/t/backcompat2.sh b/t/backcompat2.sh
new file mode 100755
index 000000000..109483b47
--- /dev/null
+++ b/t/backcompat2.sh
@@ -0,0 +1,73 @@
+#! /bin/sh
+# Copyright (C) 2010-2012 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Backward-compatibility test: check that AM_INIT_AUTOMAKE with two or
+# three arguments does AC_DEFINE the symbols PACKAGE and VERSION iff the
+# third argument is empty or non-existent.
+
+am_create_testdir=empty
+. ./defs || exit 1
+
+# A trick to make the test run muuuch faster, by avoiding repeated
+# runs of aclocal (one order of magnitude improvement in speed!).
+echo 'AC_INIT(x,0) AM_INIT_AUTOMAKE' > configure.ac
+$ACLOCAL
+rm -rf configure.ac autom4te.*
+
+touch install-sh missing
+
+cat > config.h.in <<'END'
+#undef PACKAGE
+#undef VERSION
+END
+
+for am_arg3 in ':' 'false' '#' ' '; do
+ unindent > configure.ac <<END
+ AC_INIT
+ AC_CONFIG_HEADERS([config.h])
+ AM_INIT_AUTOMAKE([pkgname], [pkgversion], [$am_arg3])
+ AC_OUTPUT
+END
+ cat configure.ac # For debugging.
+ $AUTOCONF
+ ./configure
+ cat config.h # For debugging.
+ # The non-empty third argument should prevent PACKAGE and VERSION
+ # from being AC_DEFINE'd.
+ $EGREP 'pkg(name|version)' config.h && exit 1
+ # This is required because even relatively-recent versions of the
+ # BSD shell wrongly exit when the 'errexit' shell flag is active if
+ # the last command of a compound statement fails, even if it should
+ # be protected by the use of "&&".
+ :
+done
+
+for am_extra_args in '' ',' ', []'; do
+ unindent > configure.ac <<END
+ AC_INIT
+ AC_CONFIG_HEADERS([config.h])
+ AM_INIT_AUTOMAKE([pkgname], [pkgversion]$am_extra_args)
+ AC_OUTPUT
+END
+ cat configure.ac # For debugging.
+ $AUTOCONF
+ ./configure
+ cat config.h # For debugging.
+ grep '^ *# *define *PACKAGE *"pkgname" *$' config.h
+ grep '^ *# *define *VERSION *"pkgversion" *$' config.h
+done
+
+: