-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
81 lines (62 loc) · 2.21 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: vtarasiu <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2019/07/12 14:31:34 by vtarasiu #+# #+# #
# Updated: 2020/03/07 18:18:34 by vtarasiu ### ########.fr #
# #
# **************************************************************************** #
ifeq ($(HOSTTYPE),)
HOSTTYPE := $(shell uname -m)_$(shell uname -s)
endif
CC = clang
NAME = libft_malloc_$(HOSTTYPE).so
FLAGS = -g -O2 \
-Wall \
-Wextra \
-Werror \
-Wno-unknown-pragmas
# -lpthread
SRC_DIR = ./src/
OBJ_DIR = ./obj/
LIB_DIR = ./libft
LIB_NAME = libft.a
MALLOC_SRC = realloc.c \
auxiliary.c \
region_management.c \
zones_management.c \
allocator.c \
free.c \
malloc.c \
allocator_reverse.c \
init.c
HEADERS = -I includes/ -I $(LIB_DIR)
OBJ = $(addprefix $(OBJ_DIR), $(MALLOC_SRC:.c=.o))
all: $(NAME)
$(NAME): $(OBJ_DIR) $(OBJ) $(LIB_NAME)
$(CC) -shared -flat_namespace -o $(NAME) $(OBJ) $(LIB_DIR)/$(LIB_NAME) $(HEADERS)
@ if ! [ -f libft_malloc.so ] ; then \
/bin/ln -s $(NAME) libft_malloc.so ; \
fi
$(OBJ_DIR)%.o: $(SRC_DIR)%.c includes/ft_malloc_private.h | $(OBJ_DIR)
$(CC) $(FLAGS) -fPIC -fvisibility=hidden $(HEADERS) -o $@ -c $< ;
$(LIB_NAME):
make -C $(LIB_DIR)
$(OBJ_DIR):
mkdir -p $(OBJ_DIR)
clean:
make -C libft clean
@echo "rm -rf $(OBJ_DIR)*.o"
@/bin/rm -rf $(OBJ)
/bin/rm -rf $(OBJ_DIR)
fclean: clean
make -C $(LIB_DIR) fclean
/bin/rm -f $(NAME)
/bin/rm -f $(LIB_NAME)
re: fclean $(NAME)
love:
@echo "Not all."
.PHONY: clean all fclean re love norme