Reputation:
I've create this simple makefile and I want to run all the process witn make
while do that it run only the first section module1
and not module2
,
what am I missing here ?
.PHONY: module1
module1:
@echo "run module 1"
DIR=$(PWD)
@echo $(DIR)
.PHONY: module2
module2:
@echo "run module2"
if I run make module2
the module2 is executed successfully but I want all to be run in the make
command and as far as I read in the net this is how it should work, what was wrong here ?
Upvotes: 0
Views: 509
Reputation: 12879
From the documentation...
By default, the goal is the first target in the makefile (not counting targets that start with a period). Therefore, makefiles are usually written so that the first target is for compiling the entire program or programs they describe. If the first rule in the makefile has several targets, only the first target in the rule becomes the default goal, not the whole list. You can manage the selection of the default goal from within your makefile using the .DEFAULT_GOAL variable (see Other Special Variables).
So you just need to provide a suitable default target -- all
is `traditional'...
all: module1 module2
So the complete makefile
would be...
all: module1 module2
.PHONY: module1
module1:
@echo "run module 1"
DIR=$(PWD)
@echo $(DIR)
.PHONY: module2
module2:
@echo "run module2"
Upvotes: 2