mrc0der
mrc0der

Reputation: 115

Master makefile which runs make files in subdirectories

How do I go about creating a makefile that will launch all the make files in all the sub-directories. Is it possible run "make" on the main directory for the main makefile, which will automatically trigger the makes for the sub-directories?

example:

/makefile   (this is the main makefile)
/subdirectory1/makefile
/subdirectory1/various .c/.h files compiled by the makefile in this directory
/subdirectory2/makefile
/subdirectory2/various .c/.h files compiled by the makefile in this directory
/subdirectory3/makefile
/subdirectory3/various .c/.h files compiled by the makefile in this directory

Upvotes: 1

Views: 1426

Answers (1)

Beta
Beta

Reputation: 99124

Yes, it's pretty straightforward. In the main makefile:

all:
    $(MAKE) -C subdirectory1
    $(MAKE) -C subdirectory2
    $(MAKE) -C subdirectory3

There are more sophisticated variations, once you have this down.

Upvotes: 3

Related Questions