-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
83 lines (63 loc) · 2.29 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
# **************************************************************************** #
# COLORS #
# COM_COLOR=blue, OBJ_COLOR=green, ERROR_COLOR=red, WARN_COLOR=yellow #
# **************************************************************************** #
COM_COLOR := \033[0;34m
OBJ_COLOR := \033[0;32m
ERROR_COLOR := \033[0;31m
WARN_COLOR := \033[0;33m
# **************************************************************************** #
# VARIABLES #
# **************************************************************************** #
NAME := ft_printf
LIB := libftprintf.a
CC := gcc
CFLAGS := -Wall -Werror -Wextra -Iheader
DEPFLAGS = -MMD -MF $(DDIR)$*.d
SDIR := srcs/
ODIR := obj/
DDIR := $(ODIR)deps/
LIBFT_DIR := Libft/
LDLIBS := $(LIBFT_DIR)libft.a
SRCS := main.c \
ft_printf.c ft_conversion.c \
ft_print_char.c ft_print_string.c \
ft_print_hexa.c ft_print_int.c \
ft_itoa_unsigned.c ft_print_unsigned_int.c
OBJS := $(SRCS:%.c=$(ODIR)%.o)
DEPS := $(SRCS:%.c=$(DDIR)%.d)
# **************************************************************************** #
# RULES #
# **************************************************************************** #
.PHONY: all clean fclean re
all: $(NAME)
$(NAME): $(LIB)
@$(CC) $(CFLAGS) -o $@ $(OBJS) $< $(LDLIBS)
@echo "$(WARN_COLOR)...build executable $(NAME)"
# $(LIBFT):
# make -C $(LIBFT_DIR)
# @echo "compiling libft"
$(LIB): $(ODIR) $(DDIR) $(DEPS) $(OBJS)
@make -C $(LIBFT_DIR)
@echo "...compiling libft.a"
@ar -rcs $(LIB) $(OBJS)
@echo "$(COM_COLOR)...creating: $(LIB)"
$(ODIR)%.o: $(SDIR)%.c $(DDIR)%.d
@$(CC) $(CFLAGS) $(CPPFLAGS) $(DEPFLAGS) -c $< -o $@
$(ODIR):
@mkdir -p $(ODIR)
@echo "$(OBJ_COLOR)...compiling $(LIB)-object-files..."
$(DDIR):
@mkdir -p $(DDIR)
@echo "$(OBJ_COLOR)...creating dependency files..."
clean:
@rm -rf $(LIB) $(OBJS) $(ODIR) $(DDIR)
@make clean -C $(LIBFT_DIR)
@echo "$(ERROR_COLOR)...$(LIB) & object files deleted"
@echo "$(ERROR_COLOR)...$(NAME) deleted"
fclean: clean
@rm -f $(NAME)
@make fclean -C $(LIBFT_DIR)
re: fclean all
$(DEPS):
-include $(DEPS)