-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
126 lines (94 loc) · 3.06 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: pchadeni <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2018/01/08 14:57:58 by pchadeni #+# #+# #
# Updated: 2019/03/16 16:31:51 by pchadeni ### ########.fr #
# #
# **************************************************************************** #
#------Name of the project------#
LINK = libft_malloc.so
NAME = libft_malloc_$(HOSTTYPE).so
#------Assign HOSTTYPE------#
ifeq ($(HOSTTYPE),)
HOSTTYPE := $(shell uname -m)_$(shell uname -s)
endif
#------All sources------#
MALLOC = malloc.c \
free.c \
realloc.c \
show_alloc_mem.c \
find_in_pool.c \
handle_addr.c \
handle_pool.c \
align.c \
desalloc_buckets.c \
bonus.c
OBJ += $(addprefix ./$(OBJ_PATH)/, $(MALLOC:.c=.o))
#------Includes------#
INCLUDES = ./includes/
INC += -I $(INCLUDES)
INC += -I $(LIB_PATH)/$(INCLUDES)
LIB = $(LIB_PATH)/libft.a
HEAD = $(INCLUDES)/lib_alloc.h
#------Path------#
SRCS_PATH = srcs
OBJ_PATH = obj
LIB_PATH = libft
#------Main rules------#
all: $(OBJ_PATH) makelib $(NAME)
$(NAME): $(OBJ)
@printf "\33[2KObjects created $(BOLD_GREEN)✓$(EOC)\n"
@printf "Start making $(NAME)... "
@$(CC) $(C_FLAGS) $(FLAGS) $(INC) -Wpadded -Llibft -lft -shared -o $@ $^ $(LIB)
@if [ -e $(LINK) ]; \
then \
rm -Rf $(LINK); \
echo "$(BOLD_GREEN)$(LINK) deleted ✓$(EOC)"; \
fi;
@ln -s $(NAME) $(LINK)
@printf "$(BOLD_GREEN)$(NAME)$(EOC) created $(BOLD_GREEN)✓$(EOC)\n"
$(OBJ_PATH):
@mkdir -p $(OBJ_PATH)
@printf "$(OBJ_PATH) created\n"
$(OBJ_PATH)/%.o: $(SRCS_PATH)/%.c $(HEAD)
@$(CC) $(FLAGS) $(C_FLAGS) $(INC) -Wpadded -o $@ -c $<
@printf " $(COL_GREEN)[OK]$(EOC) $(COL_YELLOW)Compiling:$(EOC) $<\r"
makelib:
@make -C $(LIB_PATH) NOERR=$(NOERR) DEV=$(DEV) SAN=$(SAN)
clean: cleanlib
@rm -Rf $(OBJ_PATH)
@rm -Rf $(TEST_OBJ)
@echo "$(BOLD_GREEN)$(NAME)$(EOC) clean $(BOLD_GREEN)✓$(EOC)"
cleanlib:
@make clean -C $(LIB_PATH)
fclean: fcleanlib clean
@rm -Rf $(NAME) $(LINK)
@echo "$(BOLD_GREEN)$(NAME) $(LINK)$(EOC) fclean $(BOLD_GREEN)✓$(EOC)"
fcleanlib:
@make fclean -C $(LIB_PATH)
re:
@$(MAKE) fclean
@$(MAKE) all
#------Compilation's flags------#
CC = gcc
# flags
C_FLAGS = -Wall -Wextra
ifneq ($(NOERR),yes)
C_FLAGS += -Werror
endif
ifeq ($(DEV),yes)
FLAGS += -g
endif
ifeq ($(SAN),yes)
FLAGS += -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls
endif
#------Define colors------#
BOLD_GREEN = \033[01;32m
COL_GREEN = \033[0;32m
COL_YELLOW = \033[0;33m
EOC = \033[0m
.PHONY: all re fclean clean