From: Stefano Lattarini Date: Fri, 10 Jun 2011 10:26:42 +0000 (+0200) Subject: distcheck: add support for AM_DISTCHECK_CONFIGURE_FLAGS X-Git-Tag: v1.11.1b~26^2~23^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=976003923e43d17985a776f82cf8168e8741f7de;p=thirdparty%2Fautomake.git 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#8487. --- diff --git a/ChangeLog b/ChangeLog index cb9918fc2..1a11eb226 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,28 @@ +2011-06-10 Stefano Lattarini + + 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 maintcheck: fix some failures, extend some checks diff --git a/Makefile.in b/Makefile.in index d0951e06b..d6743e47a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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 \ diff --git a/doc/automake.texi b/doc/automake.texi index 3846e0d6d..b3aecfca0 100644 --- a/doc/automake.texi +++ b/doc/automake.texi @@ -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 diff --git a/lib/am/distdir.am b/lib/am/distdir.am index e0f3bce60..c2dd7c55a 100644 --- a/lib/am/distdir.am +++ b/lib/am/distdir.am @@ -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 \ diff --git a/tests/Makefile.am b/tests/Makefile.am index 33ae8bc62..42a88139a 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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 \ diff --git a/tests/Makefile.in b/tests/Makefile.in index d7a1761c3..664ecaa53 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -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 \ diff --git a/tests/defs.in b/tests/defs.in index 87a350dad..32fba30e8 100644 --- a/tests/defs.in +++ b/tests/defs.in @@ -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 index 000000000..a5cab6a50 --- /dev/null +++ b/tests/distcheck-configure-flags-am.test @@ -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 . + +# 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 index 000000000..695b47c19 --- /dev/null +++ b/tests/distcheck-configure-flags-subpkg.test @@ -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 . + +# 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 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 index 000000000..117d83c0e --- /dev/null +++ b/tests/distcheck-configure-flags.test @@ -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 . + +# 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 index 000000000..9a2c384ad --- /dev/null +++ b/tests/distcheck-hook.test @@ -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 . + +# 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 index 000000000..befc1d63c --- /dev/null +++ b/tests/distcheck-hook2.test @@ -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 . + +# 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 + +: