CFormat:
define Format_File :=
@echo Formatting
ifneq ("$(wildcard $(1))","")
@echo if1
# The default extensions for intermediate files are not used,
# to avoid collisions with backup files open in the editor, etc.
# Save the original source file with an '_X' suffix on the extension.
ifneq("$(wildcard $(1)_X)","")
@echo if2
else
@echo else2
endif
@ren $(1) $(1)_X
# C-Comment is invoked separately, due to pathing limitations
# The redirection is a means to suppress blabbering.
@echo Formatting $(1) . . .
$(CFORMAT_PATH)\Cformat -h$(CFORMAT_PATH) $(1)_X -o$[Base, $(1)].tmp -ino >temp.tmp;
$(CFORMAT_PATH)\Ccomment -h$(CFORMAT_PATH) $[Base, $(1)].tmp -o$(1) >temp.tmp;
else
@echo else1
endif
endef
FormatAll: CFormat
$(foreach loopFile,$(ALL_S_SOURCES),$(eval $(call Format_File,$(loopFile))))
.PHONY: FormatAll
When I replaced eval with info it printed out the function call correctly but every time I try to actually eval the formatter it gives me the error in the title.
Edit: This question was plagued with syntax errors everywhere but following the advice of @MadScientist I was eventually able to get it to work using shell loops.
ALL_S_SOURCES? What else is in that makefile? What version of make? With that exact snippet I don't that error with a few different versions of make. (As an aside what is$[Base, $(1)].tmpsupposed to be doing in that recipe line for you?) - Etan ReisnerALL_S_SOURCESwith a filename (that exists) I get a missing separator error. That define looks like it wants to output recipe lines but$(eval)doesn't generate any output. Also assigning a define with:=causes it to be evaluated immediately which means all your$1references are going to be empty. In short this isn't even close to being able to work as-is. - Etan Reisner$(eval)from theforeachloop. Change the define to beecho $(1). Put@before the$(foreach)and indent it with a tab. Then put;at the end of the last argument of the$(foreach)call. Roughly. - Etan Reisner