-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
114 lines (89 loc) · 3.3 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: aabduvak <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2022/02/15 16:23:46 by aabduvak #+# #+# #
# Updated: 2022/08/08 11:57:40 by aabduvak ### ########.fr #
# #
# **************************************************************************** #
# Colors
BLACK = "\033[0;30m"
RED = "\033[0;31m"
GREEN = "\033[0;32m"
YELLOW = "\033[0;33m"
CYAN = "\033[0;35m"
BLUE = "\033[0;36m"
WHITE = "\033[0;37m"
END = "\033[0;0m"
# Files
SRCS = $(shell find sources -type f -name "*.c")
OBJS = $(SRCS:sources/%.c=sources/bin/%.o)
ROOT = $(shell echo $(HOME))
LOG = output.file
# Command and Flags
NAME = minishell
CC = gcc
RM = rm -rf
CFLAGS = -Wall -Wextra -Werror -I./lib/readline/include
LDFLAGS = -L./lib/readline/lib -lreadline
LIBFT = ./libft/libft.a
# Directories
INC_FT = ./libft/sources
INC_GN = ./libft/GNL/sources
INC_PR = ./libft/ft_printf/sources
INC = ./includes/
BIN = ./sources/bin/
LIB = ./lib/.minishell
# Rules
all : $(LIB) $(LIBFT) $(NAME)
$(LIBFT):
@make -C ./libft
$(LIB):
@make -C ./lib
$(BIN):
@mkdir $(BIN)
$(BIN)%.o: sources/%.c
@mkdir -p $(shell dirname $@)
@echo $(YELLOW) "Compiling..." $< $(END)
@$(CC) $(CFLAGS) -c $< -o $@ -I$(INC_PR) -I$(INC_GN) -I$(INC_FT) -I$(INC)
$(NAME): $(BIN) $(OBJS)
@echo $(YELLOW) "Building... $(NAME)" $(END)
@$(CC) $(OBJS) $(LDFLAGS) -o $(NAME) $(LIBFT)
@echo $(GREEN) "$(NAME) created successfully!\n" $(END)
# $< input files
# $@ output files
# in makefile used to create oputput files in their subfolder
clean :
@echo $(YELLOW) "Removing object files...$(NAME)" $(END)
@$(RM) $(OBJS)
@echo $(RED) "All files deleted successfully!\n" $(END)
fclean : clean
@echo $(YELLOW) "Removing $(NAME)..." $(END)
@$(RM) $(NAME)
@$(RM) $(BIN)
@echo $(RED) "$(NAME) deleted successfully!\n" $(END)
ffclean: fclean
@make fclean -C ./libft
fffclean: ffclean
@make fclean -C ./lib
norm :
@norminette libft/
@norminette includes/
@norminette sources
re : ffclean all
run : $(NAME)
@./$(NAME)
help :
@echo "------------------------------------ <<HELP COMMAND>> ------------------------------------"
@echo ""
@echo "make --------- compiles all *.c files and create libftprintf.a library"
@echo "make clean --------- cleans all *.o files in sources"
@echo "make fclean --------- cleans all *.o files in sources and libftprintf.a library"
@echo "make re --------- cleans all files and compiles again"
@echo "make norm --------- controls all *.c and *.h codes to norminette standart"
@echo "make run --------- compile and run program"
@echo "make leaks --------- checks all leaks in the program and creates output.file"
.PHONY: all clean fclean re run