Hi

I am creating Makefile and it gives me following error

Makefile:124: *** unterminated call to function `foreach': missing `)'.  Stop.

The Makefile around line 124 is

.PHONY: popiso
popiso: isolinux_cfg $(foreach x,$(_$(country)_pops_roles), pop_iso_$(x))  $(isomedia)
        @echo $@
        @echo
        @echo allhostname $(allhostname)
        @echo
        @echo
        @echo allnetwork_setup $(allnetwork_setup)
        @sudo cp $(addsuffix .ks.cfg,$(allhostname)) $(isomedia)
        @sudo cp isolinux.cfg $(isomedia)/isolinux/
        @echo ready to make iso

$(_$(country)_pops_roles) gets expanded correctly and it calls pop_iso_XXXX 4 times as it suppose to.
And then it gives above mentioned error.

I'm using RHEL6 - 64bit machine
I'm not that deep into Makefile/Gmake, and so I'm not sure what's the issue.

Hemanshu

Dani AI

Generated

This error is raised while GNU make is parsing, not when the shell runs a command. So ’s guess about hidden files is unlikely. The usual culprit is an unmatched parenthesis introduced earlier (often via an included file or a variable expansion), and the parser only realizes it by the time it reaches your target line. is on the right track: the broken $(...) can be well before the reported line, or inside the value of a variable used there.

Practical ways to pinpoint it:

  • Print values at parse time where they are defined. $(warning ...) runs during parsing, so you can catch bad text early.
$(warning country=$(country))
$(warning roles_raw=$(value _$(country)_pops_roles))
$(warning roles_expanded=$(_$(country)_pops_roles))
  • If -i seems to "fix" it, you are probably ignoring a failing sub-make. Search for recipes that run $(MAKE) or make; the parse error could be in a child makefile. Run those sub-makes manually with -n or -d to see exactly where they choke.
grep -nE '(^|\s)\$?\(MAKE\)|(^|\s)make(\s|$)' -n Makefile*
  • Check for Windows CRLF line endings or stray carriage returns that can confuse the parser (especially if a ) is followed by \r).
grep -n $'\r' -H Makefile*
  • Inspect any include/-included files; a missing ) in one of them will be blamed on the line that finally tripped the counter. Temporarily comment out includes or bisect the file to isolate.

Once you find the source, ensure every $( has a matching ), especially inside dynamically constructed names like $(_$(country)_pops_roles). Adding a few $(warning ...) lines near variable definitions usually reveals the offending text fast, .

Recommended Answers

All 4 Replies

My guess is that there is a hidden file in the directory which the shell is not able to expand, resulting in the error. Check for that.

Well nothing like that, I did check. I did run make with debug, it doesnt give any error and yet it fails.
the strange part is, that if I replace

popiso: isolinux_cfg $(foreach x,$(_$(country)_pops_roles), pop_iso_$(x)) $(isomedia)

with

popiso: 
    @echo testing

error stays the same.How can this be?
This means error is due to some other part and its, just showing this line due to god knows what.

Do you have any foreach loops before line 124? While line 124 is the one with the reported error, the cause of the error could be before it.

Nope there is none.
I'm not sure what this error is but running make file with -i (ignore error) flags, makes it to run and generate final product successfully.

So this error, doesnt effect anything that is to be generated via make.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.