-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
68 lines (49 loc) · 2.09 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
#* ************************************************************************** *#
#* *#
#* ::: :::::::: *#
#* Makefile :+: :+: :+: *#
#* +:+ +:+ +:+ *#
#* By: victor <[email protected]> +#+ +:+ +#+ *#
#* +#+#+#+#+#+ +#+ *#
#* #+# #+# *#
#* ### ########.fr *#
#* *#
#* ************************************************************************** *#
################################################################################
# VARIABLE DECLARATION
################################################################################
SRC_DIR = src
INC_DIR = inc
OBJ_DIR = obj
BIN_DIR = bin
SRCS = ft_printf.c\
ft_printf_str.c\
ft_printf_nbr.c\
OBJS = $(addprefix $(OBJ_DIR)/, $(SRCS:.c=.o))
NAME = libftprintf.a
CC = gcc
CFLAGS = -Wall -Werror -Wextra
RM = rm -rf
################################################################################
# IMPLICIT RULES
################################################################################
all: $(NAME)
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c | $(OBJ_DIR)
@$(CC) $(CFLAGS) -c $< -o $@
main: $(NAME)
@$(CC) $(CFLAGS) $(NAME) $(addprefix $(SRC_DIR)/, main.c)
$(NAME): $(OBJS)
@ar rcs $(NAME) $(OBJS)
$(OBJ_DIR):
@mkdir -p $(OBJ_DIR)
#clean implicit rules
# clean: remove object files (.o)
# fclean: remove object files and the binary (.o, .a)
# re: remove object files and the binary (.a, .a). Remake the binary
clean:
@$(RM) $(OBJS)
fclean: clean
@$(RM) $(NAME) $(OBJ_DIR)
re: fclean all
# .PHONY prerequisitest always run independently if name exists or modification time
.PHONY: all bonus clean fclean r