-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
90 lines (78 loc) · 2.25 KB
/
Makefile
File metadata and controls
90 lines (78 loc) · 2.25 KB
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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: yucchen <yucchen@student.42singapore.sg +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2025/11/04 19:02:27 by yucchen #+# #+# #
# Updated: 2026/01/11 15:59:05 by yucchen ### ########.fr #
# #
# **************************************************************************** #
# Compiler and flags
CC = cc
CFLAGS = -Wall -Wextra -Werror
# Linker flags for external library (readline)
LDFLAGS = -lreadline
# Project name and file list
NAME = minishell
SOURCES = signals.c \
tokenize_utils1.c \
tokenize_utils2.c \
tokenize.c \
expand_utils1.c \
expand_utils2.c \
expand.c \
parser_utils1.c \
parser_utils2.c \
parser.c \
heredoc_utils.c \
heredoc.c \
env_utils.c \
builtin_exit.c \
builtin_unset.c \
builtin_export.c \
builtin_cd.c \
builtin_echo.c \
builtin_env.c \
builtin_pwd.c \
builtins.c \
redir.c \
path.c \
executor_utils1.c \
executor_utils2.c \
executor_utils3.c \
executor.c \
main.c
OBJECTS = $(SOURCES:.c=.o)
HEADERS = tokenize.h \
expand.h \
parser.h \
executor.h
# Libft
LIBFT_DIR = libft
LIBFT_AR = $(LIBFT_DIR)/libft.a
# Tools
RM = rm -f
# Rules
# Compile mandatory part
all: $(NAME)
$(NAME): $(OBJECTS) $(LIBFT_AR)
$(CC) $(CFLAGS) $(OBJECTS) $(LIBFT_AR) $(LDFLAGS) -o $(NAME)
# Compile each .c into .o
%.o: %.c $(HEADERS)
$(CC) $(CFLAGS) -c $< -o $@
# Build libft
$(LIBFT_AR):
$(MAKE) -C $(LIBFT_DIR)
# Clean object files
clean:
$(MAKE) -C $(LIBFT_DIR) clean
$(RM) $(OBJECTS)
# Clean object files and lib
fclean: clean
$(MAKE) -C $(LIBFT_DIR) fclean
$(RM) $(NAME)
# Recompile everything
re: fclean all
.PHONY: all clean fclean re