-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
executable file
·130 lines (100 loc) · 2.17 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
VPATH = sources/:\
sources/draw/:\
sources/grid/:\
sources/mlx_utils/:\
sources/utils/:\
sources/rays/:\
sources/parsing/:\
sources/textures/\
SRCS = main.c
# Draw
SRCS += bresenham.c \
draw.c \
circle.c \
square.c \
triangle.c \
# Grid
SRCS += print_grid.c \
set_grid_cell.c \
grid_utils.c \
# Mlx utils
SRCS += hooks.c \
mlx_utils.c \
update.c \
# Utils
SRCS += fps_counter.c \
init_vision.c \
floor_and_ceiling.c \
return_error.c \
minimap.c \
player_movement.c \
free_cube.c \
# Rays
SRCS += create_rays.c \
dda.c \
calculate_collisions.c \
rays_render.c \
# Parsing
SRCS += parsing.c \
map_check.c \
description_check.c \
print_map.c \
get_map.c \
# Textures
SRCS += init_textures.c \
render_sprite.c \
sprites_init.c \
get_text_pixel.c \
OBJS = $(addprefix .objects/, $(SRCS:.c=.o))
INCLUDES = includes/cube3d.h \
includes/alias.h
CC = gcc
CFLAGS = -Wall -Wextra -Werror
DEBUG_FLAGS = #-fsanitize=address -g3
OPTI_FLAGS = -O3
NAME = cube_3d
LIB = Libft/libft.a
LFT = -L Libft -lft
RM = rm -rf
OS = $(shell uname -s)
ifeq ($(OS), Darwin)
OS_VAL = 1
MLX = ./mlx/mlx_mac
MLX_FLAGS = -L${MLX} -lmlx -framework OpenGL -framework Appkit $(LFT)
END=$'\x1b[0m
RED=$'\x1b[31m
GREEN=$'\x1b[32m
BLUE=$'\x1b[34m
ERASE=\033[2K\r
else
OS_VAL = 2
MLX = ./mlx/mlx_linux
MLX_FLAGS = -L${MLX} -lmlx -lXext -lX11 -lm -lz $(LFT)
END=\033[0m
RED=\033[31m
GREEN=\033[32m
BLUE=\033[34m
ERASE=\033[2K\r
endif
all: mlx_lib lib $(NAME)
bonus: mlx_lib lib $(NAME_BONUS)
mlx_lib:
make -C ${MLX}
lib:
make -C Libft
$(NAME): $(OBJS) $(INCLUDES) $(LIB) Makefile
@$(CC) $(OBJS) ${CFLAGS} $(DEBUG_FLAGS) $(OPTI_FLAGS) $(MLX_FLAGS) -I includes -o $@
@echo "$(ERASE)$(GREEN)[CREATED $(NAME)]$(END)"
.objects/%.o: %.c Makefile $(INCLUDES)
@mkdir -p .objects
@$(CC) -D OS=$(OS_VAL) $(CFLAGS) $(DEBUG_FLAGS) $(OPTI_FLAGS) -I${MLX} -I includes -c $< -o $@
@printf "$(ERASE)$(BLUE)[BUILDING]$(END) $@"
clean:
@${RM} ${OBJS} ${MAIN_OBJ} ${MAIN_BONUS_OBJ}
@make fclean -C Libft
@echo "${RED}[DELETED CUBE3D OBJS]${END}"
fclean: clean
@${RM} ${NAME} ${NAME_BONUS}
@${RM} .objects
@echo "${RED}[DELETED]${END} ${NAME}"
re: fclean all