-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
46 lines (35 loc) · 853 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
DEBUG = 0
TARGET = lindenmaker
CXX = g++
LD = $(CXX)
CXXFLAGS = -std=c++17 -Wall -Wextra -Wno-sign-compare
LDFLAGS =
ifeq ($(DEBUG), 1)
CXXFLAGS += -g
else
CXXFLAGS += -O2 -DNDEBUG
endif
UNAME = $(shell uname -s)
ifeq ($(UNAME), Darwin)
GL_LDFLAGS = -framework OpenGL
else
GL_LDFLAGS = -lGL
endif
CXXFLAGS += -fPIC $(shell pkg-config --cflags glfw3 glm)
LDFLAGS += -lm -ldl $(GL_LDFLAGS) $(shell pkg-config --libs glfw3)
SRCS = $(wildcard src/*.cpp)
OBJS = $(patsubst src/%.cpp, build/obj/%.o, $(SRCS))
DEPS = $(wildcard build/deps/*.d)
.PHONY: all clean
all: build/$(TARGET)
build/$(TARGET): $(OBJS)
@mkdir -p $(@D)
$(LD) -o $@ $^ $(LDFLAGS)
build/obj/%.o: src/%.cpp
@mkdir -p $(@D) build/deps/
$(CXX) $(CXXFLAGS) -MMD -MF build/deps/$*.d -c -o $@ $<
ifneq ($(MAKECMDGOALS), clean)
-include $(DEPS)
endif
clean:
$(RM) -r build/