-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
179 lines (137 loc) · 5.22 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
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
168
169
170
171
172
173
174
175
176
177
178
179
CC = gcc
CPPC = g++
NAME = nibbler
CFLAGSOG =
CPPFLAGSOG = -std=c++17
FLAGS = -Wall -Werror -Wextra -I glfw/include -I glad/include -I SDL2/include -I includes -I SFML/include -I SFML/lib
SFMLTAR='SFML-clang.tar.gz'
SFML_DIR='SFML-2.5.0-macOS-clang'
DWNLD=sh -c '$$(curl -Lo $(SFMLTAR) --progress-bar https://www.sfml-dev.org/files/SFML-2.5.0-macOS-clang.tar.gz)'
UNTAR=sh -c '$$(tar -xzf $(SFMLTAR) && rm -rf $(SFMLTAR))'
CR_MV=sh -c '$$(mv $(SFML_DIR) ./SFML && mkdir -p ./SFML/Frameworks && cp -rf ./SFML/extlibs/* ./SFML/Frameworks/.)'
CFLAGS = $(CFLAGSOG) $(FLAGS)
CPPFLAGS = $(CPPFLAGSOG) $(FLAGS)
RPATH = -Wl,-rpath,$(PWD)/SFML/Frameworks
OPENGLCDEP = $(ODIR)/glad.o glfw/src/libglfw3.a -framework GLUT -framework Cocoa -framework OpenGL -framework IOKit -framework CoreVideo
SDLCDEP = SDL2/build/libSDL2main.a SDL2/build/libSDL2.a -framework AudioToolbox -framework CoreVideo -framework Carbon -framework ForceFeedback -framework IOKit -framework Cocoa -framework CoreAudio -liconv -lm -Wl,-current_version,10.0.0 -Wl,-compatibility_version,1.0.0 -Wl,-undefined,error
SFMLCDEP = -F SFML/Frameworks $(RPATH) -framework sfml-graphics -framework sfml-audio -framework sfml-network -framework sfml-window -framework sfml-system
FILES = main.cpp Game.cpp Snoekie.cpp Food.cpp Exceptions.cpp
OPENGLSRC = Renderers/OpenGLRenderer.cpp
SDLSRC = Renderers/SDLRenderer.cpp
SFMLSRC = Renderers/SFMLRenderer.cpp
OPENGLLIB = libOpengl.so
SDLLIB = libSDL.so
SFMLLIB = libSFML.so
OPENGLLIBDEP = Renderers/OpenGLRenderer.hpp
SDLLIBDEP = Renderers/SDLRenderer.hpp
SFMLLIBDEP = Renderers/SFMLRenderer.hpp
COMPILEDHPP = nibblerpch.hpp
ODIR = obj
SDIR = src
LDIR = lib
IDIR = inc
DEPS = IRenderer.hpp Game.hpp Snoekie.hpp IEntity.hpp Vec.hpp Food.hpp Exceptions.hpp
OPENGLOBJ := $(patsubst %.cpp, $(ODIR)/%.o, $(OPENGLSRC))
SDLOBJ := $(patsubst %.cpp, $(ODIR)/%.o, $(SDLSRC))
SFMLOBJ := $(patsubst %.cpp, $(ODIR)/%.o, $(SFMLSRC))
OPENGLLIBDEP := $(patsubst %, $(IDIR)/%, $(OPENGLLIBDEP))
SDLLIBDEP := $(patsubst %, $(IDIR)/%, $(SDLLIBDEP))
SFMLLIBDEP := $(patsubst %, $(IDIR)/%, $(SFMLLIBDEP))
OPENGLLIB := $(patsubst %, $(LDIR)/%, $(OPENGLLIB))
SDLLIB := $(patsubst %, $(LDIR)/%, $(SDLLIB))
SFMLLIB := $(patsubst %, $(LDIR)/%, $(SFMLLIB))
OPENGLSRC := $(patsubst %, $(SDIR)/%, $(OPENGLSRC))
SDLSRC := $(patsubst %, $(SDIR)/%, $(SDLSRC))
SFMLSRC := $(patsubst %, $(SDIR)/%, $(SFMLSRC))
OBJ := $(patsubst %.cpp, $(ODIR)/%.o, $(FILES))
OBJ := $(patsubst %.c, $(ODIR)/%.o, $(OBJ))
SRC := $(patsubst %, $(SDIR)/%, $(FILES))
DEPS := $(patsubst %, $(IDIR)/%, $(DEPS))
PCH := $(patsubst %, %.gch, $(COMPILEDHPP))
COMPILEDHPP := $(patsubst %, %, $(COMPILEDHPP))
BLACK=\033[0;30m
RED=\033[0;31m
GREEN=\033[0;32m
YELLOW=\033[0;33m
BLUE=\033[0;34m
PURPLE=\033[0;35m
CYAN=\033[0;36m
WHITE=\033[0;37m
END=\033[0m
all: $(ODIR) $(LDIR) $(PCH) $(SDLLIB) $(SFMLLIB) $(OPENGLLIB) $(NAME)
GLFW:
@echo "$(CYAN)Making\t\t$(GREEN)GLFW$(END)"
@git submodule init glfw
@git submodule update glfw
@cd glfw && cmake .
@make -C glfw
SDL2: SDL2.tar.gz
@echo "$(CYAN)Making\t\t$(GREEN)SDL2$(END)"
@mkdir -p SDL2
@mkdir -p SDL2/build
@tar -xf SDL2.tar.gz -C SDL2 --strip-components 1
@cd SDL2/build && cmake .. && make
SDL2.tar.gz:
@curl -o SDL2.tar.gz https://www.libsdl.org/release/SDL2-2.0.9.tar.gz
SFML:
mkdir -p $(SFML_DIR)
$(DWNLD)
$(UNTAR)
$(CR_MV)
# FREETYPE: freetype.tar.gz
# mkdir -p FREETYPE
# mkdir -p FREETYPE/build
# tar -xf freetype.tar.gz -C FREETYPE --strip-components 1
# cd FREETYPE/build && cmake .. && make
# freetype.tar.gz:
# curl -o freetype.tar.gz https://tenet.dl.sourceforge.net/project/freetype/freetype2/2.10.1/freetype-2.10.1.tar.gz
$(OPENGLLIB): GLFW $(ODIR)/glad.o $(OPENGLOBJ) $(OPENGLLIBDEP)
@echo "$(CYAN)Compiling\t$(GREEN)$(OPENGLLIB)$(END)"
$(CPPC) -shared $(OPENGLOBJ) -o $@ $(CPPFLAGS) $(OPENGLCDEP)
$(SFMLLIB): SFML $(SFMLOBJ) $(SFMLLIBDEP)
@echo "$(CYAN)Compiling\t$(GREEN)$(SFMLLIB)$(END)"
@$(CPPC) -shared $(SFMLOBJ) -o $@ $(CPPFLAGS) $(SFMLCDEP)
$(SDLLIB): SDL2 $(SDLOBJ) $(SDLLIBDEP)
@echo "$(CYAN)Compiling\t$(GREEN)$(SDLLIB)$(END)"
@$(CPPC) -shared $(SDLOBJ) -o $@ $(CPPFLAGS) $(SDLCDEP)
$(NAME): $(ODIR) $(OBJ)
@echo "$(CYAN)Linking\t\t$(GREEN)$(NAME)$(END)";
$(CPPC) -o $(NAME) $(OBJ) $(CPPFLAGS) -I $(IDIR) -L$(LDIR)
%.hpp.gch: %.hpp
@echo "$(YELLOW)Compiling\t$(GREEN)$@$(END)";
$(CPPC) -o $@ $< $(CPPFLAGS) -I $(IDIR)
$(ODIR)/glad.o: glad/src/glad.c $(DEPS) $(COMPILEDHPP)
@echo "$(CYAN)Compiling\t$(GREEN)$@$(END)";
@$(CC) -c -o $@ $< $(CFLAGS)
$(ODIR)/%.o: $(SDIR)/%.cpp $(DEPS) $(COMPILEDHPP)
@echo "$(CYAN)Compiling\t$(GREEN)$@$(END)";
@$(CPPC) -c -o $@ $< $(CPPFLAGS) -I $(IDIR) -I . -include $(COMPILEDHPP)
$(LDIR):
mkdir -p $(LDIR)
$(ODIR):
@echo "$(CYAN)Creating\t$(GREEN)$(ODIR)$(END)";
@cd $(SDIR) && \
find . -type d > ../hold.txtAVM && \
cd .. && \
mkdir -p $(ODIR) && \
cd $(ODIR) && \
xargs mkdir -p < ../hold.txtAVM;
@rm hold.txtAVM;
clean:
@echo "$(RED)Cleaning\t$(END)";
@rm -rf $(ODIR)
@rm -rf $(PCH)
fclean: clean
@echo "$(RED)Removing\t$(GREEN)$(NAME)$(END)";
@rm -rf $(NAME)
@rm -rf $(OPENGLLIB)
@rm -rf $(SDLLIB)
@rm -rf $(SFMLLIB)
@make clean -C glfw
@rm -rf SDL2
@rm -rf SDL2.tar.gz
@rm -rf $(SFML_DIR)
@rm -rf SFML
re: fclean all
shallowre: clean all
.PHONY: re clean all fclean GLUT GLFW $(ODIR) SDL2 FREETYPE