-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
135 lines (110 loc) · 4.03 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
135
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: amalsago <amalsago@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2019/10/05 11:39:15 by amalsago #+# #+# #
# Updated: 2020/01/18 18:12:51 by amalsago ### ########.fr #
# #
# **************************************************************************** #
# **************************************************************************** #
# General
NAME = minishell
LIBNAME = libft.a
# **************************************************************************** #
# GNU Compiler Collection
GCC = /usr/bin/clang
WOPT = -Wall -Wextra -Werror
OOPT = -O3
IOPT = -I $(INCDIR)
# **************************************************************************** #
# System commands
AR = /usr/bin/ar -rc
LESS = /usr/bin/less
MAKE = /usr/bin/make -C
RANLIB = /usr/bin/ranlib
NORMINETTE = /usr/bin/norminette
MKDIR = /bin/mkdir -p
RM = /bin/rm -rf
# **************************************************************************** #
# Directories of source and object files
LIBDIR = ./libft
SRCDIR = ./sources
OBJDIR = ./objects
INCDIR = ./includes
# **************************************************************************** #
# List of source files
SRCNAME = main.c \
builtins/builtin_builtins.c \
builtins/builtin_cd.c \
builtins/builtin_echo.c \
builtins/builtin_env.c \
builtins/builtin_exit.c \
builtins/builtin_pwd.c \
builtins/builtin_setenv.c \
builtins/builtin_unsetenv.c \
builtins/ft_setenv.c \
builtins/ft_unsetenv.c \
execution/execute.c \
execution/execute_builtin.c \
execution/execute_command.c \
execution/find_executable.c \
output/display_logtime.c \
output/display_prompt.c \
output/errors.c \
output/print_commands.c \
predicates/is_builtin.c \
predicates/is_var_exist.c \
tools/check_access.c \
tools/expansion.c \
tools/get_input.c \
tools/history.c \
tools/increment_level.c \
tools/parse_input.c \
tools/total_environ_rows.c \
tools/setup_environ.c
# **************************************************************************** #
# Automatic variables where are listed the names of sources and objects files
SRC = $(addprefix $(SRCDIR)/, $(SRCNAME))
OBJ = $(addprefix $(OBJDIR)/, $(SRCNAME:.c=.o))
LFT = $(addprefix $(LIBDIR)/, $(LIBNAME))
# **************************************************************************** #
# Extra
CR = "\r"$(CLEAR)
CLEAR = "\\033[0K"
EOC = "\033[0;0m"
RED = "\033[0;31m"
GREEN = "\033[0;32m"
BASENAME = `basename $(PWD)`
# **************************************************************************** #
# Rules
all: $(NAME) $(LFT)
$(NAME): $(LFT) $(OBJ)
@$(GCC) $(WOPT) $(OBJ) $(LFT) -o $(NAME)
@printf $(CR)$(GREEN)"✓ $(NAME) is created\n"$(EOC)
$(OBJDIR)/%.o: $(SRCDIR)/%.c
@$(MKDIR) $(dir $@)
@$(GCC) $(WOPT) $(OOPT) $(IOPT) -c $< -o $@
@printf $(CR)"[ ./$(BASENAME)/%s ]"$(CLEAR) $@
$(LFT): FORCE
@$(MAKE) $(LIBDIR)
clean:
@if [ -d $(OBJDIR) ]; then \
$(RM) $(OBJ) $(OBJDIR) \
&& printf $(CR)$(RED)"✗ The objects files of $(NAME) are cleaned\n"$(EOC)\
&& $(MAKE) $(LIBDIR) clean; \
fi
fclean: clean
@$(RM) minishell.dSYM
@if [ -e $(NAME) ]; then \
$(RM) $(NAME) \
&& printf $(CR)$(RED)"✗ $(NAME) is cleaned\n"$(EOC) \
&& $(MAKE) $(LIBDIR) fclean; \
fi
re: fclean all
norm:
@$(NORMINETTE) $(SRCDIR) $(INCDIR) $(LIBDIR)/sources | $(LESS)
.PHONY: all clean fclean re norm
FORCE: