-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
98 lines (78 loc) · 3.76 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: pibouill <pibouill@student.42prague.com +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/10/29 13:49:56 by pibouill #+# #+# #
# Updated: 2023/11/01 12:49:51by pibouill ### ########.fr #
# #
# **************************************************************************** #
################################################################################
## ARGUMENTS
NAME = libftprintf.a
AR = ar rc
CFLAGS = -Wall -Werror -Wextra
CC = cc
RM = rm -rf
SRC_DIR = src
INC = -I inc/
BIN_DIR = bin
################################################################################
## COLORS
# Reset
END_COLOR = \033[0m # Text Reset
# Regular Colors
BLACK = \033[0;30m # Black
RED = \033[0;31m # Red
GREEN = \033[0;32m # Green
YELLOW = \033[0;33m # Yellow
BLUE = \033[0;34m # Blue
PURPLE = \033[0;35m # Purple
CYAN = \033[0;36m # Cyan
WHITE = \033[0;37m # White
################################################################################
## SOURCES
SRCS_FILES = $(shell find ./src -type f -exec basename {} \; | rev | cut -d. -f2- | rev)
OBJ = $(addprefix $(BIN_DIR)/, $(addsuffix .o, $(SRCS_FILES)))
SRC = $(addprefix $(SRC_DIR)/, $(addsuffix .c, $(SRCS_FILES)))
################################################################################
## RULES
all: $(NAME)
$(NAME): $(OBJ)
@$(AR) $(NAME) $(OBJ)
@echo "$(CYAN) :::::::::: ::::::::::: ::::::::: ::::::::: ::::::::::: :::: ::: ::::::::::: ::::::::::"
@echo "$(YELLOW) :+: :+: :+: :+: :+: :+: :+: :+:+: :+: :+: :+:"
@echo "$(PURPLE) +:+ +:+ +:+ +:+ +:+ +:+ +:+ :+:+:+ +:+ +:+ +:+"
@echo "$(CYAN) :#::+::# +#+ +#++:++#+ +#++:++#: +#+ +#+ +:+ +#+ +#+ :#::+::#"
@echo "$(YELLOW) +#+ +#+ +#+ +#+ +#+ +#+ +#+ +#+#+# +#+ +#+"
@echo "$(PURPLE) #+# #+# #+# #+# #+# #+# #+# #+#+# #+# #+#"
@echo "$(CYAN) ### ### ########## ### ### ### ########### ### #### ### ###"
@echo "$(GREEN)$(NAME) Compiled.$(END_COLOR)"
$(BIN_DIR)/%.o: $(SRC_DIR)/%.c Makefile | $(BIN_DIR)
@$(CC) -c $(CFLAGS) $(INC) $< -o $@
@echo "$(BLUE)Compiling... $(notdir $<)$(END_COLOR)"
$(BIN_DIR):
@mkdir $(BIN_DIR)
@echo "$(YELLOW)Object files created and moved to $(BIN_DIR)/ directory.$(END_COLOR)"
clean:
@rm -rf $(BIN_DIR)
@echo "$(PURPLE)Object files and bin/ cleaned.$(END_COLOR)"
fclean: clean
@rm -f $(NAME)
@echo "$(YELLOW)$(NAME) file cleaned.$(END_COLOR)"
re: fclean all
@echo "$(GREEN)Cleaned all and rebuilt $(NAME) $(END_COLOR)"
test:
@cc $(CFLAGS) $(LIB_INC) $(INC) test.c src/*.c
@echo "$(CYAN)< Test compiled and ready to run a.out>$(END_COLOR)"
noflags:
@cc $(LIB_INC) $(INC) test.c src/*.c
@echo "$(CYAN)< Test compiled without flags and ready to run a.out>$(END_COLOR)"
header:
clear
@echo "$$HEADER"
################################################################################
## PHONY
.PHONY: all clean fclean re test noflags