-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
80 lines (55 loc) · 1.52 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
NAME = cub3D
# PROGRAMS #
CC = cc
RM = rm
# DIRECTORIES #
INC_DIR = include
LIB_DIR = lib
SRC_DIR = src
BUILD_DIR = build
SUB_DIRS = game parser world hud structs utils
LIBFT_DIR = $(LIB_DIR)/libft
MLX_DIR = $(LIB_DIR)/MLX42
MLX_BUILD = $(MLX_DIR)/build
# FLAGS #
CFLAGS = -Wall -Wextra -Werror -MMD# -g3 -fsanitize=address
MLXFLAGS = -lglfw -framework Cocoa -framework OpenGL -framework IOKit
RMFLAGS = -rf
INCFLAGS = -I./$(INC_DIR) \
-I./$(LIBFT_DIR)/include \
-I./$(MLX_DIR) \
-I./$(MLX_DIR)/include/MLX42
# FILES #
SRCS = $(SRC_DIR)/main.c \
$(foreach dir, $(SUB_DIRS), $(wildcard $(SRC_DIR)/$(dir)/*.c))
OBJS = $(addprefix $(BUILD_DIR)/, $(SRCS:.c=.o))
DEPS = $(OBJS:.o=.d)
# ARCHIVES #
LIBFT = $(LIBFT_DIR)/libft.a
MLX42 = $(MLX_BUILD)/libmlx42.a
# RULES #
$(NAME): $(LIBFT) $(MLX42) $(OBJS)
$(CC) $(CFLAGS) $(INCFLAGS) $(LIBFT) $(MLX42) $(MLXFLAGS) -o $@ $(OBJS)
$(LIBFT):
@git submodule update --init --recursive --remote $(LIBFT_DIR)
@make -C $(LIBFT_DIR)
$(MLX42):
@git submodule update --init --recursive --remote $(MLX_DIR)
@brew install glfw
@cmake -S $(MLX_DIR)/ -B $(MLX_BUILD) -DGLFW_FETCH=1
@make -C $(MLX_BUILD)
-include $(DEPS)
$(BUILD_DIR)/%.o: %.c
@mkdir -p $(@D)
$(CC) $(CFLAGS) $(INCFLAGS) -c $< -o $@
all: $(NAME)
clean:
$(RM) $(RMFLAGS) $(BUILD_DIR)
fclean: clean
$(RM) $(RMFLAGS) $(NAME)
re: fclean all
libclean:
$(RM) $(RMFLAGS) $(LIBFT_DIR) $(MLX_DIR)
allclean: libclean fclean
libupdate: libclean all
.PHONY: all clean fclean re libclean allclean libupdate