eric@osiris.UUCP (Eric Bergan) (03/13/85)
I seem to have run into a strange "make" problem involving user defined suffixes. I started with a makefile: .SUFFIXES: .qc .qc.c: cat $< >mtest.c mtest: mtest.o cc -o mtest mtest.o and a file "mtest.qc". If I say "make mtest" - it comes back "don't know how to make mtest.o". However if I do "make mtest.c" and then "make mtest" it works fine. If I change the makefile to: .SUFFIXES: .qc .qc.c: cat $< >mtest.c mtest: mtest.o cc -o mtest mtest.o mtest.o: mtest.c and the only file is "mtest.qc", and I do a "make mtest", it works fine. This happens under both 4.2 and System V. Has anyone gotten user defined suffixes to work correctly? -- eric ...!seismo!umcp-cs!aplvax!osiris!eric
gdsd1@homxb.UUCP (M.LAI) (03/15/85)
[munch munch] > I seem to have run into a strange "make" problem involving user > defined suffixes. I started with a makefile: > > .SUFFIXES: .qc > > .qc.c: > cat $< >mtest.c > > mtest: mtest.o > cc -o mtest mtest.o > > and a file "mtest.qc". If I say "make mtest" - it comes back "don't know > how to make mtest.o". However if I do "make mtest.c" and then "make mtest" > it works fine. Try: .SUFFIXES: .qc .qc: cat $< > $(?:.qc=.c) $(CC) $(CFLAGS) -o $@ $(?:.qc=.c) @rm $(?:.qc=.c) and you won't need to specify any dependencies. Just: $ make mtest cat mtest.qc > mtest.c cc -O -o mtest mtest.c Neal Nuckolls ..!houxa!homxb!gdsd1
greg@ncr-tp.UUCP (Greg Noel) (03/19/85)
In article <177@osiris.UUCP> eric@osiris.UUCP (Eric Bergan) writes: >......................................... Has anyone gotten user defined >suffixes to work correctly? Er, I don't know how to break this to you, but make is working exactly as advertised; it is your makefile that is not correct. The thing you need to understand is that make will take no leaps of faith in finding the files it needs -- in other words, it won't chain rules together. In particular, the fragment: > mtest: mtest.o > cc -o mtest mtest.o says that mtest depends upon mtest.o -- a reasonable thing. Since mtest.o does not exist, make now tries to find a way to make it. It does this by searching for a rule of the form ".XXX.o" for which mtest.XXX \already/ \exists/. It can't find it, hence it says "don't know how to make mtest.o". > However if I do "make mtest.c" and then "make mtest" it works fine. Yep -- it knows how to convert mtest.qc into mtest.c using the rule you have given and it knows how to convert mtest.c into mtest.o using the built-in rule, but it won't chain the rules. If you think about it, this is a reasonable restriction: suppose you have the rules .y.c, .y.s, .c.o, and .s.o and you want to convert xx.y into xx.o -- there are two possible paths (.y => .c => .o and .y => .s => .o) and it couldn't chose between them. > If I change the makefile to: > > [ same as before ] > > mtest.o: mtest.c > >and the only file is "mtest.qc", and I do a "make mtest", it works fine. Again true -- this time you have given make an explicit dependancy so that make knows that it must create mtest.c, so it searchs to find a rule .XXX.c for which a file mtest.XXX already exists; it finds the rule .qc.c and the file mtest.qc. It then applies the rule, making mtest.c, and then tries to make mtest.o again. Since you didn't give any specific actions for making mtest.o, it applies the search rules again, looking for a rule .XXX.o and a file mtest.XXX; this time it finds .c.o and mtest.c. (Just because you said you needed it doesn't mean that make will use it -- if you had a mtest.s in the directory (and the .SUFFIXES were in a slightly different order), this makefile would make mtest.c as you told it, but then it would make mtest.o by assembling mtest.s. It can be confusing at times......) To cause make to combine the rules in the way you want, you must explicitly tell it how. I.e., you must have a rule that goes from your special suffix all the way to the desired object: .SUFFIXES: .qc .qc.o: cat $< >$*.c $(CC) $(CFLAGS) -c $*.c rm -f $*.c Hope this helps. -- -- Greg Noel, NCR Torrey Pines Greg@ncr-tp.UUCP or Greg@nosc.ARPA