From: Stefano Lattarini <stefano.lattar...@gmail.com> This change is useful only in view of soon-to-follow refactorings and simplifications, related to the fixing of Automake bug#7669 a.k.a. PR/547.
* automake.in (%am_remake_options): New global hash variable. (parse_arguments): Initialize it. (scan_autoconf_traces) [$macro eq 'AM_INIT_AUTOMAKE']: Update it. (handle_configure): Use it. * tests/remake-am-opts.test: New test. * tests/Makefile.am (TESTS): Update. --- ChangeLog | 13 +++ automake.in | 23 ++++- tests/Makefile.am | 1 + tests/Makefile.in | 1 + tests/remake-am-opts.test | 195 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 228 insertions(+), 5 deletions(-) create mode 100755 tests/remake-am-opts.test diff --git a/ChangeLog b/ChangeLog index 4985428..4bf9faa 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,18 @@ 2010-12-20 Stefano Lattarini <stefano.lattar...@gmail.com> + Refactoring: new $automake_remake_options global variable. + This change is useful only in view of soon-to-follow refactorings + and simplifications, related to the fixing of Automake bug#7669 + a.k.a. PR/547. + * automake.in (%am_remake_options): New global hash variable. + (parse_arguments): Initialize it. + (scan_autoconf_traces) [$macro eq 'AM_INIT_AUTOMAKE']: Update it. + (handle_configure): Use it. + * tests/remake-am-opts.test: New test. + * tests/Makefile.am (TESTS): Update. + +2010-12-20 Stefano Lattarini <stefano.lattar...@gmail.com> + Warnings win over strictness on command line. This change ensures that, on the command line at least, explicitly defined warnings always take precedence over implicit strictness diff --git a/automake.in b/automake.in index fd00369..9bef982 100644 --- a/automake.in +++ b/automake.in @@ -298,6 +298,9 @@ use constant QUEUE_STRING => "string"; ## Variables related to the options. ## ## ---------------------------------- ## +# Options to be passed to automake in the generated remake rules. +my %am_remake_options; + # TRUE if we should always generate Makefile.in. my $force_generation = 1; @@ -4263,9 +4266,9 @@ sub handle_configure ($$$@) push @configuredeps, '$(ACLOCAL_M4)' if -f 'aclocal.m4'; define_pretty_variable ('am__configure_deps', TRUE, INTERNAL, @configuredeps); - - my $automake_options = '--' . (global_option 'cygnus' ? 'cygnus' : $strictness_name) - . (global_option 'no-dependencies' ? ' --ignore-deps' : ''); + my $automake_options = '--' . $am_remake_options{strictness} + . ($am_remake_options{ignore_deps} ? + ' --ignore-deps' : ''); $output_rules .= file_contents ('configure', @@ -5460,9 +5463,16 @@ sub scan_autoconf_traces ($) } elsif (defined $args[1]) { + my @opts = split (' ', $args[1]); + foreach my $opt (@opts) + { + $am_remake_options{strictness} = $opt + if $opt =~ /^(cygnus|foreign|gnits|gnu)$/; + $am_remake_options{ignore_deps} = 1 + if $opt eq 'no-dependencies'; + } exit $exit_code - if (process_global_option_list ($where, - split (' ', $args[1]))); + if process_global_option_list ($where, @opts); } } elsif ($macro eq 'AM_MAINTAINER_MODE') @@ -8501,6 +8511,9 @@ sub parse_arguments () &parse_warnings('-W', $warning); } + $am_remake_options{strictness} = ($cygnus ? 'cygnus' : $strictness); + $am_remake_options{ignore_deps} = $ignore_deps; + return unless @ARGV; if ($ARGV[0] =~ /^-./) diff --git a/tests/Makefile.am b/tests/Makefile.am index 428011a..307cf5f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -754,6 +754,7 @@ remake10b.test \ remake10c.test \ remake11.test \ remake12.test \ +remake-am-opts.test \ regex.test \ regex-obsolete.test \ req.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index c0534ef..2e265c2 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -1017,6 +1017,7 @@ remake10b.test \ remake10c.test \ remake11.test \ remake12.test \ +remake-am-opts.test \ regex.test \ regex-obsolete.test \ req.test \ diff --git a/tests/remake-am-opts.test b/tests/remake-am-opts.test new file mode 100755 index 0000000..64312d5 --- /dev/null +++ b/tests/remake-am-opts.test @@ -0,0 +1,195 @@ +#! /bin/sh +# Copyright (C) 2010 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/>. + +# +# Test that remake rules calls automake with proper command-line +# options derived from options in AM_INIT_AUTOMAKE, or passed on +# the command line of the original invocation. +# +# NOTE: That just described above might not be a very smart semantic, +# after all. See this message related to automake bug #7673: +# <http://debbugs.gnu.org/cgi/bugreport.cgi?bug=7673#11> +# Update this testcase if the semantic is changed. +# + +. ./defs || Exit 1 + +set -e + +write_automake_wrapper () +{ + d='#' + strictness= + while test $# -gt 0; do + echo "info: process option $1" >&2 + case $1 in + -S) strictness=$2; shift 2;; + -I) d=' '; shift;; + *) Exit 99;; + esac + done + test -n "$strictness" || Exit 99 + cat <<END +#!$SHELL +seen_strictness=false +${d}seen_ignore_deps=false +while test \$# -gt 0; do + case \$1 in + --$strictness) seen_strictness=: ;; +$d --ignore-deps) seen_ignore_deps=: ;; + Makefile|./Makefile) ;; + *) echo "\$0: \$1: invalid argument" >&2; exit 1;; + esac + shift +done +\$seen_strictnrss || { + echo "\$0: option --$strictness not seen" >&2 + exit 1 +} +$d\$seen_ignore_deps || { +$d echo "\$0: option --ignore_deps not seen" >&2 +$d exit 1 +$d} +exit 0 +END +} + +write_automake_wrapper -S foreign -I > wrap-automake-I-foreign +write_automake_wrapper -S foreign > wrap-automake-foreign +write_automake_wrapper -S cygnus > wrap-automake-cygnus +write_automake_wrapper -S cygnus -I > wrap-automake-I-cygnus +write_automake_wrapper -S gnu > wrap-automake-gnu +chmod a+x wrap-automake-* + +# We need (almost) complete control over automake options. +AUTOMAKE=`(set $AUTOMAKE && echo $1)`' -Werror' || Exit 99 + +: > Makefile.am + +cwd=`pwd` || Exit 1 + +cat > configure.in <<END +AC_INIT([$me], [1.0]) +AM_INIT_AUTOMAKE([foreign no-dependencies]) +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT +END + +$ACLOCAL +$AUTOCONF +$AUTOMAKE +./configure + +for am_opt in -Wportability --gnu --gnits --include-deps; do + $AUTOMAKE $am_opt Makefile + ./config.status + $sleep + touch Makefile.am + AUTOMAKE="$cwd/wrap-automake-I-foreign" $MAKE -e Makefile >stdout \ + || { cat stdout; Exit 1; } + cat stdout + grep 'wrap-automake-I-foreign .*--foreign' stdout + grep 'wrap-automake-I-foreign .*--ignore-deps' stdout + grep ' -W' stdout && Exit 1 + grep '.*--gnu' stdout && Exit 1 + grep '.*--gnits' stdout && Exit 1 +done + +$MAKE maintainer-clean +rm -rf autom4te*.cache + +cat > configure.in <<END +AC_INIT([$me], [1.0]) +AM_INIT_AUTOMAKE([cygnus]) +AM_MAINTAINER_MODE dnl: required in cygnus mode +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT +END + +$ACLOCAL +$AUTOCONF +$AUTOMAKE +./configure --enable-maintainer-mode + +for am_opt in -Wall --gnu --foreign --include-deps; do + $AUTOMAKE $am_opt + ./config.status Makefile + $sleep + touch Makefile.am + AUTOMAKE="$cwd/wrap-automake-cygnus" $MAKE -e Makefile >stdout \ + || { cat stdout; Exit 1; } + cat stdout + grep 'wrap-automake-cygnus .*--cygnus' stdout + grep ' -W' stdout && Exit 1 + grep '.*--gnu' stdout && Exit 1 + grep '.*--foreign' stdout && Exit 1 + grep '.*--.*deps' stdout && Exit 1 +done + +$AUTOMAKE --ignore-deps Makefile +./config.status Makefile +$sleep +touch Makefile.am +AUTOMAKE="$cwd/wrap-automake-I-cygnus" $MAKE -e Makefile >stdout \ + || { cat stdout; Exit 1; } +cat stdout +grep 'wrap-automake-I-cygnus .*--cygnus' stdout +grep 'wrap-automake-I-cygnus .*--ignore-deps' stdout +grep ' -W' stdout && Exit 1 +grep '.*--gnu' stdout && Exit 1 +grep '.*--foreign' stdout && Exit 1 + +$MAKE maintainer-clean +rm -rf autom4te*.cache + +# Files required in gnu strictness. +touch README INSTALL NEWS AUTHORS ChangeLog COPYING + +cat > configure.in <<END +AC_INIT([$me], [1.0]) +AM_INIT_AUTOMAKE +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT +END + +$ACLOCAL +$AUTOCONF +$AUTOMAKE +./configure + +$sleep +touch Makefile.am +AUTOMAKE="$cwd/wrap-automake-gnu" $MAKE -e Makefile >stdout \ + || { cat stdout; Exit 1; } +grep 'wrap-automake-gnu .*--gnu' stdout +grep ' -W' stdout && Exit 1 +grep '.*--foreign' stdout && Exit 1 +grep '.*--.*deps' stdout && Exit 1 + +$AUTOMAKE --foreign +./config.status + +$sleep +touch Makefile.am +AUTOMAKE="$cwd/wrap-automake-foreign" $MAKE -e Makefile >stdout \ + || { cat stdout; Exit 1; } +cat stdout +grep 'wrap-automake-foreign .*--foreign' stdout +grep ' -W' stdout && Exit 1 +grep '.*--gnu' stdout && Exit 1 +grep '.*--.*deps' stdout && Exit 1 + +: -- 1.7.2.3