From 4e6b2b188539ee8f6f4e7113fcd3acd884a7b241 Mon Sep 17 00:00:00 2001 From: Kolan Sh Date: Fri, 1 Jul 2011 15:46:55 +0400 Subject: [PATCH] TRUE Makefile with automatic clear on mode change --- c/tex_parser/Makefile | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/c/tex_parser/Makefile b/c/tex_parser/Makefile index 4d1f6a5..1ef12e6 100644 --- a/c/tex_parser/Makefile +++ b/c/tex_parser/Makefile @@ -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 |