From 441ec0a6081852ccd02cf6c3e2515f4605a44f5a Mon Sep 17 00:00:00 2001 From: Ralf Wildenhues Date: Wed, 18 Jun 2008 00:16:25 +0200 Subject: [PATCH] Fix conditional rules competing with config.status rules. * automake.in (handle_configure): Teach targets about the conditional config.status rule. * tests/cond39.test: Adjust test to expose this. Signed-off-by: Ralf Wildenhues --- ChangeLog | 5 +++++ automake.in | 9 +++++++-- tests/cond39.test | 57 ++++++++++++++++++++++++++++++++++++++++++------------- 3 files changed, 56 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index 927437de0..0742b7582 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2008-06-18 Ralf Wildenhues + Fix conditional rules competing with config.status rules. + * automake.in (handle_configure): Teach targets about the + conditional config.status rule. + * tests/cond39.test: Adjust test to expose this. + For AC_CONFIG_LINKS(X,X), do not clean X in a non-VPATH build. * automake.in (rewrite_inputs_into_dependencies): Do distribute inputs where input and output name are equal. This relies on diff --git a/automake.in b/automake.in index dc431feeb..c49045fb9 100755 --- a/automake.in +++ b/automake.in @@ -4201,8 +4201,13 @@ sub handle_configure ($$$@) next if (substitute_ac_subst_variables $local) =~ /\$/; my $condstr = ''; - $condstr = $ac_config_files_condition{$lfile}->subst_string - if ($ac_config_files_condition{$lfile}); + my $cond = $ac_config_files_condition{$lfile}; + if (defined $cond) + { + $condstr = $cond->subst_string; + Automake::Rule::define ($local, $configure_ac, RULE_AUTOMAKE, $cond, + $ac_config_files_location{$file}); + } $output_rules .= ($condstr . $local . ': ' . '$(top_builddir)/config.status ' . "@rewritten_inputs\n" diff --git a/tests/cond39.test b/tests/cond39.test index 93f0363fd..1431ed11e 100755 --- a/tests/cond39.test +++ b/tests/cond39.test @@ -23,24 +23,44 @@ . ./defs set -e +mkdir sub + cat >>configure.in <<'END' AC_PROG_CC AM_CONDITIONAL([COND], [test "$COND" = true]) AM_COND_IF([COND], [], - [AC_CONFIG_FILES([prog], [chmod 755 prog])]) + [AC_CONFIG_FILES([prog1], [chmod 755 prog1]) + AC_CONFIG_FILES([sub/prog2], [chmod 755 sub/prog2])]) +AC_CONFIG_FILES([sub/Makefile]) AC_OUTPUT END cat >Makefile.am <<'END' +SUBDIRS = sub if COND -bin_PROGRAMS = prog -prog_SOURCES = prog.c +bin_PROGRAMS = prog1 +prog1_SOURCES = prog.c else -# FIXME: the next line is still needed to get automake to output the -# bin_PROGRAMS above in the right condition only. -prog: -bin_SCRIPTS = prog -CLEANFILES = prog +bin_SCRIPTS = prog1 +CLEANFILES = prog1 +endif + +sure-exist: + test -f prog1 || test -f prog1$(EXEEXT) + test -f sub/prog2 || test -f sub/prog2$(EXEEXT) + +sure-not-exist: + test ! -f prog1 && test ! -f prog1$(EXEEXT) + test ! -f sub/prog2 && test ! -f sub/prog2$(EXEEXT) +END + +cat >sub/Makefile.am <<'END' +if COND +bin_PROGRAMS = prog2 +prog2_SOURCES = prog.c +else +bin_SCRIPTS = prog2 +CLEANFILES = prog2 endif END @@ -48,12 +68,15 @@ cat >prog.c <<'END' int main () { return 42; } END -cat >prog.in <<'END' +cat >prog1.in <<'END' #! /bin/sh bindir='@bindir@' echo "hi, this is $0, and bindir is $bindir" END +cp prog.c sub +cp prog1.in sub/prog2.in + $ACLOCAL $AUTOCONF $AUTOMAKE --add-missing @@ -62,17 +85,25 @@ $AUTOMAKE --add-missing $MAKE 2>stderr cat stderr grep 'overriding commands' stderr && exit 1 -./prog && exit 1 +$MAKE sure-exist +./prog1 && exit 1 +./sub/prog2 && exit 1 $MAKE clean +$MAKE sure-not-exist $MAKE -./prog && exit 1 +$MAKE sure-exist +./prog1 && exit 1 +./sub/prog2 && exit 1 $MAKE distclean ./configure COND=false $MAKE 2>stderr cat stderr grep 'overriding commands' stderr && exit 1 -./prog +./prog1 +./sub/prog2 $MAKE clean +$MAKE sure-not-exist $MAKE -./prog +./prog1 +./sub/prog2 -- 2.11.4.GIT