-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
87 lines (72 loc) · 3.26 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: ***REMOVED*** <***REMOVED***@student.***REMOVED***. +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/01/30 14:27:39 by ***REMOVED*** #+# #+# #
# Updated: 2024/03/20 11:01:15 by ***REMOVED*** ### ########.fr #
# #
# **************************************************************************** #
NAME := cub3d
CC := cc
CFLAGS := -Wall -Wextra -Werror
SRCDIR := src
OBJDIR := objs
LIBMLX := ./libs/MLX42
MLXLIB := $(LIBMLX)/build/libmlx42.a
LIB := -L ./libs/libft_combined -lmylib -L $(LIBMLX)/build -ldl -lglfw -lm -lmlx42 -pthread
HEADERS := -I ./includes -I ./libs/libft_combined/includes -I $(LIBMLX)/include/MLX42
SRCS := $(SRCDIR)/main.c\
$(SRCDIR)/mlx_drawing/drawing_main.c\
$(SRCDIR)/mlx_handlers/handlers_main.c\
$(SRCDIR)/mlx_handlers/movement_utils.c\
$(SRCDIR)/mlx_handlers/key_hook_utils.c\
$(SRCDIR)/mlx_handlers/cleanup_utils.c\
$(SRCDIR)/mlx_handlers/input_hooks.c\
$(SRCDIR)/map_parsing/parsing_main.c\
$(SRCDIR)/map_parsing/parsing/parse_type_ids_1.c\
$(SRCDIR)/map_parsing/parsing/parse_type_ids_2.c\
$(SRCDIR)/map_parsing/helper/print_error_message.c\
$(SRCDIR)/map_parsing/free_memory/free.c\
$(SRCDIR)/map_parsing/helper/atoi.c\
$(SRCDIR)/map_parsing/parsing/get_config_file_members.c\
$(SRCDIR)/map_parsing/parsing/parse_colors.c\
$(SRCDIR)/map_parsing/parsing/trim.c\
$(SRCDIR)/map_parsing/parsing/type_id_info.c\
$(SRCDIR)/map_parsing/parsing/open_config_file.c\
$(SRCDIR)/map_parsing/parsing/copy_map.c\
$(SRCDIR)/map_parsing/parsing/copy_map_2.c\
$(SRCDIR)/map_parsing/parsing/parse_map.c\
$(SRCDIR)/map_parsing/parsing/parse_map_2.c\
$(SRCDIR)/map_parsing/parsing/check_textures.c\
$(SRCDIR)/raycasting/raycasting_main.c\
$(SRCDIR)/raycasting/textures.c\
$(SRCDIR)/raycasting/raycasting_dda.c\
$(SRCDIR)/mlx_handlers/position_manipulation.c\
OBJS := $(patsubst $(SRCDIR)/%.c,$(OBJDIR)/%.o,$(SRCS))
all: $(MLXLIB) $(OBJDIR) $(NAME)
$(MLXLIB):
@if [ ! -d "$(LIBMLX)" ]; then \
mkdir -p libs && \
git clone --depth 1 --branch v2.3.3 https://github.com/codam-coding-college/MLX42 $(LIBMLX) && \
cmake -S $(LIBMLX) -B $(LIBMLX)/build && \
make -C $(LIBMLX)/build -j4; \
fi
$(OBJDIR):
mkdir -p $(OBJDIR) $(OBJDIR)/map_parsing $(OBJDIR)/mlx_drawing $(OBJDIR)/mlx_handlers $(OBJDIR)/raycasting $(OBJDIR)/map_parsing/parsing $(OBJDIR)/map_parsing/helper $(OBJDIR)/map_parsing/free_memory
$(OBJDIR)/%.o: $(SRCDIR)/%.c
$(CC) $(CFLAGS) $(HEADERS) -c $< -o $@
$(NAME): $(OBJS)
make -C libs/libft_combined
$(CC) $(CFLAGS) $(LIB) $(HEADERS) $(OBJS) -o $(NAME)
clean:
make -C libs/libft_combined clean
rm -rf $(OBJDIR)
fclean: clean
rm -rf $(LIBMLX)
make -C libs/libft_combined fclean
rm -rf $(NAME)
re: fclean all
.PHONY: all, clean, fclean, re