+2001-11-16 Alexandre Duret-Lutz <duret_g@epita.fr>
+
+ * 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 <duret_g@epita.fr>
* automake.in (KNOWN_EXTENSIONS_PATTERN, known_extensions_list):
'(?:' . 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.
{
$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;
}
# 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;
--- /dev/null
+#! /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