-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
60 lines (43 loc) · 1.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
NAME = minishell
NAME_BONUS = minish
LIBFT = libft
OBJDIR = objs
CC = /usr/bin/clang
RM = /bin/rm
include srcs.mk
CFLAGS = -Wall -Wextra -Werror
IFLAGS = -I$(INCDIR) -I$(LIBFT)/includes
LFLAGS = -L$(LIBFT) -lft
OBJS = $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(SRCS))
OBJS_BONUS = $(patsubst $(SRCDIR)/%.c, $(OBJDIR)/%.o, $(SRCS_BONUS))
all: libft $(NAME)
libft:
make -C $(LIBFT) NAME=libft.a CC="$(CC)" CFLAGS="$(CFLAGS)"
$(LIBFT)/libft.a: libft
$(NAME): $(OBJS) $(LIBFT)/libft.a
@echo LINK $@
$(CC) $(OBJS) $(CFLAGS) $(LFLAGS) -o $@
$(NAME_BONUS): LFLAGS += -lcurses -ltermcap
$(NAME_BONUS): $(OBJS_BONUS) $(LIBFT)/libft.a
@echo LINK $@
$(CC) $(OBJS_BONUS) $(CFLAGS) $(LFLAGS) -o $@
$(OBJDIR):
mkdir -p $@
$(OBJDIR)/%.o: $(SRCDIR)/%.c $(HDRS) Makefile | $(OBJDIR)
@mkdir -p '$(@D)'
@echo CC $<
@$(CC) $(CFLAGS) $(IFLAGS) -c -o $@ $<
clean:
make -C $(LIBFT) $@
@echo RM $(OBJDIR)
@$(RM) -rf $(OBJDIR)
fclean: clean
make -C $(LIBFT) $@
@echo RM $(NAME)
@$(RM) -f $(NAME)
@echo RM $(NAME_BONUS)
@$(RM) -f $(NAME_BONUS)
re: fclean all
bonus: $(NAME_BONUS)
.PHONY: libft clean fclean bonus
$(VERBOSE).SILENT: