If I have a list of n commands, c = c1 ... cn, how can I execute them in order for a given target? I tried the foreach construct
$(foreach x,$(c),./$(x))
but that puts all the commands on one line. Any clues?
First, put a { on its own line. Then, insert your commands. Then, put a } on a new line and press Enter . Your commands will be executed.
We can run all scripts in a directory or path using "run-parts" command. The run-parts command is used to run scripts or programs in a directory or path.
You identified the problem (“but that puts all the commands on one line”). You just need to append a newline whenever you expand $x
in your loop.
define \n
endef
Now simply use $(foreach x,$c,./$(x)${\n})
in your recipe.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With