Makefile Rules and If Statements -- How? Makefile Rules and If Statements -- How? unix unix

Makefile Rules and If Statements -- How?


You're just missing some parentheses:

ifeq ($(TOOL), toolA)...

P.S. You can make the conditional a little tighter (and remove a little redundancy):

ci:ifeq ($(TOOL), toolA)    [syntax for tool (A)]else    [syntax for tool (B)endif


Usually, you do that with a macro:

  # put tool A or tool B command line here  TOOL=...  ci:       $(TOOL) args

That can be extended with something like a TOOLARGS macro, so something like

  ci:       $(TOOL) $(TOOLARGS)

Then you can modify the makefile, or put the macros on the command line

  $ make TOOL=... TOOLARGS=...

If you want to encapsulate it, you could use an if to set the arguments.


Try this:

TOOLARGS_toolA = -a1 -a2TOOLARGS_toolB = -b1 -b2ci:        $(TOOL) $(TOOLARGS_$(TOOL))

Now if TOOL is toolA it will use the args -a1 -a2, and if TOOL is toolB then it will use the args -b1 -b2.