-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·166 lines (151 loc) · 4.31 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: ngragas <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2021/01/30 19:52:31 by ngragas #+# #+# #
# Updated: 2021/05/19 21:54:14 by ngragas ### ########.fr #
# #
# **************************************************************************** #
NAME = cub3D
CC = clang
CFLAGS = -Wall -Wextra -Werror -MMD -g -Ofast -march=native #-fsanitize=address
SRC := main \
control \
control_borders \
draw_walls \
initialize \
parse \
parse_set \
parse_set_map \
raycasting \
utils
SRC_BONUS := control_extra \
demo_tools \
doors \
doors_extra \
draw_ceilfloor \
draw_ceilfloor_plain \
draw_effects \
draw_figures \
draw_fills \
draw_hud \
draw_message \
draw_objects \
draw_pixels \
draw_map \
draw_texture_set \
enemies \
enemy_logic \
free_resources \
hooks \
initialize_images \
image_utils \
load_files \
load_resources \
objects \
pathfind \
pathfind_bfs_grid \
pathfind_construct \
pickups \
sounds \
screenshot \
terminate \
weapons \
os_adapters/put_image_to_window \
os_adapters/new_image
ifeq ($(OS),Windows_NT)
NAME := $(addsuffix .exe, $(NAME))
endif
SRC_DIR := sources/
INC_DIR := includes/
OBJ_DIR = objects/
SRC_BONUS_DIR = sources_bonus/
ifeq ($(filter bonus, $(MAKECMDGOALS)), bonus)
SWITCH_CLEAN := $(addsuffix .o, $(SRC))
SRC_DIR = $(SRC_BONUS_DIR)
SRC := $(addsuffix _bonus, $(SRC) $(SRC_BONUS))
else
SWITCH_CLEAN := $(addsuffix _bonus.o, $(SRC) $(SRC_BONUS))
endif
SWITCH_CLEAN := $(addprefix $(OBJ_DIR), $(SWITCH_CLEAN) $(SWITCH_CLEAN:.o=.d))
RM_SWITCH_CLEAN := $(shell $(RM) $(SWITCH_CLEAN))
SRC := $(addsuffix .c, $(SRC))
OBJ = $(addprefix $(OBJ_DIR), $(SRC:.c=.o))
DEP = $(OBJ:.o=.d)
LIBFT_DIR = libft/
LIBFT = $(LIBFT_DIR)libft.a
PLATFORM := $(shell uname -s)
ifeq ($(PLATFORM), Darwin)
MLX_DIR = minilibx_macos_opengl/
else
MLX_DIR = minilibx_linux/
endif
MLX = $(MLX_DIR)libmlx.a
CUTE_PNG_DIR = cute_png/
CUTE_PNG = $(CUTE_PNG_DIR)cute_png.o
CUTE_SOUND_DIR = cute_sound/
CUTE_SOUND = $(CUTE_SOUND_DIR)cute_sound.o
LIBS = $(LIBFT) $(MLX)
CPPFLAGS = -I$(LIBFT_DIR) -I$(MLX_DIR) -I$(INC_DIR)
LDFLAGS = -L$(LIBFT_DIR) -L$(MLX_DIR)
LDLIBS = -lft -lmlx
ifeq ($(PLATFORM), Darwin)
LDLIBS += -framework OpenGL -framework AppKit -lz
else
LDLIBS += -lX11 -lXext -lXrender -lm
LIBS += $(CUTE_PNG)
LDLIBS += $(CUTE_PNG)
CPPFLAGS+= -I$(CUTE_PNG_DIR)
endif
ifeq ($(filter bonus, $(MAKECMDGOALS)), bonus)
LIBS += $(CUTE_SOUND)
LDLIBS += $(CUTE_SOUND)
CPPFLAGS += -I$(CUTE_SOUND_DIR)
ifeq ($(PLATFORM), Darwin)
LDLIBS += -framework AudioUnit
else ifeq ($(PLATFORM), Linux)
LDLIBS += -lSDL2 -pthread
else ifeq ($(OS),Windows_NT)
LDLIBS += -lSDL2 -lpthread
endif
endif
all bonus: $(NAME)
$(NAME): $(LIBS) $(OBJ)
$(CC) $(CFLAGS) $(OBJ) -o $@ $(LDFLAGS) $(LDLIBS)
$(LIBFT): FORCE
$(MAKE) -C $(LIBFT_DIR)
$(MLX): FORCE
$(MAKE) -C $(MLX_DIR) "CFLAGS=-DSTRINGPUTX11 -Ofast \
-Wno-deprecated -Wno-return-type -Wno-parentheses -Wno-pointer-sign"
$(CUTE_PNG): FORCE
$(MAKE) -C $(CUTE_PNG_DIR)
$(CUTE_SOUND): FORCE
$(MAKE) -C $(CUTE_SOUND_DIR)
$(OBJ): | $(OBJ_DIR)os_adapters
$(OBJ_DIR)os_adapters:
mkdir -p $@
$(OBJ_DIR)%.o: $(SRC_DIR)%.c Makefile
$(CC) $(CFLAGS) -c $< -o $@ $(CPPFLAGS)
-include $(DEP)
clean:
$(RM) $(OBJ)
$(RM) $(DEP)
$(RM)r $(OBJ_DIR)
$(MAKE) -C $(LIBFT_DIR) $@
$(MAKE) -C $(MLX_DIR) $@
$(MAKE) -C $(CUTE_PNG_DIR) $@
$(MAKE) -C $(CUTE_SOUND_DIR) $@
fclean: clean
$(RM) $(NAME)
$(RM) $(LIBFT)
$(RM) $(MLX)
$(RM) $(CUTE_PNG)
$(RM) $(CUTE_SOUND)
re: fclean all
norm:
@norminette $(SRC_DIR)* $(INC_DIR)*
.PHONY: FORCE all clean fclean re bonus switch_clean norm
FORCE: