[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: execute commands in foreach loop
From: |
Mike Shal |
Subject: |
Re: execute commands in foreach loop |
Date: |
Thu, 23 Jul 2009 09:37:49 -0400 |
On 7/23/09, Fritz Code <address@hidden> wrote:
> I've a problem with the following make foreach construct:
>
> $(foreach tobuild,$(shell cat file.dist | awk -F/ '{print $$1}'),
> $(call mymake,$(tobuild))
>
> define mymake
> $(MAKE) $1
> endef
>
It looks like you expect the $(foreach) to actually execute make on
each of the targets? You might just want to put that in the command
script for a default target, like so:
define mymake
$(MAKE) $1;
endef
all: ; $(foreach tobuild,$(shell cat file.dist | awk -F/ '{print
$$1}'),$(call mymake,$(tobuild)))
target1: ; @echo "Making target1"
target2: ; @echo "Making target2"
I made a file.dist file contain:
target1
target2
Note that in the Makefile, I added a ';' after the $(MAKE) $1 line so
it will run separate commands. Also I added another ')' after the
$(call) function to properly end the $(foreach) function.
Does that do what you want? Why do you want your targets in a separate
file.dist file? It would seem much simpler if you just used make and
did something like:
all: target1 target2
target1: ; @echo "Making target1"
target2: ; @echo "Making target2"
Maybe I'm completely misunderstanding what you're trying to accomplish.
-Mike