TRUE Makefile with automatic clear on mode change

This commit is contained in:
Kolan Sh 2011-07-01 15:46:55 +04:00
parent 6c846ba6db
commit 4e6b2b1885
1 changed files with 11 additions and 2 deletions

View File

@ -16,6 +16,7 @@ TARGET=tex_parser_test
ifeq ($(mode),) ifeq ($(mode),)
mode = debug mode = debug
endif endif
ifeq ($(mode),debug) ifeq ($(mode),debug)
CFLAGS = -O0 -g -std=gnu99 -pedantic -Wextra -Wconversion CFLAGS = -O0 -g -std=gnu99 -pedantic -Wextra -Wconversion
LDFLAGS = LDFLAGS =
@ -36,7 +37,7 @@ endif
CFLAGS += -Wall CFLAGS += -Wall
LDFLAGS += -Wall $(LIBRARIES) LDFLAGS += -Wall $(LIBRARIES)
all: $(TARGET) all: change_build_mode $(TARGET)
ifneq ($(mode),debug) ifneq ($(mode),debug)
ifneq ($(mode),profile) ifneq ($(mode),profile)
@ -55,13 +56,21 @@ endif
@echo "LDFLAGS=$(LDFLAGS)" @echo "LDFLAGS=$(LDFLAGS)"
@echo ".........................." @echo ".........................."
OLD_BUILD_MODE=$(shell cat build_mode.out 2>/dev/null)
change_build_mode:
ifneq ($(mode), $(OLD_BUILD_MODE))
@echo CLEANING...
@make clean &>/dev/null
@echo $(mode) > build_mode.out
endif
%.o : %.o :
$(CC) -c $(CFLAGS) $(INCLUDE) -o $@ $< $(CC) -c $(CFLAGS) $(INCLUDE) -o $@ $<
clean: clean:
$(RM) *.o *.out callgrind.out.* *.gcno $(TARGET) $(RM) *.o *.out callgrind.out.* *.gcno $(TARGET)
.PHONY: all clean .PHONY: all change_build_mode clean
#_________________________________ #_________________________________
# R U L E S | # R U L E S |