命令行与环境的Makefile变量
答
是的。您可以使用origin函数来确定变量的定义位置。
ifneq (,$(findstring environment,$(origin LIB))) # LIB was defined by the environment else # LIB was defined some other way endif
答
随着非GNU做,你可能有问题的变量运行export
命令和grep
。这只适用于规则,只要变量没有设置为一次性(如LIB=foo make
)。
请用[make]标签标记与制作相关的问题。有关基本原理,请参阅http://meta.stackexchange.com/questions/24030/why-do-they-specify-makefile-tag-instead-of-make/26567#26567 – 2009-10-23 20:40:59