* Ralf Wildenhues wrote on Wed, Mar 26, 2008 at 12:14:00AM CET: > > I think I have a followup patch to address the FIXME.
This is to fix the other half of <http://gcc.gnu.org/ml/gcc-patches/2008-03/msg00941.html> <http://thread.gmane.org/gmane.comp.sysutils.automake.patches/3129>, namely to let automake detect and output a conditional config file rule also if the complementary conditions don't have a competing user-provided rule. This still isn't quite symmetric with how automake handles Makefile.am-provided targets, but that's on purpose: If you use AC_CONFIG_FILES in some AM_COND_IF condition, then the rebuild rule for that file will always be output under exactly that condition, no matter whether the Makefile.am contains, say, file: whatever under some condition, including unconditionally. This results from us throwing away the return value of Automake::Rule::define in the patch. In that sense, AM_COND_IF trumps conditions given in Makefile.am. This fact allows a smooth upgrade path for the classpath bug. :-) Applied, but still, comments are much appreciated. Cheers, Ralf 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. diff --git a/automake.in b/automake.in index dc431fe..c49045f 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 93f0363..1431ed1 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
