-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
162 lines (130 loc) · 4.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
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: cpieri <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2018/03/15 11:20:25 by cpieri #+# #+# #
# Updated: 2018/06/28 12:42:51 by cvautrai ### ########.fr #
# #
# **************************************************************************** #
NAME = rt
CC = gcc
CFLAGS = -Wall -Wextra -Werror -O3 -flto #-g -fsanitize=address -fno-omit-frame-pointer
FW_PATH = frameworks
SDL_PATH = $(FW_PATH)/SDL2.framework
IMG_PATH = $(FW_PATH)/SDL2_image.framework
TTF_PATH = $(FW_PATH)/SDL2_ttf.framework
SDL_FLAGS = -F $(FW_PATH) -framework SDL2 -framework SDL2_image -framework SDL2_ttf -rpath $(FW_PATH)
SDL_LOCAL_FLAGS = -framework SDL2 -F $(FW_PATH) -framework SDL2_image -framework SDL2_ttf -rpath $(FW_PATH)
CPPFLAGS= -Iincludes
FLAGSFT = -L./libft -lft -L./libgraph -lgraph
SRC_PATH= srcs
OBJ_PATH= obj
DEPS = Makefile \
includes/rt.h \
libft/libft.a \
libgraph/libgraph.a
SRC_NAME= main.c \
display.c \
init_struct.c \
inputs.c \
utils.c \
intersection.c \
normal.c \
camera.c \
img.c \
rotation_matrix.c \
ray_adapter.c \
light.c \
exit.c \
filter.c \
ui.c \
textures.c \
limit.c \
sdl_init.c \
parser.c \
parser_check_print.c\
parser_get_objs.c \
parser_get_lights.c \
parser_sc_infos.c \
parser_utils.c \
draw_ui.c \
setf_btn.c \
button_event.c \
textures_setup.c \
screenshot.c \
new_objs.c \
perlin.c \
perlin_init.c \
free_ui.c \
filter_2.c \
fastmode_complete.c \
transparency.c \
parser_grab_objs.c \
parser_grab_extras.c\
change_sc.c \
ui_filters.c \
command.c \
ui_command.c \
get_intersection.c \
cam_move.c \
get_shape.c \
command_rot.c \
blur_mode.c \
check_light.c
OBJ_NAME= $(SRC_NAME:.c=.o)
SRC = $(addprefix $(SRC_PATH)/,$(SRC_NAME))
OBJ = $(addprefix $(OBJ_PATH)/,$(OBJ_NAME))
NONE = \033[0m
RED = \033[31m
GREEN = \033[32m
YELLOW = \033[33m
BLUE = \033[34m
MAGENTA = \033[35m
CYAN = \033[36m
.PHONY: all clean fclean re echo norm
all: LFT LGRAPH $(NAME)
$(NAME): libft echo $(OBJ)
@if [ -d "/Library/Frameworks/SDL2.framework" ]; then \
$(CC) $(CFLAGS) $(FLAGSFT) -o $(NAME) $(OBJ) $(CPPFLAGS) $(SDL_LOCAL_FLAGS); \
else \
$(CC) $(CFLAGS) $(FLAGSFT) -o $(NAME) $(OBJ) $(CPPFLAGS) $(SDL_FLAGS); \
fi
@echo "\n$(GREEN)$(NAME) ready!$(NONE)"
echo:
@ echo -n Getting $(NAME) ready
$(OBJ_PATH)/%.o: $(SRC_PATH)/%.c $(DEPS)
@mkdir $(OBJ_PATH) 2> /dev/null || true
@if [ -d "/Library/Frameworks/SDL2.framework" ]; then \
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -I/Library/Frameworks/SDL2.framework/Headers/ -I $(IMG_PATH)/Headers -I $(TTF_PATH)/Headers -o $@; \
else \
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -I $(SDL_PATH)/Headers -I $(TTF_PATH)/Headers -I $(IMG_PATH)/Headers -o $@; \
fi
@echo -n .
clean:
@echo "$(YELLOW)Cleaning...$(NONE)"
@make clean -C ./libft/
@make clean -C ./libgraph/
@/bin/rm -f $(OBJ)
@rmdir $(OBJ_PATH) 2> /dev/null || true
@/bin/rm -rf $(PATH_SDL)
fclean: clean
@make fclean -C ./libft/
@echo "$(RED)Libft.a deleted$(NONE)"
@make fclean -C ./libgraph/
@echo "$(RED)Libgraph.a deleted$(NONE)"
@/bin/rm -f $(NAME)
@echo "$(RED)$(NAME) deleted !$(NONE)"
norm: clean
@echo "$(CYAN)Running norminette...$(NONE)"
@norminette $(SRC_PATH) $(INCLUDE) libft/ libgraph/ \
| grep -B 1 '^Error' 2> /dev/null || echo '$(GREEN)Norme OK !$(NONE)';
re: fclean all
LFT:
@make -C ./libft/;
@echo "\n$(GREEN)Libft ready!$(NONE)";
LGRAPH:
@make -C ./libgraph/;
@echo "\n$(GREEN)Libgraph ready!$(NONE)";