-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·69 lines (49 loc) · 1.41 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
62
63
64
65
66
67
68
69
CC=$(CROSS)gcc
CXX=$(CROSS)g++
LD=$(CROSS)ld
AR=$(CROSS)ar
PKG_CONFIG=$(CROSS)pkg-config
RESDIR = ./res
DATADIR = ./shaders
BINDIR = ./bin
OBJDIR = ./bin
CXXSRC = $(wildcard src/*.cpp)\
$(wildcard src/opengl/*.cpp)\
$(wildcard src/imgui/*.cpp)
CSRC = $(wildcard src/*.c)
CXXOBJ = $(CXXSRC:%.cpp=$(OBJDIR)/%.o)
COBJ = $(CSRC:.cpp=.o)
DEPS = $(CXXOBJ:.o=.d)
BIN = application
BINDEPS = sdl2 glew
BUILDFLAGS = -pthread -O3 -flto -fopenmp -Wall -std=c++17
LDFLAGS = $(shell $(PKG_CONFIG) --libs $(BINDEPS))
CFLAGS = $(shell $(PKG_CONFIG) --cflags $(BINDEPS))
CXXFLAGS = $(BUILDFLAGS) $(CFLAGS)
$(BINDIR)/$(BIN): $(CXXOBJ)
mkdir -p $(@D)
$(CXX) $(BUILDFLAGS) $(CFLAGS) -o $@ $^ $(LDFLAGS)
#-include $(DEPS) # include all dep files in the makefile
$(CXXOBJ): $(OBJDIR)/%.o: %.cpp
@mkdir -p $(@D)
$(CXX) $(BUILDFLAGS) $(CFLAGS) -c -o $@ $<
# rule to generate a dep file by using the C preprocessor
# (see man cpp for details on the -MM and -MT options)
%.d: %.c
mkdir -p $(@D)
@$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
%.d: %.cpp
mkdir -p $(@D)
@$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
%.d: %.cpp
mkdir -p $(@D)
@$(CPP) $(CFLAGS) $(CXXFLAGS) $< -MM -MT $(@:.d=.o) >$@
.PHONY: all build release debug clean
#all: cleandeps
all: build $(BINDIR)/$(BIN)
debug: BUILDFLAGS = -ggdb -O0 -Wall -pthread -fopenmp
debug: all
clean:
rm -rf $(BINDIR) $(COBJ) $(CXXOBJ) $(DEPS)
cleandeps:
rm -f $(DEPS)