help-make
[Top][All Lists]
Advanced

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

creating a chain which has an explicit target rule


From: Fithian, Craig [IT]
Subject: creating a chain which has an explicit target rule
Date: Tue, 11 Jan 2005 16:13:11 -0500

I would like to create a makefile that has an explicit rule for generating a C 
source file and then uses a general pattern rule for compiling the source file. 
  The following seems like it should work (and does with other versions of 
make).   Unfortunately it doesn't  work with gnu make - make claims it does not 
know how to make odir/file.o (it ignores the pattern rule given because 
gsrcdir/file.c does not exist initially).

default: odir/file.o

gsrcdir/file.c: input.l 
        generate_file < input.l > $@

odir/%.o: gsrcdir/%.c
        cc -c $< -o $@

If I replace the gsrcdir/file.c target above with a pattern rule (e.g. 
gsdir/%.c: %.l), make is able to chain the two rules together to make 
odir/file.o.  Gnu make does not seem to recognize a chain unless all the 
components are pattern rules.   Unfortunately, it is not natural to use a 
pattern rule in my case.   Does anyone know why gnu make does not support mixed 
explicit/implicit chains (it seems entirely consistent with having explicit 
rules overriding implicit rules in the same makefile)?  Even better, can 
someone suggest a construct that provides the behavior I want?   Thanks




reply via email to

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