-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
127 lines (99 loc) · 2.18 KB
/
Makefile
File metadata and controls
127 lines (99 loc) · 2.18 KB
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
NAME = cub3d
CC = cc
CFLAGS = -Wall -Wextra -Werror -O3
DEBUG = -g3 -fsanitize=address -DDEBUG_FLAG=1 #-fsanitize=address
RM = rm -f
SRC = main.c\
get_next_line.c\
get_next_line_utils.c\
error.c\
garbage_collector/garbage_collector.c\
exit.c\
init_data.c\
read_config.c\
read_config_utils.c\
init_map.c\
init_map_util.c\
init_sprite.c\
check_map_validity.c\
check_map_util.c\
minimap.c\
screen_renderer.c\
hook.c\
player_move.c\
raycasting.c\
raycasting_util.c\
drawline.c\
drawline_util.c\
door.c\
door_util.c\
sprite.c\
sprite_util.c\
user_interface.c\
gun.c\
enemy.c\
SRC := $(SRC:%=src/%)
OBJ = $(SRC:%.c=%.o)
INC_DIR = -Isrc
LIBFLAGS += -L.
# NOTE: library order (-ldlinkedlist and -lft) can be problem
LIBFLAGS += -ldlinkedlist
DLLIST = libdlinkedlist.a
DLLIST_DIR = dlinkedlist
LIBRARYS += DLLIST.lib
INC_DIR += -I$(DLLIST_DIR)
LIBFLAGS += -lft
LIBFT = libft.a
LIBFT_DIR = libft
LIBRARYS += LIBFT.lib
INC_DIR += -I$(LIBFT_DIR)
LIBFLAGS += -lmlx42
MLX42 = libmlx42.a
MLX42_DIR = mlx42
LIBRARYS += MLX42.lib
INC_DIR += -I$(MLX42_DIR)/include/MLX42
ifeq ($(shell uname), Linux)
LIBFLAGS += -ldl -lglfw -pthread -lm
else ifeq ($(shell uname -m), arm64)
LIBFLAGS += -lglfw -L"/opt/homebrew/Cellar/glfw/3.3.8/lib/"
else
LIBFLAGS += -lglfw -L"/Users/$(USER)/.brew/opt/glfw/lib/"
endif
ifeq ($(DEBUG_FLAG), 1)
CFLAGS += $(DEBUG)
LIB_DEBUG_FLAG = DEBUG_FLAG=1
COMPILE = DEBUG.flag
else
COMPILE = RELEASE.flag
endif
libs: $(COMPILE) $(LIBRARYS)
$(MAKE) $(NAME)
all: $(NAME)
debug:
$(MAKE) DEBUG_FLAG=1 libs
RELEASE.flag:
$(MAKE) fclean
touch RELEASE.flag
DEBUG.flag:
$(MAKE) fclean
touch DEBUG.flag
$(LIBRARYS): %.lib:
$(MAKE) -C $($*_DIR) $(LIB_DEBUG_FLAG) all
@cp -p $($*_DIR)/$($*) .
$(NAME): $(OBJ)
$(CC) $(CFLAGS) -o $@ $(OBJ) $(LIBFLAGS) $(INC_DIR)
$(OBJ): %.o: %.c
$(CC) $(CFLAGS) -c -o $@ $< $(INC_DIR)
clean:
$(RM) $(OBJ)
$(RM) DEBUG.flag RELEASE.flag
fclean: clean $(LIBRARYS:%=%.clean)
$(RM) $($(LIBRARYS:%.lib=%))
$(RM) $(NAME)
$(LIBRARYS:%=%.clean): %.lib.clean:
$(RM) $($*)
@$(MAKE) -C $($*_DIR) fclean
$(RM) $*.lib
re: fclean
$(MAKE) libs
.PHONY: all clean fclean re libs