[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Force Rebuild if CXXFLAGS Change?
From: |
Oleksandr Gavenko |
Subject: |
Re: Force Rebuild if CXXFLAGS Change? |
Date: |
Fri, 12 Aug 2011 15:18:06 +0300 |
User-agent: |
Mozilla/5.0 (Windows NT 5.1; rv:5.0) Gecko/20110624 Thunderbird/5.0 |
11.08.2011 10:27, Jeffrey Walton пишет:
Hi All,
Is it possible to have make rebuild a target if its CXXFLAGS change?
For example:
`make debug` # CXXFLAGS = -D_GLIBCXX_DEBUG -DDEBUG=1 -g3 -ggdb -O0
<user runs debug build>
`make release` #CXXFLAGS = -DNDEBUG=1 -g -O2
<make: nothing to make>
Hi Jeff! I use such technique:
################################################################
# Build files definition.
# Makefile itself.
MK_FILE := $(firstword $(MAKEFILE_LIST))
# Storage for CLI options.
MK_CLI_FILE := $(patsubst %,build/%.cli,$(MK_FILE))
BUILD_SCRIPTS += $(MK_FILE)
################################################################
# Force rebuild project if in CLI you change valuable options.
-include $(MK_CLI_FILE)
$(shell mkdir -p $(dir $(MK_CLI_FILE)); printf "DEBUG_OLD=$(DEBUG)\n"
>$(MK_CLI_FILE))
ifneq '$(DEBUG_OLD)' '$(DEBUG)'
$(shell touch $(MK_FILE))
endif
%.o: %.c $(BUILD_SCRIPTS) # Place dependency on makefile to all
xxx # target that build something...
So if I build with debug ON next time if I build with debug OFF
make rebuild all targets marked by $(BUILD_SCRIPTS).
--
С уважением, Александр Гавенко.