If 语句 Makefile tcsh
If statement Makefile tcsh
我想要这样的东西:
my_rule:
if($(VAR) == $@) then
echo 'ok'
else
echo 'ko'
endif
我必须使用 tsch 但我知道 Makefile 使用 sh,所以我真的很想知道我是否必须使用 sh 或 tcsh if 语句语法在这里...?
tsch 脚本 中 if 语句的正确语法是(我检查过):
#!/bin/csh
if(3 == 3) then
echo 'yes'
else
echo 'no'
endif
我试图将 ;
和 \
放在我的 Makefile 中的任何地方,但没有任何效果。
shell取自变量SHELL
,如果不指定,默认为/bin/sh
。假设您没有覆盖 shell,那么您的语法将是:
my_rule:
if [ "$(VAR)" == "$@" ]; then \
echo 'ok'; \
else \
echo 'ko'; \
fi
您需要使用 \
将这些行连接成一个配方行。请注意,这不会引入实际的换行符,因此您还必须使用 ;
手动终止每个命令。最后,在变量周围加上引号,这样如果一个变量恰好为空,就不会出现语法错误。
我想要这样的东西:
my_rule:
if($(VAR) == $@) then
echo 'ok'
else
echo 'ko'
endif
我必须使用 tsch 但我知道 Makefile 使用 sh,所以我真的很想知道我是否必须使用 sh 或 tcsh if 语句语法在这里...? tsch 脚本 中 if 语句的正确语法是(我检查过):
#!/bin/csh
if(3 == 3) then
echo 'yes'
else
echo 'no'
endif
我试图将 ;
和 \
放在我的 Makefile 中的任何地方,但没有任何效果。
shell取自变量SHELL
,如果不指定,默认为/bin/sh
。假设您没有覆盖 shell,那么您的语法将是:
my_rule:
if [ "$(VAR)" == "$@" ]; then \
echo 'ok'; \
else \
echo 'ko'; \
fi
您需要使用 \
将这些行连接成一个配方行。请注意,这不会引入实际的换行符,因此您还必须使用 ;
手动终止每个命令。最后,在变量周围加上引号,这样如果一个变量恰好为空,就不会出现语法错误。