【发布时间】:2016-01-06 10:56:12
【问题描述】:
我有以下 Makefile:
SHELLS = $(call adjust, profile bash zsh)
adjust = $(foreach arg, $(1), $(DIR)/$(DOT)$(arg))
sys:
$(eval DIR = /etc)
$(eval DOT = )
usr:
$(eval DIR = $(wildcard ~))
$(eval DOT = .)
# Installation Recipes {{{1
shell-sys: $(SHELLS) | sys
@echo $(SHELLS)
shell-usr: $(SHELLS) | usr
@echo $(SHELLS)
$(SHELLS): $(DIR)/$(DOT)%: $(wildcard %/*)
@echo $(SHELLS)
现在我运行make shell-sys 并期望得到以下结果:
$ make shell-sys
/etc/profile /etc/bash /etc/zsh
/etc/profile /etc/bash /etc/zsh
/etc/profile /etc/bash /etc/zsh
/etc/profile /etc/bash /etc/zsh
但是我得到的是以下内容:
$ make shell-sys
/profile /bash /zsh
/profile /bash /zsh
/profile /bash /zsh
/etc/profile /etc/bash /etc/zsh
内部静态模式规则$(DIR) 和$(DOT) 无法扩展,但是在普通规则中它们似乎可以正常扩展。我究竟做错了什么?有没有更好的方法来实现sys 和usr 目标的功能?
【问题讨论】:
标签: macos bash makefile gnu-make