Reputation: 823
I want something like :
my_rule:
if($(VAR) == $@) then
echo 'ok'
else
echo 'ko'
endif
I have to use tsch but I know that Makefile use sh, so I really wonder if I have to use sh or tcsh if statement syntax here... ? The correct syntax for if statement in a tsch script is (I checked) :
#!/bin/csh
if(3 == 3) then
echo 'yes'
else
echo 'no'
endif
I tried to put ;
and \
everywhere in my Makefile but nothing work.
Upvotes: 0
Views: 484
Reputation: 6387
The shell is taken from the variable SHELL
, and if not specified, defaults to /bin/sh
. Assuming you're not overriding the shell, then your syntax would be:
my_rule:
if [ "$(VAR)" == "$@" ]; then \
echo 'ok'; \
else \
echo 'ko'; \
fi
You need to use the \
's to concatenate the lines into a single recipe line. Notice this does not introduce actual newlines, so you also have to manually terminate each command with a ;
. Finally, put quotes around the variables, so that if one happens to be blank, you don't get a syntax error.
Upvotes: 3