Use different object filenames between debug/non-debug builds

This commit is contained in:
Maxime Coste 2015-09-21 13:38:09 +01:00
parent 889499e3e8
commit 8b9452680a

View File

@ -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) sources := $(wildcard *.cc)
objects := $(addprefix ., $(sources:.cc=.o)) objects := $(addprefix ., $(sources:.cc=$(suffix).o))
deps := $(addprefix ., $(sources:.cc=.d)) deps := $(addprefix ., $(sources:.cc=$(suffix).d))
PREFIX ?= /usr/local PREFIX ?= /usr/local
DESTDIR ?= # root dir DESTDIR ?= # root dir
@ -23,24 +36,13 @@ else
LDFLAGS += -rdynamic LDFLAGS += -rdynamic
endif 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) kak : $(objects)
$(CXX) $(LDFLAGS) $(CXXFLAGS) $(objects) $(LIBS) -o $@ $(CXX) $(LDFLAGS) $(CXXFLAGS) $(objects) $(LIBS) -o $@
-include $(deps) -include $(deps)
.%.o: %.cc .%$(suffix).o: %.cc
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -MD -MP -MF $(addprefix ., $(<:.cc=.d)) -c -o $@ $< $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MD -MP -MF $(addprefix ., $(<:.cc=$(suffix).d)) -c -o $@ $<
test: test:
cd ../test && ./run cd ../test && ./run