-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
125 lines (100 loc) · 4.18 KB
/
Makefile
File metadata and controls
125 lines (100 loc) · 4.18 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# **************************************************************************** #
# LE - / #
# / #
# Makefile .:: .:/ . .:: #
# +:+:+ +: +: +:+:+ #
# By: vischlum <[email protected]> +:+ +: +: +:+ #
# #+# #+ #+ #+# #
# Created: 2018/04/23 19:11:16 by tle-coza #+# ## ## #+# #
# Updated: 2018/10/22 18:35:14 by vbranco ### #+. /#+ ###.fr #
# / #
# / #
# **************************************************************************** #
NAME = 42sh
UNAME := $(shell uname) # Detect the current OS
#$(info OS="$(UNAME)")
ifeq ($(UNAME),Darwin ) # Mac OS X
CC = gcc
TERMCAP_LNK = -ltermcap
endif
ifeq ($(UNAME),Linux ) # Weird as it seems, the space is necessary
CC = clang
TERMCAP_LNK = -lncurses
endif
FLAGS = -Wall -Wextra -Werror -O2
MSH_INIT = $(addprefix msh_init/, \
msh_hashbin_utils.c msh_prompt.c msh_local_var.c \
init_shell.c msh_lstenv.c msh_hashbin.c \
msh_environment.c msh_terminal.c msh_signal.c)
MSH_BULTIN = $(addprefix msh_builtin/, \
msh_builtin.c msh_env.c msh_unset.c msh_export.c \
msh_cd.c msh_var_utils.c msh_exit.c msh_echo.c \
msh_unsetenv.c msh_setenv.c msh_hash.c msh_cd_calculate.c \
msh_cd_utils.c msh_env_dispatch.c)
MSH_INPUT = $(addprefix msh_input/, \
msh_input.c move_choice.c input_utils.c \
cursor_position.c history_navigation.c cursor_navigation.c \
backspace_delete.c utils_backspace_delete.c input_checker.c \
cut_copy.c paste.c window_size.c process_input.c\
msh_completion.c compl_get_matches.c compl_get_word.c \
compl_display.c compl_display_calculate.c compl_process_word.c \
compl_process_closest_match.c clear_screen.c \
compl_matches_utils.c)
MSH_LEXER = $(addprefix msh_lexer/, \
tokenize_backslash.c tokenize_operators.c tokenize_quote.c \
tokenize_dquote.c tokenize_regular.c lexer_tokenize.c \
tokenlst_utils.c tools_parse.c lexer_tools.c operator_utils.c)
MSH_PARSER = $(addprefix msh_parser/, \
ft_remove_quoting.c msh_expand.c cmds_utils.c here_doc.c \
syntax_checker.c msh_redir.c msh_simple_cmd.c msh_parser.c \
ft_expand_tilde.c ft_expand_dollar.c)
MSH_EXEC = $(addprefix msh_exec/, \
exec_all.c process_redir.c fd_utils.c msh_pipe.c msh_exec.c \
msh_dispatch_cmd.c msh_parse_status.c pipe_utils.c)
MSH_HISTORY = $(addprefix msh_history/, \
msh_history.c history_utils.c history_options.c history_lst.c \
bang_expand.c bang_hist_getters.c bang_event_utils.c \
bang_process_event.c history_opt_utils.c history_opt_anrw.c \
history_opt_cdsp.c bang_parsers.c bang_parser_utils.c)
FILENAMES = main.c msh_error2.c msh_error.c msh_error_term.c msh_utils.c \
$(MSH_INIT) \
$(MSH_BULTIN) \
$(MSH_INPUT) \
$(MSH_LEXER) \
$(MSH_PARSER) \
$(MSH_EXEC) \
$(MSH_HISTORY)
SOURCES = $(addprefix srcs/, $(FILENAMES))
OBJECTS = $(SOURCES:.c=.o)
L_FT = ./libft
LIB_LNK = -L $(L_FT) -l ft
LIB_INC = -I $(L_FT)/libft.h
.PHONY: all clean fclean re
all: $(NAME)
lib:
@if (make -q -C $(L_FT)); then \
echo "\033[0;35mlibft.a: Ready to go ️🏎️ \033[0m";\
fi;
@if !(make -q -C $(L_FT)); then \
echo "\033[0;96mlibft.a: Compiling ⏳️\033[0m"; \
make -C $(L_FT); \
fi;
$(NAME): $(OBJECTS) lib
@echo "\033[0;96m$(NAME): Compiling ⏳️\033[0m"
@$(CC) -I ./includes $(OBJECTS) $(TERMCAP_LNK) $(LIB_LNK) -o $@
@echo "\033[1;34m~ Welcome to LazySH ~\033[0m"
%.o: ./%.c
@$(CC) $(FLAGS) $(LIB_INC) -I ./includes -c $< -o $@
clean:
@$(MAKE) -C $(L_FT) clean
@rm -rf $(OBJECTS)
@echo "\033[0;32m$(NAME): Spotless ✨\033[0m"
fclean: clean
@rm -rf $(NAME)
@$(MAKE) -C $(L_FT) fclean
clear:
@$(MAKE) all
@$(MAKE) clean
re:
@$(MAKE) fclean
@$(MAKE) all