-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
167 lines (129 loc) · 3.67 KB
/
Makefile
File metadata and controls
167 lines (129 loc) · 3.67 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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
UNAME_S := $(shell uname -s)
NAME = game
CC = g++
INCS = includes/
SRCS = sources/
OBJS = objs
SHELL := /bin/bash
INCLUDES = -I $(INCS) \
-I $(INCS)/CustomSceneControllers/ \
-I $(INCS)/CustomSceneControllers/VoxelProcedural/ \
-I GLScene/includes \
-I GLScene/CLDevice/includes \
-I libs/nanogui/include \
-I libs/nlohmannjson \
\
-I libs/nanogui/ext/eigen \
-I libs/nanogui/ext/nanovg/src/ \
\
LIBS = -lm \
`pkg-config --static --libs glfw3` \
`pkg-config --static --libs glm` \
`pkg-config --static --libs assimp` \
`pkg-config glfw3 --cflags-only-I` \
`pkg-config glm --cflags-only-I` \
`pkg-config assimp --cflags-only-I` \
-L GLScene -lGLScene \
-L libs/nanogui/build -lnanogui \
ifeq ($(UNAME_S),Linux)
USE_GLAD = ON
LIBS += -L/usr/lib \
-lOpenCL \
-lOpenGL \
endif
ifeq ($(UNAME_S),Darwin)
USE_GLAD = OFF
LIBS += -L/usr/lib \
-framework OpenCL \
-framework OpenGL \
endif
CPP_FILES = $(shell find $(SRCS) -type f -name *.cpp)
CPP_DIRS = $(shell find $(SRCS) -depth -type d)
CPP_FLAGS += -std=c++17 -Wall -Wextra
ifeq ($(release), )
CPP_FLAGS += -g -DDEBUG
else
CPP_FLAGS += -O3 -DNDEBUG
endif
O_DIRS = $(addprefix $(OBJS)/,$(CPP_DIRS))
O_FILES_TMP = $(CPP_FILES:%.cpp=$(OBJS)/%.o)
O_FILES = $(O_FILES_TMP:%.s=$(OBJS)/%.o)
DEPS = $(O_FILES:.o=.d)
$(shell mkdir -p $(O_DIRS) $(OBJS))
# Print
ACTUAL = $(words $(COUNT))
TOTAL = $(words $(filter %.cpp,$(CPP_FILES)))
INCREMENT = $(eval COUNT+=1)
PRINTINC = $(INCREMENT) $(PRINT)
PRINT = printf "\r \033[31;1m%3s%%\033[0m\t -->>\t\033[31;1m%-65s\033[0m\r" "$(shell echo $(ACTUAL)\*100\/$(TOTAL) | bc)" "$^"
PRINTDONE = printf "\r \033[32;1m%3s%%\033[0m\t -->>\t\033[32;1m%-65s\033[0m\r" "$(shell echo $(ACTUAL)\*100\/$(TOTAL) | bc)" "$@"
all: $(NAME)
run: all
./$(NAME)
cmakerun:
mkdir build && cd build && cmake .. || echo
cd build && make -j4
./build/$(NAME)
install:
brew update
brew install pkg-config || brew upgrade pkg-config
brew install glfw || brew upgrade glfw
brew install glm || brew upgrade glm
brew install assimp || brew upgrade assimp
GLScene:
@make -C GLScene release=$(release)
$(NAME): GLScene libs/nanogui/build/libnanogui.a libs/nlohmannjson $(O_FILES)
@$(CC) $(CPP_FLAGS) \
$(INCLUDES) \
$(LIBS) \
-o $@ $(O_FILES) && $(PRINTDONE) && echo || exit
$(OBJS)/%.o: %.cpp
@$(CC) $(CPP_FLAGS) \
$(INCLUDES) \
-o $@ -c $< && $(PRINTINC) || exit
clean:
rm -fr $(O_FILES) $(OBJS)
make -C GLScene clean
fclean: clean
make -C GLScene fclean
rm -f $(NAME)
rm -fr $(NAME).app
rm -fr build
rm -fr libs
re: fclean all
app: all
mkdir -p $(NAME).app/Contents/MacOS
mkdir -p $(NAME).app/Contents/Resources
cp $(NAME) $(NAME).app/Contents/MacOS/game 2> /dev/null
cp Info.plist $(NAME).app/Contents
cp -r assets $(NAME).app/Contents/Resources
libs:
@mkdir libs || :
libs/nanogui: libs
@if [ ! -d $@ ]; then \
git clone --recursive https://github.com/wjakob/nanogui.git libs/nanogui ; \
fi
@touch $@
libs/nanogui/build: libs/nanogui
@mkdir libs/nanogui/build 2> /dev/null || :
libs/nanogui/build/Makefile: libs/nanogui/build
@if [ ! -f $@ ]; then \
cd libs/nanogui/build && cmake -DNANOGUI_USE_GLAD=$(USE_GLAD) -DNANOGUI_BUILD_SHARED=OFF -DNANOGUI_BUILD_PYTHON=OFF -DNANOGUI_BUILD_EXAMPLE=OFF .. ; \
fi
@touch $@
libs/nanogui/build/libnanogui.a: libs/nanogui/build/Makefile
@if [ ! -f $@ ]; then \
make -j4 -C libs/nanogui/build ; \
fi
@touch $@
libs/nlohmannjson: libs
@if [ ! -d $@ ]; then \
cd libs && \
wget https://github.com/nlohmann/json/releases/download/v3.7.0/include.zip && \
unzip -q include.zip -d . && \
mv include nlohmannjson && \
rm include.zip ; \
fi
@touch $@
-include $(DEPS)
.PHONY: all GLScene install clean fclean re app