-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
70 lines (53 loc) · 1.54 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
# Variables
NAME := cub3D
SOURCES_DIR := sources/
OBJECTS_DIR := objects/
HEADERS_DIR := includes/
LIBRARIES_DIR := libraries/
LIBFT_DIR := $(addprefix $(LIBRARIES_DIR), libft/)
LIBFT_FILE := libft.a
MAKE := make
MAKE_LIBS := $(MAKE) -sC
CC := cc
CFLAGS := -Wall -Wextra -Werror -Wunreachable-code -Ofast -g3
MKDIR := mkdir -p
RM := rm -rf
# Sources
FILES := main
SOURCES := $(addprefix $(SOURCES_DIR), $(addsuffix .c, $(FILES)))
OBJECTS := $(addprefix $(OBJECTS_DIR), $(addsuffix .o, $(FILES)))
LIBFT := $(addprefix $(LIBFT_DIR), $(LIBFT_FILE))
LIBFT_HEADER := $(addprefix $(LIBFT_DIR), includes/libft.h)
HEADERS := -I $(HEADERS_DIR)
MESSAGE1 := "------------------Compiling cub3d Objects!-------------------"
MESSAGE2 := "---------------Objects Compiled Successfully!----------------"
MESSAGE3 := "-----------------'.cub3d' File Compiled Successfully!----------------"
# Rules
.PHONY: all clean fclean re bonus
all: $(NAME)
$(NAME): $(LIBFT) $(OBJECTS)
@ echo ' '
@ echo $(MESSAGE1)
@ echo ' '
@$(CC) $(CFLAGS) $^ $(LIBFT) -o $(NAME) $(INCLUDES) $(LFLAGS)
@ echo $(MESSAGE2)
@ echo ' '
@ echo $(MESSAGE3)
@ echo ' '
cleanlibft:
@$(MAKE_LIBS) $(LIBFT_DIR) clean
fcleanlibft:
@$(MAKE_LIBS) $(LIBFT_DIR) fclean
clean: cleanlibft
@ rm -rf $(OBJECTS_DIR)
fclean: clean fcleanlibft
@$(RM) $(NAME)
re: fclean
@$(MAKE) -s
bonus: all
$(OBJECTS_DIR)%.o: $(SOURCES_DIR)%.c
@$(MKDIR) $(OBJECTS_DIR)
@$(CC) $(CFLAGS) -c $< -o $@
libraries: $(LIBFT)
$(LIBFT):
@$(MAKE_LIBS) $(LIBFT_DIR)