-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
56 lines (43 loc) · 1.07 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
NAME = libft_leaks.a
CC = gcc
OBJ_DIR = obj
CFLAGS = -Wall -Wextra -Werror
INCLUDES = -I./include
# Détection du système d'exploitation
UNAME_S := $(shell uname -s)
# Configuration de l'echo selon le système
ifeq ($(UNAME_S),Linux)
ECHO := echo -e
else
ECHO := echo
endif
# Colors
RED := \033[0;31m
GREEN := \033[0;32m
YELLOW := \033[0;33m
CYAN := \033[0;36m
NC := \033[0m
# ft_leaks utils
FTLEAKS_UTILS = $(addprefix utils/, fct_putstr_fd.c fct_strlen.c)
# ft_leaks
LEAKS_SRC = ft_malloc.c ft_free.c ft_putalloc.c
# ft_leaks sources
LEAKS = $(addprefix src/, $(FTLEAKS_UTILS) $(LEAKS_SRC))
LEAKS_OBJS = $(LEAKS:%.c=$(OBJ_DIR)/%.o)
# Compilation rules
all: $(NAME)
$(NAME): $(LEAKS_OBJS)
@ar rcs $(NAME) $^
@$(ECHO) "$(YELLOW)Library $(NAME) created.$(NC)"
$(OBJ_DIR)/%.o: %.c
@mkdir -p $(dir $@)
@$(ECHO) -n "\r$(CYAN)Compiling $<...$(NC)"
@$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
clean:
@rm -rf $(OBJ_DIR)
@$(ECHO) "$(GREEN)Object files cleaned.$(NC)"
fclean: clean
@rm -f $(NAME)
@$(ECHO) "$(RED)All files removed.$(NC)"
re: fclean all
.PHONY: all clean fclean re