-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
121 lines (101 loc) · 3.18 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
NAME = cub3d
NAMEF = cub3dsani
MAKEFLAGS += --quiet
OS = $(shell uname -s)
LIBFT = libft_ext/libft.a
LIBMLX = libraries/minilibx-linux/libmlx.a
CFLAGS = -g -Wall -Wextra -Werror -O3 -fsanitize=address
# CFLAGS = -I/usr/include -Imlx_linux -O3 -g
IFLAGS = -I libraries/minilibx-linux -Ilmlx -I/includes -Imath
LFLAGS = -L libraries/minilibx-linux -lmlx -lXext -lX11 -lm
IFLAGS_D = -I libraries/minilibx_opengl -Ilmlx -I/includes
LFLAGS_D = -L libraries/minilibx_opengl -lmlx -framework OpenGL -framework AppKit
# LFLAGS = -I ./mlx_linux -L ./mlx_linux -lmlx -Ilmlx -lXext -lX11
AR = ar rcsv
OBJ_DIR = obj
SRC_DIR = src
OBJ = $(SRC:%.c=$(OBJ_DIR)/%.o)
HEADER = cub3d.h\
mlx.h\
SRC = main.c\
parse.c\
check.c\
play.c\
play_utils.c\
draw.c\
draw_utils.c\
draw_vertical_rays.c\
draw_horizontal_rays.c\
error.c\
player.c\
map.c\
math.c\
draw_utils2.c\
all: $(NAME)
$(NAME): $(OBJ)
ifeq ($(OS),Darwin)
$(MAKE) all -C libft_ext
$(MAKE) -C libraries/minilibx_opengl
@echo $(ANSI_RESET) ""
@echo $(ANSI_B_BGREEN) "compile executable" $(ANSI_RESET)$(ANSI_F_BBLACK)
clang $(CFLAGS) $(IFLAGS_D) $(OBJ) $(LIBFT) $(LFLAGS_D) -o $(NAME)
@echo $(ANSI_RESET) ""
endif
ifeq ($(OS),Linux)
@echo $(ANSI_B_BGREEN) "compile libft_ext" $(ANSI_RESET)$(ANSI_F_BBLACK)
$(MAKE) all -C libft_ext
@echo $(ANSI_RESET) ""
@echo $(ANSI_B_BGREEN) "compile libmlx" $(ANSI_RESET)$(ANSI_F_BBLACK)
@echo $(ANSI_RESET) ""
$(MAKE) -C libraries/minilibx-linux
@echo $(ANSI_RESET) ""
@echo $(ANSI_B_BGREEN) "compile executable" $(ANSI_RESET)$(ANSI_F_BBLACK)
clang $(CFLAGS) $(IFLAGS) $(OBJ) $(LIBFT) $(LFLAGS) -o $(NAME)
@echo $(ANSI_RESET) ""
endif
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(addprefix includes/,$(HEADER))
# @echo $(ANSI_B_BGREEN) "compile $(NAME) objects" $(ANSI_RESET)$(ANSI_F_BBLACK)
mkdir -p $(dir $@)
clang $(CFLAGS) -Iincludes -c $< -o $@
# @echo $(ANSI_RESET)
clean:
@echo $(ANSI_B_RED) "clean" $(ANSI_RESET)$(ANSI_F_BRED)
$(MAKE) clean -C libft_ext
rm -rf $(OBJ_DIR)
@echo $(ANSI_RESET) ""
fclean: clean
@echo $(ANSI_B_RED) "fclean" $(ANSI_RESET)$(ANSI_F_BRED)
$(MAKE) fclean -C libft_ext
rm -f $(NAME)
@echo $(ANSI_RESET) ""
re: fclean all
.PHONY: all clean fclean
# colors
ANSI_RESET = "\033[0m"
ANSI_B_RED = "\033[41m"
ANSI_B_YELLOW = "\033[43m"
ANSI_B_BGREEN = "\033[42;1m"
ANSI_F_BRED = "\033[31;1m"
ANSI_F_BBLACK = "\033[30;1m"
lib:
$(MAKE) -C libft_ext
norm:
@echo $(ANSI_B_RED) "norminette v3" $(ANSI_RESET)
$(MAKE) norminette -C libft_ext
@norminette $(addprefix inc/,$(HEADER)) \
$(addprefix src/,$(SRC))
libnorm:
@echo $(ANSI_B_RED) "libft norminette" $(ANSI_RESET)
$(MAKE) norm -C libft_ext
run: all
@echo $(ANSI_B_RED) "Running Game" $(ANSI_RESET)
./$(NAME) $(MAP)
# @./$(NAME)
runv: all
@echo $(ANSI_B_RED) "Valgrind RESULT" $(ANSI_RESET)
#valgrind -q --leak-check=full --track-origins=yes --show-leak-kinds=all ./$(NAME)
valgrind --leak-check=full --show-leak-kinds=all -s ./$(NAME) maps/map.cub
test: all
@echo $(ANSI_B_RED) "Running test" $(ANSI_RESET)
clang -I ./libraries/mlx_linux -L ./libraries/mlx_linux -lmlx -Ilmlx -lXext -lX11 libraries/mlx_linux/libmlx.a test.c libft_ext/libft.a libraries/mlx_linux/libmlx.a -o windows_test
./windows_test