-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
68 lines (57 loc) · 2.26 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: phelebra <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/05/19 12:15:10 by fvonsovs #+# #+# #
# Updated: 2023/08/02 14:03:57 by phelebra ### ########.fr #
# #
# **************************************************************************** #
UNAME_S = $(shell uname -s)
NAME = minishell
SRCS = main.c minishell.c utils_1.c utils_2.c utils_3.c \
builtins_1.c builtins_2.c lexer_1.c lexer_2.c parser.c expand.c \
execute.c pipex.c path.c get.c fill_list.c builtin_cd.c \
builtin_export.c builtin_echo.c
OBJS = ${SRCS:.c=.o}
LIBC = ar -cq
RM = rm -f
LIBFT = ./libft/libft.a
# Common flags
CFLAGS = -Wall -Wextra -Werror -I./
# Linker flags
LDFLAGS = -lreadline
ifeq ($(UNAME_S),Linux)
CFLAGS += -fsanitize=address -g
LDFLAGS += -fsanitize=address -g
endif
ifeq ($(UNAME_S),Darwin)
CFLAGS += -fsanitize=address -g -I/usr/local/opt/readline/include
LDFLAGS += -lSystem -fsanitize=address -g -L/usr/local/opt/readline/lib
endif
# Colors
GREEN = $(shell printf "\033[0;32m")
YELLOW = $(shell printf "\033[0;33m")
RESET = $(shell printf "\033[0m")
.c.o:
@echo "$(YELLOW)Compiling: $(GREEN)$<$(RESET)"
@${CC} ${CFLAGS} -c $< -o ${<:.c=.o} -I. -I./libft
all: $(NAME)
$(NAME): ${OBJS}
@echo "$(YELLOW)Compiling libft...$(RESET)"
make -C ./libft
@echo "$(YELLOW)Linking objects...$(RESET)"
@${CC} ${OBJS} ${LDFLAGS} -o ${NAME} ${LIBFT}
@echo "$(GREEN)Compilation successful.$(RESET)"
clean:
@echo "$(YELLOW)Removing object files...$(RESET)"
make clean -C ./libft
@${RM} ${OBJS}
fclean: clean
@echo "$(YELLOW)Removing executable...$(RESET)"
make fclean -C ./libft
@${RM} ${NAME}
re: fclean all
.PHONY: all clean fclean re