automake-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

3-dot-less-suffix-rules.patch


From: Alexandre Duret-Lutz
Subject: 3-dot-less-suffix-rules.patch
Date: Tue, 13 Nov 2001 22:05:54 +0100

You may note some ressemblance between 
http://mail.gnu.org/pipermail/automake-patches/2001-November/000431.html
and tests/suffix7.test.

The old Automake generates 
.SUFFIXES: .idl S.cpp C.h C.cpp S.h .cpp .idlC
for suffix7.test.  With this patch you get
.SUFFIXES: .idl S.cpp C.h C.cpp S.h
which is cleaner.

Index: ChangeLog
--- ChangeLog
+++ ChangeLog
@@ -1,1 +1,11 @@
+2001-11-13  Alexandre Duret-Lutz  <address@hidden>
+
+       * 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.
+

Index: automake.in
===================================================================
RCS file: /home/adl/CVSROOT/automake-20011109-2037/automake.in,v
retrieving revision 1.3
diff -u -r1.3 automake.in
--- automake.in 12 Nov 2001 20:32:30 -0000      1.3
+++ automake.in 13 Nov 2001 19:54:27 -0000
@@ -1086,6 +1086,21 @@
     }
 }
 
+# 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));
+    print "$KNOWN_EXTENSIONS_PATTERN\n";
+}
+
 ################################################################
 
 # Parse command line.
@@ -5783,6 +5798,13 @@
     {
       $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;
 }
 
 
@@ -6596,13 +6618,24 @@
 
 
   # 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: tests/Makefile.am
===================================================================
RCS file: /home/adl/CVSROOT/automake-20011109-2037/tests/Makefile.am,v
retrieving revision 1.1
diff -u -r1.1 Makefile.am
--- tests/Makefile.am   9 Nov 2001 19:38:06 -0000       1.1
+++ tests/Makefile.am   13 Nov 2001 20:16:28 -0000
@@ -292,6 +292,8 @@
 suffix3.test \
 suffix4.test \
 suffix5.test \
+suffix6.test \
+suffix7.test \
 symlink.test \
 symlink2.test \
 symlink3.test \
Index: tests/Makefile.in
===================================================================
RCS file: /home/adl/CVSROOT/automake-20011109-2037/tests/Makefile.in,v
retrieving revision 1.1
diff -u -r1.1 Makefile.in
--- tests/Makefile.in   9 Nov 2001 19:38:06 -0000       1.1
+++ tests/Makefile.in   13 Nov 2001 20:16:31 -0000
@@ -365,6 +365,8 @@
 suffix3.test \
 suffix4.test \
 suffix5.test \
+suffix6.test \
+suffix7.test \
 symlink.test \
 symlink2.test \
 symlink3.test \
Index: tests/suffix6.test
===================================================================
RCS file: tests/suffix6.test
diff -N tests/suffix6.test
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ tests/suffix6.test  13 Nov 2001 19:41:47 -0000
@@ -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
Index: tests/suffix7.test
===================================================================
RCS file: tests/suffix7.test
diff -N tests/suffix7.test
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ tests/suffix7.test  13 Nov 2001 20:29:21 -0000
@@ -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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]