-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
44 lines (33 loc) · 847 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
CXX ?= clang++
CFLAGS = -std=c++14 -MMD -MP -Wall -Wextra
CFLAGS_DEBUG = -g -O0
CFLAGS_RELEASE = -O3
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
TARGETDIR = ./bin/$(buildtype)
TARGET = $(TARGETDIR)/dmc
SRCDIR = ./src
SOURCES = $(shell find $(SRCDIR) -name *.cpp)
OBJDIR = ./obj/$(buildtype)
OBJECTS = $(addprefix $(OBJDIR)/, $(SOURCES:$(SRCDIR)/%.cpp=%.o))
DEPENDS = $(OBJECTS:.o=.d)
.PHONY: all
all: $(TARGET)
$(TARGET): $(OBJECTS) $(LIBS)
-mkdir -p $(@D)
$(CXX) -o $@ $^ $(LDFLAGS)
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
-mkdir -p $(@D)
$(CXX) $(CFLAGS) $(INCLUDE) -o $@ -c $<
.PHONY: clean
clean:
-rm -f $(OBJECTS) $(DEPENDS) $(TARGET)
-include $(DEPENDS)