howard@cyb-eng.UUCP (Howard Johnson) (03/15/85)
The problem with Mr. Bergan's makefile stems from the evaluation of the .SUFFIXES dependencies. His goal was to have a preprocessor perform some transformation on his source code and produce C code (presumably "cat" is for illustration). The solution: .SUFFIXES: .qc mtest: mtest.o $(CC) -o $@ mtest.o .qc.o: cat $< > $*.c $(CC) $(CFLAGS) -c $*.c .qc.c: # optional rule so "make mtest.c" works cat $< > $*.c The problem with Mr. Bergan's first example is discussed below: > .SUFFIXES: .qc > > .qc.c: > cat $< >mtest.c > > mtest: mtest.o > cc -o mtest mtest.o First, "make mtest" is invoked. Unless a .SUFFIXES: dependency with nothing after the colon is given (to clear default dependencies), the .qc suffix is appended to a default list producing something like: .SUFFIXES: .o .c .e .r .f .y .yr .ye .l .s .qc "mtest" depends on "mtest.o". Since there are no explicit dependencies for mtest.o, the .SUFFIXES list is scanned. Note that the first suffix which has an implicit dependency for .o is .c. Several other implicit dependency rules are found, but none of them have the inferred prerequisites either. (This includes the .qc prerequisite, since there is no .qc.o rule.) Hence, *make* gives up, complaining that (most likely) the prerequisite mtest.c file is missing. Mr. Bergan's quick fix (including the explicit "mtest.o: mtest.c" dependency) works because it forces make to match the .SUFFIX dependencies for a .qc.c rule. After wading through a few 10-page makefiles, one soon has motivation to learn about details such as this. -- Howard Johnson Cyb Systems, Austin, TX cyb-eng!howard@ut-sally.ARPA or ..!{gatech,harvard,ihnp4,nbires,seismo,ucb-vax}!ut-sally!cyb-eng!howard