-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
120 lines (92 loc) · 3.11 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: imisumi <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/01/28 00:51:40 by ichiro #+# #+# #
# Updated: 2024/08/07 13:29:45 by imisumi ### ########.fr #
# #
# **************************************************************************** #
NAME = miniRT
CFLAGS = -I$(INCDIR)
CFLAGS += -I./lib/libft/includes/
CFLAGS += -I./lib/lib3d/includes/
CFLAGS += -I./lib/MLX42/include/
CFLAGS += -I./lib/tinyEXR/
CC = gcc -O2
CC += -Wall -Wextra -Werror -g -fsanitize=address
# CC += -g -fsanitize=thread -pthread
# CC += -Wuninitialized -Wall -Wextra -Werror
SRCDIR := src
INCDIR := includes
OBJDIR := .obj
MLX = lib/MLX42/build/libmlx42.a
LIBFT = lib/libft/libft.a
LIB3D = lib/lib3d/lib3d.a
TINYEXR = ./lib/tinyEXR/tinyexr.o ./lib/tinyEXR/dep/miniz.o
SOURCES = $(wildcard $(SRCDIR)/**/*.c) $(wildcard $(SRCDIR)/*.c)
SOURCES += ./lib/MLX42/lib/png/lodepng.c
OBJECTS = $(patsubst $(SRCDIR)/%.c,$(OBJDIR)/%.o,$(SOURCES))
RED=\033[1;31m
PINK=\033[1;35m
CYAN=\033[1;36m
GREEN=\033[0;32m
NC=\033[0m
# MLX42
LFLAGS = -lglfw -L./lib/MLX42/build/ -lmlx42
# libft
LFLAGS += -L./lib/libft/ -lft
# lib3d
LFLAGS += -L./lib/lib3d/ -l3d
# c++ for tinyexr
LFLAGS += -lstdc++
OS := $(shell uname -m)
ifeq ($(OS), arm64)
LFLAGS += -framework Cocoa -framework OpenGl -framework IOKit -lglfw
$(info arm64)
else ifeq ($(OS),x86_64)
LFLAGS += -ldl -lglfw -pthread -lm
$(info x86_64)
endif
$(NAME): $(OBJECTS) $(MLX) $(LIBFT) $(LIB3D) $(TINYEXR)
@$(CC) $(CFLAGS) $^ -o $@ $(LFLAGS)
$(OBJDIR)/%.o: $(SRCDIR)/%.c
@mkdir -p $(dir $@)
@$(CC) $(CFLAGS) -c $< -o $@
@echo "$(CYAN)[Created $@]$(NC)"
$(MLX):
git submodule update --init --recursive lib/MLX42
cd ./lib/MLX42 && cmake -B build && cmake --build build --parallel
$(LIBFT):
$(MAKE) -C lib/libft
$(LIB3D):
@$(MAKE) -C lib/lib3d
$(TINYEXR):
$(MAKE) -C lib/tinyEXR/dep
$(MAKE) -C lib/tinyEXR
$(eval OBJECTS += ./lib/tinyEXR/tinyexr.o ./lib/tinyEXR/dep/miniz.o)
all: $(NAME)
@echo "$(GREEN)[Compiled $(NAME)]$(NC)"
run: all
./$(NAME)
norm:
norminette $(SRCDIR) includes/constants.h includes/darray.h includes/minirt.h includes/struct.h
norminette lib/libft/src lib/libft/includes
norminette lib/lib3d/srcs lib/lib3d/includes
rerun: re
./$(NAME)
clean:
@rm -rf $(OBJDIR)
@echo "$(RED)[Deleted $(NAME) objects]$(NC)"
fclean: clean
@rm -rf $(NAME)
@echo "$(RED)[Deleted $(NAME)]$(NC)"
re: fclean all
libclean:
$(MAKE) -C lib/tinyEXR clean
$(MAKE) -C lib/tinyEXR/dep clean
$(MAKE) -C lib/lib3d fclean
$(MAKE) -C lib/libft fclean
.PHONY: all clean fclean re