-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
135 lines (117 loc) · 4.29 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
NAME := cub3D
CC := gcc
RM := rm -rf
OS := $(shell uname -s)
PATH_BUILD := build
PATH_LIBFT := libft
PATH_LIBMLX_MAC := dependencies/minilibx-macos
PATH_LIBMLX_LINUX := dependencies/minilibx-linux
SRCS_COMMON := \
srcs/exit/exit.c \
srcs/exit/free_assets.c \
srcs/extract/extract_main.c \
srcs/extract/extract_map.c \
srcs/extract/extract_map_finalize.c \
srcs/extract/extract_scene.c \
srcs/extract/extract_scene_extras.c \
srcs/extract/extract_utils.c \
srcs/extract/validate_map.c \
srcs/extract/validate_scene.c \
srcs/main.c \
srcs/play/draw/walls_ceiling_floor/draw_wall.c \
srcs/play/draw/walls_ceiling_floor/draw_floor_ceiling.c \
srcs/play/draw/extras/draw_gun.c \
srcs/play/draw/extras/draw_sprites.c \
srcs/play/draw/extras/draw_take_damage.c \
srcs/play/draw/extras/draw_healthbars.c \
srcs/play/draw/extras/draw_crosshair.c \
srcs/play/draw/menus/game_menu.c \
srcs/play/draw/menus/game_over.c \
srcs/play/draw/minimap/minimap.c \
srcs/play/play.c \
srcs/play/prepare/prepare_rays.c \
srcs/play/prepare/prepare_player.c \
srcs/play/prepare/textures/prepare_load_textures.c \
srcs/play/prepare/textures/prepare_load_items.c \
srcs/play/prepare/textures/prepare_load_weapons.c \
srcs/play/prepare/textures/prepare_map_specials.c \
srcs/play/prepare/textures/prepare_weapon_pos_dmg.c \
srcs/play/prepare/hooks/events.c \
srcs/play/prepare/hooks/keyboard_movement.c \
srcs/play/renderables/collect_renderables.c \
srcs/play/renderables/renderables.c \
srcs/play/update/cast_ray/ray_cast.c \
srcs/play/update/player/player_pos.c \
srcs/play/update/player/player_taking_damage.c \
srcs/play/update/shooting/handle_shooting.c \
srcs/play/update/shooting/handle_shooting_hits.c \
srcs/play/update/shooting/handle_shooting_traverse.c \
srcs/play/update/shooting/switch_weapon.c \
srcs/play/update/sprites/update_sprite_render_info.c \
srcs/play/update/sprites/update_sprites_utils.c \
srcs/play/update/sprites/update_main.c \
srcs/play/update/sprites/update_sprite_position.c \
srcs/play/update/items/update_items.c \
srcs/play/update/items/spawn_items.c \
srcs/play/update/items/update_item_effects.c \
srcs/play/update/items/book_of_wisdom.c \
srcs/utils/blend_colors.c \
srcs/utils/free_str_utils.c \
srcs/utils/math_utils.c \
srcs/utils/t_map.c \
srcs/utils/t_map2.c \
srcs/utils/str_to_long.c
FLAG_INC := $(addprefix -I, includes $(PATH_LIBFT))
ifeq ($(OS),Linux)
FLAG_INC += -I$(PATH_LIBMLX_LINUX)
SRCS_PLATFORM := \
srcs/exit/free_mlx_linux.c \
srcs/play/prepare/hooks/mouse_linux.c \
srcs/play/draw/menus/input_game_over_linux.c
else
FLAG_INC += -I$(PATH_LIBMLX_MAC)
SRCS_PLATFORM := \
srcs/exit/free_mlx_macos.c \
srcs/play/prepare/hooks/mouse_macos.c \
srcs/play/draw/menus/input_game_over_macos.c
endif
SRCS := $(SRCS_COMMON) $(SRCS_PLATFORM)
OBJS := $(SRCS:%.c=$(PATH_BUILD)/%.o)
DEPS := $(OBJS:.o=.d)
FLAGS_COMP := -O3 -Wall -Wextra -Werror $(FLAG_INC) -MMD -MP -g
FLAG_LIBFT := -L$(PATH_LIBFT) -lft
FLAG_LIBMLX_MAC := -L$(PATH_LIBMLX_MAC) -lmlx -framework OpenGL -framework AppKit -lz
FLAG_LIBMLX_LINUX := -L$(PATH_LIBMLX_LINUX) -lmlx -lX11 -lXext
ifeq ($(OS),Linux)
FLAGS_LINKING := -lm $(FLAG_LIBFT) $(FLAG_LIBMLX_LINUX)
FLAGS_COMP += -D LINUX
else
FLAGS_LINKING := -lm $(FLAG_LIBFT) $(FLAG_LIBMLX_MAC)
endif
all: init $(NAME)
@printf "\033[0;32mGame $(NAME) created. 🎮\033[0m\n"
init:
@ make -s -C $(PATH_LIBFT)
ifeq ($(OS),Linux)
@ make -C $(PATH_LIBMLX_LINUX)
else
@ make -C $(PATH_LIBMLX_MAC)
endif
$(NAME): $(OBJS)
@$(CC) $(OBJS) $(FLAGS_LINKING) -o $@
$(PATH_BUILD)/%.o: %.c
@mkdir -p $(dir $@)
@$(CC) $(FLAGS_COMP) -c $< -o $@
@printf "\033[0;33mCompiling $< 🔨\033[0m\n"
bonus: all
clean:
@ $(RM) $(PATH_BUILD)
@ make -s -C $(PATH_LIBFT) clean
@ make -s -C $(PATH_LIBMLX_MAC) clean
@ make -s -C $(PATH_LIBMLX_LINUX) clean
fclean: clean
@ $(RM) $(NAME)
@ make -s -C $(PATH_LIBFT) fclean
re: fclean all
.PHONY: all clean fclean re
-include $(DEPS)