I have one use case to iterate arguments which I pass via a make command as shown below code,
if you can see x=$(filter-out $@,$(MAKECMDGOALS))
in Makefile I am getting below error:
Error:
$ make plan ab1,ab2
TARGET=""
x=ab1,ab2
echo
for i in
/bin/sh: 1: Syntax error: end of file unexpected
make: *** [Makefile:9: plan] Error 2
MakeFile
SHELL := /bin/sh
all: plan
plan:
TARGET=""
x=$(filter-out $@,$(MAKECMDGOALS))
echo $x
for i in ${x//,/ }
do
TARGET="$TARGET -target=module.abc$i"
done
echo $TARGET
terraform plan $TARGET
%: # The target name % means that it is a rule that matches anything
@: # The @: is a recipe; the : means do nothing, and the @ means do it silently.
calling command
make plan ab1,ab2
Please help me to optimize my Makefile,
and also please do let me know about assigning $(filter-out $@,$(MAKECMDGOALS))
into a variable.
Thanks in Advance.