-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
99 lines (69 loc) · 1.81 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
LIBFTPRINTF_DIR = ../
ERROR_LIMIT = 0
SHELL = /bin/sh
# I'm not proud of this
TESTS = $(shell for ((i=1;i<=2000;i++)); do echo "$$i "; done)
NAME = tester
LIBTEST = libtest/libtest.a
LIBFTPRINTF = ${LIBFTPRINTF_DIR}/libftprintf.a
SRC_DIR = ./src
OBJ_DIR = ./obj
SRCS_FILES = main.c \
tests.c \
get_next_line.c \
get_next_line_utils.c \
utils.c
HEADERS_FILES = helpers.h
HEADERS = ${addprefix ${SRC_DIR}/, ${HEADERS_FILES}}
SRCS = ${addprefix ${SRC_DIR}/, ${SRCS_FILES}}
OBJS_FILES = ${SRCS_FILES:.c=.o}
OBJS = ${addprefix ${OBJ_DIR}/, ${OBJS_FILES}}
CFLAGS = -Wall -Wextra -g3
PRINTF_FLAGS = ${CFLAGS} -Werror
SANITIZE = -fsanitize=address
UNAME = ${shell uname -s}
ifeq (${UNAME}, Darwin)
SRCS_FILES := ${SRCS_FILES} malloc_count.c
endif
CC = clang ${CFLAGS}
export LSAN_OPTIONS=exitcode=30
all: ${NAME}
@echo ""
nosan: SANITIZE :=
nosan: ${NAME}
@echo ""
${NAME}: ${LIBFTPRINTF} ${LIBTEST} ${HEADERS} ${OBJS}
${CC} ${SANITIZE} -L./libtest -L${LIBFTPRINTF_DIR} ${OBJS} -o ${NAME} -ltest -lftprintf -ldl
mkdir -p files
${LIBFTPRINTF}:
make -C ${LIBFTPRINTF_DIR}
${LIBTEST}:
make -C libtest CFLAGS="${CFLAGS}"
${OBJ_DIR}/%.o: ${SRC_DIR}/%.c ${HEADERS} Makefile
${CC} -DERROR_LIMIT=${ERROR_LIMIT} -DBUFFER_SIZE=32 -c $< -o $@
r: run
run:
./${NAME} 2>myleaks.txt
${TESTS}: SANITIZE := -fsanitize=address
${TESTS}: ${NAME}
./${NAME} $@ 2>myle
_bonus:
make CFLAGS="${PRINTF_FLAGS}" -C ${LIBFTPRINTF_DIR} bonus
bonus: _bonus ${NAME}
bonusnosan: SANITIZE :=
bonusnosan: _bonus ${NAME}
push:
git add -A
git commit -m "chore: automated commit"
git push
clean:
@echo cleaning...
@make -C ./libtest clean
make -C ${LIBFTPRINTF_DIR} clean
@${RM} ${OBJS}
fclean: clean
@make -C ./libtest fclean
make -C ${LIBFTPRINTF_DIR} fclean
@${RM} ${NAME}
re: fclean all
.PHONY: ${NAME} ${LIBTEST} ${LIBFTPRINTF}