-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
67 lines (51 loc) · 1.77 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: gpoblon <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2017/12/02 15:03:29 by aditsch #+# #+# #
# Updated: 2018/02/08 22:02:18 by gpoblon ### ########.fr #
# #
# **************************************************************************** #
ifeq ($(HOSTTYPE),)
HOSTTYPE := $(shell uname -m)_$(shell uname -s)
endif
NAME = libft_malloc.so
NAME_LINK = libft_malloc_$(HOSTTYPE).so
SRCS = thread_safe.c \
malloc.c \
free.c \
realloc.c \
maps.c \
blocks.c \
utils.c \
show_alloc_mem.c \
show_alloc_mem_full.c \
show_alloc_mem_hex.c \
reallocf.c \
calloc.c \
INC_D = includes/
SRC_D = srcs/
OBJ_D = objs/
OBJS = $(addprefix $(OBJ_D), $(SRCS:.c=.o))
CC = gcc
CFLAGS = -Wextra -Wall -fpic -I $(INC_D)
.PHONY: all, clean, fclean, re
all: $(NAME)
$(NAME): $(NAME_LINK)
rm $(NAME) 2> /dev/null || true
ln -s $(NAME_LINK) $(NAME)
$(NAME_LINK): $(OBJ_D) $(OBJS)
$(CC) -shared $(CFLAGS) -o $(NAME_LINK) $(OBJS)
$(OBJ_D)%.o: $(SRC_D)%.c $(INC_D)/malloc.h
$(CC) -c $< -o $@ $(CFLAGS)
$(OBJ_D):
mkdir -p $(OBJ_D)
mkdir -p $(dir $(OBJ_D))
clean:
rm -rf $(OBJ_D)
fclean: clean
rm -fv $(NAME) $(NAME_LINK)
re: fclean all