-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
129 lines (96 loc) · 3.17 KB
/
Makefile
File metadata and controls
129 lines (96 loc) · 3.17 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
UNAME := $(shell uname -s)
CXXFLAGS = -std=c++17 -Wall -Wno-unused-variable -Wno-unused-private-field
SRC = $(wildcard src/*.cpp)
OBJS = $(SRC:src/%.cpp=obj/%.o)
INC_DIR := -Ideps -Iinclude
GLAD =
ifeq ($(UNAME),Linux)
CXX := c++
LDFLAGS += `pkg-config --libs glfw3`
CXXFLAGS += $(INC_DIR) -fPIC
GLAD = obj/glad.o
endif
ifeq ($(UNAME),Darwin)
CXX := clang++
LD=lld
LDFLAGS += -lglfw -framework Cocoa -framework IOKit -framework CoreVideo -framework OpenGL -g
LDFLAGS += -L${HOMEBREW_PREFIX}/opt/llvm/lib/c++
LDFLAGS += -L${HOMEBREW_PREFIX}/lib
CXXFLAGS += $(INC_DIR)
endif
ifeq ($(UNAME),MINGW64_NT-10.0-17134)
INC_DIR += -I/mingw64/include
GLAD = obj/glad.o
CXXFLAGS += $(INC_DIR) -fPIC
LDFLAGS += platform/win/glfw3.dll
endif
EXE = main
MACOS_DIST_NAME = shapegame.a
LINUX_DIST_NAME = shapegame.a
WIN_DIST_NAME = shapegame.lib
DIST_DIR=dist-libs
all: main.test
run: all
./$(EXE)
main.test: $(OBJS) $(GLAD) obj/main.test.o
$(CXX) -o bin/$@ $^ $(LDFLAGS)
add-child-as: $(OBJS) $(GLAD) obj/add-child-as.o
$(CXX) -o bin/$@ $^ $(LDFLAGS)
prod: CXXFLAGS += -Ofast
prod: main.test
sani: CXXFLAGS += -fsanitize=address -fno-omit-frame-pointer -glldb -g -O0 -gfull -g3 -gcolumn-info
sani: LDFLAGS += -L/usr/local/opt/llvm/lib -fsanitize=address -fno-omit-frame-pointer -g
sani: main.test
dbg: CXXFLAGS += -glldb -g -O0 -gfull -g3 -gcolumn-info
dbg: LDFLAGS += -g
dbg: main.test
dbg-run: dbg
PATH=/usr/bin /usr/bin/lldb ./main.test
deletion.test: $(OBJS) deletion.test.o
$(CXX) -o $@ $^ $(LDFLAGS)
triangle.test: $(OBJS) triangle.test.o
$(CXX) -o $@ $^ $(LDFLAGS)
obj/glad.o:
$(CXX) $(CXXFLAGS) $(INC_DIR) -c deps/glad.c -o obj/glad.o
shapegame.dylib: $(OBJS)
$(CXX) -std=c++17 -dynamiclib -current_version 0.0.1 -compatibility_version 0.0.1\
-undefined suppress -flat_namespace $(OBJS) -o $(MACOS_DIST_NAME)
obj/main.test.o:
$(CXX) $(CXXFLAGS) $(INC_DIR) -c examples/main.test.cpp -o obj/main.test.o
obj/add-child-as.o:
$(CXX) $(CXXFLAGS) $(INC_DIR) -c examples/add-child-as.cpp -o $@
$(OBJS): obj/%.o : src/%.cpp
$(CXX) $(CXXFLAGS) $(INC_DIR) -c $< -o $@
# Generic rule for building any example file from ./examples
%: $(OBJS) $(GLAD) obj/%.o
$(CXX) -o bin/$@ $^ $(LDFLAGS)
obj/%.o: examples/%.cpp
$(CXX) $(CXXFLAGS) $(INC_DIR) -c $< -o $@
dist-zip-mac: $(OBJS)
ar rcs $(MACOS_DIST_NAME) $(OBJS)
mv $(MACOS_DIST_NAME) ./$(DIST_DIR)/platform/mac
python3 tools/zip_dist.py
dist-mac: $(OBJS)
ar rcs $(MACOS_DIST_NAME) $(OBJS)
mv $(MACOS_DIST_NAME) ./$(DIST_DIR)/platform/mac
dist-zip-linux: $(OBJS) $(GLAD)
ar rcs $(LINUX_DIST_NAME) $(OBJS) $(GLAD)
mv $(LINUX_DIST_NAME) ./$(DIST_DIR)/platform/linux
python3 tools/zip_dist.py
dist-linux: $(OBJS) $(GLAD)
ar rcs $(LINUX_DIST_NAME) $(OBJS) $(GLAD)
mv $(LINUX_DIST_NAME) ./$(DIST_DIR)/platform/linux
dist-win: $(OBJS) $(GLAD)
ar rcs $(WIN_DIST_NAME) $(OBJS) $(GLAD)
mv $(WIN_DIST_NAME) ./$(DIST_DIR)/platform/win
.PHONY: clean
clean:
@echo "Cleaning..."
@rm -f $(OBJS) $(GLAD) bin/* obj/main.test.o $(EXE) $(MACOS_DIST_NAME) $(LINUX_DIST_NAME) $(WIN_DIST_NAME) *.o *.test
@rm -rf *.dSYM
@echo "Done cleaning"
.PHONY: clean-main
clean-main:
@echo "Cleaning main.test..."
@rm -f obj/main.test.o $(EXE)
@echo "Done cleaning main.test"