-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
50 lines (36 loc) · 1.03 KB
/
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 = g++
LD = g++
WXCONFIG = wx-config
CXXFLAGS = `$(WXCONFIG) --cxxflags` -std=c++17 -Wall -Wextra
CPPFLAGS = `$(WXCONFIG) --cppflags`
EXEC := $(notdir $(CURDIR))
LIBS := `$(WXCONFIG) --libs xrc,propgrid,aui,adv,core,base,xml` -lpng -lyaml-cpp
SRCDIR := ./src
BUILDDIR := build
BINDIR := bin
INC_DIRS := ./third_party
INCS := $(SRCDIR) $(INC_DIRS)
SRC := $(foreach sdir,$(SRCDIR),$(wildcard $(sdir)/*/*/src/*.cpp))
OBJ := $(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.o,$(SRC))
INCLUDES := $(addprefix -I,$(INCS))
vpath %.cpp $(SRCDIR) $(EXEC_SDIR)
DEBUG=no
ifeq ($(DEBUG),yes)
CXXFLAGS += -O0 -g
else
CXXFLAGS += -O3 -DNDEBUG
endif
.PHONY: all checkdirs clean clean-all
all: checkdirs $(EXEC)
checkdirs: $(BUILDDIR)
$(BUILDDIR):
@mkdir -p $@
clean:
@rm -rf $(BUILDDIR)
clean-all: clean
@rm -rf $(EXEC)
$(BUILDDIR)/%.o: $(SRCDIR)/%.cpp
@mkdir -p $(dir $@)
$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(INCLUDES) -c $< -o $@
$(EXEC): $(OBJ) $(patsubst $(SRCDIR)/%.cpp,$(BUILDDIR)/%.o,$(wildcard $(SRCDIR)/*.cpp))
$(LD) $^ -o $@ $(LIBS)