forked from sgkhusal/42-miniRT
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
125 lines (103 loc) · 4.33 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
122
123
124
125
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: elraira- <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/02/04 21:14:15 by coder #+# #+# #
# Updated: 2022/10/08 11:51:591 by elraira- ### ########.fr #
# #
# **************************************************************************** #
NAME = miniRT
NAME_BONUS = miniRT_bonus
# **************************************************************************** #
LIBFT_PATH = ./libraries/libft
LIBFT = $(LIBFT_PATH)/libft.a
MLX_PATH = ./libraries/minilibx_linux
MLX = $(MLX_PATH)/libmlx.a
UNIT_TESTS_PATH = ./unit_tests
# **************************************************************************** #
# INPUTS
SRCS = minirt.c $(WORLD) $(SHAPES) $(INTERSECT) $(INPUT) $(INPUT_M) \
$(TUPLES) $(MATRICES) $(UTILS)
WORLD = world.c transform.c computations.c camera.c light.c lighting.c
SHAPES = sphere.c cylinder.c objects.c plane.c material.c normal.c
INTERSECT = ray.c intersection.c hit.c intersect_sort.c
INPUT = handle_input.c input_file.c handle_ambient.c handle_camera.c \
handle_sphere.c handle_plane.c handle_cylinder.c \
validate_utils.c transform_utils.c input_utils.c get_rotation.c
INPUT_M = handle_content.c handle_light.c
TUPLES = point.c vector.c vector_and_point_operations.c \
vector_operations.c
MATRICES = matrix.c matrix_multiply.c matrix_operations.c \
matrix_inverse.c matrix_transform.c matrix_rotation.c
UTILS = utils.c error.c mlx_utils.c colors.c canvas.c plot.c clean.c
OBJS_DIR = ./obj
OBJS = $(SRCS:%.c=$(OBJS_DIR)/%.o)
HEADERS = minirt.h matrix.h tuples.h mlx_utils.h elements.h utils.h
VPATH = includes src src/tuple src/matrix src/input src/objects \
src/utils src/world src/intersect
INCLUDE = -I./ -I./includes
# bonus
INPUT_B = handle_content_bonus.c handle_light_bonus.c
SRCS_BONUS = minirt.c $(WORLD) $(SHAPES) $(INTERSECT) $(INPUT) $(INPUT_B) \
$(TUPLES) $(MATRICES) $(UTILS)
OBJS_BONUS = $(SRCS_BONUS:%.c=$(OBJS_DIR)/%.o)
# compilation
CC = gcc
CFLAGS = -Wall -Werror -Wextra -g -O3 #-fsanitize=leak
MLXFLAGS = -lm -lXext -lX11
# clean
RM = -rm -f
RM_DIR = rm -rf
# colors
YELLOW = \033[1;33m
GREEN = \033[1;32m
RESET = \033[0m
# **************************************************************************** #
# rules
all: $(NAME)
bonus: $(NAME_BONUS)
$(OBJS_DIR)/%.o: %.c $(HEADERS)
$(CC) $(CFLAGS) -c $< -o $@ $(INCLUDE)
$(NAME): $(OBJS_DIR) $(LIBFT) $(MLX) $(OBJS)
$(CC) $(CFLAGS) -o $@ $(OBJS) $(LIBFT) $(MLX) $(MLXFLAGS)
@echo "$(GREEN)"
@echo "************************************"
@echo " miniRT created"
@echo "************************************"
@echo "$(RESET)"
$(NAME_BONUS): $(OBJS_DIR) $(LIBFT) $(MLX) $(OBJS_BONUS)
$(CC) $(CFLAGS) -o $@ $(OBJS_BONUS) $(LIBFT) $(MLX) $(MLXFLAGS)
@echo "$(GREEN)"
@echo "************************************"
@echo " miniRT_bonus created"
@echo "************************************"
@echo "$(RESET)"
$(LIBFT):
@echo "$(YELLOW)making libft....$(RESET)"
$(MAKE) --no-print-directory -C $(LIBFT_PATH)
@echo "$(YELLOW)libft.a created$(RESET)"
@echo "------------------------------------------------------------------"
$(MLX):
@echo "$(YELLOW)making minilibx....$(RESET)"
$(MAKE) --no-print-directory -C $(MLX_PATH)
@echo "$(YELLOW)libmlx.a created$(RESET)"
@echo "------------------------------------------------------------------"
$(OBJS_DIR):
mkdir -p $(OBJS_DIR)
test: $(NAME)
./$(NAME) scenes/composition.rt
utest:
@$(MAKE) --no-print-directory -C $(UNIT_TESTS_PATH) test
clean:
$(RM_DIR) $(OBJS_DIR)
@$(MAKE) --no-print-directory -C $(LIBFT_PATH) clean
fclean: clean
$(RM) $(NAME)
$(RM) $(NAME_BONUS)
@$(MAKE) --no-print-directory -C $(LIBFT_PATH) fclean
@$(MAKE) --no-print-directory -C $(MLX_PATH) clean
re: fclean all
.PHONY: all clean fclean re test utest