-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
84 lines (67 loc) · 2.31 KB
/
Makefile
File metadata and controls
84 lines (67 loc) · 2.31 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
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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: otodd <otodd@student.42london.com> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/11/29 16:33:58 by otodd #+# #+# #
# Updated: 2024/07/16 15:57:47 by otodd ### ########.fr #
# #
# **************************************************************************** #
YELLOW = \033[1;33m
RED = \033[1;31m
GREEN = \033[1;32m
BLUE = \033[1;34m
CYAN = \033[1;36m
NC = \033[0m
CC = gcc
NAME = libftprintf.a
CFLAGS = -Wall -Wextra -Werror -fPIC
SRCS = ft_printf.c \
ft_printf_ingest.c \
ft_printf_arth_u.c \
ft_printf_arth.c \
ft_printf_char.c \
ft_printf_ptr.c \
ft_printf_str.c \
ft_printf_utils.c \
ft_printf_str_array.c \
ft_printf_nbr_array.c \
ft_printf_linked_list.c \
ft_printf_bool.c \
ft_printf_arth_l.c
OBJS = $(SRCS:%.c=obj/%.o)
BUILD_DIR = build
all: $(NAME)
$(NAME): $(OBJS) | $(BUILD_DIR)
@echo "[$(BLUE)FTPRINTF$(NC)] Building standalone lib..."
@ar -rcs $(NAME) $(OBJS)
@mv $(NAME) $(BUILD_DIR)/
$(BUILD_DIR):
@if [ ! -d "$(BUILD_DIR)" ]; then \
echo "[$(GREEN)FTPRINTF$(NC)] Creating build directory..."; \
mkdir -p $(BUILD_DIR); \
fi
module: $(OBJS)
dir:
@if [ ! -d "obj" ]; then \
echo "[$(GREEN)FTPRINTF$(NC)] Creating obj directory..."; \
mkdir -p obj; \
fi
obj/%.o: src/%.c include/ft_printf.h | dir
@echo "[$(CYAN)FTPRINTF$(NC)] Compiling $< --> $@"
@$(CC) -o $@ -c $< $(CFLAGS)
clean:
@echo "[$(YELLOW)FTPRINTF$(NC)] Cleaning object directory..."
@rm -rf obj
fclean: clean
@echo "[$(RED)FTPRINTF$(NC)] Cleaning build directory..."
@rm -rf $(BUILD_DIR)/
re: fclean all
build_test:
@rm -f a.out
@$(CC) test/test.c build/libftprintf.a
run_test: build_test
@./a.out
.PHONY: all clean fclean re