forked from memkind/memkind
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
234 lines (206 loc) · 7.59 KB
/
configure.ac
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
#
# Copyright (C) 2014 - 2019 Intel Corporation.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright notice(s),
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright notice(s),
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) ``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(S) 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.
#
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.63])
AC_INIT([memkind],m4_esyscmd([tr -d '\n' < VERSION]))
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_SRCDIR([memkind.spec.mk])
AM_INIT_AUTOMAKE([-Wall -Werror foreign 1.11 silent-rules subdir-objects parallel-tests tar-pax])
AM_SILENT_RULES([yes])
# Checks for programs and libraries.
m4_ifdef([AM_PROG_AR], [AM_PROG_AR])
AC_PROG_CXX
AC_PROG_CC
AC_OPENMP
AC_CHECK_LIB(numa, numa_available, [], [AC_MSG_ERROR([libnuma is required dependency])])
AX_PTHREAD([LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS" CC="$PTHREAD_CC"],
[AC_MSG_ERROR([pthreads are required dependency])])
AM_PROG_CC_C_O
#============================tls===============================================
# Check for thread local storage support
AC_ARG_ENABLE([tls],
[AS_HELP_STRING([--enable-tls], [Enable thread-local storage (__thread keyword)])],
[if test "x$enable_tls" = "xyes" ; then
enable_tls="1"
else
enable_tls="0"
fi
],
[enable_tls="0"]
)
if test "x${enable_tls}" = "x1" ; then
AC_MSG_CHECKING([for TLS support])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
[[
__thread int x;
]], [[
x = 1234;
]])],
AC_MSG_RESULT([yes]),
AC_MSG_RESULT([no])
enable_tls="0")
fi
if test "x${enable_tls}" = "x1" ; then
AC_DEFINE([MEMKIND_TLS], [ ], [Enables TLS usage for mapping arenas to threads])
fi
AC_SUBST([enable_tls])
#============================decorators========================================
AC_ARG_ENABLE([decorators],
[AS_HELP_STRING([--enable-decorators], [Enable decorators])],
[if test "x$enable_decorators" = "xyes" ; then
enable_decorators="1"
else
enable_decorators="0"
fi
],
[enable_decorators="0"]
)
if test "x${enable_decorators}" = "x1" ; then
AC_DEFINE([MEMKIND_DECORATION_ENABLED], [ ], [Enables decorators])
fi
AC_SUBST([enable_decorators])
#============================debug=============================================
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug], [Build debugging code and compile with -O0 -g])],
[if test "x$enable_debug" = "xno" ; then
enable_debug="0"
else
enable_debug="1"
fi
],
[enable_debug="0"]
)
if test "x$enable_debug" = "x1" ; then
AC_DEFINE([MEMKIND_DEBUG], [ ], [Enables code for debugging])
CFLAGS="$CFLAGS -O0 -g"
CXXFLAGS="$CXXFLAGS -O0 -g"
fi
AC_SUBST([enable_debug])
#============================gcov==============================================
AC_ARG_ENABLE([gcov],
[AS_HELP_STRING([--enable-gcov], [Build code with gcov instructions])],
[if test "x$enable_gcov" = "xno" ; then
enable_gcov="0"
else
enable_gcov="1"
fi
],
[enable_gcov="0"]
)
if test "x$enable_gcov" = "x1" ; then
CFLAGS="$CFLAGS -O0 -fprofile-arcs -ftest-coverage"
CXXFLAGS="$CXXFLAGS -O0 -fprofile-arcs -ftest-coverage"
fi
AC_SUBST([enable_gcov])
#============================secure_flags======================================
AC_ARG_ENABLE([secure],
[AS_HELP_STRING([--enable-secure], [Build library with security enchantments])],
[if test "x$enable_secure" = "xno" ; then
enable_secure="0"
else
enable_secure="1"
fi
],
[enable_secure="1"]
)
if test "x$enable_secure" = "x1" ; then
CFLAGS="$CFLAGS -fstack-protector"
LDFLAGS="$LDFLAGS -Wl,-z,relro,-z,now"
if test "$CFLAGS" != "${CFLAGS%-O0*}" ; then # if CFLAGS contains -O0
echo "WARNING: Could not apply FORTIFY_SOURCE=2 due to lack of optimization (-O0)"
else
CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2" #FORTITFY_SOURCE does not work with -O0 (ex. if enable_debug=1 or enable_gcov=1)
fi
fi
AC_SUBST([enable_secure])
#============================tcache_max_size_class======================
tcache_max_size_class=12;
AC_DEFINE_UNQUOTED([JEMALLOC_TCACHE_CLASS], $tcache_max_size_class,
[Maximum size class (log base 2) to cache in jemalloc tcache])
AC_SUBST(tcache_max_size_class)
#============================auto_arenas================================
auto_arenas=256;
AC_DEFINE_UNQUOTED([ARENA_LIMIT_DEFAULT_KIND], $auto_arenas,
[Maximum number of automatic managed arenas by jemalloc (used by MEMKIND_DEFAULT)])
AC_SUBST(auto_arenas)
#============================arena_limit=======================================
arena_limit=256;
AC_ARG_VAR(ARENA_LIMIT,
[Upper bound for number of arenas per kind, if set to 0 then no limit]
)
if test "$ARENA_LIMIT" != "" ; then
arena_limit=$ARENA_LIMIT;
fi
AC_DEFINE_UNQUOTED([ARENA_LIMIT_PER_KIND], $arena_limit, [Upper bound for number of arenas per kind])
#============================memkind_prefix=======================================
memkind_prefix=jemk_;
AC_ARG_VAR(MEMKIND_PREFIX,
[Prefix used for all jemalloc public API under memkind, default value jemk_]
)
if test "$MEMKIND_PREFIX" != "" ; then
memkind_prefix=$MEMKIND_PREFIX;
fi
AC_SUBST(memkind_prefix)
#===============================daxctl=========================================
AC_ARG_ENABLE([daxctl],
[AS_HELP_STRING([--enable-daxctl], [Build library with daxctl support])],
[if test "x$enable_daxctl" = "xno" ; then
enable_daxctl="0"
else
enable_daxctl="1"
fi
],
[enable_daxctl="1"]
)
if test "x$enable_daxctl" = "x1" ; then
AC_CHECK_LIB(daxctl, daxctl_dev_get_memory, [daxctl_kmem=yes], [daxctl_kmem=no])
fi
if test $daxctl_kmem = "yes" ; then
AC_DEFINE([MEMKIND_DAXCTL_KMEM], [1], [Automatic recognition of PMEM as system memory in MEMKIND_DAX_KMEM])
AC_SUBST(DAXCTL_LIBS, [-ldaxctl])
LDFLAGS="$LDFLAGS -ldaxctl"
fi
AC_SUBST([enable_daxctl])
#============================cxx11=============================================
AX_CXX_COMPILE_STDCXX_11([noext], [optional])
AM_CONDITIONAL([HAVE_CXX11], [test "x$HAVE_CXX11" = x1])
LT_PREREQ([2.2])
LT_INIT
AC_CONFIG_FILES([Makefile memkind.pc])
AC_OUTPUT
AC_MSG_RESULT([=================================================================================])
AC_MSG_RESULT([
Memkind version $VERSION])
if test $daxctl_kmem = "yes" ; then
AC_MSG_RESULT([
Automatic recognition of PMEM NUMA in MEMKIND_DAX_KMEM is enabled])
else
AC_MSG_RESULT([
Automatic recognition of PMEM NUMA in MEMKIND_DAX_KMEM is disabled
To enable this feature please install libdaxctl-devel v66 or later
and run configure again])
fi
AC_MSG_RESULT([=================================================================================])