-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
161 lines (128 loc) · 4.17 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: #
# +:+ +:+ +:+ #
# By: ivan-mel <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/08/22 13:32:22 by jboeve #+# #+# #
# Updated: 2024/05/28 15:44:02 by joppe ######## odam.nl #
# #
# **************************************************************************** #
######################
# OS Dependend flags #
######################
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
endif
ifeq ($(UNAME_S),Darwin)
I_RL := -I $(shell brew --prefix readline)/include
L_RL := -L $(shell brew --prefix readline)/lib
endif
NAME := megashell
RUN_CMD := ./$(NAME)
CFLAGS += -Wall -Wextra -Werror
# CFLAGS += -Wall -Wextra
# CFLAGS += -g -fsanitize=address
# CFLAGS += -g
LIBFT := libft/build/libft.a
IFLAGS := -Ilibft/include -Iinclude $(I_RL)
LFLAGS := -lreadline $(L_RL)
SRC_DIR := src
SRCS := execute/error.c \
execute/path.c \
execute/free.c \
execute/environment.c \
execute/execute.c \
execute/execute_utils.c \
execute/pipeline_utils.c \
execute/pipeline.c \
execute/access.c \
execute/heredoc_list.c \
builtins/builtins.c \
builtins/builtin_cd.c \
builtins/builtin_cd_utils.c \
builtins/builtin_echo.c \
builtins/builtin_env.c \
builtins/builtin_exit.c \
builtins/builtin_export.c \
builtins/builtin_export_utils.c \
builtins/builtin_pwd.c \
builtins/builtin_unset.c \
builtins/builtin_history.c \
input/prompt.c \
input/signals.c \
input/history_file.c \
plarser/lexer.c \
plarser/lexer_list.c \
plarser/lexer_utils.c \
plarser/lexer_utils2.c \
plarser/plarser.c \
plarser/syntax.c \
plarser/syntax_func.c \
plarser/syntax_func2.c \
plarser/tokenize.c \
plarser/parser.c \
plarser/parser_utils.c \
plarser/parser_joiner.c \
plarser/parser_list.c \
plarser/expander.c \
plarser/expander_utils.c \
plarser/expander_utils2.c \
plarser/space_count.c \
plarser/heredoc_expander.c \
utils/utils_string.c \
utils/utils_path.c \
redirections/redirections.c \
redirections/heredoc.c \
megashell.c \
test_utils.c
HEADER_DIR := include
HEADERS := input.h \
plarser.h \
megashell.h \
builtins.h \
test_utils.h \
execute.h \
utils.h
OBJ_DIR := obj
TEST_LFLAGS := -L /home/jboeve/.capt/root/usr/lib/x86_64-linux-gnu
TEST_IFLAGS := -I /home/jboeve/.capt/root/usr/include
TEST_SRCS := test_tokenizer.c \
test_expander.c
TEST := tests
TEST_SRCS := $(addprefix $(TEST)/, $(TEST_SRCS))
TEST_BINS := $(patsubst $(TEST)/%.c, $(TEST)/bin/%, $(TEST_SRCS))
SRCS := $(addprefix $(SRC_DIR)/, $(SRCS))
HEADERS := $(addprefix $(HEADER_DIR)/, $(HEADERS))
OBJS := $(patsubst $(SRC_DIR)%.c, $(OBJ_DIR)%.o, $(SRCS))
OBJ_DIRS := $(dir $(OBJS))
.PHONY: make_libs
all: make_libs $(NAME)
$(NAME): $(OBJS) $(LIBFT) $(SRC_DIR)/main.c
$(CC) $(SRC_DIR)/main.c $(OBJS) $(LIBFT) $(CFLAGS) $(IFLAGS) $(LFLAGS) -o $(NAME)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c $(HEADERS)
@mkdir -p $(OBJ_DIRS)
$(CC) $(CFLAGS) $(IFLAGS) -c -o $@ $<
make_libs:
$(MAKE) -C libft
clean:
rm -rf $(OBJ_DIR)
tclean:
rm -rf $(TEST)/bin
fclean: clean tclean
$(MAKE) -C libft fclean
rm -f $(NAME)
re: fclean all
run: all
$(RUN_CMD)
compile_commands: fclean
$(MAKE) | compiledb
norm:
norminette libft include src
$(TEST)/bin:
mkdir $@
$(TEST)/bin/%: $(TEST)/%.c $(OBJS)
$(CC) $(CFLAGS) $(IFLAGS) $< $(OBJS) $(LIBFT) -o $@ -lcriterion $(LFLAGS) $(TEST_IFLAGS) $(TEST_LFLAGS)
test: make_libs $(OBJS) $(TEST)/bin $(TEST_BINS)
for test in $(TEST_BINS) ; do ./$$test -j1 ; done