How to execute each command in the list?

If I have a list of n commands, c = c1 ... cn, how can I execute them for a given purpose? I tried the foreach construct

$(foreach x,$(c),./$(x))

but these are all commands on one line. Any clues?

+5
source share
2 answers

You have identified the problem ("but these are all commands on the same line"). You just need to add a new line when you expand $xin your loop.

define \n


endef

Now just use $(foreach x,$c,./$(x)${\n})in your recipe.

+8
source

If there is no need to verify success, add a semicolon:

$(foreach x,$c,./$(x);)

, , . make-:

define execute-command
$(1)

endef

execute-list:
        $(foreach x,$(c),$(call execute-command,./$(x)))
+5

All Articles