-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
64 lines (50 loc) · 1.9 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
# **************************************************************************** #
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: vsokolog <[email protected]> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2021/03/25 18:38:50 by vsokolog #+# #+# #
# Updated: 2021/07/08 17:19:05 by vsokolog ### ########.fr #
# #
# **************************************************************************** #
INCL = -I inc
DEPS = inc/malloc.h
SRCDIR = src
OBJDIR = obj
SRC = malloc.c realloc.c free.c utils.c tinysmall.c large.c
OBJ = $(addprefix $(OBJDIR)/, $(SRC:.c=.o))
ifeq ($(HOSTTYPE),)
HOSTTYPE := $(shell uname -m)_$(shell uname -s)
endif
PREFIX = libft_malloc
NAME = $(PREFIX)_$(HOSTTYPE).so
CC = gcc
CFLAGS = -Wall -Wextra -Werror -fPIC
LDFLAGS = -shared
RED = "\033[0;31m"
YELLOW = "\033[33m"
GREEN = "\033[0;32m"
NOCOLOR = "\033[0m"
all: $(NAME)
$(NAME): $(DEPS) $(OBJ)
@$(CC) $(LDFLAGS) $(INCL) -o $@ $(OBJ) -install_name $(abspath $(NAME))
@ln -sf $(NAME) $(PREFIX).so
@echo ${GREEN}$(NAME) has compiled successfully!${NOCOLOR}
$(OBJDIR)/%.o: $(SRCDIR)/%.c $(DEPS) $(LIBFT)
@echo ${YELLOW}Compiling $<${NOCOLOR}
@mkdir -p $(OBJDIR)
@$(CC) $(CFLAGS) $(INCL) -c -o $@ $<
clean:
@echo ${YELLOW}Cleaning $(OBJDIR)/*.o ${NOCOLOR}
@rm -rf $(OBJDIR)
@make clean -C test
fclean: clean
@echo ${YELLOW}Cleaning *.so $(NAME) ${NOCOLOR}
@rm -f *.so
@rm -f $(NAME)
re: fclean all
test: all
@make -C test
.PHONY: all clean fclean re test