-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
executable file
·90 lines (74 loc) · 3.16 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
# **************************************************************************** #
# #
# :::::::: #
# Makefile :+: :+: #
# +:+ #
# By: carlo <[email protected]> +#+ #
# +#+ #
# Created: 2022/10/10 09:28:26 by cwesseli #+# #+# #
# Updated: 2023/05/18 10:11:11 by carlo ######## odam.nl #
# #
# **************************************************************************** #
#//= Colors =//#
BOLD := \033[1m
GREEN := \033[32;1m
BLUE := \033[34;1m
RESET := \033[0m
#//= Variables = //#
NAME = minishell
NAME_BONUS = minishell_bonus
CC ?= clang
CFLAGS = -Wall -Wextra -Werror -g
ifeq ($(USER), cariencaljouw)
RL_INC = /opt/homebrew/opt/readline/include
RL_LIB = /opt/homebrew/opt/readline/lib
else
RL_INC = /Users/$(USER)/.brew/opt/readline/include
RL_LIB = /Users/$(USER)/.brew/opt/readline/lib
endif
#//= Locations =//#
INCLUDE = ./include
LIBFT = ./libft
LIBS = $(LIBFT)/libft.a -L$(RL_LIB)
HEADERS = -I $(LIBFT) -I$(INCLUDE) -I$(RL_INC)
OBJ_FILES = $(addprefix obj/src/, minishell.o lst_utils/t_node.o utils/utils.o lst_utils/t_smpl_cmd.o \
lexer.o utils/env_utils.o init.o print.o lst_utils/node.o signals.o \
lst_utils/delete.o lst_utils/t_pipe.o heredoc.o) \
$(addprefix obj/src/parser/, parser.o parser_utils.o parse_redirect.o quotes.o cond_pipe.o cond_pipe_utils.o check_syntax.o ) \
$(addprefix obj/src/expander/, expander.o expand_var_utils.o wildcards.o ) \
$(addprefix obj/src/executor/, executor.o executor_utils.o executor_set.o executor_checks.o executor_init_exit.o)
OBJ_BUILTIN = $(addprefix obj_builtin/, echo.o cd.o cd_utils.o cd_utils2.o pwd.o unset.o export.o env.o exit.o)
#//= Modifiable =//#
all: libft $(NAME)
$(NAME): libft $(OBJ_FILES) $(OBJ_BUILTIN)
@$(CC) $(OBJ_FILES) $(OBJ_BUILTIN) $(LIBS) $(HEADERS) -o $(NAME) $(CFLAGS) -lreadline
bonus: CFLAGS = -Wall -Wextra -Werror -DBONUS=1
bonus: fclean all
libft:
@$(MAKE) -C $(LIBFT)
$(OBJ_FILES): obj/%.o: %.c
@mkdir -p $(dir $@)
@echo "$(GREEN)$(BOLD)Compiling minishell:$(RESET) $(notdir $<)"
@$(CC) -c $(CFLAGS) $(HEADERS) -o $@ $<
$(OBJ_BUILTIN): obj_builtin/%.o: builtin/%.c
@mkdir -p $(dir $@)
@echo "$(GREEN)$(BOLD)Compiling minishell builtins:$(RESET) $(notdir $<)"
@$(CC) -c $(CFLAGS) $(HEADERS) -o $@ $<
clean:
@echo "$(BLUE)Cleaning minishell$(RESET)"
@rm -rf obj/
@rm -rf obj_builtin/
@$(MAKE) -C $(LIBFT) clean
fclean: clean
@rm -rf $(NAME)
@echo "$(BLUE)Cleaning tester $(RESET)"
@echo "$(BLUE)Cleaning history $(RESET)"
@rm -rf tester/output
@rm -rf tester/trace
@rm -rf $(NAME_BONUS)
@echo "" > log/history_log
@$(MAKE) -C $(LIBFT) fclean
debug: CFLAGS = -Wall -Wextra
debug: all
re: fclean all
.PHONY: all bonus clean fclean re libft debug