-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
78 lines (62 loc) · 2.66 KB
/
Makefile
File metadata and controls
78 lines (62 loc) · 2.66 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: nmikuka <nmikuka@student.42heilbronn.de +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2025/05/19 20:34:46 by nmikuka #+# #+# #
# Updated: 2025/08/26 18:06:44 by nmikuka ### ########.fr #
# #
# **************************************************************************** #
# Directories
SRC_DIR := src
OBJ_DIR := obj
LIBFT_DIR := libft
GNL_DIR := get_next_line
INCLUDES := include
# Compiler and flags
CC := cc
CFLAGS := -Wall -Wextra -Werror -I$(INCLUDES) -I$(LIBFT_DIR) -I/opt/homebrew/opt/readline/include
READLINE_LIB := -lreadline -L/opt/homebrew/opt/readline/lib
LIBFT = $(LIBFT_DIR)/libft.a
# Library name
NAME := minishell
# Source and object files
SRC_FILES := main.c tokenize_pipe_redir.c tokenize_space.c signals.c\
builtin_cmds.c builtin_export.c builtin_simple_cmds.c builtin_unset.c \
builtin_add_var.c builtin_env_utils.c builtin_utils.c ft_split_ignore_quotes.c \
redir_init.c redir_handler.c redir_stdin.c redir_heredoc_utils.c\
create_cmd.c create_cmd_utils.c create_cmd_utils2.c create_single_cmd.c \
run_cmd.c run_single_cmd.c find_executable.c var_expansion.c \
minishell_utils.c minishell_validate.c minishell_validate2.c \
bonus_wildcards.c bonus_wildcards_utils.c bonus_create_wildcard.c \
handle_malloc_exit.c
GNL_FILES := get_next_line.c get_next_line_utils.c
# Structure of SRC and OBJ
SRC = $(addprefix $(SRC_DIR)/, $(SRC_FILES))
GNL_SRC = $(addprefix $(GNL_DIR)/, $(GNL_FILES))
OBJ = $(addprefix $(OBJ_DIR)/, $(SRC_FILES:.c=.o))
GNL_OBJ = $(addprefix $(GNL_DIR)/, $(GNL_FILES:.c=.o))
all: $(LIBFT) $(NAME)
# Build libft.a
$(LIBFT):
@echo "Building libft..."
@$(MAKE) -C $(LIBFT_DIR)
$(NAME): $(OBJ) $(GNL_OBJ)
$(CC) $(CFLAGS) $(OBJ) $(GNL_OBJ) $(READLINE_LIB) $(LIBFT) -o $@
@echo "\nMinishell is ready to go!"
$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c
@mkdir -p $(OBJ_DIR)
$(CC) $(CFLAGS) -c -o $@ $<
$(GNL_DIR)/%.o : $(GNL_DIR)/%.c
$(CC) $(CFLAGS) -c -o $@ $<
clean:
@$(MAKE) -C $(LIBFT_DIR) clean
rm -rf $(OBJ_DIR)
rm -f $(GNL_OBJ)
fclean: clean
@$(MAKE) -C $(LIBFT_DIR) fclean
rm -f $(NAME)
re: fclean all
.PHONY: all clean fclean re