Alex Rivera | Logout

Creating nested makefile

Asked 2009-04-07T03:42:22.130
16

I am learning makefiles and I know how to create a simple makefile. I am moving on to nested makefiles. Here is my directory structure

/src
...makefile
...main.cpp
...foo
......makefile
......foo.cpp
......foo.h

When root makefile is called, it calls the makefile in directory foo. Here are my questions

  1. Which makefile should I use to write code for linking all object files? If it is in the root makefile, do I need to specify all object file names there?
  2. Is this nested makefiles a best practice? Or is it good to have only one makefile which is at root?

Any help would be great!

Edit
Report

1 Answer

3

Recursive make is generally considered harmful.

If you really want to be able to type "make" in the root dir and have it build everything using only POSIX makefiles, it is the only way. In that case, link the subprojects in their own directory, and final stuff together in root.

If you're willing to use gmake syntax, take a look at the Makefiles here: http://github.com/singpolyma/theveeb-ecosystem

answered 2009-04-07T03:48:02.817

Your Answer