AymenTM
AymenTM

Reputation: 569

Makefile: Storing the Argument that comes after 'make' (i.e the 2nd command line argument) isn't Working

I'm trying to store the 2nd argument passed in command line (i.e the argument after make) in a variable called NAME, and then use it to do stuff. If there is no 2nd argument then NAME = a .

Why doesn't it work?

Here is a snippet from my Makefile:

NAME := $(shell $2)

ifeq ($(strip $(NAME)),)
    $(NAME) = a
endif


# ... and do other things with NAME

It gives me this error:

*** empty variable name. Stop

Upvotes: 0

Views: 449

Answers (1)

uzsolt
uzsolt

Reputation: 6027

You can't use $1 (and similar) in make.

The parameters of make are targets or options and can't access with $1.

The command make foo instructs make to create foo target. If you want pass parameters you can use make param=foo and can access in Makefile the ${param} variable (with value foo).

Upvotes: 2

Related Questions