vinoth kumar
vinoth kumar

Reputation: 323

what is meaning of export in multiple-line variable

What is the meaning of export in this multiple-line variable?

In this example even i command export foo or not, the output is 'welcome'.

define foo  
echo welcome
endef
export foo
all:
      @$(foo)

Upvotes: 0

Views: 94

Answers (1)

sujin
sujin

Reputation: 2853

Variable values of the top-level make can be passed to the sub-make(sub directory makefile) through the environment by explicit request. These variables are defined in the sub-make as defaults.

The special variables SHELL and MAKEFLAGS are always exported (unless you unexport them).

If you want to export specific variables to a sub-make, use the export directive, like this:

export variable

If you want to prevent a variable from being exported, use the unexport directive, like this:

unexport variable

Upvotes: 1

Related Questions