Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you declare custom variable inside of make target?

Tags:

makefile

How do you define dynamic variables in a makefile target? For example:

all:
    VAR := $@
    @echo $(VAR)
like image 766
cmcginty Avatar asked Mar 16 '10 01:03

cmcginty


People also ask

How do I set an environment variable in makefile?

Re: Setting Environment variable in Makefile To get the shell to see one "$", you must use "$$" in the Makefile. 2.) Environment variables can only be inherited from parent to child processes, not vice versa. In this case, the parent process is the 'make' that is processing the Makefile.

What is := in makefile?

Expanded assignment = defines a recursively-expanded variable. := defines a simply-expanded variable.


1 Answers

I realize this is the correct way:

all: VAR = $@
all:
    @echo $(VAR)
like image 93
cmcginty Avatar answered Oct 11 '22 17:10

cmcginty