-
Notifications
You must be signed in to change notification settings - Fork 3
/
Makefile
108 lines (87 loc) · 2.76 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: rlambert <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2014/11/03 11:25:08 by rlambert #+# #+# #
# Updated: 2015/11/12 18:15:47 by rlambert ### ########.fr #
# #
# **************************************************************************** #
NAME = libftprintf.a
C_INCLUDE_PATH += include/ libft/include
CFLAGS += -Wall -Wextra -Werror
CFLAGS += $(foreach d, $(C_INCLUDE_PATH), -I$d)
SRCS = src/ft_printf.c \
src/parse_handlers.c \
src/utils/get_unsigned_from_length.c \
src/utils/width_pad.c \
src/utils/nbrlen.c \
src/utils/calc_nbrstrlen.c \
src/utils/nbrforceprefix.c \
src/handlers/get_handler_arr.c \
src/handlers/generic_handle_unsigned.c \
src/handlers/handle_null.c \
src/handlers/handle_char.c \
src/handlers/handle_escape.c \
src/handlers/handle_hex.c \
src/handlers/handle_int.c \
src/handlers/handle_long.c \
src/handlers/handle_octal.c \
src/handlers/handle_ptr.c \
src/handlers/handle_str.c \
src/handlers/handle_unsigned.c \
src/handlers/handle_wchar.c \
src/handlers/handle_binary.c \
src/handlers/handle_charswritten.c \
src/handlers/handle_float.c \
src/handlers/handle_wstr.c
LIBFT_FUNS = putchar_fd \
putchar_fd \
putstr_fd \
putnbrbase_fd \
putnstr_fd \
putwchar_fd \
memset \
strchr \
putstr \
strlen \
putnstr \
bzero \
isdigit \
memalloc \
putchar \
max \
tolower \
nstrlen \
putwchar \
putnwstr \
putnbrbase \
CFLAGS += $(foreach fun,$(LIBFT_FUNS),-Dft_$(fun)=ft_printf_libft_$(fun))
OBJS = $(patsubst src/%.c,obj/%.o,$(SRCS))
OBJS += $(foreach fun,$(LIBFT_FUNS),obj/libft/ft_$(fun).o)
CP = cp
RM = rm -f
all: $(NAME)
$(OBJS): | obj
obj:
@mkdir -p $@
@mkdir -p $@/handlers
@mkdir -p $@/utils
@mkdir -p $@/libft
obj/%.o: src/%.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
obj/libft/%.o: libft/%.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
$(NAME): $(OBJS)
$(AR) -rcs $(NAME) $^
clean:
$(RM) $(OBJS)
libfttest: $(NAME) obj/main.o
$(CC) -o $@ obj/main.o -L. -lftprintf
fclean: clean
$(RM) $(NAME)
$(RM) -rf obj
re: fclean all
.PHONY: all clean fclean re