-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
95 lines (78 loc) · 4.64 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: mmateo-t <mmateo-t@student.42madrid> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2021/12/03 10:00:24 by mmateo-t #+# #+# #
# Updated: 2022/02/19 20:45:48 by mmateo-t ### ########.fr #
# #
# **************************************************************************** #
#USAGE
#make #compile all binary
#make clean #remove all binaries
#make fclean #remove all binaries and executable
SRCS_DIR:= files/srcs/
SRCS := $(wildcard $(SRCS_DIR)*.c) $(wildcard $(SRCS_DIR)builtins/*.c)
OBJS := $(SRCS:%.c=%.o)
NAME:= minishell
CC:= gcc
DEBUG_FLAG:= -g -g3 -fsanitize=address
CFLAGS:= -Wall -Werror -Wextra
LIBFT_PATH:= files/lib/libft
LIBFT_LIB:= -L$(LIBFT_PATH) $(LIBFT_PATH)/libft.a
RM := rm -rvf
UNAME_P:= $(shell uname -p)
ifeq ($(UNAME_P), arm)
#-------------MacBook Air M1---------------------------
LDFLAGS=-L/opt/homebrew/opt/readline/lib
CPPFLAGS=-I/opt/homebrew/opt/readline/include
else
#-------------iMac school-----------------------
LDFLAGS=-L/Users/${USER}/.brew/opt/readline/lib
CPPFLAGS=-I/Users/${USER}/.brew/opt/readline/include
endif
SYS_LIB:= -lreadline $(LDFLAGS) $(CPPFLAGS)
UNAME_S := $(shell uname -s)
ifeq (${UNAME_S}, Darwin)
LEAKS:= leaks minishell
else
LEAKS:= valgrind --leak-check=full ./minishell
endif
all: libft $(NAME) msg
$(NAME): $(OBJS)
$(CC) $(CFLAGS) $(OBJS) -o $(NAME) $(LIBFT_LIB) $(SYS_LIB)
$(%.o): $(%.c)
$(CC) -c $^ -o $@
@echo "Creating objects"
libft:
make -C $(LIBFT_PATH)
leaks: all
$(LEAKS)
run: all
./minishell
clean:
@echo "Removing objects"
$(RM) $(OBJS)
fclean:
make clean
cd $(LIBFT_PATH) && $(MAKE) fclean
$(RM) $(NAME)
msg:
@echo " "
@echo "\033[1;34m██████ ██████ █████ ██████ █████ █████ █████████ █████ █████ ██████████ █████ █████ \033[0m"
@echo "\033[1;34m░░██████ ██████ ░░███ ░░██████ ░░███ ░░███ ███░░░░░███░░███ ░░███ ░░███░░░░░█░░███ ░░███ \033[0m"
@echo "\033[1;34m░███░█████░███ ░███ ░███░███ ░███ ░███ ░███ ░░░ ░███ ░███ ░███ █ ░ ░███ ░███ \033[0m"
@echo "\033[1;34m░███░░███ ░███ ░███ ░███░░███░███ ░███ ░░█████████ ░███████████ ░██████ ░███ ░███ \033[0m"
@echo "\033[1;34m░███ ░░░ ░███ ░███ ░███ ░░██████ ░███ ░░░░░░░░███ ░███░░░░░███ ░███░░█ ░███ ░███ \033[0m"
@echo "\033[1;34m░███ ░███ ░███ ░███ ░░█████ ░███ ███ ░███ ░███ ░███ ░███ ░ █ ░███ █ ░███ █\033[0m"
@echo "\033[1;34m█████ █████ █████ █████ ░░█████ █████░░█████████ █████ █████ ██████████ ███████████ ███████████\033[0m"
@echo "\033[1;34m░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░ ░░░░░░░░░ ░░░░░ ░░░░░ ░░░░░░░░░░ ░░░░░░░░░░░ ░░░░░░░░░░░\033[0m"
@echo " "
@echo "Usage -> \033[1;36m./minishell\033[0m"
@echo " "
re:
make fclean all
@echo "All files has been deleted and recompiled"
.PHONY: clean fclean all re objects debug libft msg run leaks