Gnu-Make
確定 makefile 配方的類型
我想確定使用者在 shell 中輸入的配方類型。但是下面的程式碼總是返回 false 。
all clean: ifeq ("$@", "clean") echo "This is an clean recipe" else echo "This is not a clean recipe." endif
您可以使用MAKECMDGOALS來獲取目標:
all clean: ifeq ($(MAKECMDGOALS), clean) @echo "This is an clean recipe" else @echo "This is not a clean recipe." endif
$ make This is not a clean recipe. $ make clean This is an clean recipe