Max*_*xpm 1 build-automation makefile
为多种体系结构和配置提供makefile支持的最简单方法是什么?例如,发布配置可能使用比调试配置更多的优化.是否应将更改选项定义为makefile中的变量,并依赖用户根据需要更新它们?
# Change to -O2 for release.
COMPILER_OPTIONS := -arch x86_64 -O0
Run Code Online (Sandbox Code Playgroud)
或者应该在规则中处理这类事情?
*_Release.a:
# Recipe for building a release library, i.e., with optimization.
# Unsure how to integrate this with different architectures.
Run Code Online (Sandbox Code Playgroud)
或者两者的组合?
架构和配置是一种正交; 他们呼吁采用不同的方法.用户应该能够在构建时选择配置,最简洁的方法是使用不同的目标.但是我认为尝试在另一个架构上构建一个架构没有任何意义,因此应该自动处理架构的选择.详细信息会根据您的需要而有所不同,但您的makefile最终可能会看起来像这样:
# Determine whatever we need to know about architecture with "uname" or its
# equivalent (I think it's "ver" on Windows).
MACHINE = $(shell "uname -m")
ifeq ($(MACHINE), i386)
SOME_VAR = 386
foo:
make a foo the i386 way
else
SOME_VAR = something else
foo:
make a foo some other way
endif
# Choice of configuration is up to the user
release: COMPILER_OPTIONS += -O0
debug: CCFLAGS += -g -Wall
debug release:
whatever...
Run Code Online (Sandbox Code Playgroud)