help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to expand computed variable names within for script command?


From: Paul Smith
Subject: Re: How to expand computed variable names within for script command?
Date: Mon, 27 Jul 2015 13:59:02 -0400

On Mon, 2015-07-27 at 12:47 -0500, Larry Evans wrote:
> How should the which command within the for loop script be
> modified to produce the same output as the which command
> before the for loop script?

The recipe is run by the shell, not by make.  Make simply expands the
make variables and functions one time before the shell is started, then
sends the results to the shell to be run, then waits for the exit code
to see if it worked.  The shell, being a separate shell process, cannot
access make's database of variables.  So, you cannot write a _shell_
loop that uses _make_ computed variables.

If you want to use make variables, you have to use a make loop via
$(foreach ...) or similar.

compiles:
        make -version
        @echo "COMPILE.gcc=" $(COMPILE.gcc)
        which $(COMPILE.gcc)
        for HOW_CXX in $(foreach C,gcc,$(COMPILE.$C)) ; do \
          which $$HOW_CXX ; \
        done ;




reply via email to

[Prev in Thread] Current Thread [Next in Thread]