-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
61 lines (45 loc) · 1.49 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
50
51
52
53
54
55
56
57
58
59
60
61
CXX = g++
CXXFLAGS = -Wpedantic -Wall -Wextra -std=c++17 `sdl2-config --cflags`
IMGUI_DIR = external/imgui
SRCS = main.cpp
SRCS += $(IMGUI_DIR)/backends/imgui_impl_sdl2.cpp
SRCS += $(IMGUI_DIR)/backends/imgui_impl_sdlrenderer.cpp
SRCS += $(IMGUI_DIR)/imgui.cpp
SRCS += $(IMGUI_DIR)/imgui_draw.cpp
SRCS += $(IMGUI_DIR)/imgui_widgets.cpp
SRCS += $(IMGUI_DIR)/imgui_tables.cpp
HEADERS=$(shell find * -name "*.h")
INCLUDES = $(IMGUI_DIR) $(IMGUI_DIR)/backends
LIBS = `sdl2-config --libs`
OBJS = $(SRCS:.cpp=.o)
EXE = rt
DBGDIR = bin/debug
DBGEXE = $(DBGDIR)/$(EXE)
DBGOBJS = $(addprefix $(DBGDIR)/, $(OBJS))
DBGCXXFLAGS = -g -O0 -DDEBUG
RELDIR = bin/release
RELEXE = $(RELDIR)/$(EXE)
RELOBJS = $(addprefix $(RELDIR)/, $(OBJS))
RELCXXFLAGS = -Ofast -DNDEBUG -flto -fopenmp
.PHONY: all clean debug prep release remake
all: prep release
debug: $(DBGEXE)
$(DBGEXE): $(DBGOBJS)
$(CXX) $(CXXFLAGS) $(DBGCXXFLAGS) -o $(DBGEXE) $^ $(LIBS)
$(DBGDIR)/%.o: %.cpp $(HEADERS)
$(CXX) -c $(CXXFLAGS) $(DBGCXXFLAGS) -I $(INCLUDES) -o $@ $<
release: $(RELEXE)
$(RELEXE): $(RELOBJS)
$(CXX) $(CXXFLAGS) $(RELCXXFLAGS) -o $(RELEXE) $^ $(LIBS)
$(RELDIR)/%.o: %.cpp $(HEADERS)
$(CXX) -c $(CXXFLAGS) $(RELCXXFLAGS) -I $(INCLUDES) -o $@ $<
prep:
@mkdir -p $(DBGDIR) $(RELDIR)
@mkdir -p $(DBGDIR)/$(IMGUI_DIR)/backends
@mkdir -p $(RELDIR)/$(IMGUI_DIR)/backends
remake: clean all
clean:
rm -f $(RELEXE) $(RELOBJS) $(DBGEXE) $(DBGOBJS)
image:
$(RELEXE) > ./asset/gen/image.ppm
convert ./asset/gen/image.ppm ./asset/gen/image.png