-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
81 lines (59 loc) · 2.59 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
CC = gcc
CFLAGS = -g3 -Wall -Wextra -Werror
RM = rm -f
SRCD = ./srcs/
UNAME = $(shell uname)
#echo $(UNAME)
ifeq ($(UNAME), Linux)
SRC = main.c ft_lexor.c ft_parser.c ft_executor.c ft_initiator.c ft_echo_utils.c ft_builtins2.c ft_builtins.c ft_globlal_fun.c \
ft_builtins_utils.c ft_cd_utils.c ft_lexor_utils.c ft_lexor_utils2.c ft_lexor_handlers.c ft_parser_utils.c utils.c \
ft_free_linked_list.c ft_exit_utils.c ft_export_utils.c get_next_line.c get_next_line_utils.c ft_init_utils.c \
pipex.c helper.c exit_handler.c ft_heredoc.c ft_signal_handler.c ft_get_path_linux.c
endif
ifeq ($(UNAME), Darwin)
SRC = main.c ft_lexor.c ft_parser.c ft_executor.c ft_initiator.c ft_echo_utils.c ft_builtins2.c ft_builtins.c ft_globlal_fun.c \
ft_builtins_utils.c ft_cd_utils.c ft_lexor_utils.c ft_lexor_utils2.c ft_lexor_handlers.c ft_parser_utils.c utils.c \
ft_free_linked_list.c ft_exit_utils.c ft_export_utils.c get_next_line.c get_next_line_utils.c ft_init_utils.c \
pipex.c helper.c exit_handler.c ft_heredoc.c ft_signal_handler.c ft_get_path_mac.c
endif
# Command to add the source folder prefix (instead of having it added manually to SRC)
SRCF = $(addprefix $(SRCD),$(SRC))
OBJD = ./objs/
# for every SRCF file which is an .c file an o file will be created according to the implicit rule (see $(OBJD)%.o: $(SRCD)%.c)
OBJF = $(SRCF:$(SRCD)%.c=$(OBJD)%.o)
BUILD = $(OBJF:$(OBJD)%.o)
NAME = minishell
HEADD = ./incl/
HEADF = minishell.h
LIBFTD = ./libft/
LIBFT_OBJD = objs
LIBFT_SRCD = srcs/
LIBFTL = libft.a
LIBFT_OBJF = ${LIBFTD}${LIBFT_OBJD}/*.o
LIBFT_MAKE = make -C ${LIBFTD}
#if to the respective c file in the source directory no matching o file in the object
#directory is available, then create it according to the following rules:
#Note: the object directory will only be created if not existing already. -p flag throws no errors when already there
$(OBJD)%.o: $(SRCD)%.c
@mkdir -p $(OBJD)
$(CC) $(CFLAGS) -I ${HEADD} -c -o $@ $<
# $(NAME): ${OBJF}
# make libftmake
# $(CC) $(CFLAGS) $(SRCF) -o $(NAME) $(HEADD)$(HEADF) $(LIBFTD)$(LIBFTL)
$(NAME): ${OBJF}
make libftmake
$(CC) $(CFLAGS) $(SRCF) -o $(NAME) -L $(HEADD) $(LIBFTD)$(LIBFTL) -L /usr/local/lib -I /usr/local/include -lreadline
all: ${NAME}
libftmake:
${LIBFT_MAKE}
clean:
${RM} ${OBJD}*.o
make -C ${LIBFTD} clean
fclean: clean
${RM} ${NAME}
${RM} ${LIBFTD}${LIBFTL}
@${RM} ${HEADD}minishell.h.gch
@${RM} ${HEADD}minishe11.h.gch
@rm -rf minishell.dSYM
re: fclean all
.PHONY: all clean fclean re