我并不精通makefile。我有RTFM并且看了SO,但在这个简单的例子中我仍然没有得到我做错的事。
有效:
TARGET = nim
ifeq ($(CONFIG),Release)
$(eval $(call LINK_RULE,$(TARGET)_unstripped,$(APP_SOURCES) Neonim.cc,$(LIBS),$(DEPS)))
$(eval $(call STRIP_RULE,$(TARGET),$(TARGET)_unstripped))
else
$(eval $(call LINK_RULE,$(TARGET),$(APP_SOURCES) Neonim.cc,$(LIBS),$(DEPS)))
endif
$(eval $(call NMF_RULE,$(TARGET),))
TARGET = ttt
ifeq ($(CONFIG),Release)
$(eval $(call LINK_RULE,$(TARGET)_unstripped,$(APP_SOURCES) TTToe3D.cc,$(LIBS),$(DEPS)))
$(eval $(call STRIP_RULE,$(TARGET),$(TARGET)_unstripped))
else
$(eval $(call LINK_RULE,$(TARGET),$(APP_SOURCES) TTToe3D.cc,$(LIBS),$(DEPS)))
endif
$(eval $(call NMF_RULE,$(TARGET),))
不起作用:
define bld =
SOURCES = $(APP_SOURCES) $(2)
ifeq ($(CONFIG),Release)
$(eval $(call LINK_RULE,$(1)_unstripped,$(SOURCES),$(LIBS),$(DEPS)))
$(eval $(call STRIP_RULE,$(1),$(1)_unstripped))
else
$(eval $(call LINK_RULE,$(1),$(SOURCES),$(LIBS),$(DEPS)))
endif
$(eval $(call NMF_RULE,$(1),))
endef
$(eval $(call bld,nim,Neonim.cc))
$(eval $(call bld,ttt,TTToe3D.cc))
它们不相同吗?我该如何写这个函数?
答案 0 :(得分:0)
你没有给我们足够的信息来重现这个错误(我真的不认为你的例子是minimal),但我会走出困境。改变这个:
define bld =
SOURCES = $(APP_SOURCES) $(2)
ifeq ($(CONFIG),Release)
$(eval $(call LINK_RULE,$(1)_unstripped,$(SOURCES),$(LIBS),$(DEPS)))
$(eval $(call STRIP_RULE,$(1),$(1)_unstripped))
else
$(eval $(call LINK_RULE,$(1),$(SOURCES),$(LIBS),$(DEPS)))
endif
$(eval $(call NMF_RULE,$(1),))
endef
到此:
define bld
SOURCES = $(APP_SOURCES) $(2)
ifeq ($(CONFIG),Release)
$(call LINK_RULE,$(1)_unstripped,$(SOURCES),$(LIBS),$(DEPS))
$(call STRIP_RULE,$(1),$(1)_unstripped)
else
$(call LINK_RULE,$(1),$(SOURCES),$(LIBS),$(DEPS))
endif
$(call NMF_RULE,$(1),)
endef