The top half of this snippet was provided only for clarity, it's the last
line that I'm unsure if there is an issue with, if there's not then I will
try at the GCC mailing list. If you need it then here's the breakdown of
On Mon, 2016-07-25 at 18:47 +0100, Lee Shallis wrote:
> I don't know whether this is because of the way I used foreach or
> whether it is because of the way I used gcc so I'm going to start
> with the snippet involving my foreach statement:
> GNUmakefile:46: *** missing separator. Stop.
> ERROR: Command `%make% test` exited with status code 2.
> The last 2 lines are why I'm trying here first
Well, the best thing is to look at the content of the GNUmakefile line
46 and see what's there, since that's what the error is.
Certainly there's not much help we can give you with what you've
provided to us: you don't show the values of any of the variables
you're using, you don't show which lines make is actually complaining
about. You didn't even tell us which version of GNU make you're using
or what operating system you're using. I can infer it's Windows based
on the drive letters in your path names, but in that case we'd need to
know how you built GNU make (it it from cygwin? MinGW32? DOS?
Prebuilt from Eli's repository? Special options? etc.)
If you provide that detail, and a small, self-contained reproduce case
or at least show exactly which lines of the makefile generate the error
and what the value of the variables used in that line are, then we
might be able to help more.
The issue is that the evaluation of TEST_MACRO produced a non-empty string
consisting of whitespace. Once make begins evaluating a line as in my
example it assumes you're going to do something on that line, but what it
gets back is something it cannot interpret as a valid makefile directive.
You can resolve this problem by wrapping the foreach in a $(strip):
On Wed, 2016-07-27 at 11:26 -0600, Brian Vandenberg wrote:
> Fortunately this is rather easy to reproduce without foreach:
> > $ cat /tmp/makefile
> > define TEST_MACRO =
> > $(eval a=b)
> > $(eval a=b)
> > endef
> > $(call TEST_MACRO)
> > $ make -f /tmp/makefile
> > /tmp/makefile:8: *** missing separator. Stop.
> The issue is that the evaluation of TEST_MACRO produced a non-empty
> string consisting of whitespace.
Ah. It's even simpler to reproduce:
(note that's two blank lines in the define)
It's not whitespace per se, it's the newline. Just using spaces alone
won't cause a problem. This probably SHOULD be considered a bug in
make; it should be able to ignore blank lines in this context just like
> You can resolve this problem by wrapping the foreach in a $(strip):
> > $(strip $(foreach ...))
Yes, and also you can just write:
TEST_MACRO = $(eval a=a) $(eval b=b)
(you don't need define/endef for this) which also ensures there are no
newlines in the content of TEST_MACRO.
You all realise I already posted that I fixed the issue with a eval wrapper
right? As for which version of make I'm using if you look at the output
you'll notice the path mentions mingw64, that's what I'm using at the
moment though I'll test with cygwin later.
Help-make mailing list
[hidden email] https://lists.gnu.org/mailman/listinfo/help-make