使用MinGW msys和Cygwin测试以下内容
在makefile中定义伪目标EXPORT_ALL_VARIABLES然后执行子make时,不会导出带点的变量。
因此导出 CFLAGS 但 CFLAGS.cpp 和 CFLAGS.c 不会。
这是一个记录的功能吗?什么是理性? 有没有办法解决它导出所有变量?
示例:
test1.mak
CFLAGS=-O2
CFLAGS.cpp=-O2 -fno-rtti
all:
$(MAKE) -f test2.mak
.EXPORT_ALL_VARIABLES:
test2.mak
$(info CFLAGS='$(CFLAGS)')
$(info CFLAGS.cpp='$(CFLAGS.cpp)')
all:
@echo Done
输出:
make -f test1.mak
CFLAGS='-O2'
CFLAGS.cpp=''
Done
答案 0 :(得分:2)
POSIX sh中的环境变量不能包含“。”;试试吧:
$ FOO.BAR=foobar
FOO.BAR=foobar: command not found
Make只会导出对shell有效的变量。
GNU make手册说:
If you use export by itself to export variables by
default, variables whose names contain characters other than
alphanumerics and underscores will not be exported unless specifically
mentioned in an export directive.
然后:
you can write a rule for the special target
.EXPORT_ALL_VARIABLES instead of using the export directive.
因此,该目标与使用export
本身相同,并且具有相同的限制。