-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
55 lines (37 loc) · 1.22 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
NAME = miniRT
include src.mk
SRC = $(addprefix src/, $(SRC_FILES))
OBJ = $(SRC:.c=.o)
LIBS = ft mlx Xext X11 m
# **************************************************************************** #
LIB_DIR = lib/libft
MLX_DIR = lib/minilibx-linux
INC_DIR = include $(MLX_DIR) $(addsuffix /include, $(LIB_DIR))
SRC_DIR = src
LIB_PATHS = $(LIB_DIR) $(MLX_DIR)
# **************************************************************************** #
CC = gcc
CFLAGS = -Wall -Wextra -Werror
CPPFLAGS = $(foreach path, $(INC_DIR), -I $(path))
LDFLAGS = $(foreach path, $(LIB_PATHS), -L $(path))
LIBFLAGS = $(foreach lib, $(LIBS), -l $(lib))
RM = rm -f
.c.o:
@$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $(<:.c=.o)
$(NAME): $(OBJ)
@$(foreach path, $(LIB_PATHS), make -C $(path);)
@$(CC) $(OBJ) $(LDFLAGS) $(LIBFLAGS) -o $@
all: $(NAME)
clean:
@$(RM) $(OBJ)
@echo "Object files for $(NAME) removed."
@$(foreach lib, $(LIB_PATHS), make -C $(lib) clean;)
fclean: clean
@$(RM) $(NAME)
@echo "$(NAME) removed."
@$(foreach lib, $(LIB_DIR), make -C $(lib) fclean;)
re: fclean all
check_leaks: re
valgrind --leak-check=full --show-leak-kinds=all --track-origins=yes \
./miniRT scenes/sphere1.rt
.PHONY: all clean fclean re .c.o