-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
49 lines (34 loc) · 994 Bytes
/
Makefile
File metadata and controls
49 lines (34 loc) · 994 Bytes
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
CC = gcc
CFLAGS = -I./include -Wall -Wextra -Wformat=2 -Wformat-overflow=2 -Wformat-truncation=2 -Werror -z noexecstack -fstack-protector-strong -std=c99
PRJ = my_secmalloc
OBJS = src/my_secmalloc.o \
src/utils/my_free.o \
src/utils/my_calloc.o \
src/utils/my_realloc.o \
src/utils/initialize.o \
src/utils/log.o
SLIB = lib${PRJ}.a
LIB = lib${PRJ}.so
all: ${LIB}
${LIB} : CFLAGS += -fpic -shared
${LIB} : ${OBJS}
${SLIB}: ${OBJS}
dynamic: CFLAGS += -DDYNAMIC
dynamic: ${LIB}
my_secmalloc_exe: src/my_secmalloc.o $(OBJS)
$(CC) $(CFLAGS) -o $@ $^
static: ${SLIB}
clean:
${RM} src/.*.swp src/*~ src/*.o test/*.o src/utils/*.o
distclean: clean
${RM} ${SLIB} ${LIB}
build_test: CFLAGS += -DTEST
build_test: ${OBJS} test/test.o
$(CC) -o test/test $^ -lcriterion -Llib
test: build_test
LD_LIBRARY_PATH=./lib valgrind test/test
.PHONY: all clean build_test dynamic test static distclean
%.so:
$(LINK.c) -shared $^ $(LDLIBS) -o $@
%.a:
${AR} ${ARFLAGS} $@ $^