如何使用makefile构建一个项目的多个变体?

时间:2012-09-05 12:20:00

标签: makefile nmake

我从事的项目通常是在多个操作系统和多种配置下构建和运行的。我使用两个编译器:icc和gcc,以及那些编译器的多组参数。这可以为我提供一个项目构建的多种变体。

我想做的是:

  
      
  • 使用带有一组参数的icc或gcc编译器编译项目
  •   
  • 测试应用程序的性能以及新构建之后>
  •   
  • 比较获得的结果
  •   
  • 为另一组参数编译项目并重复前面的步骤
  •   

有没有人知道如何使用makefile很好地完成它?

1 个答案:

答案 0 :(得分:1)

您只需根据需要级联制作目标: E.g:

# Assumed that $(CONFIGURATION_FILES) is a list of files, all named *.cfg
# There you store your set of arguments per step

#The main target 
all: $(CONFIGURATION_FILES)

#Procedure for each configuration-file
%.cfg: compile_icc compile_gcc test compare

compile_icc:
#DO whatever is necesarry

compile_gcc:
#DO whatever is necesarry

test:
#DO whatever is necesarry

compare:
#DO whatever is necesarry

但是,对于这种工作,我宁愿使用一些构建自动化工具......我只知道Maven,但对于基于Makefile的构建,一些其他工具可能更合适...看看不同的选项,例如这里: https://en.wikipedia.org/wiki/List_of_build_automation_software

相关问题