且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何参数化Eclipse生成的make文件

更新时间:2023-11-17 19:23:10

CDT生成的makefile包含以下几行:

Makefiles generated by CDT include the following lines:

-include ../makefile.init
 ...
-include ../makefile.defs
 ...
-include ../makefile.targets

也就是说,您可以添加例如makefile.defs在项目根目录中以控制构建.

That is, you can add e.g. makefile.defs in the project root to control the build.

JeffV 我添加了一个makefile.init:

JeffV I added a makefile.init:

 BOOST_HOME = C:\code\boost_1_48_0
 ZMQ_HOME = C:\code\zmq\zeromq-2.1.11

在项目设置"Build Variables"配置中,我还添加了以下条目:

In the project settings "Build Variables" config I also added these entries:

BOOST_HOME = $(BOOST_HOME)
ZMQ_HOME = $(ZMQ_HOME)

这会导致eclipse用make文件中的$(BOOST_HOME)变量替换我的lib中引用的$ {BOOST_HOME}并包含路径.

Which causes eclipse to replace ${BOOST_HOME} where it is references in my lib and include paths, with the $(BOOST_HOME) variable in the make file.

这使我可以在每个构建平台上拥有特定于平台的makefile.init版本.

This allows me to have a platform specific version of the makefile.init on each build platform.