Reputation: 25782
I have a project with a directory structure like this:
╷ /
├ Makefile
├┐ dir1/
│├ foo.in
│└ foo.out
├┐ dir2/
┊┊
and the Makefile contains rules for all file in the project, e.g.
dir1/%.out: dir1/%.in
gen_out $< $@
If I am in the top level directory, I can run make dir1/foo.out
just fine.
The question is: What is the most elegant way that calling make foo.out
inside dir1
has the same effect?
Upvotes: 0
Views: 1454
Reputation: 508
You can do that easily with makepp. Just rename your Makefile to RootMakeppfile. This will be loaded first where ever you are in your tree.
Unlike traditional makes, makepp does not need to do recursive builds. So you can also put a Makefile into each directory, and makepp will load all the ones you need into one process. That way it has a consistent view of your whole project, and can detect and keep track of all dependencies.
Upvotes: 0
Reputation: 101081
Your choices are limited. You can use the -f ../Makefile
flag on the make
command line, maybe by writing a wrapper script around make
that will determine the current location and invoke it with the proper flags depending on where you are.
You can set the MAKEFILES
environment variable to contain the fully-qualified pathname of the makefile.
You can create a little mini-makefile in each directory which does nothing except re-invoke $(MAKE)
with the proper top-level makefile.
Upvotes: 1