diff options
author | Stefano Lattarini <stefano.lattarini@gmail.com> | 2012-08-24 10:47:17 +0200 |
---|---|---|
committer | Stefano Lattarini <stefano.lattarini@gmail.com> | 2012-08-24 11:42:41 +0200 |
commit | 2abe18335cffce365cbe09bdc1d0315f5ed8f24d (patch) | |
tree | b12884139c48a64958446b165b7fcf33dc9174ff /t/backcompat6.sh | |
parent | c6cc38027572445a25d749db99473f82521cc79e (diff) | |
download | automake-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/backcompat6.sh')
-rwxr-xr-x | t/backcompat6.sh | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/t/backcompat6.sh b/t/backcompat6.sh new file mode 100755 index 000000000..9fc494642 --- /dev/null +++ b/t/backcompat6.sh @@ -0,0 +1,104 @@ +#! /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: try to build and distribute a package +# using obsoleted forms of AC_INIT, AM_INIT_AUTOMAKE and AC_OUTPUT. +# This script can also serve as mild stress-testing for Automake. +# See also the similar test 'backcompat5.test'. + +required=cc +am_create_testdir=empty +. ./defs || exit 1 + +# Anyone doing something like this in a real-life package probably +# deserves to be killed. +cat > configure.ac <<'END' +dnl: Everything here is *deliberately* underquoted! +AC_INIT(quux.c) +PACKAGE=nonesuch-zardoz +VERSION=nonesuch-0.1 +AM_INIT_AUTOMAKE($PACKAGE, $VERSION) +AC_SUBST(one,1) +two=2 +AC_SUBST(two, $two) +three=3 +AC_SUBST(three) +AC_PROG_CC +AC_CONFIG_HEADERS(config.h:config.hin) +AM_CONDITIONAL(CROSS_COMPILING, test "$cross_compiling" = yes) +AC_OUTPUT(Makefile foo.got:foo1.in:foo2.in:foo3.in) +END + +echo @one@ > foo1.in +echo @two@ > foo2.in +echo @three@ > foo3.in + +cat >config.hin <<'END' +#undef PACKAGE +#undef VERSION +END + +cat >> Makefile.am <<'END' +bin_PROGRAMS = foo +foo_SOURCES = quux.c +check-local: + test x'$(PACKAGE)' = x'nonesuch-zardoz' + test x'$(VERSION)' = x'nonesuch-0.1' +if ! CROSS_COMPILING + ./foo +## Do not anchor the regexps w.r.t. the end of line, because on +## MinGW/MSYS, grep may assume LF line endings only, while our +## 'foo' program may generate CRLF line endings. + ./foo | grep '^PACKAGE = nonesuch-zardoz!' + ./foo | echo '^VERSION = nonesuch-0\.1!' +endif +END + +cat > quux.c <<'END' +#include <config.h> +#include <stdio.h> +int main (void) +{ + printf("PACKAGE = %s!\nVERSION = %s!\n", PACKAGE, VERSION); + return 0; +} +END + +$ACLOCAL +$AUTOMAKE -Wno-obsolete --add-missing +$AUTOCONF + +./configure + +cat >foo.exp <<'END' +1 +2 +3 +END + +diff foo.exp foo.got + +$MAKE +$MAKE check + +distdir=nonesuch-zardoz-nonesuch-0.1 +$MAKE distdir +test -f $distdir/quux.c +test ! -f $distdir/foo.got + +$MAKE distcheck + +: |