-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
77 lines (59 loc) · 1.58 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
NAME = minishell
TEST_NAME = test/unit_test
SRC_DIR = src/
BUILD_DIR = build/
BUILD_SUBDIRS = build/builtin build/env build/expand build/lexer build/parse
UNPREFIXED_SRC = main.c \
builtin/env.c \
builtin/pwd.c \
builtin/cd.c \
builtin/echo.c \
builtin/exit.c \
builtin/export.c \
builtin/unset.c \
env/env.c \
expand/rel_path.c \
expand/parent_dir.c \
lexer/lexer.c \
lexer/lexer_error.c \
lexer/lexer_utils.c \
lexer/tokenize_word.c \
lexer/tokenize_operator.c \
parse/parse.c \
parse/parse_util.c \
parse/parse_redir.c \
parse/parse_word.c \
parse/parse_expand.c \
TEST_SRC = test/test.c
OBJ = $(addprefix $(BUILD_DIR), $(UNPREFIXED_SRC:.c=.o))
SRC = $(addprefix $(SRC_DIR), $(UNPREFIXED_SRC))
INC = inc/
TEST_INC = test/criterion--git/include
#FLAGS = -fsanitize=address -g
#FLAGS = -Wall -Wextra -Werror
LIB = lib/
LIBFT = lib/libft/libft.a
CRITERION = test/criterion--git/libcriterion.dylib
all: $(LIBFT) $(BUILD_DIR) $(NAME)
test: $(TEST_NAME)
$(LIBFT):
$(MAKE) -C $(LIB)libft/ WITH_BONUS=1
$(BUILD_DIR):
mkdir $@
$(BUILD_SUBDIRS):
mkdir $@
$(NAME): $(OBJ) $(INC)*
$(CC) $(FLAGS) $(OBJ) $(LIBFT) -lreadline -I$(INC) -o $(NAME)
$(BUILD_DIR)%.o: $(SRC_DIR)%.c | $(BUILD_DIR) $(BUILD_SUBDIRS)
$(CC) $(FLAGS) -I$(INC) -c $< -o $@
$(TEST_NAME): $(LIBFT) $(TEST_SRC) $(filter-out main.c, $(SRC))
$(CC) $(TEST_SRC) $(LIBFT) $(filter-out src/main.c, $(SRC)) $(CRITERION) -I$(INC) -I$(TEST_INC) -o $(TEST_NAME)
clean:
rm -f $(OBJ)
$(MAKE) clean -C $(LIB)libft/
fclean: clean
rm -f $(NAME)
$(MAKE) fclean -C $(LIB)libft/
re: fclean all
.PHONY:
all clean fclean re test