-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
67 lines (48 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
# Makefile ver2.2
NAME = minishell
CC = gcc
CFLAGS = -I./include -g -Wall -Wextra -Werror
#SRCS += の形式でディレクトリを追加。コメントアウトで特定ディレクトリ除外可能
SRCS = $(shell find ./src -maxdepth 1 -type f -name "*.c")
SRCS += $(shell find ./src/builtins -type f -name "*.c")
SRCS += $(shell find ./src/env -type f -name "*.c")
SRCS += $(shell find ./src/utils -type f -name "*.c")
SRCS += $(shell find ./src/execute -type f -name "*.c")
SRCS += $(shell find ./src/parse -type f -name "*.c")
SRCS += $(shell find ./src/validation -type f -name "*.c")
SRCS += $(shell find ./src/main -type f -name "*.c")
SRCS += $(shell find ./src/signal -type f -name "*.c")
# make debug ARG=READ_CMD_LINE_C のようにして使う。
ifdef DEBUG
SRCS += $(TEST_SRCS)
CFLAGS += -D DEBUG=1 -D $(ARG)=1
endif
# sanitizeオプションをつけるときは make sanitize=1 などのように定義して使う
ifdef sanitize
CFLAGS += -fsanitize=address
endif
OBJS = $(SRCS:.c=.o)
DEPS = $(OBJS:.o=.d)
TEST_SRCS = $(shell find ./test/cfiles -type f -name "*.c")
TEST_OBJS = $(TEST_SRCS:.c=.o)
TEST_DEPS = $(TEST_OBJS:.o=.d)
LIBFT = ./lib/libft/libft.a
LIBFT_PATH = ./lib/libft
all: $(NAME)
$(NAME): $(OBJS)
make -C $(LIBFT_PATH)
$(CC) $(CFLAGS) $(OBJS) $(LIBFT) -o $(NAME)
.c.o:
$(CC) $(CFLAGS) -c -MMD -MP -MF $(<:.c=.d) $< -o $(<:.c=.o)
-include $(DEPS)
clean:
rm -rf $(OBJS) $(DEPS) $(TEST_OBJS) $(TEST_DEPS)
fclean: clean
make fclean -C $(LIBFT_PATH)
rm -rf $(NAME)
re: fclean all
debug:
make DEBUG=1
run: all
./minishell
.PHONY: all clean fclean re debug run