问题描述
我正在尝试测试食谱中$*
的值。
main.txt: main.dat
# ...
other.txt: other.dat
# ...
%.dat:
# ...
ifeq "$*" "other"
# ..,do something special for 'other'
endif
但是,我似乎无法正确理解语法。无论我怎么写ifeq "$*" "other"
政治家,都永远不会执行。
解决方法
诸如$*
之类的自动变量在make解析makefile之后会被扩展,因此您不能在条件条件中使用它们。但是您可以改用shell条件语句:
%.dat:
if [ "$*" = "other" ]; then \
do something special for other; \
else \
do something else for others than other; \
fi
但是由于模式规则的优先级低于非模式规则,因此您也可以尝试:
other.dat:
do something for other
%.dat:
do something else for others than other