Reputation: 903
I wrote a script that takes in two files ending in .cfg and outputs a file ending in .cmp. I want to include this in my Makefile because a few source code files depend on this .cmp file.
In my Makefile, I want to do this:
%.cmp: %.cfg $(dir %)/default.cfg
./compare.pl $^ $@
There are two dependencies to generate the .cmp file. First is a .cfg file with the same name, and second is a .cfg file which is always named default. Both .cfg files and the output .cmp file will be in the same directory.
Is there a way to grab the directory path of the target and use it with the prereqs?
Upvotes: 4
Views: 2236
Reputation: 25483
I guess Secondary Expansion is probably what you're looking for:
.SECONDEXPANSION:
%.cmp: %.cfg $$(dir %)default.cfg
./compare.pl $^ $@
Also note the absence of slash after $$(dir %)
, dir
function always append one to the resulting value.
Upvotes: 4