Bug 23328

Summary: make forgets about some .SUFFIXES sometimes
Product: Base System Reporter: David Wolfskill <dhw>
Component: binAssignee: Thomas Moestl <tmm>
Status: Closed FIXED    
Severity: Affects Only Me CC: jrj
Priority: Normal    
Version: 4.2-STABLE   
Hardware: Any   
OS: Any   

Description David Wolfskill 2000-12-06 16:30:01 UTC
	Certain contents of .SUFFIXES lines work normally, while slight
	modifications (including permutations of suffix entries) will
	cause "make" to "forget" how to handle files with certain
	suffixes.

Fix: 

Another circumvention appears to be to comment out the first
	(empty) ".SUFFIXES" line.

	Unfortunately, in a situation where the Makefile itself is
	generated by other tools (such as automake), one doesn't
	necessarily have enough control to avoid the behavior in
	question... which appears pretty bogus, regardless.
How-To-Repeat: 
	Create a test directory; copy in the following Makefile:

--------->%-------- cut here -----------------
.SUFFIXES:
# .SUFFIXES: .c .h .lo .o .obj .sh .pl
.SUFFIXES: .c .h .lo .o .obj .pl .sh

.sh:
	cat $< > $@
	chmod +x $@

.pl:
	cat $< > $@
	chmod +x $@

S=	jj.sh kk.pl
T=	jj kk

all:    jj kk

clean:
	rm -f ${T}

realclean:
	rm -f ${S} ${T}

test:
	touch ${S}
----------------- snip! --------%<---------

	First, "make test"; this should create jj.sh & kk.pl.

	Then "make -n all"; I get:

	cat jj.sh > jj
	chmod +x jj
	make: don't know how to make kk. Stop

	(I just used the -n so I don't need to clean so often.)

	Then un-comment the commented .SUFFIXES line (line #2), and
	comment out the 3rd .SUFFIXES line instead.  Re-do the "make -n
	all"; I get:

	cat jj.sh > jj
	chmod +x jj
	cat kk.pl > kk
	chmod +x kk

	

	Re-running the above tests under "script", with the "-d A"
	debugging flag, yields the following differences between the
	outputs:

--- bad	Wed Dec  6 08:13:34 2000
+++ good	Wed Dec  6 08:13:44 2000
@@ -1,4 +1,4 @@
-Script started on Wed Dec  6 08:12:32 2000
+Script started on Wed Dec  6 08:13:08 2000
 m1022069438[1]%	make -n -d A all
 Global:.MAKEFLAGS =  -n -d
 Global:.MAKEFLAGS =  -n -d A
@@ -234,11 +234,11 @@
 inserting .c(0)...at end of list
 inserting .o(3)...at end of list
 defining transformation from `.sh' to `'
-inserting .sh(6)...before .sh(22)
+inserting .sh(5)...already there
 inserting (0)...at end of list
 transformation .sh complete
 defining transformation from `.pl' to `'
-inserting .pl(5)...already there
+inserting .pl(6)...before .sh(22)
 inserting (0)...at end of list
 transformation .pl complete
 Global:S = jj.sh kk.pl
@@ -412,11 +412,11 @@
 #	To: 
 #	From: 
 #	Search Path: 
-# `.pl' [0] 
+# `.sh' [0] 
 #	To:  
 #	From: 
 #	Search Path: 
-# `.sh' [1] 
+# `.pl' [1] 
 #	To:  
 #	From: 
 #	Search Path: 
@@ -533,6 +533,8 @@
 adding suffix rules
 	trying jj.c...Searching for jj.c...failed.
 not there
+	trying jj.pl...Searching for jj.pl...failed.
+not there
 	trying jj.sh...Searching for jj.sh...in '.'
 got it
 jj:@ = jj
@@ -551,33 +553,42 @@
 jj:? = jj.sh
 cat jj.sh > jj
 chmod +x jj
-update time:  8:12:40 Dec 06, 2000
+update time:  8:13:14 Dec 06, 2000
 SuffFindDeps (kk)
 	No known suffix on kk. Using .NULL suffix
 adding suffix rules
 	trying kk.c...Searching for kk.c...failed.
 not there
-	trying kk.sh...Searching for kk.sh...failed.
-not there
-	trying kk.sh...Searching for kk.sh...failed.
-not there
-	trying kk.y...Searching for kk.y...failed.
-not there
-	trying kk.l...Searching for kk.l...failed.
-not there
+	trying kk.pl...Searching for kk.pl...in '.'
+got it
 kk:@ = kk
 kk:* = kk
-Searching for kk...failed.
-Examining kk...Searching for kk...failed.
-non-existent...non-existent and no sources...out-of-date.
-kk:? = 
-kk:> = 
-make: don't know how to make kk. Stop
+	applying .pl ->  to "kk"
+SuffFindDeps (kk.pl)
+kk.pl:@ = kk.pl
+kk.pl:* = kk
+Searching for kk.pl...in '.'
+kk.pl:@ = kk.pl
+kk.pl:* = kk
+kk:< = kk.pl
+Examining kk.pl...modified  7:26:56 Dec 06, 2000...up-to-date.
+Examining kk...non-existent...modified before source...out-of-date.
+kk:> = kk.pl
+kk:? = kk.pl
+cat kk.pl > kk
+chmod +x kk
+update time:  8:13:14 Dec 06, 2000
+Examining all...non-existent...modified before source...out-of-date.
+all:> = jj
+all:? = jj
+all:> = jj kk
+all:? = jj kk
+update time:  8:13:14 Dec 06, 2000
 #*** Input graph:
 #
 # *** MAIN TARGET ***
 # 2 unmade children
-# non-existent (maybe): aborted
+# last modified  8:13:14 Dec 06, 2000: made
 all             : jj kk 
 
 
@@ -610,6 +621,7 @@
 #	kk [kk]
 #	.END [.END]
 #	jj.sh [jj.sh]
+#	kk.pl [kk.pl]
 #*** Global Variables:
 .LIBS            = 
 .INCLUDES        = 
@@ -721,9 +733,9 @@
 #*** Command-line Variables:
 
 #*** Directory Cache:
-# Stats: 3 hits 14 misses 0 near misses 7 losers (30%)
+# Stats: 5 hits 9 misses 0 near misses 7 losers (41%)
 # directory            referenced	hits
-# .                             2	   2
+# .                             2	   4
 # /usr/share/mk                 1	   1
 
 #*** Suffixes:
@@ -747,11 +759,11 @@
 #	To: 
 #	From: 
 #	Search Path: 
-# `.pl' [0] 
+# `.sh' [2] 
 #	To:  
 #	From: 
 #	Search Path: 
-# `.sh' [5] 
+# `.pl' [5] 
 #	To:  
 #	From: 
 #	Search Path: 
@@ -860,4 +872,4 @@
 
 m1022069438[2]%	^Dexit
 
-Script done on Wed Dec  6 08:12:43 2000
+Script done on Wed Dec  6 08:13:17 2000
Comment 1 Johan Karlsson freebsd_committer freebsd_triage 2000-12-08 21:54:45 UTC
Responsible Changed
From-To: freebsd-bugs->will

Over to make maintainer.
Comment 2 David Wolfskill 2001-01-13 00:50:23 UTC
Please see http://www.FreeBSD.org/cgi/query-pr.cgi?pr=24102 for more
information and patches (for -CURRENT and -STABLE).
Comment 3 Thomas Moestl freebsd_committer freebsd_triage 2001-03-07 23:18:30 UTC
Responsible Changed
From-To: will->tmm

I'll take this over (with permission from will)
Comment 4 Thomas Moestl freebsd_committer freebsd_triage 2001-03-08 00:59:38 UTC
State Changed
From-To: open->closed

A fix for this was committed to -CURRENT