0
我需要一個通用的Makefile來執行我的項目,但我似乎無法在Makefiles中獲得define
的掛起。目標不是一般生成的
到最低限度降低了,我有什麼如下:
TARGETS = target1 target2
define TARGET_template =
$(1):
@echo "Hi there, I'm $(1)!"
endef
.PHONY: all
all: $(TARGETS)
$(foreach TARGET, $(TARGETS), $(eval $(call TARGET_template, $(TARGET))))
如果我執行make all
,我期望的控制檯輸出:
Hi there, I'm target1!
Hi there, I'm target2!
而是我得到
make: *** No rule to make target `target1', needed by `all'. Stop.
我做錯了什麼?我正在使用GNU make 3.81