-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
93 lines (76 loc) · 2.89 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: bnidia <bnidia@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2021/10/25 19:16:59 by bnidia #+# #+# #
# Updated: 2022/05/21 05:22:42 by bnidia ### ########.fr #
# #
# **************************************************************************** #
# Manual for Makefile
# https://www.gnu.org/software/make/manual/html_node/index.html
NAME = libftprintf.a
SRCDIR = ./
OBJDIR = ./obj/
SRC = ft_printf.c ft_printf_c.c ft_printf_d.c ft_printf_p.c ft_printf_s.c
SRC += ft_printf_u.c ft_printf_x.c ft_print_out.c reset_width_precision.c
SRC += ft_itoa_base.c ft_printf_common_functions.c
OBJ = $(addprefix $(OBJDIR), $(notdir $(SRC:.c=.o)))
D_FILES = $(addprefix $(OBJDIR), $(notdir$(SRC:.c=.d)))
HEADER = ft_printf.h
CC = gcc -Werror -Wall -Wextra
DEBUG_SWITCH = TRUE
ifeq ($(DEBUG_SWITCH), TRUE)
DEBUG = -g
else
OPTIMIZATION = -O1
endif
all: $(NAME)
# translation of assembly language code into machine code
# -c, stops after assembly stage
# -MD lists both system header files and user header files, dependencies
# -MMD lists only user header files, dependencies
# $< the first prerequisite (usually a source file) main.c (dependency %.c)
# $@ is the name of the target being generated main.o (target %.o)
$(OBJDIR)%.o: $(SRCDIR)%.c $(HEADER) | obj
$(CC) $(DEBUG) $(OPTIMIZATION) -c $< -o $@ -MMD
# arc stage
$(NAME): $(OBJ)
make -C ./libraries/libft/
cp ./libraries/libft/libft.a $(NAME)
ar rcs $@ $^
obj:
mkdir -p $(OBJDIR)
include $(wildcard $(D_FILES))
bonus: all
norm:
norminette $(SRC) $(HEADER)
test:
make all
gcc -g main.c libftprintf.a -o test #&& ./test | cat -e
test1:
echo "paulo-santana/ft_printf_tester"
git clone https://github.com/rustem-spb/ft_printf_tester.git
# git clone https://github.com/paulo-santana/ft_printf_tester.git
bash -c "cd ft_printf_tester && sh test"
rm -rf ft_printf_tester
test11:
bash -c "cd ft_printf_tester && sh test"
test2:
echo "Tripouille/printfTester"
git clone https://github.com/Tripouille/printfTester.git
make a -C ./printfTester/
rm -rf printfTester
# rule for the cleaning
clean:
make clean -C ./libraries/libft/
rm -rf $(OBJDIR)
fclean: clean
make fclean -C ./libraries/libft/
rm -rf $(OBJDIR) $(NAME)
# rule for rebuild a project
re: fclean all
# directory exceptions
.PHONY: all clean fclean norm re bonus test test1 test2