-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
134 lines (116 loc) · 4.02 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: yait-el- <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2021/01/23 16:25:47 by yait-el- #+# #+# #
# Updated: 2021/03/07 08:14:51 by yait-el- ### ########.fr #
# #
# **************************************************************************** #
####################### Make Makefile beautiful
BLACK := $(shell tput -Txterm setaf 0)
RED := $(shell tput -Txterm setaf 1)
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
LIGHTPURPLE := $(shell tput -Txterm setaf 4)
PURPLE := $(shell tput -Txterm setaf 5)
BLUE := $(shell tput -Txterm setaf 6)
WHITE := $(shell tput -Txterm setaf 7)
RESET := $(shell tput -Txterm setaf 9)
####################### Project Name
NAME = RTv1
######################Executable / Libraries
MLX = libmlx.a
FT = libft.a
######################DIR
LFTDIR = library/Libft
SRCSDIR = src
OBJSDIR = obj
INCSDIR := inc
INCSDIR += $(LFTDIR)
MLXDIR = library/mlx
CHILDDIR := start
CHILDDIR += parse
CHILDDIR += mlx
CHILDDIR += libvect
CHILDDIR += raytracing
CHILDDIR += error
####################INC
INCS := inc/rtv1.h
INCS += inc/fuction.h
INCS += inc/struct.h
INCS += library/Libft/include/libft.h
INCS += library/mlx/mlx.h
########################SRC files
SRC :=start/main.c
SRC +=start/freeing.c
SRC +=mlx/mlx_stuff.c
SRC +=parse/parse.c
SRC +=parse/objs_parse.c
SRC +=parse/check_obj.c
SRC +=parse/tools_parse.c
SRC +=libvect/calc_vect.c
SRC +=libvect/vector_calculation.c
SRC +=libvect/vector_calculation2.c
SRC +=parse/light_parse.c
SRC +=parse/tools_parse2.c
SRC +=error/parse_error.c
SRC +=raytracing/raytracing.c
SRC +=raytracing/rotation.c
SRC +=raytracing/intersection.c
SRC +=raytracing/get_pxl.c
SRC +=raytracing/colors.c
#################### Libraries
LIBS := -L$(MLXDIR) -lmlx
LIBS += -framework OpenGL
LIBS += -framework AppKit
LIBS += -lz
LIBS += -L$(LFTDIR) -lft
################### 3ya9a li makine lache Oops!... I Did It Again
LFT = $(LFTDIR)/$(FT)
MLXX = $(MLXDIR)/$(MLX)
D_SRCS = $(addsuffix /, $(SRCSDIR))
D_OBJS = $(addsuffix /, $(OBJSDIR))
C_OBJS = $(addprefix $(D_OBJS), $(SRC:.c=.o))
C_INCS = $(foreach include, $(INCSDIR), -I$(include))
C_CHILDDIR = $(foreach dir, $(CHILDDIR),$(D_OBJS)$(dir))
################# Compilation flags
CC = gcc
RM = rm -rf
CFLAGS = $(C_INCS)
#----------------->>>>>>>>>>>>>>>>START<<<<<<<<<<<<<-------------------#
$(D_OBJS)%.o: $(D_SRCS)%.c $(INCS)
@echo "$(PURPLE)**********>>>Compiling : $(RESET) $(LIGHTPURPLE)" $<
@$(CC) $(CFLAGS) -c $< -o $@
all:$(OBJSDIR) $(C_CHILDDIR) $(NAME)
########## for D-bug
print-% : ; @echo $* = $($*)
############################
$(NAME):$(LFT) $(MLXX) $(C_OBJS)
@echo "$(RED)\n***********>>>Building : $(RESET)$(NAME) $(YELLOW)...\n$(RESET)"
@$(CC) $(CFLAGS) -o $(NAME) $(C_OBJS) $(LIBS)
######### make libft
$(LFT):
@make -sC $(LFTDIR)
######## create obj dir
$(OBJSDIR):
@mkdir -p $(OBJSDIR)
####### create sub folder
$(C_CHILDDIR):
@mkdir -p $(C_CHILDDIR)
####### make mlix
$(MLXX):
make -sC $(MLXDIR)
clean:
@make -sC $(LFTDIR) clean
@echo "$(GREEN)********** Deleting all object from $(NAME) **********\n$(RESET)"
@$(RM) $(C_OBJS)
fclean: clean
@make -sC $(LFTDIR) fclean
@echo "$(GREEN)********** Deleting $(NAME) **********\n$(RESET)"
@$(RM) $(NAME)
@$(RM) $(OBJSDIR)
re: fclean all
.PHONY: all clean fclean re