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).
--
С уважением, Александр Гавенко.
_______________________________________________
Help-make mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-make