I'd like to propose the patch below to put any $(SUFFIXES) from
Makefile.am at the head of the .SUFFIXES list in Makefile.in.

This would help a certain situation in GMP where either a foo.c or
foo.s is used, according to the configured target.  With the whole
.SUFFIXES list sorted, .c is before .s and the ansi2knr rules cause
'make' to want foo.c even if foo.s exists and foo.c doesn't.

In general this change would make it possible to force the suffixes
order should that be necessary.  I think having $(SUFFIXES) at the
start (as opposed to the end say) of .SUFFIXES is sensible, since new
suffixes are likely to be sources wanting preprocessing or the like,
rather than new object file types.

If adopted, the following few words might be good for the end of the
suffixes section in the manual.

      Any given @code{SUFFIXES} go at the start of the generated
      suffixes list, followed by automake generated suffixes not
      already in the list.


--- automake.in.old	Sun Nov  5 08:17:45 2000
+++ automake.in	Sun Nov  5 08:23:11 2000
@@ -3663,13 +3663,6 @@
 	$output_vars .= "\n";
     }
 
-    if (&variable_defined ('SUFFIXES'))
-    {
-	# Push actual suffixes, and not $(SUFFIXES).  Some versions of
-	# make do not like variable substitutions on the .SUFFIXES
-	# line.
-	push (@suffixes, &variable_value_as_list ('SUFFIXES', ''));
-    }
     if (&target_defined ('.SUFFIXES'))
     {
 	&am_line_error ('.SUFFIXES',
@@ -3683,13 +3676,22 @@
     if (@suffixes)
     {
 	# Make sure suffixes has unique elements.  Sort them to ensure
-	# the output remains consistent.
+	# the output remains consistent.  $(SUFFIXES) is always at the
+	# start of the list, unsorted.
+	#
+	# Push actual suffixes, and not $(SUFFIXES).  Some versions of
+	# make do not like variable substitutions on the .SUFFIXES
+	# line.
+
 	local (%suffixes);
+	local (@user_suffixes) = &variable_defined ('SUFFIXES')
+	    ? variable_value_as_list ('SUFFIXES', '') : ();
 
 	grep ($suffixes{$_} = 1, @suffixes);
+	delete @suffixes{@user_suffixes};
 
 	$output_header .= (".SUFFIXES: "
-			   . join (' ', sort keys %suffixes)
+			   . join (' ', @user_suffixes, sort keys %suffixes)
 			   . "\n");
     }
     $output_trailer .= &file_contents ('footer');

Reply via email to