generated from nd-cse-30341-fa20/cse-30341-fa20-project03
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
56 lines (45 loc) · 1.41 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
CC= gcc
CFLAGS= -g -std=gnu99 -Wall -Iinclude
LDFLAGS=
LIBRARIES= lib/libmalloc-ff.so \
lib/libmalloc-bf.so \
lib/libmalloc-wf.so
HEADERS= $(wildcard include/malloc/*.h)
SOURCES= $(wildcard src/*.c)
TESTS= $(patsubst tests/%,bin/%,$(patsubst %.c,%,$(wildcard tests/*.c)))
all: $(LIBRARIES) $(TESTS)
lib/libmalloc-ff.so: $(SOURCES) $(HEADERS)
@echo "Building $@"
@$(CC) -shared -fPIC $(CFLAGS) -DFIT=0 -o $@ $(SOURCES) $(LDFLAGS)
lib/libmalloc-wf.so: $(SOURCES) $(HEADERS)
@echo "Building $@"
@$(CC) -shared -fPIC $(CFLAGS) -DFIT=1 -o $@ $(SOURCES) $(LDFLAGS)
lib/libmalloc-bf.so: $(SOURCES) $(HEADERS)
@echo "Building $@"
@$(CC) -shared -fPIC $(CFLAGS) -DFIT=2 -o $@ $(SOURCES) $(LDFLAGS)
bin/test_%: tests/test_%.c
@echo "Building $@"
@$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
bin/unit_%: tests/unit_%.c src/counters.c src/block.c src/freelist.c
@echo "Building $@"
@$(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
tests: $(LIBRARIES) $(TESTS)
test: tests
@for test in bin/unit_*; do \
for i in $$(seq 0 $$($$test 2>&1 | tail -n 1 | awk '{print $$1}')); do \
echo "Running $$(basename $$test) $$i"; \
$$test $$i; \
done \
done
@echo
@for test in bin/run_test_*.sh; do \
echo "Running $$(basename $$test)"; \
$$test; \
echo ""; \
done
clean:
@echo "Removing libraries"
@rm -f $(LIBRARIES)
@echo "Removing tests"
@rm -f $(TESTS) test.log
.PHONY: all clean