summaryrefslogtreecommitdiff
path: root/Makefile.am
blob: 4137d9e7cc0c08b525670e0b4a7943020e1af3e5 (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
# 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

## 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

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

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

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

# Benchmark harness
noinst_LIBRARIES = \
	libmallocbench.a \
	libglibc.a \
	libjemalloc.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