-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
107 lines (73 loc) · 2.97 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
# --------------------------------- MAKEFILE --------------------------------- #
# ---------------------------------------------------------------------------- #
# Config #
# ---------------------------------------------------------------------------- #
NAME := miniRT
CC := cc
RPP := 10
CFLAGS := -I./includes -Wall -Wextra -Werror
LINKS = -Iinclude -lglfw -L"/Users/$(USER)/.brew/opt/glfw/lib/"
LINKS += -framework Cocoa -framework OpenGL -framework IOKit
LINKS += -pthread
LIBFT_DIR := ./libraries/libft
LIBFT := ./libraries/libft/libft.a
MLX_DIR := ./libraries/mlx
MLX := ./libraries/mlx/build/libmlx42.a
# ---------------------------------------------------------------------------- #
# Files #
# ---------------------------------------------------------------------------- #
OBJ_DIR := ./objs
VPATH := ./src/ ./src/parser/ ./src/utils/ ./src/debugging/ ./src/input/
VPATH += ./src/free/ ./src/render/ ./src/vec_utils/ ./src/lighting/
VPATH += ./src/objects/
SRC := main.c
PARSER_SRC := parser.c init_scene.c parser_utils.c init_objects.c input_check.c
UTIL_SRC := progress_bar.c split_line.c colour_utils.c ft_dabs.c utils.c
FREE_SRC := free_objects.c
INPUT_SRC := input.c
RENDER_SRC := render_scene.c ray_calculations.c mlx.c anti_aliasing.c viewport.c
DEBUGGING_SRC := t_printing.c
VEC_UTILS_SRC := vector_operations.c vector_operations2.c
LIGHTING_SRC := lighting.c ambient_light.c lighting_utils.c
OBJECTS_SRC := cylinder.c cylinder2.c plane.c sphere.c objects.c
SRCS := $(SRC) $(PARSER_SRC) $(UTIL_SRC) $(DEBUGGING_SRC) $(INPUT_SRC)
SRCS += $(FREE_SRC) $(RENDER_SRC) $(VEC_UTILS_SRC) $(LIGHTING_SRC)
SRCS += $(OBJECTS_SRC)
OBJS := $(addprefix $(OBJ_DIR)/, $(SRCS:%.c=%.o))
# ---------------------------------------------------------------------------- #
# Rules #
# ---------------------------------------------------------------------------- #
all: .submodules_initialized $(NAME)
$(NAME): $(OBJS) $(LIBFT) $(MLX)
$(CC) $(CFLAGS) $(OBJS) -o $(NAME) $(LIBFT) $(MLX) $(LINKS)
@echo $(GREEN)"Linking MiniRT"$(DEFAULT);
$(LIBFT):
make -C $(LIBFT_DIR)
$(MLX):
@cd libraries/mlx && cmake -B build && cmake --build build -j4
$(OBJ_DIR)/%.o: %.c
mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@
debug: CFLAGS += -g
debug: re
nflag: CFLAGS = -I./includes
nflag: all
.submodules_initialized:
git submodule init $(LIBFT_DIR)
git submodule update $(LIBFT_DIR)
git submodule init $(MLX_DIR)
git submodule update $(MLX_DIR)
@touch .submodules_initialized
wsl: LINKS := -ldl -lglfw -pthread -lm
wsl: all
# wsl: CFLAGS += -g
clean:
rm -rf $(OBJS)
fclean: clean
make fclean -C $(LIBFT_DIR)
rm -f $(NAME) .submodules_initialized
re: fclean all
.PHONY: all clean fclean re
# Colours to make it look nice :)
DEFAULT = "\033[39m"
GREEN = "\033[32m"