-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
177 lines (147 loc) · 4.02 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
CC := clang++
TARGET := Nibbler
SDL2_LOC := $(shell brew --prefix sdl2)
SDL2_INC := $(SDL2_LOC)/include/SDL2/
SDL2_LINK := -L $(SDL2_LOC)/lib/ -lSDL2
SDL2_IMAGE_LOC := $(shell brew --prefix sdl2_image)
SDL2_IMAGE_INC := $(SDL2_IMAGE_LOC)/include/SDL2/
SDL2_IMAGE_LINK := -L $(SDL2_IMAGE_LOC)/lib/ -lSDL2_image
SDL2_TTF_LOC := $(shell brew --prefix sdl2_ttf)
SDL2_TTF_INC := $(SDL2_TTF_LOC)/include/SDL2/
SDL2_TTF_LINK := -L $(SDL2_TTF_LOC)/lib/ -lSDL2_ttf
SDL2_MIXER_LOC := $(shell brew --prefix sdl2_mixer)
SDL2_MIXER_INC := $(SDL2_MIXER_LOC)/include/SDL2/
SDL2_MIXER_LINK := -L $(SDL2_MIXER_LOC)/lib/ -lSDL2_mixer
SFML_LOC := $(shell brew --prefix sfml)
SFML_INC := $(SFML_LOC)/include/
SFML_LINK := -Wl,-rpath $(SFML_LOC)/lib \
-L $(SFML_LOC)/lib/ -lsfml-system \
-L $(SFML_LOC)/lib/ -lsfml-graphics \
-L $(SFML_LOC)/lib/ -lsfml-window
SFML_NETWORK_LINK := -Wl,-rpath $(SFML_LOC)/lib \
-L $(SFML_LOC)/lib/ -lsfml-system \
-L $(SFML_LOC)/lib/ -lsfml-network \
GLEW_LOC := $(shell brew --prefix glew)
GLEW_INC := $(GLEW_LOC)/include/
GLEW_LINK := -L $(GLEW_LOC)/lib/ -lGLEW
GLM_LOC := $(shell brew --prefix glm)
GLM_INC := $(GLM_LOC)/include/
CFLAGS := -std=c++11 -Wall -Werror -Wextra -Wfatal-errors
INCLUDES := includes/
HEADERS := -I $(INCLUDES) \
-I $(SDL2_INC) \
-I $(SDL2_IMAGE_INC) \
-I $(SDL2_TTF_INC) \
-I $(SDL2_MIXER_INC) \
-I $(SFML_INC) \
-I $(GLEW_INC) \
-I $(GLM_INC)
SRCSDIR := srcs/
SRCS := \
AudioManager.cpp \
Board.cpp \
Cell.cpp \
Client.cpp \
Enemy.cpp \
EnemyCell.cpp \
FoodCell.cpp \
Model.cpp \
NetworkEntity.cpp \
Nibbler.cpp \
NibblerException.cpp \
OpenGLModule.cpp \
ParsingException.cpp \
Player.cpp \
ResourceManager.cpp \
SDLModule.cpp \
SFMLModule.cpp \
Server.cpp \
Shader.cpp \
Snake.cpp \
SnakeCell.cpp \
direction.cpp \
main.cpp
OBJDIR := objs/
OBJS := $(addprefix $(OBJDIR), $(SRCS:.cpp=.o))
MY_SFML_LIB := myLibSFML.so
MY_SDL_LIB := myLibSDL.so
MY_OPENGL_LIB := myLibOpenGL.so
MY_AUDIO_LIB := myLibAudio.so
MY_SFML_OBJS := \
objs/SFMLModule.o
MY_SDL_OBJS := \
objs/NibblerException.o \
objs/ResourceManager.o \
objs/SDLModule.o
MY_OPENGL_OBJS := \
objs/Model.o \
objs/NibblerException.o \
objs/OpenGLModule.o \
objs/ResourceManager.o \
objs/Shader.o
MY_AUDIO_OBJS := \
objs/AudioManager.o \
objs/NibblerException.o \
objs/ResourceManager.o
REMAINING_OBJS := \
objs/Board.o \
objs/Cell.o \
objs/Client.o \
objs/Enemy.o \
objs/EnemyCell.o \
objs/FoodCell.o \
objs/NetworkEntity.o \
objs/Nibbler.o \
objs/NibblerException.o \
objs/ParsingException.o \
objs/Player.o \
objs/Server.o \
objs/Snake.o \
objs/SnakeCell.o \
objs/direction.o \
objs/main.o
all: $(TARGET)
$(MY_SFML_LIB): $(MY_SFML_OBJS)
@echo "\x1b[1mBuilding $(MY_SFML_LIB)...\x1b[0m"
$(CC) -shared -fPIC $(HEADERS) \
-o $(MY_SFML_LIB) $(MY_SFML_OBJS) \
$(SFML_LINK)
$(MY_SDL_LIB): $(MY_SDL_OBJS)
@echo "\x1b[1mBuilding $(MY_SDL_LIB)...\x1b[0m"
$(CC) -shared -fPIC $(HEADERS) \
-o $(MY_SDL_LIB) $(MY_SDL_OBJS) \
$(SDL2_LINK) \
$(SDL2_IMAGE_LINK)
$(MY_OPENGL_LIB): $(MY_OPENGL_OBJS)
@echo "\x1b[1mBuilding $(MY_OPENGL_LIB)...\x1b[0m"
$(CC) -shared -fPIC $(HEADERS) \
-o $(MY_OPENGL_LIB) $(MY_OPENGL_OBJS) \
$(SDL2_LINK) \
$(SDL2_IMAGE_LINK) \
$(GLEW_LINK) \
-framework OpenGL
$(MY_AUDIO_LIB): $(MY_AUDIO_OBJS)
@echo "\x1b[1mBuilding $(MY_AUDIO_LIB)...\x1b[0m"
$(CC) -shared -fPIC $(HEADERS) \
-o $(MY_AUDIO_LIB) $(MY_AUDIO_OBJS) \
$(SDL2_LINK) \
$(SDL2_MIXER_LINK)
$(OBJDIR)%.o: $(SRCSDIR)%.cpp
@mkdir -p $(OBJDIR)
$(CC) -c $(CFLAGS) $(HEADERS) $< -o $@
$(TARGET): $(OBJS) $(MY_SFML_LIB) $(MY_SDL_LIB) $(MY_OPENGL_LIB) $(MY_AUDIO_LIB)
@echo "\x1b[1mBuilding $(TARGET)...\x1b[0m"
$(CC) -o $(TARGET) $(REMAINING_OBJS) \
$(MY_SFML_LIB) $(MY_SDL_LIB) $(MY_OPENGL_LIB) $(MY_AUDIO_LIB) \
$(SFML_NETWORK_LINK)
@echo "\x1b[1mBuild finished!!\x1b[0m"
clean:
@echo "\x1b[1mCleaning...\x1b[0m"
/bin/rm -rf $(OBJDIR)
@echo
fclean: clean
@echo "\x1b[1mFcleaning...\x1b[0m"
/bin/rm -f $(TARGET) $(MY_SFML_LIB) $(MY_SDL_LIB) $(MY_OPENGL_LIB) $(MY_AUDIO_LIB)
@echo
re: fclean all
.PHONY: all clean fclean re sdl2 sdl2_image sdl2_ttf sdl2_mixer sfml