From 8b9452680a16ed4d45b1c7f122c042480cf469d2 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Mon, 21 Sep 2015 13:38:09 +0100 Subject: [PATCH] Use different object filenames between debug/non-debug builds --- src/Makefile | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/Makefile b/src/Makefile index f44d36e1..bd5e871e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,6 +1,19 @@ +debug ?= yes +ifeq ($(debug),yes) + CPPFLAGS += -DKAK_DEBUG + suffix := .debug +else + ifeq ($(debug),no) + CXXFLAGS += -O3 + suffix := .opt + else + $(error debug should be either yes or no) + endif +endif + sources := $(wildcard *.cc) -objects := $(addprefix ., $(sources:.cc=.o)) -deps := $(addprefix ., $(sources:.cc=.d)) +objects := $(addprefix ., $(sources:.cc=$(suffix).o)) +deps := $(addprefix ., $(sources:.cc=$(suffix).d)) PREFIX ?= /usr/local DESTDIR ?= # root dir @@ -23,24 +36,13 @@ else LDFLAGS += -rdynamic endif -debug ?= yes -ifeq ($(debug),yes) - CPPFLAGS += -DKAK_DEBUG -else - ifeq ($(debug),no) - CXXFLAGS += -O3 - else - $(error debug should be either yes or no) - endif -endif - kak : $(objects) $(CXX) $(LDFLAGS) $(CXXFLAGS) $(objects) $(LIBS) -o $@ -include $(deps) -.%.o: %.cc - $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MD -MP -MF $(addprefix ., $(<:.cc=.d)) -c -o $@ $< +.%$(suffix).o: %.cc + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MD -MP -MF $(addprefix ., $(<:.cc=$(suffix).d)) -c -o $@ $< test: cd ../test && ./run