-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
92 lines (80 loc) · 2.54 KB
/
Makefile
File metadata and controls
92 lines (80 loc) · 2.54 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
85
86
87
88
89
90
91
92
#******************************************************************************#
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: pguillie <pguillie@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2018/08/15 12:56:13 by pguillie #+# #+# #
# Updated: 2018/09/25 18:51:05 by pguillie ### ########.fr #
# #
#******************************************************************************#
ifeq ($(HOSTTYPE),)
HOSTTYPE := $(shell uname -m)_$(shell uname -s)
endif
NAME = libft_malloc_$(HOSTTYPE).so
SOLINK = libft_malloc.so
CC = gcc
CFLAGS = -Wall -Werror -Wextra -fpic
DEBUG = -g3 -fsanitize=address
INCPATH = includes/
HEADERS = $(addprefix $(INCPATH), malloc.h malloc_struct.h malloc_debug_var.h)
LIBPATH = libft/
LIB = $(LIBPATH)libft.a
SOURCES = $(addprefix src/, \
abort.c \
calloc.c \
free.c \
get_chunk.c \
malloc.c \
malloc_init.c \
malloc_small_list_api.c \
malloc_verbose.c \
ptcalloc.c \
ptfree.c \
ptfree_large.c \
ptfree_small.c \
ptfree_tiny.c \
ptmalloc.c \
ptmalloc_large.c \
ptmalloc_small.c \
ptmalloc_tiny.c \
ptmalloc_top.c \
ptrealloc.c \
ptrealloc_large.c \
ptrealloc_relocate.c \
ptrealloc_small.c \
ptrealloc_tiny.c \
ptshow_alloc_mem.c \
ptshow_alloc_mem_free.c \
realloc.c \
reallocf.c \
show_alloc_mem.c \
show_alloc_mem_free.c \
show_alloc_mem_res.c \
show_alloc_mem_total.c \
)
OBJECTS = $(SOURCES:src/%.c=obj/%.o)
.PHONY: all clean fclean re
all: $(NAME)
$(NAME): obj $(LIB) $(OBJECTS)
@ echo "Compiling $(NAME) shared library..."
$(CC) -shared $(CFLAGS) -o $(NAME) $(OBJECTS) $(LIB)
rm -f $(SOLINK) && ln -s $(NAME) $(SOLINK)
@ echo "$(NAME) successfully compiled"
obj/%.o: src/%.c $(HEADERS) Makefile
$(CC) $(CFLAGS) -I $(INCPATH) -o $@ -c $<
obj:
@ echo "Creating $(NAME) objects directory..."
mkdir obj
$(LIB):
make -C $(LIBPATH)
clean:
@ echo "Removing $(NAME) object files..."
make -C $(LIBPATH) clean
rm -rf obj
fclean:
@ echo "Removing $(NAME) all compiled files..."
make -C $(LIBPATH) fclean
rm -rf obj $(NAME) $(SOLINK)
re: fclean all