-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
92 lines (70 loc) · 2.66 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: jovicto2 <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/09/13 14:09:11 by jovicto2 #+# #+# #
# Updated: 2023/09/26 08:51:38 by jovicto2 ### ########.org.br #
# #
# **************************************************************************** #
# Variables
NAME := fdf
SOURCES_DIR := sources/
OBJECTS_DIR := objects/
HEADERS_DIR := includes/
LIBRARIES_DIR := libraries/
BUILD_DIR := build/
MLX_DIR := $(addprefix $(LIBRARIES_DIR), mlx42/)
LIBFT_DIR := $(addprefix $(LIBRARIES_DIR), libft/)
MLX_FILE := libmlx42.a
LIBFT_FILE := libft.a
MAKE := make
CMAKE := cmake
MAKE_LIBS := $(MAKE) -C
CC := cc
CFLAGS := -Wall -Wextra -Werror -Wunreachable-code -Ofast -O3 -g3
FSANITIZE := -fsanitize=address
MKDIR := mkdir -p
RM := rm -rf
MLX_FLAGS := -ldl -lglfw -pthread -lm
# Sources
SOURCE_FILES := fdf \
apply_bresenham \
handle_data handle_mlx handle_points \
handle_camera_hooks handle_view_hooks \
parse_map \
render_map render_menu
SOURCES := $(addprefix $(SOURCES_DIR), $(addsuffix .c, $(SOURCE_FILES)))
OBJECTS := $(addprefix $(OBJECTS_DIR), $(addsuffix .o, $(SOURCE_FILES)))
LIBFT := $(addprefix $(LIBFT_DIR), $(LIBFT_FILE))
MLX_BUILD := $(addprefix $(MLX_DIR), $(BUILD_DIR))
MLX := $(addprefix $(MLX_BUILD), $(MLX_FILE))
LIBFT_HEADER := $(addprefix $(LIBFT_DIR), includes/libft.h)
MLX_HEADER := $(addprefix $(MLX_DIR), include/)
HEADERS := -I $(HEADERS_DIR) -I $(MLX_HEADER)
# Rules
.PHONY: all clean fclean re
all: libraries $(NAME)
libraries: $(MLX) $(LIBFT)
$(NAME): $(OBJECTS)
@$(CC) $(CFLAGS) $(FSANITIZE) $(OBJECTS) $(LIBFT) $(MLX) $(MLX_FLAGS) -o $(NAME) $(HEADERS)
$(LIBFT):
@$(MAKE_LIBS) $(LIBFT_DIR)
$(MLX):
@$(CMAKE) $(MLX_DIR) -B $(MLX_BUILD) && $(MAKE_LIBS) $(MLX_BUILD) -j4
$(OBJECTS_DIR)%.o: $(SOURCES_DIR)%.c
@$(MKDIR) $(OBJECTS_DIR)
@$(CC) $(CFLAGS) -c $< -o $@
clean: cleanlibs
@$(RM) $(OBJECTS_DIR)
cleanlibs: cleanmlx cleanlibft
cleanlibft:
@$(MAKE_LIBS) $(LIBFT_DIR) fclean
cleanmlx:
@$(RM) $(MLX_BUILD)
fclean: clean
@$(RM) $(NAME)
re: fclean
@$(MAKE)