-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMakefile
76 lines (59 loc) · 2.65 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: jterrazz <jterrazz@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2019/04/23 18:00:29 by jterrazz #+# #+# #
# Updated: 2019/07/21 15:12:52 by jterrazz ### ########.fr #
# #
# **************************************************************************** #
ifeq ($(HOSTTYPE),)
HOSTTYPE := $(shell uname -m)_$(shell uname -s)
endif
# **************************************************************************** #
# FILES #
# **************************************************************************** #
PATH_INC = inc
PATH_LIB = lib
PATH_OBJ = obj
PATH_SRC = src
SOURCES += shared/block_merge.c shared/block_setup.c shared/heap.c \
shared/helper.c shared/shared.c shared/fill.c shared/getenv.c \
shared/block_get.c shared/block_remove.c shared/heap_get.c shared/ptr.c
SOURCES += log/show_alloc_mem_ex.c log/show_alloc_mem.c log/show_heap.c \
log/call.c
SOURCES += libc/ft_itoa_base.c libc/ft_bzero.c libc/ft_putstr.c \
libc/ft_memcpy.c libc/ft_memmove.c libc/ft_memset.c libc/ft_putstr_fd.c \
libc/ft_putchar_fd.c
SOURCES += calloc.c free.c malloc.c realloc.c
OBJECTS = $(SOURCES:%.c=$(PATH_OBJ)/%.o)
# **************************************************************************** #
# VARIABLES #
# **************************************************************************** #
NAME = libft_malloc_$(HOSTTYPE).so
LIB_NAME = libft_malloc.so
CC = gcc
FLAGS_CC = -Wall -Wextra -Werror -fPIC
FLAGS_LIB = -shared
# **************************************************************************** #
# COMMANDS #
# **************************************************************************** #
.PHONY: all clean fclean re
all: $(NAME)
$(NAME): $(OBJECTS)
$(CC) $(FLAGS_LIB) -o $@ $(OBJECTS)
@rm -f $(LIB_NAME)
ln -s $(NAME) $(LIB_NAME)
@echo "Make done"
$(PATH_OBJ)/%.o: $(PATH_SRC)/%.c
@mkdir -p $(@D)
$(CC) -c -o $@ $(FLAGS_CC) $^ -O0 -g -I $(PATH_INC)
clean:
@rm -rf $(PATH_OBJ)
@echo "Clean done"
fclean: clean
@rm -f $(NAME) $(LIB_NAME)
@echo "Fclean done"
re: fclean $(NAME)