Makefile 定制功能不支持';得不到参数

Makefile 定制功能不支持';得不到参数,makefile,gnu-make,Makefile,Gnu Make,我想将模块添加到构建系统中 为了在添加新模块时保持makefile干净,它们都遵循相同的模式,因此我尝试用一个函数来概括它: uc = $(shell echo $1 | tr '[a-z]' '[A-Z]') define driver-mod $(eval CFLAGS += -DUSE_$(call uc, $1)); $(eval include $(DRIVERS_SRC)/$1/Makefile.include); endef ifneq (,$(filter led,$(USE

我想将模块添加到构建系统中

为了在添加新模块时保持makefile干净,它们都遵循相同的模式,因此我尝试用一个函数来概括它:

uc = $(shell echo $1 | tr '[a-z]' '[A-Z]')

define driver-mod
$(eval CFLAGS += -DUSE_$(call uc, $1));
$(eval include $(DRIVERS_SRC)/$1/Makefile.include);
endef

ifneq (,$(filter led,$(USEMODULE)))
$(call driver-mod, led)
endif
ifneq (,$(filter uart,$(USEMODULE)))
$(call driver-mod, uart)
endif
ifneq (,$(filter button,$(USEMODULE)))
$(call driver-mod, button)
endif
(ifneq的
将被替换为
$(foreach x,$(USEMODULE),$(call driver mod,$(x))

然而,我得到的结果是,驱动程序模块中的
$1
似乎没有被评估

make: *** $(DRIVERS_SRC): Is a directory.  Stop.
(实际上不输出
$(DRIVERS\u SRC)
,但它是值,为清晰起见进行了编辑) 当我将$1替换为例如
led
时,它会按预期工作


我遗漏了什么?

结果是我不得不逃离
$
进行评估:

define driver-mod
$(eval CFLAGS += -DUSE_$(call uc, $1));
$(eval include $(DRIVERS_SRC)/\$1/Makefile.include);
endef

工作!

可以简化如下:

uc = $(shell echo $1 | tr '[a-z]' '[A-Z]')

define __driver-mod
    CFLAGS += -DUSE_$(uc)
    include $(DRIVERS_SRC)/$1/Makefile.include
endef

driver-mod = $(eval $(call __driver-mod,$(strip $1)))

$(foreach 1,$(USEMODULE),$(driver-mod))