-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
80 lines (67 loc) · 2.65 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
NAME = minishell
# IFLAGS = -Iinclude -I$(LIBFT_DIR) -I$(shell brew --prefix readline)/include
IFLAGS = -Iinclude -I$(LIBFT_DIR)
# CFLAGS = -Wall -Wextra -Werror -g -fsanitize=address
CFLAGS = -Wall -Wextra -Werror
# LFLAGS = -Llibft -lft -lreadline -lhistory -L$(shell brew --prefix readline)/lib
LFLAGS = -Llibft -lft -lreadline -lhistory
SRC_DIR = sources
SRCS = b_cd.c expander_variable_length.c \
b_echo.c heredoc.c b_env.c heredoc_expansion.c \
b_exit.c index_in_env.c b_export.c lexer.c \
b_export_utils.c lexer_count_tokens.c \
b_pwd.c lexer_create_tokens.c b_unset.c lexer_utils.c \
builtin_utils.c main.c check_for_builtin.c main_utils.c \
command_utils.c mainprogram.c create_env.c \
parser.c executer.c \
parser_create_command.c executer_commands.c \
parser_free_commands.c executer_pipes.c \
parser_syntax_validation.c executer_redirections.c \
signal_setters.c executer_utils.c signal_utils.c \
expander.c single_builtin.c expander_build_str.c \
update_oldpwd_env.c expander_length.c update_pwd_env.c \
expander_variable.c update_shlvl.c expander_exit_status.c \
executer_apply_redirect.c debug_printing.c
OBJ_DIR = obj
OBJS = $(addprefix $(OBJ_DIR)/, $(SRCS:.c=.o))
LIBFT_DIR = libft
LIBFTNAME = libft.a
all: $(NAME)
$(NAME): $(OBJS) $(LIBFT_DIR)/$(LIBFTNAME)
@$(CC) $(CFLAGS) $(IFLAGS) $^ -o $(NAME) $(LFLAGS)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@mkdir -p $(OBJ_DIR)
@$(CC) -c $(CFLAGS) $(CFLAGS) $(IFLAGS) $< -o $@
$(LIBFT_DIR)/$(LIBFTNAME):
@$(MAKE) -C $(LIBFT_DIR) bonus
clean:
@rm -rf $(OBJ_DIR)
@$(MAKE) -C $(LIBFT_DIR) clean
fclean: clean
@rm -f $(NAME)
@$(MAKE) -C $(LIBFT_DIR) fclean
re: fclean all
.PHONY: all clean fclean re
# testing
TEST_SRCS = test.c
FUNCTION_SRCS = b_cd.c expander_variable_length.c \
b_echo.c heredoc.c b_env.c heredoc_expansion.c \
b_exit.c index_in_env.c b_export.c lexer.c \
b_export_utils.c lexer_count_tokens.c \
b_pwd.c lexer_create_tokens.c b_unset.c lexer_utils.c \
builtin_utils.c check_for_builtin.c main_utils.c \
command_utils.c mainprogram.c create_env.c \
parser.c executer.c \
parser_create_command.c executer_commands.c \
parser_free_commands.c executer_pipes.c \
parser_syntax_validation.c executer_redirections.c \
signal_setters.c executer_utils.c signal_utils.c \
expander.c single_builtin.c expander_build_str.c \
update_oldpwd_env.c expander_length.c update_pwd_env.c \
expander_variable.c update_shlvl.c expander_exit_status.c \
executer_apply_redirect.c debug_printing.c
TEST_FLAGS = -Wall -g $(IFLAGS) $(LFLAGS)
test: $(NAME)
@$(CC) $(TEST_FLAGS) $(addprefix tests/, $(TEST_SRCS)) $(addprefix sources/, $(FUNCTION_SRCS)) $(LIBFT_DIR)/$(LIBFTNAME) -o test.out
@./test.out
@rm -rf test.out*