-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
95 lines (73 loc) · 3.26 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: tjensen <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2021/10/27 22:03:08 by tjensen #+# #+# #
# Updated: 2022/07/25 20:43:58 by tjensen ### ########.fr #
# #
# **************************************************************************** #
NAME := minishell
CC := gcc
CFLAGS := -Wall -Wextra -Werror -O2
CPPFLAGS := -I./inc -I./lib/libft/inc
DEPFLAGS = -MT $@ -MMD -MP -MF $(DDIR)/$*.d
LDFLAGS := -L./lib/libft
LDLIBS := -lft -lreadline
VPATH := src/ src/builtin/ src/cmd/ src/env/ src/exec/ src/expand/ \
src/lexer/ src/parser/ src/printer/ src/redir/ src/signals/ \
src/token/ src/utils/
SRCS := minishell.c
SRCS += builtin_echo.c builtin_cd.c builtin_exit.c builtin_pwd.c \
builtin_env.c builtin_export.c builtin_unset.c builtin.c
SRCS += cmd.c scmd.c
SRCS += env.c env_modify.c
SRCS += exec.c exec_pipeline.c exec_pipeline_pipes.c exec_scmd.c \
exec_scmd_path.c exec_wait.c exec_group.c exec_exit_status.c
SRCS += expand.c expand_wildcard.c expand_wildcard_utils.c \
expand_var.c expand_var_split.c
SRCS += lexer.c lexer_syntax.c lexer_token_other.c lexer_token_text.c
SRCS += parser.c parser_scmd.c parser_pipeline.c parser_group.c \
parser_heredoc.c
SRCS += printer_token.c printer_scmd.c printer_cmd.c
SRCS += redir.c redir_undo.c
SRCS += signals.c
SRCS += token.c token_list.c
SRCS += utils_error.c utils_gnl.c utils_lst.c utils_split.c utils_str.c
ODIR := obj
OBJS := $(SRCS:%.c=$(ODIR)/%.o)
DDIR := $(ODIR)/.deps
DEPS := $(SRCS:%.c=$(DDIR)/%.d)
# **************************************************************************** #
# SYSTEM SPECIFIC SETTINGS #
# **************************************************************************** #
ifeq ($(shell uname -s), Linux)
CFLAGS += -D LINUX -Wno-unused-result
endif
# **************************************************************************** #
# RULES #
# **************************************************************************** #
.PHONY: all clean fclean re test
$(NAME): lib/libft/libft.a $(OBJS)
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $@ $(LDLIBS)
$(ODIR)/%.o: %.c $(DDIR)/%.d | $(ODIR) $(DDIR)
$(CC) $(CFLAGS) $(CPPFLAGS) $(DEPFLAGS) -c $< -o $@
$(ODIR):
mkdir -p $@
$(DDIR):
mkdir -p $@
%.a:
$(MAKE) -C $(dir $@)
all: $(NAME)
clean:
$(MAKE) -C lib/libft fclean
$(RM) -r $(DDIR) $(ODIR)
fclean: clean
$(RM) $(NAME)
re: fclean all
test:
@cd tests && bash tester.sh a
$(DEPS):
include $(wildcard $(DEPS))