-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
59 lines (43 loc) · 1.23 KB
/
Makefile
File metadata and controls
59 lines (43 loc) · 1.23 KB
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
NAME = libftprintf.a
LIBFT_DIR = libft/libft
LIBFT = $(LIBFT_DIR)/libft.a
SRC = src
OBJ = obj
PRS = parse
PRT = print
SRCS = $(addprefix $(SRC)/, ft_printf.c parser.c printer.c)
PRS_SRC = $(addprefix $(SRC)/$(PRS)/, flags.c parse_utils.c)
PRT_SRC = $(addprefix $(SRC)/$(PRT)/, types.c out_char.c \
out_string.c out_pointer.c out_signed.c out_unsigned.c \
out_percent.c print_utils.c)
SRC_OBJ = $(subst $(SRC), $(OBJ), $(SRCS:.c=.o))
PRS_OBJ = $(subst $(SRC)/$(PRS), $(OBJ), $(PRS_SRC:.c=.o))
PRT_OBJ = $(subst $(SRC)/$(PRT), $(OBJ), $(PRT_SRC:.c=.o))
CFLAGS = -g -Wall -Wextra -Werror
RM = rm -f
all: $(NAME)
bonus: $(NAME)
$(NAME): $(LIBFT) $(SRC_OBJ) $(PRS_OBJ) $(PRT_OBJ)
$(OBJ)/%.o: src/%.c
@mkdir -p $(OBJ)
$(CC) $(CFLAGS) -c $< -o $@
ar -rcs $(NAME) $@
$(OBJ)/%.o: src/parse/%.c
$(CC) $(CFLAGS) -c $< -o $@
ar -rcs $(NAME) $@
$(OBJ)/%.o: src/print/%.c
$(CC) $(CFLAGS) -c $< -o $@
ar -rcs $(NAME) $@
$(LIBFT):
git submodule init
git submodule update
@make -C $(LIBFT_DIR)
@cp $(LIBFT) $(NAME)
clean:
$(RM) -r $(SRC_OBJ) $(PRS_OBJ) $(PRT_OBJ)
$(RM) -r $(OBJ)
fclean: clean
@make fclean -C $(LIBFT_DIR)
$(RM) $(NAME)
re: fclean all
.PHONY: all clean fclean re