-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
100 lines (72 loc) · 2.58 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#******************************************************************************#
# #
# ::: :::::::: #
# Makefile :+: :+: :+: #
# +:+ +:+ +:+ #
# By: bazaluga <bazaluga@student.42.fr> +#+ +:+ +#+ #
# +#+#+#+#+#+ +#+ #
# Created: 2023/09/05 15:24:21 by bazaluga #+# #+# #
# Updated: 2024/05/14 15:17:00 by bazaluga ### ########.fr #
# #
#******************************************************************************#
################################### VARIABLES ##################################
LIBFTDIR = ../libft
LIBFT = $(LIBFTDIR)/libft.so
LIBFTSO = obj/libft.so
LIBFTRULE = breaker
NAME = run-breaker
SRCN = src/allTests.c src/run_all.c src/CuTest.c src/utils.c
SRCS = src/staticAllTests.c src/run_all.c src/CuTest.c src/utils.c
MALLOC = src/malloc.c
LMALLOC = obj/libmalloc.so
CC = cc
CFLAGS = -Wall -Wextra -Werror -g
ifeq ($(shell uname), Darwin)
MACOS = 1
LIBINCLUDES = -Lobj -lmalloc
LIBFLAGS = -dynamiclib
else
LIBINCLUDES = $(LMALLOC) -lbsd
LIBFLAGS = -shared -nostartfiles -fPIC -ldl
endif
ANSI_COLOR_RED = "\033[31m"
ANSI_COLOR_GREEN = "\033[32m"
ANSI_COLOR_RESET = "\033[0m"
##################################### RULES #####################################
all: $(NAME)
$(NAME): $(LMALLOC) $(LIBFTSO) $(SRCN)
$(CC) $(CFLAGS) -o $@ $(SRCN) $(LIBINCLUDES)
static: $(LMALLOC) $(LIBFTSO) $(SRCS)
$(CC) $(CFLAGS) -o $(NAME) $(SRCS) $(LIBINCLUDES)
run: $(NAME)
./$(NAME) $(filter-out $@, $(MAKECMDGOALS))
srun: static
./$(NAME) $(filter-out $@, $(MAKECMDGOALS))
$(LMALLOC): $(MALLOC)
mkdir -p obj
$(CC) $(LIBFLAGS) -o $@ $<
ifdef MACOS
$(LIBFTSO): $(LIBFTDIR)
rm -rf libft/*
mkdir -p libft
cp $(LIBFTDIR)/* ./libft
make -C libft/ $(LIBFTRULE)
mv libft/libft.so $(LIBFTSO)
else
$(LIBFTSO): $(LIBFTDIR)
make -C $(LIBFTDIR) $(LIBFTRULE)
cp $(LIBFT) $(LIBFTSO)
endif
$(LIBFTDIR):
@echo $(ANSI_COLOR_RED)\
PLEASE PROVIDE THE CORRECT PATH TO YOUR LIBFT\
$(ANSI_COLOR_RESET)
@false
%:
@true
clean:
rm -f $(NAME) $(SRCN:.c=.o) $(SRCS:.c=.o)
fclean: clean
rm -rf obj libft
re: fclean all
.PHONY: all clean force fclean static run srun $(LIBFTSO)