summaryrefslogtreecommitdiff
path: root/Makefile.am
blob: 04d7719bb97d75e85b5b7ca5a3ee2427dbd1edc0 (plain)
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# Copyright (c) 2013, Linaro Limited
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#     * Redistributions of source code must retain the above copyright
#       notice, this list of conditions and the following disclaimer.
#     * Redistributions in binary form must reproduce the above copyright
#       notice, this list of conditions and the following disclaimer in the
#       documentation and/or other materials provided with the distribution.
#     * Neither the name of the Linaro nor the
#       names of its contributors may be used to endorse or promote products
#       derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#

# Top level Makefile for cortex-malloc

# The main library
lib_LTLIBRARIES = \
	libcortex-malloc.la \
	tools/mtrace_logger/libmtrace.la

## Test suite
check_PROGRAMS = \
	tests/tst-calloc \
	tests/tst-malloc \
	tests/tst-mallocfork \
	tests/tst-mallocstate \
	tests/tst-malloc-usable \
	tests/tst-realloc \
	tests/tst-trim1 \
	tests/tst-valloc

# Options for the tests
tests_cflags = -I$(srcdir)/tests $(AM_CFLAGS) -D_GNU_SOURCE
tests_ldadd = libcortex-malloc.la
tests_tst_calloc_LDADD = $(tests_ldadd)
tests_tst_calloc_CFLAGS = $(tests_cflags)
tests_tst_malloc_LDADD = $(tests_ldadd)
tests_tst_malloc_CFLAGS = $(tests_cflags)
tests_tst_mallocfork_LDADD = $(tests_ldadd)
tests_tst_mallocfork_CFLAGS = $(tests_cflags)
tests_tst_mallocstate_LDADD = $(tests_ldadd)
tests_tst_mallocstate_CFLAGS = $(tests_cflags)
tests_tst_malloc_usable_LDADD = $(tests_ldadd)
tests_tst_malloc_usable_CFLAGS = $(tests_cflags)
tests_tst_realloc_LDADD = $(tests_ldadd)
tests_tst_realloc_CFLAGS = $(tests_cflags)
tests_tst_trim1_LDADD = $(tests_ldadd)
tests_tst_trim1_CFLAGS = $(tests_cflags)
tests_tst_valloc_LDADD = $(tests_ldadd)
tests_tst_valloc_CFLAGS = $(tests_cflags)

TESTS = $(check_PROGRAMS)

libmallocbench_a_SOURCES = \
	benchmarks/mallocbench.c

libglibc_a_SOURCES = \
	reference/glibc/malloc.c \
	reference/glibc/morecore.c \
	reference/glibc/malloc.h

libglibc_a_CFLAGS = \
	-Wall -std=gnu99 -D_GNU_SOURCE -DPER_THREAD \
	-Ireference/glibc/include \
	-Ireference/glibc

libjemalloc_a_SOURCES = \
	reference/jemalloc/arena.c \
	reference/jemalloc/atomic.c \
	reference/jemalloc/base.c \
	reference/jemalloc/bitmap.c \
	reference/jemalloc/chunk.c \
	reference/jemalloc/chunk_dss.c \
	reference/jemalloc/chunk_mmap.c \
	reference/jemalloc/ckh.c \
	reference/jemalloc/ctl.c \
	reference/jemalloc/extent.c \
	reference/jemalloc/hash.c \
	reference/jemalloc/huge.c \
	reference/jemalloc/jemalloc.c \
	reference/jemalloc/mb.c \
	reference/jemalloc/mutex.c \
	reference/jemalloc/prof.c \
	reference/jemalloc/quarantine.c \
	reference/jemalloc/rtree.c \
	reference/jemalloc/stats.c \
	reference/jemalloc/tcache.c \
	reference/jemalloc/tsd.c \
	reference/jemalloc/util.c

libjemalloc_a_CFLAGS = \
	-std=gnu99 -Wall -O3 -funroll-loops -D_GNU_SOURCE -D_REENTRANT \
	-Ireference/jemalloc/include

libtcmalloc_a_SOURCES = \
	reference/tcmalloc/tcmalloc.cc \
	reference/tcmalloc/common.cc \
	reference/tcmalloc/internal_logging.cc \
	reference/tcmalloc/system-alloc.cc \
	reference/tcmalloc/memfs_malloc.cc \
	reference/tcmalloc/central_freelist.cc \
	reference/tcmalloc/page_heap.cc \
	reference/tcmalloc/sampler.cc \
	reference/tcmalloc/span.cc \
	reference/tcmalloc/stack_trace_table.cc \
	reference/tcmalloc/static_vars.cc \
	reference/tcmalloc/symbolize.cc \
	reference/tcmalloc/thread_cache.cc \
	reference/tcmalloc/malloc_hook.cc \
	reference/tcmalloc/malloc_extension.cc \
	reference/tcmalloc/maybe_threads.cc \
	reference/tcmalloc/base/spinlock.cc \
	reference/tcmalloc/base/spinlock_internal.cc \
	reference/tcmalloc/base/atomicops-internals-x86.cc \
	reference/tcmalloc/base/logging.cc \
	reference/tcmalloc/base/dynamic_annotations.c \
	reference/tcmalloc/base/sysinfo.cc

libtcmalloc_a_CXXFLAGS = \
	-Ireference/tcmalloc -Ireference/tcmalloc/spinlock \
	-Ireference/tcmalloc/logging -Ireference/tcmalloc/sysinfo \
	-DNO_TCMALLOC_SAMPLES -DNO_HEAP_CHECK -DNDEBUG \
	-DPERFTOOLS_DLL_DECL="" -DSTL_NAMESPACE="std" \
	-DPRIuS="\"zu\"" -DPRIxS="\"zx\"" -DPRIdS="\"zd\"" \
	-Wall -Wwrite-strings -Woverloaded-virtual \
	-Wno-sign-compare \
	-fno-exceptions \
	-fno-builtin-malloc -fno-builtin-free -fno-builtin-realloc \
	-fno-builtin-calloc -fno-builtin-cfree \
	-fno-builtin-memalign -fno-builtin-posix_memalign \
	-fno-builtin-valloc -fno-builtin-pvalloc

libtcmalloc_a_CFLAGS = $(libtcmalloc_a_CXXFLAGS)

try_none_SOURCES =
try_none_LDADD = libmallocbench.a -lrt -lpthread
try_this_SOURCES =
try_this_LDADD = libmallocbench.a libcortex-malloc.la -lrt -lpthread
try_glibc_SOURCES =
try_glibc_LDADD = libmallocbench.a libglibc.a -lrt -lpthread
try_jemalloc_SOURCES =
try_jemalloc_LDADD = libmallocbench.a libjemalloc.a -lrt -lpthread
try_tcmalloc_SOURCES =
try_tcmalloc_LDADD = libmallocbench.a libtcmalloc.a -lrt -lpthread
try_tcmalloc_LINK = $(CXXLINK)

if HOST_X86_64
libssmalloc_a_SOURCES = \
	reference/ssmalloc/ssmalloc.c

libssmalloc_a_CFLAGS = \
	-O3 -Wstrict-prototypes -fomit-frame-pointer -g -Wall \
	-Ireference/ssmalloc/include-x86_64

try_ssmalloc_SOURCES =
try_ssmalloc_LDADD = libmallocbench.a libssmalloc.a -lrt -lpthread

x86_64_programs = try-ssmalloc
x86_64_libraries = libssmalloc.a
endif

tools_mtrace_logger_libmtrace_la_SOURCES = \
	tools/mtrace_logger/mtrace.c

## Benchmarks
noinst_PROGRAMS = \
	try-none \
	try-this \
	try-glibc \
	try-jemalloc \
	try-tcmalloc \
	$(x86_64_programs)

# Benchmark harness
noinst_LIBRARIES = \
	libmallocbench.a \
	libglibc.a \
	libjemalloc.a \
	libtcmalloc.a \
	$(x86_64_libraries)

# Main library
libcortex_malloc_la_SOURCES = \
	src/malloc.c

libcortex_malloc_la_LDFLAGS = -version-info 1:0:0 -lpthread

AM_CFLAGS = \
	-std=gnu99 -Wall -Wextra \
	-fno-builtin -fno-stack-protector -U_FORTIFY_SOURCE \
	$(AM_CPPFLAGS)

EXTRA_DIST = \
	tests/test-skeleton.c \
	autogen.sh