我有一个很大的makefile,我已经配置了几个虚假的目标。一个用编译标志编译程序,一个用优化标志编译,等等。
我遇到的一个问题是,当您以前使用一个目标但之后再指定另一个目标时,它不知道它需要使用新的标志集重新编译所有文件。
例如,我使用调试目标编译所有内容。编译后我测试程序。看到没有问题我尝试使用优化目标运行make但它没有编译任何东西,因为Make的计算一切都是最新的。
我只是想让目标文件的位置取决于所选择的目标,但除此之外我什么都没有。
有没有办法优雅地处理这个问题?
答案 0 :(得分:1)
# Assuming you already know the type of new build
# and it is stored in this variable.
BUILD_TYPE := release
ifneq ($(MAKECMDGOALS),__clean)
# This file stores the type of the last build.
-include .last_build_type.mk
ifneq ($(__last_build_type),$(BUILD_TYPE))
.PHONY : .last_build_type.mk
.last_build_type.mk :
@$(MAKE) __clean
@echo '__last_build_type := $(BUILD_TYPE)' > $@
endif
else
.PHONY : __clean
__clean : clean # Delegate the job to your real 'clean' target.
endif
答案 1 :(得分:0)
这种事情会被makepp自动捕获。