]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
distcheck: add support for AM_DISTCHECK_CONFIGURE_FLAGS
authorStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 10 Jun 2011 10:26:42 +0000 (12:26 +0200)
committerStefano Lattarini <stefano.lattarini@gmail.com>
Fri, 10 Jun 2011 13:17:14 +0000 (15:17 +0200)
* doc/automake.texi (Checking the Distribution): Suggest to use
AM_DISTCHECK_CONFIGURE_FLAGS, not DISTCHECK_CONFIGURE_FLAGS, to
define (in the top-level Makefile.am) extra flags to be passed
to configure at "make distcheck" time; DISTCHECK_CONFIGURE_FLAGS
should be reserved for the user.  Add proper `@vindex' directive.
Document that AM_DISTCHECK_CONFIGURE_FLAGS is not honoured in a
subpackage Makefile.am, but the flags in it are passed down to
the configure script of the subpackage.
* lib/am/distdir.am (distcheck): Also pass the flags in
$(AM_DISTCHECK_CONFIGURE_FLAGS) to the configure invocation.
Update comments.
* tests/defs.in.test (AM_DISTCHECK_CONFIGURE_FLAGS,
DISTCHECK_CONFIGURE_FLAGS): Unset in case they are exported in
the environment, they might improperly influence our testsuite.
* tests/distcheck-configure-flags.test: New test.
* tests/distcheck-configure-flags-am.test: Likewise.
* tests/distcheck-configure-flags-subpkg.test: Likewise.
* distcheck-hook.test: Likewise.
* distcheck-hook2.test: Likewise.
* tests/Makefile.am (TESTS): Update.

Closes automake bug#8487.

12 files changed:
ChangeLog
Makefile.in
doc/automake.texi
lib/am/distdir.am
tests/Makefile.am
tests/Makefile.in
tests/defs.in
tests/distcheck-configure-flags-am.test [new file with mode: 0755]
tests/distcheck-configure-flags-subpkg.test [new file with mode: 0755]
tests/distcheck-configure-flags.test [new file with mode: 0755]
tests/distcheck-hook.test [new file with mode: 0755]
tests/distcheck-hook2.test [new file with mode: 0755]

index cb9918fc2a6bc04a2078a7766e496302f7d838ac..1a11eb22663b32bed4baa98437b0fffaf5c06204 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,28 @@
+2011-06-10  Stefano Lattarini  <stefano.lattarini@gmail.com>
+
+       distcheck: add support for AM_DISTCHECK_CONFIGURE_FLAGS
+       * doc/automake.texi (Checking the Distribution): Suggest to use
+       AM_DISTCHECK_CONFIGURE_FLAGS, not DISTCHECK_CONFIGURE_FLAGS, to
+       define (in the top-level Makefile.am) extra flags to be passed
+       to configure at "make distcheck" time; DISTCHECK_CONFIGURE_FLAGS
+       should be reserved for the user.  Add proper `@vindex' directive.
+       Document that AM_DISTCHECK_CONFIGURE_FLAGS is not honoured in a
+       subpackage Makefile.am, but the flags in it are passed down to
+       the configure script of the subpackage.
+       * lib/am/distdir.am (distcheck): Also pass the flags in
+       $(AM_DISTCHECK_CONFIGURE_FLAGS) to the configure invocation.
+       Update comments.
+       * tests/defs.in.test (AM_DISTCHECK_CONFIGURE_FLAGS,
+       DISTCHECK_CONFIGURE_FLAGS): Unset in case they are exported in
+       the environment, they might improperly influence our testsuite.
+       * tests/distcheck-configure-flags.test: New test.
+       * tests/distcheck-configure-flags-am.test: Likewise.
+       * tests/distcheck-configure-flags-subpkg.test: Likewise.
+       * distcheck-hook.test: Likewise.
+       * distcheck-hook2.test: Likewise.
+       * tests/Makefile.am (TESTS): Update.
+       Closes automake bug#8784.
+
 2011-06-02  Stefano Lattarini  <stefano.lattarini@gmail.com>
 
        maintcheck: fix some failures, extend some checks
index d0951e06b5de0efd5dfd580621023e8174b68793..d6743e47abbb311785c56282e35a9a2e1b4aa9cc 100644 (file)
@@ -721,6 +721,7 @@ distcheck: dist
          && am__cwd=`pwd` \
          && $(am__cd) $(distdir)/_build \
          && ../configure --srcdir=.. --prefix="$$dc_install_base" \
+           $(AM_DISTCHECK_CONFIGURE_FLAGS) \
            $(DISTCHECK_CONFIGURE_FLAGS) \
          && $(MAKE) $(AM_MAKEFLAGS) \
          && $(MAKE) $(AM_MAKEFLAGS) dvi \
index 3846e0d6d2cb40a46eedc49cfdc582458461d903..b3aecfca0072f932f03760b9cacf7b5e13241457 100644 (file)
@@ -8417,11 +8417,14 @@ makes a distribution, then tries to do a @code{VPATH} build
 (@pxref{VPATH Builds}), run the test suite, and finally make another
 tarball to ensure the distribution is self-contained.
 
+@vindex AM_DISTCHECK_CONFIGURE_FLAGS
 @vindex DISTCHECK_CONFIGURE_FLAGS
 Building the package involves running @samp{./configure}.  If you need
 to supply additional flags to @command{configure}, define them in the
-@code{DISTCHECK_CONFIGURE_FLAGS} variable, either in your top-level
-@file{Makefile.am}, or on the command line when invoking @command{make}.
+@code{AM_DISTCHECK_CONFIGURE_FLAGS} variable in your top-level
+@file{Makefile.am}.  The user can still extend or override the flags
+provided there by defining the @code{DISTCHECK_CONFIGURE_FLAGS} variable,
+on the command line when invoking @command{make}.
 
 @trindex distcheck-hook
 If the @code{distcheck-hook} rule is defined in your top-level
@@ -8431,9 +8434,10 @@ is configured and built.  Your @code{distcheck-hook} can do almost
 anything, though as always caution is advised.  Generally this hook is
 used to check for potential distribution errors not caught by the
 standard mechanism.  Note that @code{distcheck-hook} as well as
-@code{DISTCHECK_CONFIGURE_FLAGS} are not honored in a subpackage
-@file{Makefile.am}, but the @code{DISTCHECK_CONFIGURE_FLAGS} are
-passed down to the @command{configure} script of the subpackage.
+@code{AM_DISTCHECK_CONFIGURE_FLAGS} and @code{DISTCHECK_CONFIGURE_FLAGS}
+are not honored in a subpackage @file{Makefile.am}, but the flags from
+@code{AM_DISTCHECK_CONFIGURE_FLAGS} and @code{DISTCHECK_CONFIGURE_FLAGS}
+are passed down to the @command{configure} script of the subpackage.
 
 @trindex distcleancheck
 @vindex DISTCLEANFILES
index e0f3bce609d9b08637d4d2140326851580e1fdb1..c2dd7c55afbc2248f260b8c790605e5d926f9e6d 100644 (file)
@@ -468,7 +468,9 @@ distcheck: dist
          && ../configure --srcdir=.. --prefix="$$dc_install_base" \
 ?GETTEXT?          --with-included-gettext \
 ## Additional flags for configure.  Keep this last in the configure
-## invocation so the user can override previous options.
+## invocation so the developer and user can override previous options,
+## and let the user's flags take precedence over the developer's ones.
+           $(AM_DISTCHECK_CONFIGURE_FLAGS) \
            $(DISTCHECK_CONFIGURE_FLAGS) \
          && $(MAKE) $(AM_MAKEFLAGS) \
          && $(MAKE) $(AM_MAKEFLAGS) dvi \
index 33ae8bc6220270fa4b02b18630680a0c7debb7e3..42a88139a648459891128731df11aa95177bfcd0 100644 (file)
@@ -313,6 +313,11 @@ distdir.test \
 distlinks.test \
 distlinksbrk.test \
 distname.test \
+distcheck-configure-flags.test \
+distcheck-configure-flags-am.test \
+distcheck-configure-flags-subpkg.test \
+distcheck-hook.test \
+distcheck-hook2.test \
 dmalloc.test \
 dollar.test \
 dollarvar.test \
index d7a1761c31fc5f3085ebcfe0a336682924c1cc23..664ecaa5301cffd23daf1b91bdbf5a504ce77d72 100644 (file)
@@ -584,6 +584,11 @@ distdir.test \
 distlinks.test \
 distlinksbrk.test \
 distname.test \
+distcheck-configure-flags.test \
+distcheck-configure-flags-am.test \
+distcheck-configure-flags-subpkg.test \
+distcheck-hook.test \
+distcheck-hook2.test \
 dmalloc.test \
 dollar.test \
 dollarvar.test \
index 87a350dade21e639ed17b577a5689032c28b896e..32fba30e8dbb883d83b6d6f9250834290906f46c 100644 (file)
@@ -425,6 +425,8 @@ unset DESTDIR
 unset prefix exec_prefix bindir datarootdir datadir docdir dvidir
 unset htmldir includedir infodir libdir libexecdir localedir mandir
 unset oldincludedir pdfdir psdir sbindir sharedstatedir sysconfdir
+# Unset variables that might change the "make distcheck" behaviour.
+unset DISTCHECK_CONFIGURE_FLAGS AM_DISTCHECK_CONFIGURE_FLAGS
 # Also unset variables that control our test driver.  While not
 # conceptually independent, they cause some changed semantics we
 # need to control (and test for) in some of the tests to ensure
diff --git a/tests/distcheck-configure-flags-am.test b/tests/distcheck-configure-flags-am.test
new file mode 100755 (executable)
index 0000000..a5cab6a
--- /dev/null
@@ -0,0 +1,68 @@
+#! /bin/sh
+# Copyright (C) 2011 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/>.
+
+# Check support for AM_DISTCHECK_CONFIGURE_FLAGS at "make distcheck"
+# time, and its interactions with DISTCHECK_CONFIGURE_FLAGS.
+
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_ARG_ENABLE([success], [], [success=$enableval], [success=no])
+AS_IF([test $success = yes && test "$sentence" = 'it works :-)'],
+      [:],
+      [AC_MSG_ERROR([success='$success', sentence='$sentence'])])
+AC_OUTPUT
+END
+
+unset sentence || :
+
+cat > Makefile.am << 'END'
+AM_DISTCHECK_CONFIGURE_FLAGS = --enable-success sentence='it works :-)'
+END
+
+$ACLOCAL
+$AUTOMAKE
+$FGREP '$(DISTCHECK_CONFIGURE_FLAGS)' Makefile.in
+$FGREP '$(AM_DISTCHECK_CONFIGURE_FLAGS)' Makefile.in
+grep 'DISTCHECK_CONFIGURE_FLAGS.*AM_DISTCHECK_CONFIGURE_FLAGS' Makefile.in \
+  && Exit 1
+
+$AUTOCONF
+./configure --enable-success sentence='it works :-)'
+
+# The configure call in "make distcheck" should honour
+# $(AM_DISTCHECK_CONFIGURE_FLAGS).
+
+$MAKE distcheck
+
+# $(DISTCHECK_CONFIGURE_FLAGS) takes precedence over
+# $(AM_DISTCHECK_CONFIGURE_FLAGS)
+
+cat >> Makefile.am << 'END'
+AM_DISTCHECK_CONFIGURE_FLAGS += --disable-success
+END
+$AUTOMAKE Makefile
+./config.status Makefile
+
+$MAKE distcheck >output 2>&1 && { cat output; Exit 1; }
+cat output
+grep "^configure:.* success='no', sentence='it works :-)'" output
+
+$MAKE distcheck DISTCHECK_CONFIGURE_FLAGS="--enable-success=yes"
+
+:
diff --git a/tests/distcheck-configure-flags-subpkg.test b/tests/distcheck-configure-flags-subpkg.test
new file mode 100755 (executable)
index 0000000..695b47c
--- /dev/null
@@ -0,0 +1,83 @@
+#! /bin/sh
+# Copyright (C) 2011 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/>.
+
+# Check AM_DISTCHECK_CONFIGURE_FLAGS and DISTCHECK_CONFIGURE_FLAGS
+# are not honored in a subpackage Makefile.am, but the flags from
+# AM_DISTCHECK_CONFIGURE_FLAGS and DISTCHECK_CONFIGURE_FLAGS are
+# passed down to the configure script of the subpackage.  This is
+# explicitly documented in the manual.
+
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_CONFIG_SUBDIRS([subpkg])
+if test $dc != ok || test $am_dc != ok; then
+  AC_MSG_ERROR([dc=$dc am_dc=$dc])
+fi
+AC_OUTPUT
+END
+
+mkdir subpkg
+
+sed <configure.in >subpkg/configure.in \
+    -e 's/^AC_INIT.*/AC_INIT([subpkg], [2.0])/' \
+    -e '/^AC_CONFIG_SUBDIRS/d' \
+
+cat configure.in
+cat subpkg/configure.in
+
+dc=KO am_dc=KO; export dc am_dc
+
+cat > Makefile.am << 'END'
+AM_DISTCHECK_CONFIGURE_FLAGS = am_dc=ok
+DISTCHECK_CONFIGURE_FLAGS = dc=ok
+END
+
+: > subpkg/Makefile.am
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+
+cd subpkg
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+cd ..
+
+# For debugging.
+$FGREP 'DISTCHECK_CONFIGURE_FLAGS' Makefile.in subpkg/Makefile.in
+
+grep '^AM_DISTCHECK_CONFIGURE_FLAGS =' Makefile.in
+grep '^DISTCHECK_CONFIGURE_FLAGS =' Makefile.in
+$EGREP '^(AM_)?DISTCHECK_CONFIGURE_FLAGS' subpkg/Makefile.in && Exit 1
+
+./configure dc=ok am_dc=ok
+
+# Flags in $(DISTCHECK_CONFIGURE_FLAGS) and $(AM_DISTCHECK_CONFIGURE_FLAGS)
+# should be passed down to the subpackage configure when "make distcheck"
+# is run from the top-level package ...
+$MAKE distcheck
+
+# ... but not when "make distcheck" is run from the subpackage.
+cd subpkg
+$MAKE distcheck >output 2>&1 && { cat output; Exit 1; }
+cat output
+grep '^configure:.* dc=KO am_dc=KO' output
+
+:
diff --git a/tests/distcheck-configure-flags.test b/tests/distcheck-configure-flags.test
new file mode 100755 (executable)
index 0000000..117d83c
--- /dev/null
@@ -0,0 +1,56 @@
+#! /bin/sh
+# Copyright (C) 2011 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/>.
+
+# Check support for DISTCHECK_CONFIGURE_FLAGS at "make distcheck" time.
+
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_ARG_ENABLE([success], [], [success=$enableval], [success=no])
+AS_IF([test $success = yes && test "$sentence" = 'it works :-)'],
+      [:],
+      [AC_MSG_ERROR([success='$success', sentence='$sentence'])])
+AC_OUTPUT
+END
+
+unset sentence || :
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOMAKE
+$FGREP '$(DISTCHECK_CONFIGURE_FLAGS)' Makefile.in
+
+$AUTOCONF
+./configure --enable-success sentence='it works :-)'
+
+# It should be ok to define DISTCHECK_CONFIGURE_FLAGS either on the
+# make command line or in the environment.
+
+env DISTCHECK_CONFIGURE_FLAGS='--enable-success sentence=it\ works\ :-\)' \
+  $MAKE distcheck # Not `make -e' here, deliberately.
+
+$MAKE distcheck \
+  DISTCHECK_CONFIGURE_FLAGS="--enable-success=yes sentence='it works :-)'"
+
+# Sanity check.
+$MAKE distcheck >output 2>&1 && { cat output; Exit 1; }
+cat output
+grep "^configure:.* success='no', sentence=''" output
+
+:
diff --git a/tests/distcheck-hook.test b/tests/distcheck-hook.test
new file mode 100755 (executable)
index 0000000..9a2c384
--- /dev/null
@@ -0,0 +1,53 @@
+#! /bin/sh
+# Copyright (C) 2011 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/>.
+
+# Check basic support for distcheck-hook.
+
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+distcheck-hook:
+       ls -l $(distdir)
+       chmod u+w $(distdir)
+       : > $(distdir)/dc-hook-has-run
+       chmod a-w $(distdir)
+check-local:
+       ls -l $(srcdir)
+       test -f $(srcdir)/dc-hook-has-run
+END
+
+$ACLOCAL
+$AUTOMAKE
+$FGREP 'distcheck-hook' Makefile.in
+$FGREP '$(MAKE) $(AM_MAKEFLAGS) distcheck-hook' Makefile.in
+grep '^distcheck-hook:' Makefile.in
+
+$AUTOCONF
+./configure
+
+$MAKE
+$MAKE check && Exit 1
+$MAKE distdir
+test -f $distdir/dc-hook-has-run && Exit 1
+$MAKE distcheck
+
+:
diff --git a/tests/distcheck-hook2.test b/tests/distcheck-hook2.test
new file mode 100755 (executable)
index 0000000..befc1d6
--- /dev/null
@@ -0,0 +1,81 @@
+#! /bin/sh
+# Copyright (C) 2011 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/>.
+
+# Check that no 'distcheck-hook' target is created automatically by
+# Automake, and that a used-defined 'distcheck-hook' is *not* honored
+# in a subpackage Makefile.am.
+
+. ./defs || Exit 1
+
+set -e
+
+cat >> configure.in << 'END'
+AC_CONFIG_SUBDIRS([subpkg])
+AC_OUTPUT
+END
+
+mkdir subpkg
+
+cat > subpkg/configure.in << 'END'
+AC_INIT([subpkg], [1.0])
+AM_INIT_AUTOMAKE
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
+END
+
+cat > Makefile.am <<'END'
+distcheck-hook:
+       ls -l $(distdir)
+       chmod u+w $(distdir)
+       : > $(distdir)/dc-hook-has-run
+       chmod a-w $(distdir)
+check-local:
+       ls -l $(srcdir)
+       test -f $(srcdir)/dc-hook-has-run
+END
+
+cat > subpkg/Makefile.am <<'END'
+check-local:
+       ls -l $(srcdir)
+       test ! -r $(srcdir)/dc-hook-has-run
+END
+
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+cd subpkg
+$ACLOCAL
+$AUTOMAKE
+$AUTOCONF
+cd ..
+
+# For debugging.
+$FGREP 'distcheck-hook' Makefile.in subpkg/Makefile.in
+
+$FGREP 'distcheck-hook' subpkg/Makefile.in && Exit 1
+$FGREP '$(MAKE) $(AM_MAKEFLAGS) distcheck-hook' Makefile.in
+grep '^distcheck-hook:' Makefile.in
+
+./configure
+
+$MAKE
+$MAKE check && Exit 1
+cd subpkg
+$MAKE check
+cd ..
+$MAKE distcheck
+
+: