-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
91 lines (67 loc) · 1.86 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
NAME = cub3D
CC = gcc
CFLAGS = -Wall -Werror -Wextra -g
RM = rm -f
# Libft
LIBFT = include/libft/libft.a
LIBFT_PATH = include/libft/
# Minilibx
MLX = mlx/
# Detect OS and set flags
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S), Linux)
LINUX = -ldl -lglfw -pthread -lm
INC = -I include/
LIB_LINUX = mlx/libmlx42.a
CLIBS = $(INC) $(LIB_LINUX) $(LINUX)
endif
ifeq ($(UNAME_S), Darwin)
CLIBS = mlx/libmlx42.a -lglfw -L "/Users/$$USER/.brew/opt/glfw/lib/"
endif
# Sources and objects
MAIN = cub3d init
PARSING = parsing parsing_utils
UTILS = utils logs map_utils list_ops parse_utils color cast_utils move_utils moves
RAYING = casting fov mini_map texture
SRCS = $(addsuffix .c, $(addprefix src/main/, $(MAIN))) \
$(addsuffix .c, $(addprefix src/parsing/, $(PARSING))) \
$(addsuffix .c, $(addprefix src/utils/, $(UTILS))) \
$(addsuffix .c, $(addprefix src/raying/, $(RAYING))) \
OBJS = $(SRCS:.c=.o)
# Rules
all: $(NAME)
-@$(MAKE) -C $(MLX)
$(NAME): $(OBJS)
# -@norminette $(SRCS) include/
# @echo "\n$(GREEN)NORMINETTE OK✅$(DEFAULT)"
-@$(MAKE) -C $(LIBFT_PATH)
-@$(CC) $(CFLAGS) -o $@ $^ $(LIBFT) $(CLIBS)
%.o: %.c
@$(CC) $(CFLAGS) $(INC) -c $< -o $@
clean:
@$(RM) $(OBJS)
@make -C $(LIBFT_PATH) clean
@make -C $(MLX) clean
fclean: clean
-@$(RM) -rf $(NAME) $(LIBFT) $(NAME).dSYM
re: fclean all
.PHONY: all clean libft fclean re
git:
@git add .
@git commit -m "$(COMMIT)"
@echo "\n$(GREEN)$(NAME) Committed!$(DEFAULT)💯"
#COLORS
RED = \033[1;31m
GREEN = \033[1;32m
YELLOW = \033[1;33m
DEFAULT = \033[0m
COMMIT = $(shell date "+%d %B %T")
# valgrind
summary:
valgrind --leak-check=summary --trace-children=yes --track-fds=yes ./$(NAME) $m
valgrind:
valgrind --leak-check=full --trace-children=yes --track-fds=yes ./$(NAME) $m
full:
valgrind --leak-check=full --show-leak-kinds=definite ./$(NAME) $m
leak:
leaks --atExit -- ./$(NAME) $m