在makefile之间共享变量 [英] Share variables between makefiles
问题描述
我有一个目录结构,我想要一个主要的makefile在我的主文件夹,然后在我的测试和src文件夹中的另一个makefile。
在我的主makefile ,我有指令的测试/所有调用单个文件夹makefiles。
例如在我的主Makefile文件中
PACKAGES = jansson mysql ....
all:
在这里做一些事情
test:
cd test
make test
/ Makefile我想能够访问以前的PACKAGES变量,并将此makefile的各个依赖项添加到它上面。
在测试/ Makefile
PACKAGES + = googletest googlemock
pre>
test
在这里做一些事情
有人能帮我解决这个问题吗?
感谢
Makefile.variable ,其中定义了这些共享变量,并包含文件usinginclude $(PATHTOSHAREDMAKEFILE)/Makefile.variable
查看包含手册更多信息
I have a directory structure where I want one main makefile in my main folder, and then another makefile in both my test and src folder.
In my main makefile, I have directives for both test / all that call the individual folder makefiles. I'm trying to declare variables in my main makefile and have them accessible to those other folders.
For instance in my main Makefile
PACKAGES = jansson mysql .... all: do something here test: cd test make test
And then in my test/Makefile I want to be able to access the previous PACKAGES variable and add this makefile's individual dependencies onto it.
In the test/Makefile
PACKAGES += googletest googlemock test do something here
Could anyone help me solve this problem?
Thanks
解决方案You can create another file, for instance
Makefile.variable
where those shared variables are defined and include the file usinginclude $(PATHTOSHAREDMAKEFILE)/Makefile.variable
Look at the include manual for more information
这篇关于在makefile之间共享变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文