On 2011-02-27 5:10, [email protected] wrote:
Thank you so much, Luke. You've revealed this great trick just in time,
about which GNU make manual does not say. Correct me if it does say.

On Sat, 26 Feb 2011 21:23:15 -0500, Luke Shumaker<[email protected]>
wrote:
The trick is to get the different commands on different lines.  Try
this:

define _ExecuteShcmdArray
$(foreach c,$1,@$($c)
)
endef

shellcmd1 = cd .. ; pwd
shellcmd2 = cd .. ; pwd

all:
        $(call _ExecuteShcmdArray,shellcmd1 shellcmd2)
This seems VERY tricky!

I simply wrote your function as recursively expanded variable
with command invoked in separate shells (e.g. '(echo 1);(echo 2);' ):

_ExecuteShcmdArray = $(foreach c,$1,($($c));)

So in addition to

shellcmd1 = cd .. ; pwd
shellcmd2 = cd .. ; pwd

all:
        $(call _ExecuteShcmdArray,shellcmd1 shellcmd2)

it evaluated as expected:

  $ make
(cd .. ; pwd); (cd .. ; pwd);
/cygdrive/e/home/devel
/cygdrive/e/home/devel

You can put @ before call to suppress printing of command.

Question to GNU Make GURU: 'foreach' with newline in 'define'
documented behavior?

--
Best regards!


_______________________________________________
Help-make mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/help-make

Reply via email to