-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·122 lines (93 loc) · 3.28 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: fjacquem <marvin@42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2016/04/14 22:50:59 by fjacquem #+# #+# #
# Updated: 2016/05/04 15:47:47 by fjacquem ### ########.fr #
# #
# **************************************************************************** #
# directories
LIBFT_DIR = libft
GNL_DIR = get_next_line
CFG_DIR = configs
BUILTIN_DIR = builtin
FEATURES_DIR = features
CMD_DIR = cmdline
LEXER_DIR = lexer
COMMON_DIR = common
INCLUDE_DIR = headers
OBJ_DIR = obj
# compilation
NAME = minishell
CFLAGS = -Wall -Wextra -Werror -g
HEADS = -I$(INCLUDE_DIR) -I$(LIBFT_DIR)
LIBFT_A = $(LIBFT_DIR)/libft.a
# special builtins
SPEC_BUILTIN_DIR = $(BUILTIN_DIR)/supl
EXPLORER_DIR = $(SPEC_BUILTIN_DIR)/explorer
# explorer
EXPLORER_SRC = add_fcts.c extension_map.c file.c explorer.c initialize.c\
ls.c opts.c print.c print_bis.c tools.c
EXPLORER_OBJ = $(EXPLORER_SRC:.c=.o)
# necessairy for configs
GNL_SRC = get_next_line.c
GNL_OBJ = get_next_line.o
# minishell configs
CFG_SRC = init_menu.c menu_process.c menu_utils.c init_menuitem.c minicfg.c
CFG_OBJ = $(CFG_SRC:.c=.o)
# minishell builtins
BUILTIN_SRC = builtin_cd.c builtin_env.c builtin_setenv.c builtin_common.c\
builtin_unsetenv.c
BUILTIN_OBJ = $(BUILTIN_SRC:.c=.o)
# minishell command line
CMD_SRC = read_line.c init_cmdline.c ctrl_inputs.c cmd_utils.c
CMD_OBJ = $(CMD_SRC:.c=.o)
# minishell lexer
LEXER_SRC = command.c lexer.c word.c redirection.c parse.c
LEXER_OBJ = $(LEXER_SRC:.c=.o)
# minishell implementation
FEATURES_SRC = command_parser.c command_parser_bis.c environ_research.c\
completion.c historik.c completion_utils.c
FEATURES_OBJ = $(FEATURES_SRC:.c=.o)
# minishell
COMMON_SRC = term.c main.c launcher.c utils.c signal.c\
term_utils.c
COMMON_OBJ = $(COMMON_SRC:.c=.o)
# ...
SRCS = $(addprefix $(GNL_DIR)/,$(GNL_SRC))\
$(addprefix $(BUILTIN_DIR)/,$(BUILTIN_SRC))\
$(addprefix $(FEATURES_DIR)/,$(FEATURES_SRC))\
$(addprefix $(CFG_DIR)/,$(CFG_SRC))\
$(addprefix $(CMD_DIR)/,$(CMD_SRC))\
$(addprefix $(COMMON_DIR)/,$(COMMON_SRC))\
$(addprefix $(EXPLORER_DIR)/,$(EXPLORER_SRC))\
$(addprefix $(LEXER_DIR)/,$(LEXER_SRC))
OBJS = $(COMMON_OBJ)\
$(FEATURES_OBJ)\
$(BUILTIN_OBJ)\
$(GNL_OBJ)\
$(CFG_OBJ)\
$(CMD_OBJ)\
$(EXPLORER_OBJ)\
$(LEXER_OBJ)
OBJS_MOVED = $(addprefix $(OBJ_DIR)/,$(OBJS))
all: $(NAME)
$(OBJS_MOVED): $(LIBFT_A)
gcc $(CFLAGS) $(HEADS) -c $(SRCS)
mv $(OBJS) $(OBJ_DIR)
$(LIBFT_A):
make -C $(LIBFT_DIR) addbonus
$(NAME): $(OBJS_MOVED)
gcc $(CFLAGS) $(HEADS) $(OBJS_MOVED) $(LIBFT_A) -o $(NAME)
clean:
rm -f $(OBJS_MOVED)
make -C $(LIBFT_DIR) clean
fclean:
rm -rf $(OBJS_MOVED)
rm -f $(NAME)
make -C $(LIBFT_DIR) fclean
re: fclean all
.PHONY: all clean fclean re