Makefile 2.44 KB
Newer Older
1
2
3
4
.PHONY: all clean bench

.DEFAULT_GOAL = all

5
SRCDIR=benchmarks
6
7
BENCH_C_SOURCES = $(shell find $(SRCDIR) -name "*.c")
BENCH_CC_SOURCES = $(shell find $(SRCDIR) -name "*.cc")
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22

OBJDIR = ./build

CC = gcc
CXX = g++

WARNFLAGS = -Wall -Wextra
COMMONFLAGS = -fno-builtin -fPIC -DPIC -pthread
OPTFLAGS = -O3 -DNDEBUG
#OPTFLAGS = -O0 -g3

CXXFLAGS = -std=c++11 -I. $(OPTFLAGS) $(WARNFLAGS) $(COMMONFLAGS) -fno-exceptions
CFLAGS = -I. $(OPTFLAGS) $(WARNFLAGS) $(COMMONFLAGS)
#LDFLAGS= -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-free

23
VPATH = $(sort $(dir $(BENCH_C_SOURCES) $(BENCH_CC_SOURCES)))
24

25
26
27
28
GLIBC_NOTC = $(PWD)/../glibc/glibc-install-notc/lib

BENCH_OBJECTS = $(notdir $(BENCH_CC_SOURCES:.cc=.o)) $(notdir $(BENCH_C_SOURCES:.c=.o))
BENCH_OBJPRE = $(addprefix $(OBJDIR)/,$(BENCH_OBJECTS))
29
30
MAKEFILE_LIST = Makefile

Florian Fischer's avatar
Florian Fischer committed
31
BENCH_TARGETS = $(BENCH_OBJPRE:.o=) $(OBJDIR)/trace_run
32

Florian Fischer's avatar
Florian Fischer committed
33
34
35
NOTC_TARGETS = $(BENCH_TARGETS:=-glibc-notc)

all: $(BENCH_TARGETS) $(NOTC_TARGETS) $(OBJDIR)/chattymalloc.so $(OBJDIR)/print_status_on_exit.so
36
37

$(OBJDIR)/print_status_on_exit.so: print_status_on_exit.c $(MAKEFILE_LIST)
38
	$(CC) -shared $(CFLAGS) -o $@ $< -ldl
39
40

$(OBJDIR)/chattymalloc.so: chattymalloc.c $(MAKEFILE_LIST)
41
	$(CC) -shared $(CFLAGS) -o $@ $< -ldl
42

Florian Fischer's avatar
Florian Fischer committed
43
44
45
46
47
48
49
50
$(OBJDIR)/trace_run: trace_run.c $(MAKEFILE_LIST)
	$(CC) -pthread $(CFLAGS) -o $@ $<

$(OBJDIR)/trace_run-glibc-notc: $(OBJDIR)/trace_run $(MAKEFILE_LIST)
	cp $< $@
	patchelf --set-interpreter $(GLIBC_NOTC)/ld-linux-x86-64.so.2 $@
	patchelf --set-rpath $(GLIBC_NOTC) $@

51
$(OBJDIR)/cache-thrash: $(OBJDIR)/cache-thrash.o
52
53
54
55
56
57
	$(CXX) -pthread -o $@ $^

$(OBJDIR)/cache-thrash-glibc-notc: $(OBJDIR)/cache-thrash
	cp $< $@
	patchelf --set-interpreter $(GLIBC_NOTC)/ld-linux-x86-64.so.2 $@
	patchelf --set-rpath $(GLIBC_NOTC) $@
58
59

$(OBJDIR)/cache-scratch: $(OBJDIR)/cache-scratch.o
60
61
62
63
64
65
	$(CXX) -pthread -o $@ $^

$(OBJDIR)/cache-scratch-glibc-notc: $(OBJDIR)/cache-scratch
	cp $< $@
	patchelf --set-interpreter $(GLIBC_NOTC)/ld-linux-x86-64.so.2 $@
	patchelf --set-rpath $(GLIBC_NOTC) $@
66
67

$(OBJDIR)/bench_loop: $(OBJDIR)/bench_loop.o
68
69
70
71
72
73
74
75
76
	$(CC) -pthread -o $@ $^

$(OBJDIR)/bench_loop-glibc-notc: $(OBJDIR)/bench_loop
	cp $< $@
	patchelf --set-interpreter $(GLIBC_NOTC)/ld-linux-x86-64.so.2 $@
	patchelf --set-rpath $(GLIBC_NOTC) $@

$(OBJDIR)/%.o : %.c $(OBJDIR) $(MAKEFILE_LIST)
	$(CC) -c $(CFLAGS) -o $@ $<
77

78
79
$(OBJDIR)/%.o : %.cc $(OBJDIR) $(MAKEFILE_LIST)
	$(CXX) -c $(CXXFLAGS) -o $@ $<
80

81
82
$(OBJDIR):
	mkdir -p $@
83
84

clean:
85
86
	rm -rf $(OBJDIR)
	rm -rf $(DEPDIR)
87