Matthias Guenther
Matthias Guenther

Reputation: 1683

makefile: how to call macros in macros

I have the following macros in my make file:


pdf: // do something

clean: // just another fancy thing


No I want to declare a macro all: which include (or call) the macros above. The following thing doesn't work:


all: pdf: clean:


I don't want to repeat the code from pdf: and clean: in order not to rebel against DRY principle.

Thanks for your help.

Upvotes: 0

Views: 853

Answers (3)

Larry Engholm
Larry Engholm

Reputation: 380

executing make without argument is same as calling make all.

That's not correct. The first normal target in the file is the default target. There's nothing magical about all, though it is conventional to use that as the first target.

Upvotes: 1

dimba
dimba

Reputation: 27641

You also can run:

make clean pdf

Any way, all is commonly used as a default make target - in other words executing make without argument is same as calling make all. This maybe very confusing for expirienced users, therefore if you want "such a shortcut", call it deferently (e.g. cpdf)

Upvotes: 0

Yann Ramin
Yann Ramin

Reputation: 33197

Those are not macros, they are targets.

Makefiles take the syntax of [target]: [dependent target 1] [dependent target 2]

Try:

all: pdf clean

Upvotes: 2

Related Questions