-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
100 lines (81 loc) · 3.31 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: marvin <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/12/18 12:14:47 by emaravil #+# #+# #
# Updated: 2024/04/17 03:37:45 by marvin ### ########.fr #
# #
# **************************************************************************** #
UNAME = $(shell uname)
NAME = minishell
CC = cc
RM = rm -rf
LB = ar rcs
LDFLAGS = -L./libft -lft
MINISHELL_SRCS = minishell.c \
minishell_info.c \
minishell_command.c \
minishell_command_utils.c \
minishell_expanddollar.c \
minishell_command_prep.c
MINISHELL_OBJS = $(MINISHELL_SRCS:.c=.o)
HEADER = minishell.h
PARSE = parse.a
PARSE_DIR = ./parsing
PARSE_LIB = $(PARSE_DIR)/$(PARSE)
BUILTINS = builtins.a
BUILTINS_DIR = ./builtins
BUILTINS_LIB = $(BUILTINS_DIR)/$(BUILTINS)
EXEC = execution.a
EXEC_DIR = ./execution
EXEC_LIB = $(EXEC_DIR)/$(EXEC)
LIBFT = libft.a
LIBFT_DIR = ./libft
LIBFT_LIB = $(LIBFT_DIR)/$(LIBFT)
MAKE_LIBR = make --no-print-directory -C
all: $(LIBFT_LIB) $(PARSE_LIB) $(BUILTINS_LIB) $(EXEC_LIB) $(NAME)
print:
@echo "$(GREEN) libreadline.a directory: $(LIBREAD_DIR)$(DEFAULT)"
@echo "$(GREEN) readline.h directory: $(LIBREAD_INC)$(DEFAULT)"
ifeq ($(UNAME), Darwin)
CFLAGS = -Wall -Wextra -Werror -g -I $(LIBREAD_INC)
LIBREAD_DIR = /Users/emaravil/.local/opt/readline/lib
LIBREAD_INC = /Users/emaravil/.local/opt/readline/include
$(NAME): $(MINISHELL_OBJS)
$(CC) $(FLAGS) $(MINISHELL_OBJS) $(PARSE_LIB) $(EXEC_LIB) $(BUILTINS_LIB) -L$(LIBREAD_DIR) -lreadline $(LDFLAGS) -o $(NAME)
else ifeq ($(UNAME), Linux)
CFLAGS = -Wall -Wextra -Werror
LIBREAD_DIR := $(shell find /usr/local -name 'libreadline.a' -exec dirname {} \;)
LIBREAD_INC := $(shell find /usr/local -name 'readline.h' -exec dirname {} \;)
$(NAME): $(MINISHELL_OBJS)
@$(CC) $(FLAGS) $(MINISHELL_OBJS) $(PARSE_LIB) $(EXEC_LIB) $(BUILTINS_LIB) $(LDFLAGS) -o $(NAME) -lreadline
@echo "$(GREEN) libreadline.a directory: $(LIBREAD_DIR)$(DEFAULT)"
@echo "$(GREEN) readline.h directory: $(LIBREAD_INC)$(DEFAULT)"
endif
# Make libft archive
$(BUILTINS_LIB):
@$(MAKE_LIBR) $(BUILTINS_DIR)
$(LIBFT_LIB):
@$(MAKE_LIBR) $(LIBFT_DIR)
# Make parse archive
$(PARSE_LIB):
@$(MAKE_LIBR) $(PARSE_DIR)
# Make execution archive
$(EXEC_LIB):
@$(MAKE_LIBR) $(EXEC_DIR)
clean:
@$(RM) $(MINISHELL_OBJS)
@$(MAKE_LIBR) $(BUILTINS_DIR) clean
@$(MAKE_LIBR) $(LIBFT_DIR) clean
@$(MAKE_LIBR) $(PARSE_DIR) clean
@$(MAKE_LIBR) $(EXEC_DIR) clean
fclean: clean
@$(RM) $(NAME)
@$(MAKE_LIBR) $(BUILTINS_DIR) fclean
@$(MAKE_LIBR) $(LIBFT_DIR) fclean
@$(MAKE_LIBR) $(PARSE_DIR) fclean
@$(MAKE_LIBR) $(EXEC_DIR) fclean
re: fclean all