Gnu make:ifeq 和 $*
Gnu make: ifeq and $*
我正在尝试测试食谱中 $*
的价值。
main.txt: main.dat
# ...
other.txt: other.dat
# ...
%.dat:
# ...
ifeq "$*" "other"
# .., do something special for 'other'
endif
但是,我似乎无法正确理解语法。不管我怎么写 ifeq "$*" "other"
statemen 都不会被执行。
$*
等自动变量在 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
我正在尝试测试食谱中 $*
的价值。
main.txt: main.dat
# ...
other.txt: other.dat
# ...
%.dat:
# ...
ifeq "$*" "other"
# .., do something special for 'other'
endif
但是,我似乎无法正确理解语法。不管我怎么写 ifeq "$*" "other"
statemen 都不会被执行。
$*
等自动变量在 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