-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
98 lines (85 loc) · 2.19 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
CC = gcc
CFLAGS = -Wall -Wextra -Werror
NAME = minishell
CFILES = \
src/main.c \
src/alloc/alloc.c \
src/builtins/cd.c \
src/builtins/env.c \
src/builtins/exit.c \
src/builtins/export.c \
src/builtins/pwd.c \
src/builtins/unset.c \
src/builtins/echo.c \
src/cosmetic/cosmetic.c \
src/dealloc/dealloc.c \
src/dealloc/dealloc_utils.c \
src/debug/debug_print.c \
src/env/appending.c \
src/env/env_utils.c \
src/env/env.c \
src/env/expand_variables.c \
src/env/is_valid_identifier.c \
src/error/error.c \
src/error/perror.c \
src/exec/exec.c \
src/exec/exec_complex_cmd.c \
src/exec/exec_builtin.c \
src/exec/exec_utils.c \
src/exec/redirect.c \
src/exec/get_absolute_path.c \
src/heredoc/cleanup_heredocs.c \
src/heredoc/expand_heredoc_tokens.c \
src/heredoc/heredoc.c \
src/heredoc/heredocs.c \
src/parse/add_arg.c \
src/parse/add_redirect.c \
src/parse/get_arg_string_array.c \
src/parse/parse.c \
src/signals/signals.c \
src/stop/stop.c \
src/tokenize/check_token_syntax_errors.c \
src/tokenize/is_text_token.c \
src/tokenize/mark_ambiguous_redirects.c \
src/tokenize/skip_whitespace_tokens.c \
src/tokenize/split_and_add_spaced_tokens.c \
src/tokenize/subtokenizers_misc.c \
src/tokenize/subtokenizers_quotes.c \
src/tokenize/subtokenizers_redirections.c \
src/tokenize/tokenize.c \
src/tokenize/whitespace_split_tokens.c \
src/update_cwd/update_cwd.c
HEADERS = \
include/enums.h \
include/minishell.h \
include/prototypes.h \
include/splash.h \
include/structs.h
OFILES = $(addprefix obj/,$(CFILES:.c=.o))
LIBFT_PATH = libft/libft.a
LIB = -L libft -l ft
ifeq ($(shell uname), Linux)
LIB += -l readline
else
LIB += -L $(shell brew --prefix readline)/lib -lreadline
INCLUDES += -I $(shell brew --prefix readline)/include
endif
INCLUDES += -Iinclude
all: $(NAME)
$(NAME): $(OFILES) $(LIBFT_PATH)
$(CC) $(CFLAGS) $(OFILES) $(LIB) -o $(NAME)
# Will attempt to create the object's parent directory
obj/%.o: %.c $(HEADERS)
@mkdir -p $(@D)
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
$(LIBFT_PATH):
$(MAKE) -C libft/
re: fclean all
fclean: clean
@rm -f $(NAME)
@echo "DEEP CLEANING"
clean:
$(MAKE) -C libft/ fclean
@rm -rf obj/
@echo "CLEANED UP"
.PHONY: all re fclean clean