]> sourceware.org Git - automake.git/commitdiff
* automake.in (rule_define): Use $KNOWN_EXTENSIONS_PATTERN
authorAlexandre Duret-Lutz <adl@gnu.org>
Fri, 16 Nov 2001 10:30:15 +0000 (10:30 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Fri, 16 Nov 2001 10:30:15 +0000 (10:30 +0000)
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.

ChangeLog
automake.in
tests/Makefile.am
tests/Makefile.in
tests/suffix6.test [new file with mode: 0755]
tests/suffix7.test [new file with mode: 0755]

index 72746aa540904070cf8bebc9ecf20c6dfe07f5f8..b671ddf0a1a0909d61e3797ece24450aea301513 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+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): 
index 85a7416e89e849eea7a7acc423fbdb37942ab613..b15a96356802fb0e2b9a0c303d2e5f6ea5bf1b7e 100755 (executable)
@@ -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;
index 3dc3433d16bca4e4c25bde51dcb01bf703c687ed..a03a8668559e163cf74b59ec0348900dc21ddb4d 100644 (file)
@@ -292,6 +292,8 @@ suffix2.test \
 suffix3.test \
 suffix4.test \
 suffix5.test \
+suffix6.test \
+suffix7.test \
 symlink.test \
 symlink2.test \
 symlink3.test \
index cbdf2182dc66f16ee31632f79a46044cc1daf33f..4f97e86ae1cb6f15320128d775384917073dacd6 100644 (file)
@@ -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 (executable)
index 0000000..72bb2a1
--- /dev/null
@@ -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 (executable)
index 0000000..944f91f
--- /dev/null
@@ -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
This page took 0.0540310000000001 seconds and 5 git commands to generate.