generated from github/codespaces-blank
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
118 lines (95 loc) · 3.74 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: dmdemirk <dmdemirk@student.42london.c +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/11/19 12:20:29 by dmdemirk #+# #+# #
# Updated: 2023/11/20 18:29:24 by dmdemirk ### ########.fr #
# #
# **************************************************************************** #
# Colors
DEF_COLOR = \033[0;39m
GRAY = \033[0;90m
RED = \033[0;91m
GREEN = \033[0;92m
YELLOW = \033[0;93m
BLUE = \033[0;94m
MAGENTA = \033[0;95m
CYAN = \033[0;96m
WHITE = \033[0;97m
# Program
NAME = libft.a
# Comands
COMPILER = cc
CFLAGS = -Wall -Wextra -Werror -g
AR = ar rcs
RM = rm -rf
# Structure
INCLUDES = -I./inc
SRC_DIR = ./src
CTYPE_DIR = $(SRC_DIR)/ctype
LINKEDLIST_DIR = $(SRC_DIR)/linkedlist
NONSTANDART_DIR = $(SRC_DIR)/nonstandart
STDIO_DIR = $(SRC_DIR)/stdio/ft_printf
STDLIB_DIR = $(SRC_DIR)/stdlib
STRING_DIR = $(SRC_DIR)/string
CTYPE_SOURCES = $(wildcard $(CTYPE_DIR)/*.c)
LINKEDLIST_SOURCES = $(wildcard $(LINKEDLIST_DIR)/*.c)
NONSTANDART_SOURCES = $(wildcard $(NONSTANDART_DIR)/*.c)
STDIO_SOURCES = $(wildcard $(STDIO_DIR)/*.c)
STDLIB_SOURCES = $(wildcard $(STDLIB_DIR)/*.c)
STRING_SOURCES = $(wildcard $(STRING_DIR)/*.c)
SOURCES = $(CTYPE_SOURCES) \
$(LINKEDLIST_SOURCES) \
$(NONSTANDART_SOURCES) \
$(STDIO_SOURCES) \
$(STDLIB_SOURCES) \
$(STRING_SOURCES) \
# Build
BUILD_DIR = ./build
CTYPE_OBJECTS = $(patsubst $(CTYPE_DIR)/%.c, $(BUILD_DIR)/src/ctype/%.o, $(CTYPE_SOURCES))
LINKEDLIST_OBJECTS = $(patsubst $(LINKEDLIST_DIR)/%.c, $(BUILD_DIR)/src/linkedlist/%.o, $(LINKEDLIST_SOURCES))
NONSTANDART_OBJECTS = $(patsubst $(NONSTANDART_DIR)/%.c, $(BUILD_DIR)/src/nonstandart/%.o, $(NONSTANDART_SOURCES))
STDIO_OBJECTS = $(patsubst $(STDIO_DIR)/%.c, $(BUILD_DIR)/src/stdio/%.o, $(STDIO_SOURCES))
STDLIB_OBJECTS = $(patsubst $(STDLIB_DIR)/%.c, $(BUILD_DIR)/src/stdlib/%.o, $(STDLIB_SOURCES))
STRING_OBJECTS = $(patsubst $(STRING_DIR)/%.c, $(BUILD_DIR)/src/string/%.o, $(STRING_SOURCES))
OBJECTS = $(CTYPE_OBJECTS) \
$(LINKEDLIST_OBJECTS) \
$(NONSTANDART_OBJECTS) \
$(STDIO_OBJECTS) \
$(STDLIB_OBJECTS) \
$(STRING_OBJECTS) \
all: $(NAME)
$(NAME): $(OBJECTS)
@$(AR) $(NAME) $(OBJECTS)
@echo "$(GREEN)---------------$(DEF_COLOR)"
@echo "$(GREEN)libft.a created$(DEF_COLOR)"
$(BUILD_DIR)/src/ctype/%.o: $(CTYPE_DIR)/%.c
@mkdir -p $(@D)
@$(COMPILER) $(CFLAGS) $(INCLUDES) -c $< -o $@
$(BUILD_DIR)/src/linkedlist/%.o: $(LINKEDLIST_DIR)/%.c
@mkdir -p $(@D)
@$(COMPILER) $(CFLAGS) $(INCLUDES) -c $< -o $@
$(BUILD_DIR)/src/nonstandart/%.o: $(NONSTANDART_DIR)/%.c
@mkdir -p $(@D)
@$(COMPILER) $(CFLAGS) $(INCLUDES) -c $< -o $@
$(BUILD_DIR)/src/stdio/%.o: $(STDIO_DIR)/%.c
@mkdir -p $(@D)
@$(COMPILER) $(CFLAGS) $(INCLUDES) -c $< -o $@
$(BUILD_DIR)/src/stdlib/%.o: $(STDLIB_DIR)/%.c
@mkdir -p $(@D)
@$(COMPILER) $(CFLAGS) $(INCLUDES) -c $< -o $@
$(BUILD_DIR)/src/string/%.o: $(STRING_DIR)/%.c
@mkdir -p $(@D)
@$(COMPILER) $(CFLAGS) $(INCLUDES) -c $< -o $@
clean:
@$(RM) $(BUILD_DIR)
@echo "$(GRAY)files.o removed$(DEF_COLOR)"
fclean: clean
@$(RM) $(NAME)
@echo "$(RED)libft.a removed$(DEF_COLOR)"
re: fclean
@make
.PHONY: all clean fclean re