From: Alexandre Duret-Lutz Date: Fri, 16 Nov 2001 10:30:15 +0000 (+0000) Subject: * automake.in (rule_define): Use $KNOWN_EXTENSIONS_PATTERN X-Git-Tag: Release-1-5b~24 X-Git-Url: https://sourceware.org/git/?a=commitdiff_plain;h=72d0d13ab8151c01a12ef0bd644fcaa1eeffd7e8;p=automake.git * automake.in (rule_define): Use $KNOWN_EXTENSIONS_PATTERN to match suffix rules for known extensions, or call accept_extensions on suffixe rules for unknown extensions. (var_SUFFIXES_trigger): New function. (macro_define): Call var_VAR_trigger when $VAR is updated. * tests/suffix6.test, tests/suffix7.test: New files. * tests/Makefile.am (TESTS): Add suffix6.test and suffix7.test. --- diff --git a/ChangeLog b/ChangeLog index 72746aa5..b671ddf0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2001-11-16 Alexandre Duret-Lutz + + * automake.in (rule_define): Use $KNOWN_EXTENSIONS_PATTERN + to match suffix rules for known extensions, or call + accept_extensions on suffixe rules for unknown extensions. + (var_SUFFIXES_trigger): New function. + (macro_define): Call var_VAR_trigger when $VAR is updated. + * tests/suffix6.test, tests/suffix7.test: New files. + * tests/Makefile.am (TESTS): Add suffix6.test and suffix7.test. + 2001-11-16 Alexandre Duret-Lutz * automake.in (KNOWN_EXTENSIONS_PATTERN, known_extensions_list): diff --git a/automake.in b/automake.in index 85a7416e..b15a9635 100755 --- a/automake.in +++ b/automake.in @@ -1080,6 +1080,20 @@ sub accept_extensions (@) '(?:' . join ('|', map (quotemeta, @known_extensions_list)) . ')'; } +# var_SUFFIXES_trigger ($TYPE, $VALUE) +# ------------------------------------ +# This is called automagically by define_macro() when SUFFIXES +# is defined ($TYPE eq '') or appended ($TYPE eq '+'). +# The work here needs to be performed as a side-effect of the +# define_macro() call because SUFFIXES definitions impact +# on $KNOWN_EXTENSIONS_PATTERN, and $KNOWN_EXTENSIONS_PATTERN +# are used when parsing the input am file. +sub var_SUFFIXES_trigger ($$) +{ + my ($type, $value) = @_; + accept_extensions (split (' ', $value)); +} + ################################################################ # Parse command line. @@ -5777,6 +5791,13 @@ sub macro_define ($$$$$$) { $var_is_am{$var} = $var_is_am; } + + # Call var_VAR_trigger if it's defined. + # This hook helps to update some internal state *while* + # parsing the file. For instance the handling of SUFFIXES + # requires this (see var_SUFFIXES_trigger). + my $var_trigger = "var_${var}_trigger"; + &$var_trigger($type, $value) if defined &$var_trigger; } @@ -6590,13 +6611,24 @@ sub rule_define ($$$$) # Check the rule for being a suffix rule. If so, store in a hash. - - if ((my ($source_suffix, $object_suffix)) = ($target =~ $SUFFIX_RULE_PATTERN)) + # Either it's a rule for two known extensions... + if ($target =~ /^($KNOWN_EXTENSIONS_PATTERN)($KNOWN_EXTENSIONS_PATTERN)$/) + { + $suffix_rules{$1} = $2; + verbose "Sources ending in $1 become $2"; + push @suffixes, $1, $2; + } + # ...or it's a rule with unknown extensions (.i.e, the rule looks like + # `.foo.bar:' but `.foo' or `.bar' are not declared in SUFFIXES + # and are not known language extensions). + # Automake will complete SUFFIXES from @suffixes automatically + # (see handle_footer). + elsif ($target =~ /$SUFFIX_RULE_PATTERN/o) { - $suffix_rules{$source_suffix} = $object_suffix; - verbose "Sources ending in $source_suffix become $object_suffix"; - # Set SUFFIXES from suffix_rules. - push @suffixes, $source_suffix, $object_suffix; + $suffix_rules{$1} = $2; + verbose "Sources ending in $1 become $2"; + push @suffixes, $1, $2; + accept_extensions($1); } return 1; diff --git a/tests/Makefile.am b/tests/Makefile.am index 3dc3433d..a03a8668 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -292,6 +292,8 @@ suffix2.test \ suffix3.test \ suffix4.test \ suffix5.test \ +suffix6.test \ +suffix7.test \ symlink.test \ symlink2.test \ symlink3.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index cbdf2182..4f97e86a 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -365,6 +365,8 @@ suffix2.test \ suffix3.test \ suffix4.test \ suffix5.test \ +suffix6.test \ +suffix7.test \ symlink.test \ symlink2.test \ symlink3.test \ diff --git a/tests/suffix6.test b/tests/suffix6.test new file mode 100755 index 00000000..72bb2a1b --- /dev/null +++ b/tests/suffix6.test @@ -0,0 +1,26 @@ +#! /bin/sh + +# Test to make sure Automake supports implicit rules with dot-less +# extensions. + +. $srcdir/defs || exit 1 + +cat > Makefile.am << 'END' +SUFFIXES = a b .$(OBJEXT) +bin_PROGRAMS = foo +foo_SOURCES = fooa +ab: + cp $< $@ +b.$(OBJEXT): + cp $< $@ +END + +: > fooa + +$ACLOCAL || exit 1 +$AUTOMAKE || exit 1 + +# Automake must figure that fooa translates to foo.o using the +# following rules: +# fooa --[ab]--> foob --[b.$(OBJEXT)]--> foo.$(OBJEXT) +grep '_OBJECTS.*foo\.$(OBJEXT)' Makefile.in || exit 1 diff --git a/tests/suffix7.test b/tests/suffix7.test new file mode 100755 index 00000000..944f91f4 --- /dev/null +++ b/tests/suffix7.test @@ -0,0 +1,25 @@ +#! /bin/sh + +# Test to make sure Automake supports implicit rules "confusing" +# extensions. Inspired by a mail from Alex Hornby. + +. $srcdir/defs || exit 1 + +cat > Makefile.am << 'END' +SUFFIXES = .idl S.cpp C.h +SUFFIXES += C.cpp S.h +.idlC.cpp: + cp $< $@ +END + +: > fooa + +$ACLOCAL || exit 1 +$AUTOMAKE || exit 1 + +# Make sure Automake has NOT recognized .cpp and .idlC as two new +# extensions. +grep 'SUFFIXES.* \.cpp' Makefile.in && exit 1 +grep 'SUFFIXES.* \.idlC' Makefile.in && exit 1 + +exit 0