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),)
mode = debug
endif
ifeq ($(mode),debug)
CFLAGS = -O0 -g -std=gnu99 -pedantic -Wextra -Wconversion
LDFLAGS =
@ -36,7 +37,7 @@ endif
CFLAGS += -Wall
LDFLAGS += -Wall $(LIBRARIES)
all: $(TARGET)
all: change_build_mode $(TARGET)
ifneq ($(mode),debug)
ifneq ($(mode),profile)
@ -55,13 +56,21 @@ endif
@echo "LDFLAGS=$(LDFLAGS)"
@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 :
$(CC) -c $(CFLAGS) $(INCLUDE) -o $@ $<
clean:
$(RM) *.o *.out callgrind.out.* *.gcno $(TARGET)
.PHONY: all clean
.PHONY: all change_build_mode clean
#_________________________________
# R U L E S |