-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
107 lines (85 loc) · 3.12 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: akdovlet <akdovlet@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2024/12/18 10:04:18 by akdovlet #+# #+# #
# Updated: 2024/12/30 12:15:51 by akdovlet ### ########.fr #
# #
# **************************************************************************** #
# get all files with ls -d */*/* | sort
NAME := minirt
SRC := main.c \
test.c \
matrix/rotate.c \
matrix/transform.c \
matrix/degrees_to_radians.c \
matrix/matrix_cmp.c \
matrix/matrix_determinant.c \
matrix/matrix_inverse.c \
matrix/matrix_multiply.c \
matrix/matrix_print.c \
matrix/matrix_transpose.c \
matrix/matrix.c \
mlx/init_mlx.c \
mlx/key_manager.c \
mlx/mlx_clear.c \
mlx/mlx_pixel_put.c \
objects/ray_transform.c \
objects/ray.c \
objects/simulation.c \
objects/sphere.c \
tuple/color_new.c \
tuple/hadamard_product.c \
tuple/tuple_add.c \
tuple/tuple_cmp.c \
tuple/tuple_cross.c \
tuple/tuple_dot.c \
tuple/tuple_magnitude.c \
tuple/tuple_negate.c \
tuple/tuple_new.c \
tuple/tuple_normalize.c \
tuple/tuple_print.c \
tuple/tuple_scalar.c \
tuple/tuple_substract.c
SRC_DIR := src
BUILD := .build
SRC := $(addprefix $(SRC_DIR)/, $(SRC))
OBJ := $(patsubst $(SRC_DIR)/%.c, $(BUILD)/%.o, $(SRC))
DEP := $(OBJ:.o=.d)
LIBFT := libft/libft.a
CC := cc
CFLAGS := -Wall -Werror -Wextra -MMD -MP -Iinclude -Ilibft/include -g -Imlx_linux
MATH := -lm
all: create_dir $(NAME)
create_dir: | $(BUILD)
print:
@echo $(OBJ)
$(BUILD):
@mkdir -p $(BUILD)
$(NAME): $(OBJ) $(LIBFT)
@$(CC) $(CFLAGS) $(OBJ) -Lmlx_linux -lmlx_Linux -Imlx_linux -lXext -lX11 -lz -o $(NAME) $(LIBFT) $(MATH)
$(BUILD)/%.o: $(SRC_DIR)/%.c
@mkdir -p $(@D)
@$(CC) $(CFLAGS) -c $< -o $@
@printf "\033[1;32%sm\tCompiled: $(<F)\033[0m\n";
$(LIBFT):
@$(MAKE) --no-print-directory -C libft
clean:
@if [ -d $(BUILD) ]; then $(RM) -rf $(BUILD) && printf "\033[1;31m\tDeleted: $(NAME) $(BUILD)\033[0m\n"; fi
@$(MAKE) --no-print-directory clean -C libft
fclean:
@make --no-print-directory clean
@if [ -f $(NAME) ]; then $(RM) -rf $(NAME) && printf "\033[1;31m\tDeleted: $(NAME)\033[0m\n"; fi
@$(MAKE) --no-print-directory fclean -C libft
full: all
valgrind --leak-check=full --show-leak-kinds=all --track-fds=yes --trace-children=yes ./${NAME}
run:
@make --no-print-directory all && ./minirt
re:
@make --no-print-directory fclean
@make --no-print-directory all
-include $(DEP)
.PHONY: all clean fclean re create_dir