-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
60 lines (44 loc) · 1.24 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
# library name
NAME = libftprintf.a
# compiler
CC = clang
# compilation flags
CF = -Wall -Wextra -Werror
# directories
SRCS = ./srcs
OBJ = ./obj
INCLUDES = ./includes
LIBFT = ./libft
# header
FT_PRINTF_HEADER = $(patsubst %, $(INCLUDES)/%.h, libftprintf)
LIBFT_HEADER = $(patsubst %, $(LIBFT)/$(INCLUDES)/%.h, libft)
# static library
FT_PRINTF_SLIB = $(NAME)
# function names
FT_PRINTF_SRC = ft_printf parse parse_utils \
print print_num print_txt \
print_base print_float \
print_utils colors libbuf
# object files
FT_PRINTF_O_FILES = $(patsubst %, $(OBJ)/%.o, $(FT_PRINTF_SRC))
.PHONY: clean fclean re all libft
all: $(NAME)
libft: $(LIBFT)
make -C $(LIBFT)
$(OBJ)/ft_printf.o: $(SRCS)/ft_printf.c $(FT_PRINTF_HEADER) $(LIBFT_HEADER)
@mkdir -p $(OBJ)
$(CC) $(CF) -c $(SRCS)/ft_printf.c -o $(OBJ)/ft_printf.o -I $(INCLUDES) -I $(LIBFT)/$(INCLUDES)
$(OBJ)/%.o: $(SRCS)/%.c $(FT_PRINTF_HEADER) $(LIBFT_HEADER)
@mkdir -p $(OBJ)
$(CC) $(CF) -c $< -o $@ -I $(INCLUDES) -I $(LIBFT)/$(INCLUDES)
$(NAME): libft $(FT_PRINTF_O_FILES)
@cp $(LIBFT)/libft.a ./$(NAME)
ar rc $(NAME) $(FT_PRINTF_O_FILES)
ranlib $(NAME)
clean:
rm -rf $(OBJ)
make clean -C $(LIBFT)
fclean: clean
rm -rf $(FT_PRINTF_SLIB)
make fclean -C $(LIBFT)
re: fclean all