Categories
Mastering Development

Strange behavior of makefile functions

im having issues with $(foreach..) and echo functions.
im trying to iterate over a variable and append it into a file.

here is my code:

vars = a b c d
all:
    @$(foreach var, $(vars), echo $(var) >> variables.txt)

the generated file looks like

a echo  b echo c echo d

i have no idea why it prints also the word "echo" and why it is on the same line.

Im working on Windows, on linux the results are as expected.

what am i missing here?

thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *