I’m a starter at this(make), and having some problems trying to grep for a text in a file (as part of the make process on Windows). The larger problem I’m trying to solve is to check whether all binary executables in a given directory have their respective dependencies satisfied. I use depends.exe (Dependency Walker) for the later part, whose output file I’m trying to grep, and possibly abort the build process if the dependency validation fails.
binary-dependency-validate:
for BINARYEXEC in $(shell $(PATH_TO_FIND_EXE) $(PRE_DEFINED_DIR) -name "*.exe"); do \
$(PATH_TO_DEPENDS_EXE) /c /pb /ot $(PRE_DEFINED_DIR)/$$BINARYEXEC-depends.txt $(PRE_DEFINED_DIR)/$$BINARYEXEC ; \
ifeq ($(shell $(PATH_TO_GREP_EXE) "Error: At least one required implicit or forwarded dependency was not found." $(PRE_DEFINED_DIR)/$$BINARYEXEC-depends.txt),); \
@echo "Dependency ok" ; \
endif ; \
done
I’m encountering the following error :
line 1: syntax error near unexpected token `,'
Any suggestions would greatly help. I looked at this post and tried aligning ifeq without indentation as well (that didn’t help either.)
The problem is that you are mixing Make language with shell language.
A makefile contains rules, and a rule contains commands which are executed by a shell:
The commands are in shell language, and each command must be preceded by a TAB.
There are conditionals in Make:
(The indentation is just for the eye.)
There are also conditionals in the various scripting languages:
A Make conditional can enclose a command within a rule:
Make will evaluate this conditional before running the rule, and there must be no TAB before
ifeqorendif, because Make must not interpret them as commands to be passed to the shell.A command (in a rule) can contain a shell conditional:
The indentation before
ifis a TAB. The other whitespace is for the eye.Your makefile has a Make conditional in the middle of a shell command; Make can’t evaluate the conditional before the command executes, and the shell can’t understand Make syntax. You should use a shell conditional.