-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
49 lines (37 loc) · 954 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
CXX ?= clang++
CFLAGS = -std=c++14 -MMD -MP -Wall -Wextra #-fopenmp=libomp
CFLAGS_DEBUG = -g -O0
CFLAGS_RELEASE = -O3
LDFLAGS =
buildtype := release
ifeq ($(buildtype), debug)
CFLAGS += $(CFLAGS_DEBUG)
else ifeq ($(buildtype), release)
CFLAGS += $(CFLAGS_RELEASE)
else
$(error buildtype must be debug or release)
endif
LIBS =
INCLUDE = -I./include -I./ext/Catch/include
TARGETDIR = ./bin/$(buildtype)
TARGET = $(TARGETDIR)/nanikanizer_tests
SRCDIR = ./tests
SOURCES = $(wildcard $(SRCDIR)/*.cpp)
OBJDIR = ./obj/$(buildtype)
OBJECTS = $(addprefix $(OBJDIR)/, $(notdir $(SOURCES:.cpp=.o)))
DEPENDS = $(OBJECTS:.o=.d)
.PHONY: all
all: $(TARGET)
$(TARGET): $(OBJECTS) $(LIBS)
-mkdir -p $(TARGETDIR)
$(CXX) -o $@ $^ $(LDFLAGS)
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
-mkdir -p $(OBJDIR)
$(CXX) $(CFLAGS) $(INCLUDE) -o $@ -c $<
.PHONY: test
test: $(TARGET)
$(TARGET)
.PHONY: clean
clean:
-rm -f $(OBJECTS) $(DEPENDS) $(TARGET)
-include $(DEPENDS)