blob: 6f44b6c3f7f801fbda45e2956b34a4ef8df4463e [file] [log] [blame]
Jason Evansb7924f52009-06-23 19:01:18 -07001dnl Process this file with autoconf to produce a configure script.
2AC_INIT([Makefile.in])
3
Jason Evansf3340ca2009-06-30 16:17:05 -07004dnl ============================================================================
5dnl Custom macro definitions.
6
7dnl JE_CFLAGS_APPEND(cflag)
8AC_DEFUN([JE_CFLAGS_APPEND],
9[
10AC_MSG_CHECKING([whether compiler supports $1])
11TCFLAGS="${CFLAGS}"
12if test "x${CFLAGS}" = "x" ; then
13 CFLAGS="$1"
14else
15 CFLAGS="${CFLAGS} $1"
16fi
Jason Evans6684cac2012-03-05 12:15:36 -080017AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Jason Evansf3340ca2009-06-30 16:17:05 -070018[[
19]], [[
20 return 0;
21]])],
Jason Evans99b0fbb2014-02-24 16:08:38 -080022 [je_cv_cflags_appended=$1]
Jason Evansf3340ca2009-06-30 16:17:05 -070023 AC_MSG_RESULT([yes]),
Jason Evans99b0fbb2014-02-24 16:08:38 -080024 [je_cv_cflags_appended=]
Jason Evansf3340ca2009-06-30 16:17:05 -070025 AC_MSG_RESULT([no])
26 [CFLAGS="${TCFLAGS}"]
27)
28])
29
30dnl JE_COMPILABLE(label, hcode, mcode, rvar)
Jason Evans4c2faa82012-03-13 11:09:23 -070031dnl
Jason Evansf3e139a2012-03-19 09:54:20 -070032dnl Use AC_LINK_IFELSE() rather than AC_COMPILE_IFELSE() so that linker errors
Jason Evans4c2faa82012-03-13 11:09:23 -070033dnl cause failure.
Jason Evansf3340ca2009-06-30 16:17:05 -070034AC_DEFUN([JE_COMPILABLE],
35[
Jason Evans6684cac2012-03-05 12:15:36 -080036AC_CACHE_CHECK([whether $1 is compilable],
37 [$4],
Jason Evansf3e139a2012-03-19 09:54:20 -070038 [AC_LINK_IFELSE([AC_LANG_PROGRAM([$2],
39 [$3])],
40 [$4=yes],
41 [$4=no])])
Jason Evansf3340ca2009-06-30 16:17:05 -070042])
43
44dnl ============================================================================
45
Jason Evans41f2e692015-01-25 20:15:13 -080046CONFIG=`echo ${ac_configure_args} | sed -e 's#'"'"'\([^ ]*\)'"'"'#\1#g'`
Jason Evansbec6a8d2015-01-22 17:55:58 -080047AC_SUBST([CONFIG])
48
Jason Evansf576c632011-11-01 22:27:41 -070049dnl Library revision.
Jason Evans9790b962014-04-14 22:32:31 -070050rev=2
Jason Evansf576c632011-11-01 22:27:41 -070051AC_SUBST([rev])
52
Jason Evansb7924f52009-06-23 19:01:18 -070053srcroot=$srcdir
54if test "x${srcroot}" = "x." ; then
55 srcroot=""
56else
57 srcroot="${srcroot}/"
58fi
59AC_SUBST([srcroot])
60abs_srcroot="`cd \"${srcdir}\"; pwd`/"
61AC_SUBST([abs_srcroot])
62
63objroot=""
64AC_SUBST([objroot])
65abs_objroot="`pwd`/"
66AC_SUBST([abs_objroot])
67
68dnl Munge install path variables.
69if test "x$prefix" = "xNONE" ; then
70 prefix="/usr/local"
71fi
72if test "x$exec_prefix" = "xNONE" ; then
73 exec_prefix=$prefix
74fi
75PREFIX=$prefix
76AC_SUBST([PREFIX])
77BINDIR=`eval echo $bindir`
78BINDIR=`eval echo $BINDIR`
79AC_SUBST([BINDIR])
80INCLUDEDIR=`eval echo $includedir`
81INCLUDEDIR=`eval echo $INCLUDEDIR`
82AC_SUBST([INCLUDEDIR])
83LIBDIR=`eval echo $libdir`
84LIBDIR=`eval echo $LIBDIR`
85AC_SUBST([LIBDIR])
86DATADIR=`eval echo $datadir`
87DATADIR=`eval echo $DATADIR`
88AC_SUBST([DATADIR])
89MANDIR=`eval echo $mandir`
90MANDIR=`eval echo $MANDIR`
91AC_SUBST([MANDIR])
92
Jason Evansaee7fd22010-11-24 22:00:02 -080093dnl Support for building documentation.
Jason Evans7329a4f2013-01-22 10:53:29 -080094AC_PATH_PROG([XSLTPROC], [xsltproc], [false], [$PATH])
Jason Evans7091b412012-03-19 09:36:44 -070095if test -d "/usr/share/xml/docbook/stylesheet/docbook-xsl" ; then
96 DEFAULT_XSLROOT="/usr/share/xml/docbook/stylesheet/docbook-xsl"
97elif test -d "/usr/share/sgml/docbook/xsl-stylesheets" ; then
98 DEFAULT_XSLROOT="/usr/share/sgml/docbook/xsl-stylesheets"
99else
100 dnl Documentation building will fail if this default gets used.
101 DEFAULT_XSLROOT=""
102fi
Jason Evansaee7fd22010-11-24 22:00:02 -0800103AC_ARG_WITH([xslroot],
Jason Evans7091b412012-03-19 09:36:44 -0700104 [AS_HELP_STRING([--with-xslroot=<path>], [XSL stylesheet root path])], [
Jason Evansaee7fd22010-11-24 22:00:02 -0800105if test "x$with_xslroot" = "xno" ; then
Jason Evans7091b412012-03-19 09:36:44 -0700106 XSLROOT="${DEFAULT_XSLROOT}"
Jason Evansaee7fd22010-11-24 22:00:02 -0800107else
108 XSLROOT="${with_xslroot}"
Jason Evans7091b412012-03-19 09:36:44 -0700109fi
110],
111 XSLROOT="${DEFAULT_XSLROOT}"
Jason Evansaee7fd22010-11-24 22:00:02 -0800112)
113AC_SUBST([XSLROOT])
114
Jason Evansf3340ca2009-06-30 16:17:05 -0700115dnl If CFLAGS isn't defined, set CFLAGS to something reasonable. Otherwise,
116dnl just prevent autoconf from molesting CFLAGS.
Jason Evansb7924f52009-06-23 19:01:18 -0700117CFLAGS=$CFLAGS
118AC_PROG_CC
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200119if test "x$GCC" != "xyes" ; then
120 AC_CACHE_CHECK([whether compiler is MSVC],
121 [je_cv_msvc],
122 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
123 [
124#ifndef _MSC_VER
125 int fail[-1];
126#endif
127])],
128 [je_cv_msvc=yes],
129 [je_cv_msvc=no])])
130fi
131
Jason Evansb7924f52009-06-23 19:01:18 -0700132if test "x$CFLAGS" = "x" ; then
133 no_CFLAGS="yes"
Jason Evanscfeccd32010-03-03 15:48:20 -0800134 if test "x$GCC" = "xyes" ; then
135 JE_CFLAGS_APPEND([-std=gnu99])
Jason Evans99b0fbb2014-02-24 16:08:38 -0800136 if test "x$je_cv_cflags_appended" = "x-std=gnu99" ; then
137 AC_DEFINE_UNQUOTED([JEMALLOC_HAS_RESTRICT])
138 fi
Jason Evanscfeccd32010-03-03 15:48:20 -0800139 JE_CFLAGS_APPEND([-Wall])
Mike Hommeyb7b44df2014-12-18 15:12:53 +0900140 JE_CFLAGS_APPEND([-Werror=declaration-after-statement])
Jason Evanscfeccd32010-03-03 15:48:20 -0800141 JE_CFLAGS_APPEND([-pipe])
142 JE_CFLAGS_APPEND([-g3])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200143 elif test "x$je_cv_msvc" = "xyes" ; then
144 CC="$CC -nologo"
145 JE_CFLAGS_APPEND([-Zi])
146 JE_CFLAGS_APPEND([-MT])
147 JE_CFLAGS_APPEND([-W3])
Mike Hommey8c615752014-05-29 16:58:21 +0900148 JE_CFLAGS_APPEND([-FS])
Mike Hommey6f6704c2014-05-29 17:01:10 +0900149 CPPFLAGS="$CPPFLAGS -I${srcdir}/include/msvc_compat"
Jason Evanscfeccd32010-03-03 15:48:20 -0800150 fi
Jason Evansb7924f52009-06-23 19:01:18 -0700151fi
152dnl Append EXTRA_CFLAGS to CFLAGS, if defined.
153if test "x$EXTRA_CFLAGS" != "x" ; then
Jason Evansf3340ca2009-06-30 16:17:05 -0700154 JE_CFLAGS_APPEND([$EXTRA_CFLAGS])
Jason Evansb7924f52009-06-23 19:01:18 -0700155fi
156AC_PROG_CPP
157
Jason Evansdf3f2702014-03-30 16:27:08 -0700158AC_C_BIGENDIAN([ac_cv_big_endian=1], [ac_cv_big_endian=0])
159if test "x${ac_cv_big_endian}" = "x1" ; then
160 AC_DEFINE_UNQUOTED([JEMALLOC_BIG_ENDIAN], [ ])
161fi
162
Mike Hommeyff2e9992014-05-29 16:33:02 +0900163if test "x${je_cv_msvc}" = "xyes" -a "x${ac_cv_header_inttypes_h}" = "xno"; then
Mike Hommey6f6704c2014-05-29 17:01:10 +0900164 CPPFLAGS="$CPPFLAGS -I${srcdir}/include/msvc_compat/C99"
Mike Hommeyff2e9992014-05-29 16:33:02 +0900165fi
166
Jason Evansb7924f52009-06-23 19:01:18 -0700167AC_CHECK_SIZEOF([void *])
168if test "x${ac_cv_sizeof_void_p}" = "x8" ; then
Jason Evans94ad2b52009-12-29 00:09:15 -0800169 LG_SIZEOF_PTR=3
Jason Evansb7924f52009-06-23 19:01:18 -0700170elif test "x${ac_cv_sizeof_void_p}" = "x4" ; then
Jason Evans94ad2b52009-12-29 00:09:15 -0800171 LG_SIZEOF_PTR=2
Jason Evansb7924f52009-06-23 19:01:18 -0700172else
173 AC_MSG_ERROR([Unsupported pointer size: ${ac_cv_sizeof_void_p}])
174fi
Jason Evans94ad2b52009-12-29 00:09:15 -0800175AC_DEFINE_UNQUOTED([LG_SIZEOF_PTR], [$LG_SIZEOF_PTR])
176
177AC_CHECK_SIZEOF([int])
178if test "x${ac_cv_sizeof_int}" = "x8" ; then
179 LG_SIZEOF_INT=3
180elif test "x${ac_cv_sizeof_int}" = "x4" ; then
181 LG_SIZEOF_INT=2
182else
183 AC_MSG_ERROR([Unsupported int size: ${ac_cv_sizeof_int}])
184fi
185AC_DEFINE_UNQUOTED([LG_SIZEOF_INT], [$LG_SIZEOF_INT])
Jason Evansb7924f52009-06-23 19:01:18 -0700186
Jason Evans84c8eef2011-03-16 10:30:13 -0700187AC_CHECK_SIZEOF([long])
188if test "x${ac_cv_sizeof_long}" = "x8" ; then
189 LG_SIZEOF_LONG=3
190elif test "x${ac_cv_sizeof_long}" = "x4" ; then
191 LG_SIZEOF_LONG=2
192else
193 AC_MSG_ERROR([Unsupported long size: ${ac_cv_sizeof_long}])
194fi
195AC_DEFINE_UNQUOTED([LG_SIZEOF_LONG], [$LG_SIZEOF_LONG])
196
Jason Evansd81e4bd2012-03-06 14:57:45 -0800197AC_CHECK_SIZEOF([intmax_t])
198if test "x${ac_cv_sizeof_intmax_t}" = "x16" ; then
199 LG_SIZEOF_INTMAX_T=4
200elif test "x${ac_cv_sizeof_intmax_t}" = "x8" ; then
201 LG_SIZEOF_INTMAX_T=3
202elif test "x${ac_cv_sizeof_intmax_t}" = "x4" ; then
203 LG_SIZEOF_INTMAX_T=2
204else
Mike Hommey14103d32012-04-20 08:38:39 +0200205 AC_MSG_ERROR([Unsupported intmax_t size: ${ac_cv_sizeof_intmax_t}])
Jason Evansd81e4bd2012-03-06 14:57:45 -0800206fi
207AC_DEFINE_UNQUOTED([LG_SIZEOF_INTMAX_T], [$LG_SIZEOF_INTMAX_T])
208
Jason Evansb7924f52009-06-23 19:01:18 -0700209AC_CANONICAL_HOST
210dnl CPU-specific settings.
211CPU_SPINWAIT=""
212case "${host_cpu}" in
Jason Evanscb657e32014-02-25 11:21:41 -0800213 i686|x86_64)
Jason Evans81e54752014-10-10 22:34:25 -0700214 AC_CACHE_VAL([je_cv_pause],
Jason Evans2eb941a2014-10-10 20:40:43 -0700215 [JE_COMPILABLE([pause instruction], [],
216 [[__asm__ volatile("pause"); return 0;]],
217 [je_cv_pause])])
Jason Evanscb657e32014-02-25 11:21:41 -0800218 if test "x${je_cv_pause}" = "xyes" ; then
Jason Evansf3340ca2009-06-30 16:17:05 -0700219 CPU_SPINWAIT='__asm__ volatile("pause")'
220 fi
Jason Evans80061b62013-12-09 13:21:08 -0800221 ;;
222 powerpc)
223 AC_DEFINE_UNQUOTED([HAVE_ALTIVEC], [ ])
Jason Evansb7924f52009-06-23 19:01:18 -0700224 ;;
225 *)
226 ;;
227esac
228AC_DEFINE_UNQUOTED([CPU_SPINWAIT], [$CPU_SPINWAIT])
229
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +0400230LD_PRELOAD_VAR="LD_PRELOAD"
Jason Evansf576c632011-11-01 22:27:41 -0700231so="so"
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200232importlib="${so}"
Mike Hommey7cdea392012-04-30 12:38:27 +0200233o="$ac_objext"
Mike Hommey5bee66d2012-04-16 16:30:24 +0200234a="a"
Mike Hommey7cdea392012-04-30 12:38:27 +0200235exe="$ac_exeext"
Mike Hommeya19e87f2012-04-21 21:27:46 -0700236libprefix="lib"
Mike Hommeyfa08da72012-04-16 16:30:25 +0200237DSO_LDFLAGS='-shared -Wl,-soname,$(@F)'
238RPATH='-Wl,-rpath,$(1)'
Mike Hommey7cdea392012-04-30 12:38:27 +0200239SOREV="${so}.${rev}"
Mike Hommey188da7c2012-04-18 18:29:41 +0200240PIC_CFLAGS='-fPIC -DPIC'
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200241CTARGET='-o $@'
242LDTARGET='-o $@'
243EXTRA_LDFLAGS=
Jason Evans80ddf492013-08-20 11:48:19 +0100244ARFLAGS='crus'
245AROUT=' $@'
Mike Hommey79c4bca2012-05-02 21:30:51 +0200246CC_MM=1
Jason Evans7372b152012-02-10 20:22:09 -0800247
Jory A. Prattad505e02013-08-11 09:44:59 -0500248AN_MAKEVAR([AR], [AC_PROG_AR])
249AN_PROGRAM([ar], [AC_PROG_AR])
250AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL(AR, ar, :)])
251AC_PROG_AR
252
Jason Evansb7924f52009-06-23 19:01:18 -0700253dnl Platform-specific settings. abi and RPATH can probably be determined
254dnl programmatically, but doing so is error-prone, which makes it generally
255dnl not worth the trouble.
256dnl
257dnl Define cpp macros in CPPFLAGS, rather than doing AC_DEFINE(macro), since the
258dnl definitions need to be seen before any headers are included, which is a pain
259dnl to make happen otherwise.
Jason Evans59ae2762012-04-16 17:52:27 -0700260default_munmap="1"
Jason Evansd059b9d2015-07-24 18:21:42 -0700261maps_coalesce="1"
Jason Evansb7924f52009-06-23 19:01:18 -0700262case "${host}" in
Valerii Hiora5921ba72014-05-16 16:28:20 +0300263 *-*-darwin* | *-*-ios*)
Mike Hommeya6770a72012-05-03 14:12:49 +0200264 CFLAGS="$CFLAGS"
Jason Evansb7924f52009-06-23 19:01:18 -0700265 abi="macho"
Jason Evanse24c7af2012-03-19 10:21:17 -0700266 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
Jason Evansb7924f52009-06-23 19:01:18 -0700267 RPATH=""
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +0400268 LD_PRELOAD_VAR="DYLD_INSERT_LIBRARIES"
Jason Evansf576c632011-11-01 22:27:41 -0700269 so="dylib"
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200270 importlib="${so}"
Jason Evansb80581d2012-03-23 16:17:43 -0700271 force_tls="0"
Jason Evansf1f2b452015-05-01 08:57:41 -0700272 DSO_LDFLAGS='-shared -Wl,-install_name,$(LIBDIR)/$(@F)'
Mike Hommey7cdea392012-04-30 12:38:27 +0200273 SOREV="${rev}.${so}"
Jason Evans66688532013-12-03 21:49:36 -0800274 sbrk_deprecated="1"
Jason Evansb7924f52009-06-23 19:01:18 -0700275 ;;
276 *-*-freebsd*)
277 CFLAGS="$CFLAGS"
278 abi="elf"
Jason Evanse24c7af2012-03-19 10:21:17 -0700279 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
Jason Evansfd4fcef2012-03-23 17:40:58 -0700280 force_lazy_lock="1"
Jason Evansb7924f52009-06-23 19:01:18 -0700281 ;;
Michael Neumann1aa25a32014-08-05 03:06:02 +0200282 *-*-dragonfly*)
283 CFLAGS="$CFLAGS"
284 abi="elf"
285 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
286 ;;
Sébastien Marieb80fbcb2015-04-07 12:21:19 +0200287 *-*-openbsd*)
288 CFLAGS="$CFLAGS"
289 abi="elf"
290 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
291 force_tls="0"
292 ;;
293 *-*-bitrig*)
Sébastien Marie77d597e2015-01-25 10:18:32 +0100294 CFLAGS="$CFLAGS"
295 abi="elf"
296 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
297 ;;
Jason Evansb7924f52009-06-23 19:01:18 -0700298 *-*-linux*)
299 CFLAGS="$CFLAGS"
300 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
301 abi="elf"
Garrett Cooper13e4e242012-12-02 17:58:40 -0800302 AC_DEFINE([JEMALLOC_HAS_ALLOCA_H])
Jason Evanse24c7af2012-03-19 10:21:17 -0700303 AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED], [ ])
Jason Evans02b23122012-04-05 11:06:23 -0700304 AC_DEFINE([JEMALLOC_THREADED_INIT], [ ])
Jason Evansae93d6b2015-07-10 14:33:00 -0700305 AC_DEFINE([JEMALLOC_USE_CXX_THROW], [ ])
Jason Evans59ae2762012-04-16 17:52:27 -0700306 default_munmap="0"
Jason Evansb7924f52009-06-23 19:01:18 -0700307 ;;
308 *-*-netbsd*)
309 AC_MSG_CHECKING([ABI])
310 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
311[[#ifdef __ELF__
312/* ELF */
313#else
314#error aout
315#endif
316]])],
317 [CFLAGS="$CFLAGS"; abi="elf"],
318 [abi="aout"])
319 AC_MSG_RESULT([$abi])
Jason Evanse24c7af2012-03-19 10:21:17 -0700320 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
Jason Evansb7924f52009-06-23 19:01:18 -0700321 ;;
322 *-*-solaris2*)
323 CFLAGS="$CFLAGS"
324 abi="elf"
George Koladdd6bd42014-02-12 23:05:45 +0000325 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
Mike Hommeyfa08da72012-04-16 16:30:25 +0200326 RPATH='-Wl,-R,$(1)'
Jason Evansb7924f52009-06-23 19:01:18 -0700327 dnl Solaris needs this for sigwait().
328 CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
329 LIBS="$LIBS -lposix4 -lsocket -lnsl"
330 ;;
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +0400331 *-ibm-aix*)
332 if "$LG_SIZEOF_PTR" = "8"; then
333 dnl 64bit AIX
334 LD_PRELOAD_VAR="LDR_PRELOAD64"
335 else
336 dnl 32bit AIX
337 LD_PRELOAD_VAR="LDR_PRELOAD"
338 fi
339 abi="xcoff"
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +0400340 ;;
Dave Rigby70bdee02014-09-22 15:53:16 +0100341 *-*-mingw* | *-*-cygwin*)
Mike Hommeya19e87f2012-04-21 21:27:46 -0700342 abi="pecoff"
343 force_tls="0"
Jason Evans13473c72015-07-23 14:08:49 -0700344 force_lazy_lock="1"
Jason Evansd059b9d2015-07-24 18:21:42 -0700345 maps_coalesce="0"
Mike Hommeya19e87f2012-04-21 21:27:46 -0700346 RPATH=""
347 so="dll"
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200348 if test "x$je_cv_msvc" = "xyes" ; then
349 importlib="lib"
350 DSO_LDFLAGS="-LD"
351 EXTRA_LDFLAGS="-link -DEBUG"
352 CTARGET='-Fo$@'
353 LDTARGET='-Fe$@'
Jory A. Prattad505e02013-08-11 09:44:59 -0500354 AR='lib'
355 ARFLAGS='-nologo -out:'
Jason Evans80ddf492013-08-20 11:48:19 +0100356 AROUT='$@'
Mike Hommey79c4bca2012-05-02 21:30:51 +0200357 CC_MM=
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200358 else
359 importlib="${so}"
360 DSO_LDFLAGS="-shared"
361 fi
Mike Hommeya19e87f2012-04-21 21:27:46 -0700362 a="lib"
363 libprefix=""
Mike Hommey7cdea392012-04-30 12:38:27 +0200364 SOREV="${so}"
Mike Hommeya19e87f2012-04-21 21:27:46 -0700365 PIC_CFLAGS=""
366 ;;
Jason Evansb7924f52009-06-23 19:01:18 -0700367 *)
368 AC_MSG_RESULT([Unsupported operating system: ${host}])
369 abi="elf"
Jason Evansb7924f52009-06-23 19:01:18 -0700370 ;;
371esac
Mike Hommeyaffe0092014-05-28 08:10:12 +0900372
373JEMALLOC_USABLE_SIZE_CONST=const
374AC_CHECK_HEADERS([malloc.h], [
375 AC_MSG_CHECKING([whether malloc_usable_size definition can use const argument])
376 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
377 [#include <malloc.h>
378 #include <stddef.h>
379 size_t malloc_usable_size(const void *ptr);
380 ],
381 [])],[
382 AC_MSG_RESULT([yes])
383 ],[
384 JEMALLOC_USABLE_SIZE_CONST=
385 AC_MSG_RESULT([no])
386 ])
387])
Jason Evans247d1242012-10-09 16:20:10 -0700388AC_DEFINE_UNQUOTED([JEMALLOC_USABLE_SIZE_CONST], [$JEMALLOC_USABLE_SIZE_CONST])
Jason Evansb7924f52009-06-23 19:01:18 -0700389AC_SUBST([abi])
390AC_SUBST([RPATH])
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +0400391AC_SUBST([LD_PRELOAD_VAR])
Jason Evansf576c632011-11-01 22:27:41 -0700392AC_SUBST([so])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200393AC_SUBST([importlib])
Mike Hommey5bee66d2012-04-16 16:30:24 +0200394AC_SUBST([o])
395AC_SUBST([a])
396AC_SUBST([exe])
Mike Hommeya19e87f2012-04-21 21:27:46 -0700397AC_SUBST([libprefix])
Mike Hommeyfa08da72012-04-16 16:30:25 +0200398AC_SUBST([DSO_LDFLAGS])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200399AC_SUBST([EXTRA_LDFLAGS])
Mike Hommey85221d52012-04-18 18:29:40 +0200400AC_SUBST([SOREV])
Mike Hommey188da7c2012-04-18 18:29:41 +0200401AC_SUBST([PIC_CFLAGS])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200402AC_SUBST([CTARGET])
403AC_SUBST([LDTARGET])
404AC_SUBST([MKLIB])
Jason Evans80ddf492013-08-20 11:48:19 +0100405AC_SUBST([ARFLAGS])
406AC_SUBST([AROUT])
Mike Hommey79c4bca2012-05-02 21:30:51 +0200407AC_SUBST([CC_MM])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200408
Jason Evansfa5d2452011-03-15 10:25:59 -0700409JE_COMPILABLE([__attribute__ syntax],
410 [static __attribute__((unused)) void foo(void){}],
411 [],
Jason Evans6684cac2012-03-05 12:15:36 -0800412 [je_cv_attribute])
413if test "x${je_cv_attribute}" = "xyes" ; then
Jason Evansfa5d2452011-03-15 10:25:59 -0700414 AC_DEFINE([JEMALLOC_HAVE_ATTR], [ ])
415 if test "x${GCC}" = "xyes" -a "x${abi}" = "xelf"; then
416 JE_CFLAGS_APPEND([-fvisibility=hidden])
417 fi
418fi
Jason Evans3cc1f1a2012-04-03 22:30:05 -0700419dnl Check for tls_model attribute support (clang 3.0 still lacks support).
420SAVED_CFLAGS="${CFLAGS}"
421JE_CFLAGS_APPEND([-Werror])
422JE_COMPILABLE([tls_model attribute], [],
423 [static __thread int
Daniel Micayf1cf3ea2014-09-16 04:42:33 -0400424 __attribute__((tls_model("initial-exec"), unused)) foo;
Jason Evans3cc1f1a2012-04-03 22:30:05 -0700425 foo = 0;],
426 [je_cv_tls_model])
427CFLAGS="${SAVED_CFLAGS}"
428if test "x${je_cv_tls_model}" = "xyes" ; then
429 AC_DEFINE([JEMALLOC_TLS_MODEL],
430 [__attribute__((tls_model("initial-exec")))])
431else
432 AC_DEFINE([JEMALLOC_TLS_MODEL], [ ])
433fi
Jason Evans0b8f0bc2015-07-10 16:41:12 -0700434dnl Check for alloc_size attribute support.
435SAVED_CFLAGS="${CFLAGS}"
436JE_CFLAGS_APPEND([-Werror])
Jason Evans92d72ee2015-07-10 16:45:32 -0700437JE_COMPILABLE([alloc_size attribute], [#include <stdlib.h>],
438 [void *foo(size_t size) __attribute__((alloc_size(1)));],
Jason Evans0b8f0bc2015-07-10 16:41:12 -0700439 [je_cv_alloc_size])
440CFLAGS="${SAVED_CFLAGS}"
441if test "x${je_cv_alloc_size}" = "xyes" ; then
442 AC_DEFINE([JEMALLOC_HAVE_ATTR_ALLOC_SIZE], [ ])
443fi
Jason Evanse42c3092015-07-22 15:44:47 -0700444dnl Check for format(gnu_printf, ...) attribute support.
445SAVED_CFLAGS="${CFLAGS}"
446JE_CFLAGS_APPEND([-Werror])
447JE_COMPILABLE([format(gnu_printf, ...) attribute], [#include <stdlib.h>],
448 [void *foo(const char *format, ...) __attribute__((format(gnu_printf, 1, 2)));],
449 [je_cv_format_gnu_printf])
450CFLAGS="${SAVED_CFLAGS}"
451if test "x${je_cv_format_gnu_printf}" = "xyes" ; then
452 AC_DEFINE([JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF], [ ])
453fi
454dnl Check for format(printf, ...) attribute support.
455SAVED_CFLAGS="${CFLAGS}"
456JE_CFLAGS_APPEND([-Werror])
457JE_COMPILABLE([format(printf, ...) attribute], [#include <stdlib.h>],
458 [void *foo(const char *format, ...) __attribute__((format(printf, 1, 2)));],
459 [je_cv_format_printf])
460CFLAGS="${SAVED_CFLAGS}"
461if test "x${je_cv_format_printf}" = "xyes" ; then
462 AC_DEFINE([JEMALLOC_HAVE_ATTR_FORMAT_PRINTF], [ ])
463fi
Jason Evansfa5d2452011-03-15 10:25:59 -0700464
Jason Evansb7924f52009-06-23 19:01:18 -0700465dnl Support optional additions to rpath.
466AC_ARG_WITH([rpath],
Jason Evans90895cf2009-12-29 00:09:15 -0800467 [AS_HELP_STRING([--with-rpath=<rpath>], [Colon-separated rpath (ELF systems only)])],
Jason Evansb7924f52009-06-23 19:01:18 -0700468if test "x$with_rpath" = "xno" ; then
469 RPATH_EXTRA=
470else
471 RPATH_EXTRA="`echo $with_rpath | tr \":\" \" \"`"
472fi,
473 RPATH_EXTRA=
474)
475AC_SUBST([RPATH_EXTRA])
476
477dnl Disable rules that do automatic regeneration of configure output by default.
478AC_ARG_ENABLE([autogen],
Jason Evans78d815c2010-01-17 14:06:20 -0800479 [AS_HELP_STRING([--enable-autogen], [Automatically regenerate configure output])],
Jason Evansb7924f52009-06-23 19:01:18 -0700480if test "x$enable_autogen" = "xno" ; then
481 enable_autogen="0"
482else
483 enable_autogen="1"
484fi
485,
486enable_autogen="0"
487)
488AC_SUBST([enable_autogen])
489
490AC_PROG_INSTALL
491AC_PROG_RANLIB
Jason Evans7329a4f2013-01-22 10:53:29 -0800492AC_PATH_PROG([LD], [ld], [false], [$PATH])
493AC_PATH_PROG([AUTOCONF], [autoconf], [false], [$PATH])
Jason Evansb7924f52009-06-23 19:01:18 -0700494
Daniel Micay4cfe5512014-08-28 15:41:48 -0400495public_syms="malloc_conf malloc_message malloc calloc posix_memalign aligned_alloc realloc free mallocx rallocx xallocx sallocx dallocx sdallocx nallocx mallctl mallctlnametomib mallctlbymib malloc_stats_print malloc_usable_size"
Jason Evans7e77eaf2012-03-02 17:47:37 -0800496
497dnl Check for allocator-related functions that should be wrapped.
498AC_CHECK_FUNC([memalign],
Jason Evanse24c7af2012-03-19 10:21:17 -0700499 [AC_DEFINE([JEMALLOC_OVERRIDE_MEMALIGN], [ ])
Jason Evans7e77eaf2012-03-02 17:47:37 -0800500 public_syms="${public_syms} memalign"])
501AC_CHECK_FUNC([valloc],
Jason Evanse24c7af2012-03-19 10:21:17 -0700502 [AC_DEFINE([JEMALLOC_OVERRIDE_VALLOC], [ ])
Jason Evans7e77eaf2012-03-02 17:47:37 -0800503 public_syms="${public_syms} valloc"])
504
Jason Evans748dfac2013-12-06 18:27:33 -0800505dnl Do not compute test code coverage by default.
506GCOV_FLAGS=
507AC_ARG_ENABLE([code-coverage],
508 [AS_HELP_STRING([--enable-code-coverage],
509 [Enable code coverage])],
510[if test "x$enable_code_coverage" = "xno" ; then
511 enable_code_coverage="0"
512else
513 enable_code_coverage="1"
514fi
515],
516[enable_code_coverage="0"]
517)
518if test "x$enable_code_coverage" = "x1" ; then
519 deoptimize="no"
520 echo "$CFLAGS $EXTRA_CFLAGS" | grep '\-O' >/dev/null || deoptimize="yes"
521 if test "x${deoptimize}" = "xyes" ; then
522 JE_CFLAGS_APPEND([-O0])
523 fi
524 JE_CFLAGS_APPEND([-fprofile-arcs -ftest-coverage])
525 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -fprofile-arcs -ftest-coverage"
526 AC_DEFINE([JEMALLOC_CODE_COVERAGE], [ ])
527fi
528AC_SUBST([enable_code_coverage])
529
Jason Evans0a5489e2012-03-01 17:19:20 -0800530dnl Perform no name mangling by default.
531AC_ARG_WITH([mangling],
532 [AS_HELP_STRING([--with-mangling=<map>], [Mangle symbols in <map>])],
533 [mangling_map="$with_mangling"], [mangling_map=""])
Jason Evans0a5489e2012-03-01 17:19:20 -0800534
Jason Evans90895cf2009-12-29 00:09:15 -0800535dnl Do not prefix public APIs by default.
536AC_ARG_WITH([jemalloc_prefix],
537 [AS_HELP_STRING([--with-jemalloc-prefix=<prefix>], [Prefix to prepend to all public APIs])],
Jason Evansb0fd5012010-01-17 01:49:20 -0800538 [JEMALLOC_PREFIX="$with_jemalloc_prefix"],
Mike Hommey7cdea392012-04-30 12:38:27 +0200539 [if test "x$abi" != "xmacho" -a "x$abi" != "xpecoff"; then
Jason Evans2dbecf12010-09-05 10:35:13 -0700540 JEMALLOC_PREFIX=""
541else
542 JEMALLOC_PREFIX="je_"
543fi]
Jason Evans90895cf2009-12-29 00:09:15 -0800544)
545if test "x$JEMALLOC_PREFIX" != "x" ; then
Jason Evanse7339702010-10-23 18:37:06 -0700546 JEMALLOC_CPREFIX=`echo ${JEMALLOC_PREFIX} | tr "a-z" "A-Z"`
547 AC_DEFINE_UNQUOTED([JEMALLOC_PREFIX], ["$JEMALLOC_PREFIX"])
548 AC_DEFINE_UNQUOTED([JEMALLOC_CPREFIX], ["$JEMALLOC_CPREFIX"])
Jason Evans90895cf2009-12-29 00:09:15 -0800549fi
Jason Evans241abc62015-06-23 18:47:07 -0700550AC_SUBST([JEMALLOC_CPREFIX])
Jason Evans90895cf2009-12-29 00:09:15 -0800551
Mike Hommey99066602012-11-19 10:55:26 +0100552AC_ARG_WITH([export],
553 [AS_HELP_STRING([--without-export], [disable exporting jemalloc public APIs])],
554 [if test "x$with_export" = "xno"; then
Jason Evans2625c892013-01-22 16:46:27 -0800555 AC_DEFINE([JEMALLOC_EXPORT],[])
Mike Hommey99066602012-11-19 10:55:26 +0100556fi]
557)
558
Jason Evans86abd0d2013-11-30 15:25:42 -0800559dnl Mangle library-private APIs.
Jason Evans746e77a2011-07-30 16:40:52 -0700560AC_ARG_WITH([private_namespace],
561 [AS_HELP_STRING([--with-private-namespace=<prefix>], [Prefix to prepend to all library-private APIs])],
Jason Evans86abd0d2013-11-30 15:25:42 -0800562 [JEMALLOC_PRIVATE_NAMESPACE="${with_private_namespace}je_"],
563 [JEMALLOC_PRIVATE_NAMESPACE="je_"]
Jason Evans746e77a2011-07-30 16:40:52 -0700564)
Jason Evans86abd0d2013-11-30 15:25:42 -0800565AC_DEFINE_UNQUOTED([JEMALLOC_PRIVATE_NAMESPACE], [$JEMALLOC_PRIVATE_NAMESPACE])
566private_namespace="$JEMALLOC_PRIVATE_NAMESPACE"
567AC_SUBST([private_namespace])
Jason Evans746e77a2011-07-30 16:40:52 -0700568
Jason Evansb0fd5012010-01-17 01:49:20 -0800569dnl Do not add suffix to installed files by default.
570AC_ARG_WITH([install_suffix],
571 [AS_HELP_STRING([--with-install-suffix=<suffix>], [Suffix to append to all installed files])],
572 [INSTALL_SUFFIX="$with_install_suffix"],
573 [INSTALL_SUFFIX=]
574)
575install_suffix="$INSTALL_SUFFIX"
576AC_SUBST([install_suffix])
577
Jason Evans86abd0d2013-11-30 15:25:42 -0800578dnl Substitute @je_@ in jemalloc_protos.h.in, primarily to make generation of
579dnl jemalloc_protos_jet.h easy.
580je_="je_"
581AC_SUBST([je_])
582
Mike Hommeycf6032d2014-07-30 18:16:13 +0900583cfgoutputs_in="Makefile.in"
Nick White913e9a82014-09-19 22:01:23 +0100584cfgoutputs_in="${cfgoutputs_in} jemalloc.pc.in"
Mike Hommeycf6032d2014-07-30 18:16:13 +0900585cfgoutputs_in="${cfgoutputs_in} doc/html.xsl.in"
586cfgoutputs_in="${cfgoutputs_in} doc/manpages.xsl.in"
587cfgoutputs_in="${cfgoutputs_in} doc/jemalloc.xml.in"
588cfgoutputs_in="${cfgoutputs_in} include/jemalloc/jemalloc_macros.h.in"
589cfgoutputs_in="${cfgoutputs_in} include/jemalloc/jemalloc_protos.h.in"
Jason Evans82e88d12014-09-07 19:55:03 -0700590cfgoutputs_in="${cfgoutputs_in} include/jemalloc/jemalloc_typedefs.h.in"
Mike Hommeycf6032d2014-07-30 18:16:13 +0900591cfgoutputs_in="${cfgoutputs_in} include/jemalloc/internal/jemalloc_internal.h.in"
592cfgoutputs_in="${cfgoutputs_in} test/test.sh.in"
593cfgoutputs_in="${cfgoutputs_in} test/include/test/jemalloc_test.h.in"
Jason Evansb0fd5012010-01-17 01:49:20 -0800594
Jason Evansaee7fd22010-11-24 22:00:02 -0800595cfgoutputs_out="Makefile"
Nick White913e9a82014-09-19 22:01:23 +0100596cfgoutputs_out="${cfgoutputs_out} jemalloc.pc"
Jason Evansaee7fd22010-11-24 22:00:02 -0800597cfgoutputs_out="${cfgoutputs_out} doc/html.xsl"
598cfgoutputs_out="${cfgoutputs_out} doc/manpages.xsl"
Jason Evans86abd0d2013-11-30 15:25:42 -0800599cfgoutputs_out="${cfgoutputs_out} doc/jemalloc.xml"
600cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_macros.h"
601cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_protos.h"
Jason Evans82e88d12014-09-07 19:55:03 -0700602cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_typedefs.h"
Jason Evans376b1522010-02-11 14:45:59 -0800603cfgoutputs_out="${cfgoutputs_out} include/jemalloc/internal/jemalloc_internal.h"
Jason Evans86abd0d2013-11-30 15:25:42 -0800604cfgoutputs_out="${cfgoutputs_out} test/test.sh"
605cfgoutputs_out="${cfgoutputs_out} test/include/test/jemalloc_test.h"
Jason Evansb0fd5012010-01-17 01:49:20 -0800606
Jason Evansaee7fd22010-11-24 22:00:02 -0800607cfgoutputs_tup="Makefile"
Nick White913e9a82014-09-19 22:01:23 +0100608cfgoutputs_tup="${cfgoutputs_tup} jemalloc.pc:jemalloc.pc.in"
Jason Evansaee7fd22010-11-24 22:00:02 -0800609cfgoutputs_tup="${cfgoutputs_tup} doc/html.xsl:doc/html.xsl.in"
610cfgoutputs_tup="${cfgoutputs_tup} doc/manpages.xsl:doc/manpages.xsl.in"
Jason Evans86abd0d2013-11-30 15:25:42 -0800611cfgoutputs_tup="${cfgoutputs_tup} doc/jemalloc.xml:doc/jemalloc.xml.in"
612cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_macros.h:include/jemalloc/jemalloc_macros.h.in"
613cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_protos.h:include/jemalloc/jemalloc_protos.h.in"
Jason Evans82e88d12014-09-07 19:55:03 -0700614cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_typedefs.h:include/jemalloc/jemalloc_typedefs.h.in"
Jason Evans376b1522010-02-11 14:45:59 -0800615cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/internal/jemalloc_internal.h"
Jason Evans86abd0d2013-11-30 15:25:42 -0800616cfgoutputs_tup="${cfgoutputs_tup} test/test.sh:test/test.sh.in"
617cfgoutputs_tup="${cfgoutputs_tup} test/include/test/jemalloc_test.h:test/include/test/jemalloc_test.h.in"
Jason Evansb0fd5012010-01-17 01:49:20 -0800618
Mike Hommeycf6032d2014-07-30 18:16:13 +0900619cfghdrs_in="include/jemalloc/jemalloc_defs.h.in"
620cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/jemalloc_internal_defs.h.in"
621cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/private_namespace.sh"
622cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/private_unnamespace.sh"
623cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/private_symbols.txt"
624cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/public_namespace.sh"
625cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/public_unnamespace.sh"
626cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/size_classes.sh"
627cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc_rename.sh"
628cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc_mangle.sh"
629cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc.sh"
630cfghdrs_in="${cfghdrs_in} test/include/test/jemalloc_test_defs.h.in"
Jason Evansb0fd5012010-01-17 01:49:20 -0800631
Jason Evans86abd0d2013-11-30 15:25:42 -0800632cfghdrs_out="include/jemalloc/jemalloc_defs.h"
633cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc${install_suffix}.h"
Jason Evans86abd0d2013-11-30 15:25:42 -0800634cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/private_namespace.h"
635cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/private_unnamespace.h"
Jason Evansf234dc52014-01-16 17:38:01 -0800636cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_symbols.txt"
Jason Evans86abd0d2013-11-30 15:25:42 -0800637cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_namespace.h"
638cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_unnamespace.h"
Jason Evansb1726102012-02-28 16:50:47 -0800639cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/size_classes.h"
Jason Evansf234dc52014-01-16 17:38:01 -0800640cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_protos_jet.h"
641cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_rename.h"
642cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_mangle.h"
643cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_mangle_jet.h"
644cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/jemalloc_internal_defs.h"
Jason Evans80061b62013-12-09 13:21:08 -0800645cfghdrs_out="${cfghdrs_out} test/include/test/jemalloc_test_defs.h"
Jason Evansb0fd5012010-01-17 01:49:20 -0800646
Jason Evans86abd0d2013-11-30 15:25:42 -0800647cfghdrs_tup="include/jemalloc/jemalloc_defs.h:include/jemalloc/jemalloc_defs.h.in"
Mike Hommeycf6032d2014-07-30 18:16:13 +0900648cfghdrs_tup="${cfghdrs_tup} include/jemalloc/internal/jemalloc_internal_defs.h:include/jemalloc/internal/jemalloc_internal_defs.h.in"
649cfghdrs_tup="${cfghdrs_tup} test/include/test/jemalloc_test_defs.h:test/include/test/jemalloc_test_defs.h.in"
Jason Evansb0fd5012010-01-17 01:49:20 -0800650
Jason Evans644d4142014-04-14 22:49:23 -0700651dnl Silence irrelevant compiler warnings by default.
Jason Evans355b4382010-09-20 19:20:48 -0700652AC_ARG_ENABLE([cc-silence],
Jason Evans644d4142014-04-14 22:49:23 -0700653 [AS_HELP_STRING([--disable-cc-silence],
654 [Do not silence irrelevant compiler warnings])],
Jason Evans355b4382010-09-20 19:20:48 -0700655[if test "x$enable_cc_silence" = "xno" ; then
656 enable_cc_silence="0"
657else
658 enable_cc_silence="1"
659fi
660],
Jason Evans644d4142014-04-14 22:49:23 -0700661[enable_cc_silence="1"]
Jason Evans355b4382010-09-20 19:20:48 -0700662)
663if test "x$enable_cc_silence" = "x1" ; then
Jason Evanse24c7af2012-03-19 10:21:17 -0700664 AC_DEFINE([JEMALLOC_CC_SILENCE], [ ])
Jason Evans355b4382010-09-20 19:20:48 -0700665fi
666
Jason Evansb7924f52009-06-23 19:01:18 -0700667dnl Do not compile with debugging by default.
668AC_ARG_ENABLE([debug],
Jason Evanse0a08a12015-03-18 21:06:58 -0700669 [AS_HELP_STRING([--enable-debug],
670 [Build debugging code (implies --enable-ivsalloc)])],
Jason Evansb7924f52009-06-23 19:01:18 -0700671[if test "x$enable_debug" = "xno" ; then
672 enable_debug="0"
673else
674 enable_debug="1"
675fi
676],
677[enable_debug="0"]
678)
Jason Evans02e5dcf2015-02-15 20:12:06 -0800679if test "x$enable_debug" = "x1" ; then
680 AC_DEFINE([JEMALLOC_DEBUG], [ ])
681fi
Jason Evanse0a08a12015-03-18 21:06:58 -0700682if test "x$enable_debug" = "x1" ; then
683 AC_DEFINE([JEMALLOC_DEBUG], [ ])
684 enable_ivsalloc="1"
685fi
Jason Evansb7924f52009-06-23 19:01:18 -0700686AC_SUBST([enable_debug])
687
Jason Evanse0a08a12015-03-18 21:06:58 -0700688dnl Do not validate pointers by default.
689AC_ARG_ENABLE([ivsalloc],
690 [AS_HELP_STRING([--enable-ivsalloc],
691 [Validate pointers passed through the public API])],
692[if test "x$enable_ivsalloc" = "xno" ; then
693 enable_ivsalloc="0"
694else
695 enable_ivsalloc="1"
696fi
697],
698[enable_ivsalloc="0"]
699)
700if test "x$enable_ivsalloc" = "x1" ; then
701 AC_DEFINE([JEMALLOC_IVSALLOC], [ ])
702fi
703
Jason Evansb7924f52009-06-23 19:01:18 -0700704dnl Only optimize if not debugging.
705if test "x$enable_debug" = "x0" -a "x$no_CFLAGS" = "xyes" ; then
706 dnl Make sure that an optimization flag was not specified in EXTRA_CFLAGS.
Jason Evansf3340ca2009-06-30 16:17:05 -0700707 optimize="no"
Jason Evans748dfac2013-12-06 18:27:33 -0800708 echo "$CFLAGS $EXTRA_CFLAGS" | grep '\-O' >/dev/null || optimize="yes"
Jason Evansf3340ca2009-06-30 16:17:05 -0700709 if test "x${optimize}" = "xyes" ; then
710 if test "x$GCC" = "xyes" ; then
711 JE_CFLAGS_APPEND([-O3])
712 JE_CFLAGS_APPEND([-funroll-loops])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200713 elif test "x$je_cv_msvc" = "xyes" ; then
714 JE_CFLAGS_APPEND([-O2])
Jason Evansf3340ca2009-06-30 16:17:05 -0700715 else
716 JE_CFLAGS_APPEND([-O])
717 fi
Jason Evansb7924f52009-06-23 19:01:18 -0700718 fi
719fi
720
Jason Evansd073a322012-02-28 20:41:16 -0800721dnl Enable statistics calculation by default.
Jason Evansb7924f52009-06-23 19:01:18 -0700722AC_ARG_ENABLE([stats],
Jason Evans777c1912012-02-28 20:49:22 -0800723 [AS_HELP_STRING([--disable-stats],
724 [Disable statistics calculation/reporting])],
Jason Evansb7924f52009-06-23 19:01:18 -0700725[if test "x$enable_stats" = "xno" ; then
726 enable_stats="0"
727else
728 enable_stats="1"
729fi
730],
Jason Evansd073a322012-02-28 20:41:16 -0800731[enable_stats="1"]
Jason Evansb7924f52009-06-23 19:01:18 -0700732)
733if test "x$enable_stats" = "x1" ; then
734 AC_DEFINE([JEMALLOC_STATS], [ ])
735fi
736AC_SUBST([enable_stats])
737
Jason Evans6109fe02010-02-10 10:37:56 -0800738dnl Do not enable profiling by default.
739AC_ARG_ENABLE([prof],
740 [AS_HELP_STRING([--enable-prof], [Enable allocation profiling])],
741[if test "x$enable_prof" = "xno" ; then
742 enable_prof="0"
743else
744 enable_prof="1"
745fi
746],
747[enable_prof="0"]
748)
Jason Evans77f350b2011-03-15 22:23:12 -0700749if test "x$enable_prof" = "x1" ; then
750 backtrace_method=""
Jason Evansb27805b2010-02-10 18:15:53 -0800751else
Jason Evans77f350b2011-03-15 22:23:12 -0700752 backtrace_method="N/A"
Jason Evansb27805b2010-02-10 18:15:53 -0800753fi
Jason Evans77f350b2011-03-15 22:23:12 -0700754
Jason Evans6109fe02010-02-10 10:37:56 -0800755AC_ARG_ENABLE([prof-libunwind],
756 [AS_HELP_STRING([--enable-prof-libunwind], [Use libunwind for backtracing])],
757[if test "x$enable_prof_libunwind" = "xno" ; then
758 enable_prof_libunwind="0"
759else
760 enable_prof_libunwind="1"
761fi
762],
763[enable_prof_libunwind="0"]
764)
Jason Evansca6bd4f2010-03-02 14:12:58 -0800765AC_ARG_WITH([static_libunwind],
766 [AS_HELP_STRING([--with-static-libunwind=<libunwind.a>],
767 [Path to static libunwind library; use rather than dynamically linking])],
768if test "x$with_static_libunwind" = "xno" ; then
769 LUNWIND="-lunwind"
770else
771 if test ! -f "$with_static_libunwind" ; then
772 AC_MSG_ERROR([Static libunwind not found: $with_static_libunwind])
773 fi
774 LUNWIND="$with_static_libunwind"
775fi,
776 LUNWIND="-lunwind"
777)
Jason Evans77f350b2011-03-15 22:23:12 -0700778if test "x$backtrace_method" = "x" -a "x$enable_prof_libunwind" = "x1" ; then
779 AC_CHECK_HEADERS([libunwind.h], , [enable_prof_libunwind="0"])
780 if test "x$LUNWIND" = "x-lunwind" ; then
Jason Evans05125b82014-04-22 20:48:07 -0700781 AC_CHECK_LIB([unwind], [unw_backtrace], [LIBS="$LIBS $LUNWIND"],
Jason Evans77f350b2011-03-15 22:23:12 -0700782 [enable_prof_libunwind="0"])
783 else
784 LIBS="$LIBS $LUNWIND"
785 fi
786 if test "x${enable_prof_libunwind}" = "x1" ; then
787 backtrace_method="libunwind"
788 AC_DEFINE([JEMALLOC_PROF_LIBUNWIND], [ ])
789 fi
790fi
791
792AC_ARG_ENABLE([prof-libgcc],
793 [AS_HELP_STRING([--disable-prof-libgcc],
794 [Do not use libgcc for backtracing])],
795[if test "x$enable_prof_libgcc" = "xno" ; then
796 enable_prof_libgcc="0"
797else
798 enable_prof_libgcc="1"
799fi
800],
801[enable_prof_libgcc="1"]
802)
803if test "x$backtrace_method" = "x" -a "x$enable_prof_libgcc" = "x1" \
804 -a "x$GCC" = "xyes" ; then
805 AC_CHECK_HEADERS([unwind.h], , [enable_prof_libgcc="0"])
806 AC_CHECK_LIB([gcc], [_Unwind_Backtrace], [LIBS="$LIBS -lgcc"], [enable_prof_libgcc="0"])
Jason Evans77f350b2011-03-15 22:23:12 -0700807 if test "x${enable_prof_libgcc}" = "x1" ; then
808 backtrace_method="libgcc"
809 AC_DEFINE([JEMALLOC_PROF_LIBGCC], [ ])
810 fi
811else
812 enable_prof_libgcc="0"
813fi
814
815AC_ARG_ENABLE([prof-gcc],
816 [AS_HELP_STRING([--disable-prof-gcc],
817 [Do not use gcc intrinsics for backtracing])],
818[if test "x$enable_prof_gcc" = "xno" ; then
819 enable_prof_gcc="0"
820else
821 enable_prof_gcc="1"
822fi
823],
824[enable_prof_gcc="1"]
825)
826if test "x$backtrace_method" = "x" -a "x$enable_prof_gcc" = "x1" \
827 -a "x$GCC" = "xyes" ; then
Jason Evanse181f5a2014-03-30 18:58:32 -0700828 JE_CFLAGS_APPEND([-fno-omit-frame-pointer])
Jason Evans77f350b2011-03-15 22:23:12 -0700829 backtrace_method="gcc intrinsics"
830 AC_DEFINE([JEMALLOC_PROF_GCC], [ ])
831else
832 enable_prof_gcc="0"
833fi
834
835if test "x$backtrace_method" = "x" ; then
836 backtrace_method="none (disabling profiling)"
837 enable_prof="0"
838fi
839AC_MSG_CHECKING([configured backtracing method])
840AC_MSG_RESULT([$backtrace_method])
Jason Evans2dbecf12010-09-05 10:35:13 -0700841if test "x$enable_prof" = "x1" ; then
Jason Evansd37d5ad2013-12-05 23:01:50 -0800842 if test "x$abi" != "xpecoff"; then
843 dnl Heap profiling uses the log(3) function.
844 LIBS="$LIBS -lm"
845 fi
846
Jason Evans2dbecf12010-09-05 10:35:13 -0700847 AC_DEFINE([JEMALLOC_PROF], [ ])
Jason Evans2dbecf12010-09-05 10:35:13 -0700848fi
849AC_SUBST([enable_prof])
Jason Evans2dbecf12010-09-05 10:35:13 -0700850
Jason Evans84cbbcb2009-12-29 00:09:15 -0800851dnl Enable thread-specific caching by default.
852AC_ARG_ENABLE([tcache],
853 [AS_HELP_STRING([--disable-tcache], [Disable per thread caches])],
854[if test "x$enable_tcache" = "xno" ; then
855 enable_tcache="0"
Jason Evansb7924f52009-06-23 19:01:18 -0700856else
Jason Evans84cbbcb2009-12-29 00:09:15 -0800857 enable_tcache="1"
Jason Evansb7924f52009-06-23 19:01:18 -0700858fi
859],
Jason Evans84cbbcb2009-12-29 00:09:15 -0800860[enable_tcache="1"]
Jason Evansb7924f52009-06-23 19:01:18 -0700861)
Jason Evans2dbecf12010-09-05 10:35:13 -0700862if test "x$enable_tcache" = "x1" ; then
863 AC_DEFINE([JEMALLOC_TCACHE], [ ])
864fi
865AC_SUBST([enable_tcache])
Jason Evansb7924f52009-06-23 19:01:18 -0700866
Jason Evansd059b9d2015-07-24 18:21:42 -0700867dnl Indicate whether adjacent virtual memory mappings automatically coalesce
868dnl (and fragment on demand).
869if test "x${maps_coalesce}" = "x1" ; then
870 AC_DEFINE([JEMALLOC_MAPS_COALESCE], [ ])
871fi
872
Jason Evans59ae2762012-04-16 17:52:27 -0700873dnl Enable VM deallocation via munmap() by default.
874AC_ARG_ENABLE([munmap],
875 [AS_HELP_STRING([--disable-munmap], [Disable VM deallocation via munmap(2)])],
876[if test "x$enable_munmap" = "xno" ; then
877 enable_munmap="0"
878else
879 enable_munmap="1"
880fi
881],
882[enable_munmap="${default_munmap}"]
883)
Jason Evansd059b9d2015-07-24 18:21:42 -0700884if test "x$enable_munmap" = "x0" -a "x${maps_coalesce}" = "x0" ; then
885 AC_MSG_RESULT([Forcing munmap to avoid non-coalescing map issues])
886 enable_munmap="1"
887fi
Jason Evans59ae2762012-04-16 17:52:27 -0700888if test "x$enable_munmap" = "x1" ; then
889 AC_DEFINE([JEMALLOC_MUNMAP], [ ])
890fi
891AC_SUBST([enable_munmap])
892
Jason Evans4d434ad2014-04-15 12:09:48 -0700893dnl Enable allocation from DSS if supported by the OS.
894have_dss="1"
Mike Hommey83c324a2012-04-12 10:13:03 +0200895dnl Check whether the BSD/SUSv1 sbrk() exists. If not, disable DSS support.
896AC_CHECK_FUNC([sbrk], [have_sbrk="1"], [have_sbrk="0"])
897if test "x$have_sbrk" = "x1" ; then
Steven Stewart-Gallus79230fe2014-06-19 16:11:43 -0700898 if test "x$sbrk_deprecated" = "x1" ; then
Jason Evans66688532013-12-03 21:49:36 -0800899 AC_MSG_RESULT([Disabling dss allocation because sbrk is deprecated])
Jason Evans4d434ad2014-04-15 12:09:48 -0700900 have_dss="0"
Jason Evans66688532013-12-03 21:49:36 -0800901 fi
Mike Hommey83c324a2012-04-12 10:13:03 +0200902else
Jason Evans4d434ad2014-04-15 12:09:48 -0700903 have_dss="0"
Mike Hommey83c324a2012-04-12 10:13:03 +0200904fi
905
Jason Evans4d434ad2014-04-15 12:09:48 -0700906if test "x$have_dss" = "x1" ; then
Jason Evansb7924f52009-06-23 19:01:18 -0700907 AC_DEFINE([JEMALLOC_DSS], [ ])
908fi
Jason Evansb7924f52009-06-23 19:01:18 -0700909
Jason Evans777c1912012-02-28 20:49:22 -0800910dnl Support the junk/zero filling option by default.
Jason Evansb7924f52009-06-23 19:01:18 -0700911AC_ARG_ENABLE([fill],
Jason Evans122449b2012-04-06 00:35:09 -0700912 [AS_HELP_STRING([--disable-fill],
913 [Disable support for junk/zero filling, quarantine, and redzones])],
Jason Evansb7924f52009-06-23 19:01:18 -0700914[if test "x$enable_fill" = "xno" ; then
915 enable_fill="0"
916else
917 enable_fill="1"
918fi
919],
Jason Evans777c1912012-02-28 20:49:22 -0800920[enable_fill="1"]
Jason Evansb7924f52009-06-23 19:01:18 -0700921)
922if test "x$enable_fill" = "x1" ; then
923 AC_DEFINE([JEMALLOC_FILL], [ ])
924fi
925AC_SUBST([enable_fill])
926
Jason Evansb1476112012-04-05 13:36:17 -0700927dnl Disable utrace(2)-based tracing by default.
928AC_ARG_ENABLE([utrace],
929 [AS_HELP_STRING([--enable-utrace], [Enable utrace(2)-based tracing])],
930[if test "x$enable_utrace" = "xno" ; then
931 enable_utrace="0"
932else
933 enable_utrace="1"
934fi
935],
936[enable_utrace="0"]
937)
938JE_COMPILABLE([utrace(2)], [
939#include <sys/types.h>
940#include <sys/param.h>
941#include <sys/time.h>
942#include <sys/uio.h>
943#include <sys/ktrace.h>
944], [
945 utrace((void *)0, 0);
946], [je_cv_utrace])
947if test "x${je_cv_utrace}" = "xno" ; then
948 enable_utrace="0"
949fi
950if test "x$enable_utrace" = "x1" ; then
951 AC_DEFINE([JEMALLOC_UTRACE], [ ])
952fi
953AC_SUBST([enable_utrace])
954
Jason Evans122449b2012-04-06 00:35:09 -0700955dnl Support Valgrind by default.
956AC_ARG_ENABLE([valgrind],
957 [AS_HELP_STRING([--disable-valgrind], [Disable support for Valgrind])],
958[if test "x$enable_valgrind" = "xno" ; then
959 enable_valgrind="0"
960else
961 enable_valgrind="1"
962fi
963],
964[enable_valgrind="1"]
965)
966if test "x$enable_valgrind" = "x1" ; then
967 JE_COMPILABLE([valgrind], [
968#include <valgrind/valgrind.h>
969#include <valgrind/memcheck.h>
970
Mike Hommey7bfecf42012-04-30 15:15:15 +0200971#if !defined(VALGRIND_RESIZEINPLACE_BLOCK)
Jason Evans122449b2012-04-06 00:35:09 -0700972# error "Incompatible Valgrind version"
973#endif
974], [], [je_cv_valgrind])
975 if test "x${je_cv_valgrind}" = "xno" ; then
976 enable_valgrind="0"
977 fi
978 if test "x$enable_valgrind" = "x1" ; then
979 AC_DEFINE([JEMALLOC_VALGRIND], [ ])
980 fi
981fi
982AC_SUBST([enable_valgrind])
983
Jason Evansb7924f52009-06-23 19:01:18 -0700984dnl Do not support the xmalloc option by default.
985AC_ARG_ENABLE([xmalloc],
986 [AS_HELP_STRING([--enable-xmalloc], [Support xmalloc option])],
987[if test "x$enable_xmalloc" = "xno" ; then
988 enable_xmalloc="0"
989else
990 enable_xmalloc="1"
991fi
992],
993[enable_xmalloc="0"]
994)
995if test "x$enable_xmalloc" = "x1" ; then
996 AC_DEFINE([JEMALLOC_XMALLOC], [ ])
997fi
998AC_SUBST([enable_xmalloc])
999
Jason Evans8a03cf02015-05-04 09:58:36 -07001000dnl Support cache-oblivious allocation alignment by default.
1001AC_ARG_ENABLE([cache-oblivious],
1002 [AS_HELP_STRING([--disable-cache-oblivious],
1003 [Disable support for cache-oblivious allocation alignment])],
1004[if test "x$enable_cache_oblivious" = "xno" ; then
1005 enable_cache_oblivious="0"
1006else
1007 enable_cache_oblivious="1"
1008fi
1009],
1010[enable_cache_oblivious="1"]
1011)
1012if test "x$enable_cache_oblivious" = "x1" ; then
1013 AC_DEFINE([JEMALLOC_CACHE_OBLIVIOUS], [ ])
1014fi
1015AC_SUBST([enable_cache_oblivious])
1016
Mike Hommey8f50ec82014-06-04 12:12:55 +09001017dnl ============================================================================
1018dnl Check for __builtin_ffsl(), then ffsl(3), and fail if neither are found.
1019dnl One of those two functions should (theoretically) exist on all platforms
1020dnl that jemalloc currently has a chance of functioning on without modification.
1021dnl We additionally assume ffs() or __builtin_ffs() are defined if
1022dnl ffsl() or __builtin_ffsl() are defined, respectively.
1023JE_COMPILABLE([a program using __builtin_ffsl], [
1024#include <stdio.h>
1025#include <strings.h>
1026#include <string.h>
1027], [
1028 {
1029 int rv = __builtin_ffsl(0x08);
1030 printf("%d\n", rv);
1031 }
1032], [je_cv_gcc_builtin_ffsl])
Steven Stewart-Gallus79230fe2014-06-19 16:11:43 -07001033if test "x${je_cv_gcc_builtin_ffsl}" = "xyes" ; then
Mike Hommey8f50ec82014-06-04 12:12:55 +09001034 AC_DEFINE([JEMALLOC_INTERNAL_FFSL], [__builtin_ffsl])
1035 AC_DEFINE([JEMALLOC_INTERNAL_FFS], [__builtin_ffs])
1036else
1037 JE_COMPILABLE([a program using ffsl], [
1038 #include <stdio.h>
1039 #include <strings.h>
1040 #include <string.h>
1041 ], [
1042 {
1043 int rv = ffsl(0x08);
1044 printf("%d\n", rv);
1045 }
1046 ], [je_cv_function_ffsl])
Steven Stewart-Gallus79230fe2014-06-19 16:11:43 -07001047 if test "x${je_cv_function_ffsl}" = "xyes" ; then
Mike Hommey8f50ec82014-06-04 12:12:55 +09001048 AC_DEFINE([JEMALLOC_INTERNAL_FFSL], [ffsl])
1049 AC_DEFINE([JEMALLOC_INTERNAL_FFS], [ffs])
1050 else
1051 AC_MSG_ERROR([Cannot build without ffsl(3) or __builtin_ffsl()])
1052 fi
1053fi
1054
Jason Evans81e54752014-10-10 22:34:25 -07001055AC_ARG_WITH([lg_tiny_min],
1056 [AS_HELP_STRING([--with-lg-tiny-min=<lg-tiny-min>],
1057 [Base 2 log of minimum tiny size class to support])],
1058 [LG_TINY_MIN="$with_lg_tiny_min"],
1059 [LG_TINY_MIN="3"])
1060AC_DEFINE_UNQUOTED([LG_TINY_MIN], [$LG_TINY_MIN])
1061
Jason Evansfc0b3b72014-10-09 17:54:06 -07001062AC_ARG_WITH([lg_quantum],
1063 [AS_HELP_STRING([--with-lg-quantum=<lg-quantum>],
1064 [Base 2 log of minimum allocation alignment])],
Jason Evans81e54752014-10-10 22:34:25 -07001065 [LG_QUANTA="$with_lg_quantum"],
1066 [LG_QUANTA="3 4"])
1067if test "x$with_lg_quantum" != "x" ; then
1068 AC_DEFINE_UNQUOTED([LG_QUANTUM], [$with_lg_quantum])
1069fi
Jason Evansfc0b3b72014-10-09 17:54:06 -07001070
1071AC_ARG_WITH([lg_page],
1072 [AS_HELP_STRING([--with-lg-page=<lg-page>], [Base 2 log of system page size])],
1073 [LG_PAGE="$with_lg_page"], [LG_PAGE="detect"])
Jason Evansb0808d52015-02-03 12:39:31 -08001074if test "x$LG_PAGE" = "xdetect"; then
Jason Evansfc0b3b72014-10-09 17:54:06 -07001075 AC_CACHE_CHECK([LG_PAGE],
1076 [je_cv_lg_page],
Jason Evans6684cac2012-03-05 12:15:36 -08001077 AC_RUN_IFELSE([AC_LANG_PROGRAM(
Mike Hommeya19e87f2012-04-21 21:27:46 -07001078[[
Mike Hommeyfd97b1d2012-04-30 12:38:31 +02001079#include <strings.h>
Mike Hommeya19e87f2012-04-21 21:27:46 -07001080#ifdef _WIN32
1081#include <windows.h>
1082#else
Jason Evansb7924f52009-06-23 19:01:18 -07001083#include <unistd.h>
Mike Hommeya19e87f2012-04-21 21:27:46 -07001084#endif
1085#include <stdio.h>
Jason Evans6684cac2012-03-05 12:15:36 -08001086]],
1087[[
Garrett Cooper72c1e592012-12-02 17:57:28 -08001088 int result;
Jason Evansb7924f52009-06-23 19:01:18 -07001089 FILE *f;
1090
Mike Hommeya19e87f2012-04-21 21:27:46 -07001091#ifdef _WIN32
1092 SYSTEM_INFO si;
1093 GetSystemInfo(&si);
1094 result = si.dwPageSize;
1095#else
Jason Evansb7924f52009-06-23 19:01:18 -07001096 result = sysconf(_SC_PAGESIZE);
Mike Hommeya19e87f2012-04-21 21:27:46 -07001097#endif
Jason Evansb7924f52009-06-23 19:01:18 -07001098 if (result == -1) {
1099 return 1;
1100 }
Mike Hommey8f50ec82014-06-04 12:12:55 +09001101 result = JEMALLOC_INTERNAL_FFSL(result) - 1;
Mike Hommeya19e87f2012-04-21 21:27:46 -07001102
Jason Evansb7924f52009-06-23 19:01:18 -07001103 f = fopen("conftest.out", "w");
1104 if (f == NULL) {
1105 return 1;
1106 }
Garrett Cooper72c1e592012-12-02 17:57:28 -08001107 fprintf(f, "%d\n", result);
Jason Evans3cc1f1a2012-04-03 22:30:05 -07001108 fclose(f);
Jason Evansb7924f52009-06-23 19:01:18 -07001109
1110 return 0;
1111]])],
Jason Evansfc0b3b72014-10-09 17:54:06 -07001112 [je_cv_lg_page=`cat conftest.out`],
1113 [je_cv_lg_page=undefined],
1114 [je_cv_lg_page=12]))
Jason Evans6684cac2012-03-05 12:15:36 -08001115fi
Jason Evansfc0b3b72014-10-09 17:54:06 -07001116if test "x${je_cv_lg_page}" != "x" ; then
1117 LG_PAGE="${je_cv_lg_page}"
1118fi
1119if test "x${LG_PAGE}" != "xundefined" ; then
1120 AC_DEFINE_UNQUOTED([LG_PAGE], [$LG_PAGE])
1121else
1122 AC_MSG_ERROR([cannot determine value for LG_PAGE])
1123fi
1124
1125AC_ARG_WITH([lg_page_sizes],
1126 [AS_HELP_STRING([--with-lg-page-sizes=<lg-page-sizes>],
1127 [Base 2 logs of system page sizes to support])],
1128 [LG_PAGE_SIZES="$with_lg_page_sizes"], [LG_PAGE_SIZES="$LG_PAGE"])
1129
1130AC_ARG_WITH([lg_size_class_group],
1131 [AS_HELP_STRING([--with-lg-size-class-group=<lg-size-class-group>],
1132 [Base 2 log of size classes per doubling])],
1133 [LG_SIZE_CLASS_GROUP="$with_lg_size_class_group"],
1134 [LG_SIZE_CLASS_GROUP="2"])
Jason Evansb7924f52009-06-23 19:01:18 -07001135
1136dnl ============================================================================
1137dnl jemalloc configuration.
1138dnl
Jason Evansa40bc7a2010-03-02 13:01:16 -08001139
Jason Evansa5a658a2014-09-02 15:07:07 -07001140dnl Set VERSION if source directory is inside a git repository.
Dan McGregorf8880312014-12-23 16:10:08 -06001141if test "x`test ! \"${srcroot}\" && cd \"${srcroot}\"; git rev-parse --is-inside-work-tree 2>/dev/null`" = "xtrue" ; then
Jason Evansa5a658a2014-09-02 15:07:07 -07001142 dnl Pattern globs aren't powerful enough to match both single- and
1143 dnl double-digit version numbers, so iterate over patterns to support up to
1144 dnl version 99.99.99 without any accidental matches.
Dan McGregorf8880312014-12-23 16:10:08 -06001145 rm -f "${objroot}VERSION"
Jason Evansa5a658a2014-09-02 15:07:07 -07001146 for pattern in ['[0-9].[0-9].[0-9]' '[0-9].[0-9].[0-9][0-9]' \
1147 '[0-9].[0-9][0-9].[0-9]' '[0-9].[0-9][0-9].[0-9][0-9]' \
1148 '[0-9][0-9].[0-9].[0-9]' '[0-9][0-9].[0-9].[0-9][0-9]' \
1149 '[0-9][0-9].[0-9][0-9].[0-9]' \
1150 '[0-9][0-9].[0-9][0-9].[0-9][0-9]']; do
Dan McGregorf8880312014-12-23 16:10:08 -06001151 if test ! -e "${objroot}VERSION" ; then
1152 (test ! "${srcroot}" && cd "${srcroot}"; git describe --long --abbrev=40 --match="${pattern}") > "${objroot}VERSION.tmp" 2>/dev/null
Jason Evansa5a658a2014-09-02 15:07:07 -07001153 if test $? -eq 0 ; then
Dan McGregorf8880312014-12-23 16:10:08 -06001154 mv "${objroot}VERSION.tmp" "${objroot}VERSION"
Jason Evansa5a658a2014-09-02 15:07:07 -07001155 break
1156 fi
1157 fi
1158 done
Jason Evansa40bc7a2010-03-02 13:01:16 -08001159fi
Dan McGregorf8880312014-12-23 16:10:08 -06001160rm -f "${objroot}VERSION.tmp"
1161if test ! -e "${objroot}VERSION" ; then
1162 if test ! -e "${srcroot}VERSION" ; then
1163 AC_MSG_RESULT(
1164 [Missing VERSION file, and unable to generate it; creating bogus VERSION])
1165 echo "0.0.0-0-g0000000000000000000000000000000000000000" > "${objroot}VERSION"
1166 else
1167 cp ${srcroot}VERSION ${objroot}VERSION
1168 fi
Jason Evansa5a658a2014-09-02 15:07:07 -07001169fi
Dan McGregorf8880312014-12-23 16:10:08 -06001170jemalloc_version=`cat "${objroot}VERSION"`
Jason Evansa40bc7a2010-03-02 13:01:16 -08001171jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'`
1172jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'`
1173jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'`
1174jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'`
1175jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'`
Jason Evansb7924f52009-06-23 19:01:18 -07001176AC_SUBST([jemalloc_version])
Jason Evansa40bc7a2010-03-02 13:01:16 -08001177AC_SUBST([jemalloc_version_major])
1178AC_SUBST([jemalloc_version_minor])
1179AC_SUBST([jemalloc_version_bugfix])
1180AC_SUBST([jemalloc_version_nrev])
1181AC_SUBST([jemalloc_version_gid])
Jason Evansb7924f52009-06-23 19:01:18 -07001182
1183dnl ============================================================================
1184dnl Configure pthreads.
1185
Mike Hommeya19e87f2012-04-21 21:27:46 -07001186if test "x$abi" != "xpecoff" ; then
1187 AC_CHECK_HEADERS([pthread.h], , [AC_MSG_ERROR([pthread.h is missing])])
1188 dnl Some systems may embed pthreads functionality in libc; check for libpthread
1189 dnl first, but try libc too before failing.
1190 AC_CHECK_LIB([pthread], [pthread_create], [LIBS="$LIBS -lpthread"],
1191 [AC_SEARCH_LIBS([pthread_create], , ,
1192 AC_MSG_ERROR([libpthread is missing]))])
1193fi
Jason Evansb7924f52009-06-23 19:01:18 -07001194
1195CPPFLAGS="$CPPFLAGS -D_REENTRANT"
1196
Daniel Micayb74041f2014-12-09 17:41:34 -05001197dnl Check if the GNU-specific secure_getenv function exists.
1198AC_CHECK_FUNC([secure_getenv],
1199 [have_secure_getenv="1"],
1200 [have_secure_getenv="0"]
1201 )
1202if test "x$have_secure_getenv" = "x1" ; then
1203 AC_DEFINE([JEMALLOC_HAVE_SECURE_GETENV], [ ])
1204fi
1205
1206dnl Check if the Solaris/BSD issetugid function exists.
1207AC_CHECK_FUNC([issetugid],
1208 [have_issetugid="1"],
1209 [have_issetugid="0"]
1210 )
1211if test "x$have_issetugid" = "x1" ; then
1212 AC_DEFINE([JEMALLOC_HAVE_ISSETUGID], [ ])
1213fi
1214
Jason Evanscd9a1342012-03-21 18:33:03 -07001215dnl Check whether the BSD-specific _malloc_thread_cleanup() exists. If so, use
1216dnl it rather than pthreads TSD cleanup functions to support cleanup during
1217dnl thread exit, in order to avoid pthreads library recursion during
1218dnl bootstrapping.
Jason Evanscd9a1342012-03-21 18:33:03 -07001219AC_CHECK_FUNC([_malloc_thread_cleanup],
1220 [have__malloc_thread_cleanup="1"],
1221 [have__malloc_thread_cleanup="0"]
1222 )
1223if test "x$have__malloc_thread_cleanup" = "x1" ; then
1224 AC_DEFINE([JEMALLOC_MALLOC_THREAD_CLEANUP], [ ])
1225 force_tls="1"
1226fi
1227
Jason Evans41b6afb2012-02-02 22:04:57 -08001228dnl Check whether the BSD-specific _pthread_mutex_init_calloc_cb() exists. If
1229dnl so, mutex initialization causes allocation, and we need to implement this
1230dnl callback function in order to prevent recursive allocation.
1231AC_CHECK_FUNC([_pthread_mutex_init_calloc_cb],
1232 [have__pthread_mutex_init_calloc_cb="1"],
1233 [have__pthread_mutex_init_calloc_cb="0"]
1234 )
1235if test "x$have__pthread_mutex_init_calloc_cb" = "x1" ; then
1236 AC_DEFINE([JEMALLOC_MUTEX_INIT_CB])
1237fi
1238
Jason Evans0fee70d2012-02-13 12:36:11 -08001239dnl Disable lazy locking by default.
Jason Evansb7924f52009-06-23 19:01:18 -07001240AC_ARG_ENABLE([lazy_lock],
Jason Evans0fee70d2012-02-13 12:36:11 -08001241 [AS_HELP_STRING([--enable-lazy-lock],
1242 [Enable lazy locking (only lock when multi-threaded)])],
Jason Evansb7924f52009-06-23 19:01:18 -07001243[if test "x$enable_lazy_lock" = "xno" ; then
1244 enable_lazy_lock="0"
1245else
1246 enable_lazy_lock="1"
1247fi
1248],
Mike Hommeyac5db022015-08-11 14:01:59 +09001249[enable_lazy_lock=""]
Jason Evansb7924f52009-06-23 19:01:18 -07001250)
Mike Hommeyac5db022015-08-11 14:01:59 +09001251if test "x$enable_lazy_lock" = "x" -a "x${force_lazy_lock}" = "x1" ; then
Jason Evansfd4fcef2012-03-23 17:40:58 -07001252 AC_MSG_RESULT([Forcing lazy-lock to avoid allocator/threading bootstrap issues])
1253 enable_lazy_lock="1"
1254fi
Jason Evansb7924f52009-06-23 19:01:18 -07001255if test "x$enable_lazy_lock" = "x1" ; then
Mike Hommeya19e87f2012-04-21 21:27:46 -07001256 if test "x$abi" != "xpecoff" ; then
1257 AC_CHECK_HEADERS([dlfcn.h], , [AC_MSG_ERROR([dlfcn.h is missing])])
1258 AC_CHECK_FUNC([dlsym], [],
1259 [AC_CHECK_LIB([dl], [dlsym], [LIBS="$LIBS -ldl"],
1260 [AC_MSG_ERROR([libdl is missing])])
1261 ])
1262 fi
Jason Evansb7924f52009-06-23 19:01:18 -07001263 AC_DEFINE([JEMALLOC_LAZY_LOCK], [ ])
Mike Hommeyac5db022015-08-11 14:01:59 +09001264else
1265 enable_lazy_lock="0"
Jason Evansb7924f52009-06-23 19:01:18 -07001266fi
1267AC_SUBST([enable_lazy_lock])
1268
Jason Evans78d815c2010-01-17 14:06:20 -08001269AC_ARG_ENABLE([tls],
1270 [AS_HELP_STRING([--disable-tls], [Disable thread-local storage (__thread keyword)])],
1271if test "x$enable_tls" = "xno" ; then
1272 enable_tls="0"
1273else
1274 enable_tls="1"
1275fi
1276,
Mike Hommeyac5db022015-08-11 14:01:59 +09001277enable_tls=""
Jason Evans78d815c2010-01-17 14:06:20 -08001278)
Mike Hommeyac5db022015-08-11 14:01:59 +09001279if test "x${enable_tls}" = "x" -a "x${force_tls}" = "x1" ; then
Jason Evanscd9a1342012-03-21 18:33:03 -07001280 AC_MSG_RESULT([Forcing TLS to avoid allocator/threading bootstrap issues])
1281 enable_tls="1"
1282fi
Mike Hommeyac5db022015-08-11 14:01:59 +09001283if test "x${enable_tls}" = "x" -a "x${force_tls}" = "x0" ; then
Jason Evansb80581d2012-03-23 16:17:43 -07001284 AC_MSG_RESULT([Forcing no TLS to avoid allocator/threading bootstrap issues])
1285 enable_tls="0"
1286fi
Jason Evans78d815c2010-01-17 14:06:20 -08001287if test "x${enable_tls}" = "x1" ; then
1288AC_MSG_CHECKING([for TLS])
Jason Evans6684cac2012-03-05 12:15:36 -08001289AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Jason Evans78d815c2010-01-17 14:06:20 -08001290[[
1291 __thread int x;
1292]], [[
1293 x = 42;
1294
1295 return 0;
1296]])],
1297 AC_MSG_RESULT([yes]),
1298 AC_MSG_RESULT([no])
1299 enable_tls="0")
Mike Hommeyac5db022015-08-11 14:01:59 +09001300else
1301 enable_tls="0"
Jason Evans78d815c2010-01-17 14:06:20 -08001302fi
Jason Evansb267d0f2010-08-13 15:42:29 -07001303AC_SUBST([enable_tls])
Jason Evanse24c7af2012-03-19 10:21:17 -07001304if test "x${enable_tls}" = "x1" ; then
1305 AC_DEFINE_UNQUOTED([JEMALLOC_TLS], [ ])
Jason Evanscd9a1342012-03-21 18:33:03 -07001306elif test "x${force_tls}" = "x1" ; then
1307 AC_MSG_ERROR([Failed to configure TLS, which is mandatory for correct function])
Jason Evans78d815c2010-01-17 14:06:20 -08001308fi
1309
Jason Evans2dbecf12010-09-05 10:35:13 -07001310dnl ============================================================================
Chih-hung Hsieh59cd80e2014-12-05 17:42:41 -08001311dnl Check for C11 atomics.
1312
1313JE_COMPILABLE([C11 atomics], [
1314#include <stdint.h>
1315#if (__STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_ATOMICS__)
1316#include <stdatomic.h>
1317#else
1318#error Atomics not available
1319#endif
1320], [
1321 uint64_t *p = (uint64_t *)0;
1322 uint64_t x = 1;
1323 volatile atomic_uint_least64_t *a = (volatile atomic_uint_least64_t *)p;
1324 uint64_t r = atomic_fetch_add(a, x) + x;
1325 return (r == 0);
1326], [je_cv_c11atomics])
1327if test "x${je_cv_c11atomics}" = "xyes" ; then
1328 AC_DEFINE([JEMALLOC_C11ATOMICS])
1329fi
1330
1331dnl ============================================================================
Jason Evansb57d3ec2012-04-17 13:17:54 -07001332dnl Check for atomic(9) operations as provided on FreeBSD.
1333
1334JE_COMPILABLE([atomic(9)], [
1335#include <sys/types.h>
1336#include <machine/atomic.h>
1337#include <inttypes.h>
1338], [
1339 {
1340 uint32_t x32 = 0;
1341 volatile uint32_t *x32p = &x32;
1342 atomic_fetchadd_32(x32p, 1);
1343 }
1344 {
1345 unsigned long xlong = 0;
1346 volatile unsigned long *xlongp = &xlong;
1347 atomic_fetchadd_long(xlongp, 1);
1348 }
1349], [je_cv_atomic9])
1350if test "x${je_cv_atomic9}" = "xyes" ; then
1351 AC_DEFINE([JEMALLOC_ATOMIC9])
1352fi
1353
1354dnl ============================================================================
Jason Evans763baa62011-03-18 19:10:31 -07001355dnl Check for atomic(3) operations as provided on Darwin.
1356
1357JE_COMPILABLE([Darwin OSAtomic*()], [
1358#include <libkern/OSAtomic.h>
1359#include <inttypes.h>
1360], [
1361 {
1362 int32_t x32 = 0;
1363 volatile int32_t *x32p = &x32;
1364 OSAtomicAdd32(1, x32p);
1365 }
1366 {
1367 int64_t x64 = 0;
1368 volatile int64_t *x64p = &x64;
1369 OSAtomicAdd64(1, x64p);
1370 }
Jason Evans6684cac2012-03-05 12:15:36 -08001371], [je_cv_osatomic])
1372if test "x${je_cv_osatomic}" = "xyes" ; then
Jason Evanse24c7af2012-03-19 10:21:17 -07001373 AC_DEFINE([JEMALLOC_OSATOMIC], [ ])
Jason Evans763baa62011-03-18 19:10:31 -07001374fi
1375
1376dnl ============================================================================
Richard Diamond994fad92014-06-03 02:39:18 -05001377dnl Check for madvise(2).
1378
1379JE_COMPILABLE([madvise(2)], [
1380#include <sys/mman.h>
1381], [
1382 {
1383 madvise((void *)0, 0, 0);
1384 }
1385], [je_cv_madvise])
1386if test "x${je_cv_madvise}" = "xyes" ; then
1387 AC_DEFINE([JEMALLOC_HAVE_MADVISE], [ ])
1388fi
1389
1390dnl ============================================================================
Mike Hommeyc1e567b2012-03-26 17:03:41 +02001391dnl Check whether __sync_{add,sub}_and_fetch() are available despite
1392dnl __GCC_HAVE_SYNC_COMPARE_AND_SWAP_n macros being undefined.
1393
1394AC_DEFUN([JE_SYNC_COMPARE_AND_SWAP_CHECK],[
1395 AC_CACHE_CHECK([whether to force $1-bit __sync_{add,sub}_and_fetch()],
1396 [je_cv_sync_compare_and_swap_$2],
Mike Hommey2cfe6d62012-03-27 15:03:07 +02001397 [AC_LINK_IFELSE([AC_LANG_PROGRAM([
1398 #include <stdint.h>
1399 ],
1400 [
1401 #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2
1402 {
1403 uint$1_t x$1 = 0;
1404 __sync_add_and_fetch(&x$1, 42);
1405 __sync_sub_and_fetch(&x$1, 1);
1406 }
1407 #else
1408 #error __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2 is defined, no need to force
1409 #endif
1410 ])],
Mike Hommeyc1e567b2012-03-26 17:03:41 +02001411 [je_cv_sync_compare_and_swap_$2=yes],
1412 [je_cv_sync_compare_and_swap_$2=no])])
1413
1414 if test "x${je_cv_sync_compare_and_swap_$2}" = "xyes" ; then
1415 AC_DEFINE([JE_FORCE_SYNC_COMPARE_AND_SWAP_$2], [ ])
1416 fi
1417])
1418
Jason Evansb57d3ec2012-04-17 13:17:54 -07001419if test "x${je_cv_atomic9}" != "xyes" -a "x${je_cv_osatomic}" != "xyes" ; then
Mike Hommeyc1e567b2012-03-26 17:03:41 +02001420 JE_SYNC_COMPARE_AND_SWAP_CHECK(32, 4)
1421 JE_SYNC_COMPARE_AND_SWAP_CHECK(64, 8)
1422fi
1423
1424dnl ============================================================================
Jason Evansd04047c2014-05-28 16:11:55 -07001425dnl Check for __builtin_clz() and __builtin_clzl().
1426
1427AC_CACHE_CHECK([for __builtin_clz],
1428 [je_cv_builtin_clz],
1429 [AC_LINK_IFELSE([AC_LANG_PROGRAM([],
1430 [
1431 {
1432 unsigned x = 0;
1433 int y = __builtin_clz(x);
1434 }
1435 {
1436 unsigned long x = 0;
1437 int y = __builtin_clzl(x);
1438 }
1439 ])],
1440 [je_cv_builtin_clz=yes],
1441 [je_cv_builtin_clz=no])])
1442
1443if test "x${je_cv_builtin_clz}" = "xyes" ; then
1444 AC_DEFINE([JEMALLOC_HAVE_BUILTIN_CLZ], [ ])
1445fi
1446
1447dnl ============================================================================
Jason Evans893a0ed2011-03-18 19:30:18 -07001448dnl Check for spinlock(3) operations as provided on Darwin.
1449
1450JE_COMPILABLE([Darwin OSSpin*()], [
1451#include <libkern/OSAtomic.h>
1452#include <inttypes.h>
1453], [
1454 OSSpinLock lock = 0;
1455 OSSpinLockLock(&lock);
1456 OSSpinLockUnlock(&lock);
Jason Evans6684cac2012-03-05 12:15:36 -08001457], [je_cv_osspin])
1458if test "x${je_cv_osspin}" = "xyes" ; then
Jason Evanse24c7af2012-03-19 10:21:17 -07001459 AC_DEFINE([JEMALLOC_OSSPIN], [ ])
Jason Evans893a0ed2011-03-18 19:30:18 -07001460fi
1461
1462dnl ============================================================================
Jason Evans2dbecf12010-09-05 10:35:13 -07001463dnl Darwin-related configuration.
Jason Evans78d815c2010-01-17 14:06:20 -08001464
Mike Hommeyd0357f72012-11-26 18:52:41 +01001465AC_ARG_ENABLE([zone-allocator],
1466 [AS_HELP_STRING([--disable-zone-allocator],
1467 [Disable zone allocator for Darwin])],
1468[if test "x$enable_zone_allocator" = "xno" ; then
1469 enable_zone_allocator="0"
1470else
1471 enable_zone_allocator="1"
1472fi
1473],
1474[if test "x${abi}" = "xmacho"; then
1475 enable_zone_allocator="1"
1476fi
1477]
1478)
1479AC_SUBST([enable_zone_allocator])
1480
1481if test "x${enable_zone_allocator}" = "x1" ; then
1482 if test "x${abi}" != "xmacho"; then
1483 AC_MSG_ERROR([--enable-zone-allocator is only supported on Darwin])
1484 fi
Jason Evanse24c7af2012-03-19 10:21:17 -07001485 AC_DEFINE([JEMALLOC_ZONE], [ ])
Jason Evans6109fe02010-02-10 10:37:56 -08001486
Jason Evans2dbecf12010-09-05 10:35:13 -07001487 dnl The szone version jumped from 3 to 6 between the OS X 10.5.x and 10.6
1488 dnl releases. malloc_zone_t and malloc_introspection_t have new fields in
1489 dnl 10.6, which is the only source-level indication of the change.
1490 AC_MSG_CHECKING([malloc zone version])
Mike Hommey154829d2012-03-20 18:01:38 +01001491 AC_DEFUN([JE_ZONE_PROGRAM],
1492 [AC_LANG_PROGRAM(
1493 [#include <malloc/malloc.h>],
Guilherme Goncalves79725aa2014-10-20 14:08:37 -02001494 [static int foo[[sizeof($1) $2 sizeof(void *) * $3 ? 1 : -1]]]
Mike Hommey154829d2012-03-20 18:01:38 +01001495 )])
Jason Evans2dbecf12010-09-05 10:35:13 -07001496
Mike Hommey154829d2012-03-20 18:01:38 +01001497 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,14)],[JEMALLOC_ZONE_VERSION=3],[
1498 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,15)],[JEMALLOC_ZONE_VERSION=5],[
1499 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,16)],[
1500 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,9)],[JEMALLOC_ZONE_VERSION=6],[
1501 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,13)],[JEMALLOC_ZONE_VERSION=7],[JEMALLOC_ZONE_VERSION=]
1502 )])],[
1503 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,17)],[JEMALLOC_ZONE_VERSION=8],[
1504 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,>,17)],[JEMALLOC_ZONE_VERSION=9],[JEMALLOC_ZONE_VERSION=]
1505 )])])])])
1506 if test "x${JEMALLOC_ZONE_VERSION}" = "x"; then
1507 AC_MSG_RESULT([unsupported])
1508 AC_MSG_ERROR([Unsupported malloc zone version])
1509 fi
1510 if test "${JEMALLOC_ZONE_VERSION}" = 9; then
1511 JEMALLOC_ZONE_VERSION=8
1512 AC_MSG_RESULT([> 8])
1513 else
1514 AC_MSG_RESULT([$JEMALLOC_ZONE_VERSION])
1515 fi
1516 AC_DEFINE_UNQUOTED(JEMALLOC_ZONE_VERSION, [$JEMALLOC_ZONE_VERSION])
Jason Evansb27805b2010-02-10 18:15:53 -08001517fi
1518
Jason Evansb7924f52009-06-23 19:01:18 -07001519dnl ============================================================================
Sara Golemon3e24afa2014-08-18 13:06:39 -07001520dnl Check for glibc malloc hooks
1521
1522JE_COMPILABLE([glibc malloc hook], [
1523#include <stddef.h>
1524
1525extern void (* __free_hook)(void *ptr);
1526extern void *(* __malloc_hook)(size_t size);
1527extern void *(* __realloc_hook)(void *ptr, size_t size);
1528], [
1529 void *ptr = 0L;
1530 if (__malloc_hook) ptr = __malloc_hook(1);
1531 if (__realloc_hook) ptr = __realloc_hook(ptr, 2);
1532 if (__free_hook && ptr) __free_hook(ptr);
1533], [je_cv_glibc_malloc_hook])
1534if test "x${je_cv_glibc_malloc_hook}" = "xyes" ; then
1535 AC_DEFINE([JEMALLOC_GLIBC_MALLOC_HOOK], [ ])
1536fi
1537
1538JE_COMPILABLE([glibc memalign hook], [
1539#include <stddef.h>
1540
1541extern void *(* __memalign_hook)(size_t alignment, size_t size);
1542], [
1543 void *ptr = 0L;
1544 if (__memalign_hook) ptr = __memalign_hook(16, 7);
1545], [je_cv_glibc_memalign_hook])
1546if test "x${je_cv_glibc_memalign_hook}" = "xyes" ; then
1547 AC_DEFINE([JEMALLOC_GLIBC_MEMALIGN_HOOK], [ ])
1548fi
1549
Eric Wong4dcf04b2014-08-31 03:57:06 +00001550JE_COMPILABLE([pthreads adaptive mutexes], [
1551#include <pthread.h>
1552], [
1553 pthread_mutexattr_t attr;
1554 pthread_mutexattr_init(&attr);
1555 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ADAPTIVE_NP);
1556 pthread_mutexattr_destroy(&attr);
1557], [je_cv_pthread_mutex_adaptive_np])
1558if test "x${je_cv_pthread_mutex_adaptive_np}" = "xyes" ; then
1559 AC_DEFINE([JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], [ ])
1560fi
1561
Sara Golemon3e24afa2014-08-18 13:06:39 -07001562dnl ============================================================================
Jason Evansb7924f52009-06-23 19:01:18 -07001563dnl Check for typedefs, structures, and compiler characteristics.
1564AC_HEADER_STDBOOL
1565
Jason Evans748dfac2013-12-06 18:27:33 -08001566dnl ============================================================================
1567dnl Define commands that generate output files.
1568
Jason Evans86abd0d2013-11-30 15:25:42 -08001569AC_CONFIG_COMMANDS([include/jemalloc/internal/private_namespace.h], [
1570 mkdir -p "${objroot}include/jemalloc/internal"
1571 "${srcdir}/include/jemalloc/internal/private_namespace.sh" "${srcdir}/include/jemalloc/internal/private_symbols.txt" > "${objroot}include/jemalloc/internal/private_namespace.h"
Jason Evansf234dc52014-01-16 17:38:01 -08001572], [
1573 srcdir="${srcdir}"
1574 objroot="${objroot}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001575])
1576AC_CONFIG_COMMANDS([include/jemalloc/internal/private_unnamespace.h], [
1577 mkdir -p "${objroot}include/jemalloc/internal"
1578 "${srcdir}/include/jemalloc/internal/private_unnamespace.sh" "${srcdir}/include/jemalloc/internal/private_symbols.txt" > "${objroot}include/jemalloc/internal/private_unnamespace.h"
Jason Evansf234dc52014-01-16 17:38:01 -08001579], [
1580 srcdir="${srcdir}"
1581 objroot="${objroot}"
1582])
1583AC_CONFIG_COMMANDS([include/jemalloc/internal/public_symbols.txt], [
1584 f="${objroot}include/jemalloc/internal/public_symbols.txt"
1585 mkdir -p "${objroot}include/jemalloc/internal"
1586 cp /dev/null "${f}"
1587 for nm in `echo ${mangling_map} |tr ',' ' '` ; do
1588 n=`echo ${nm} |tr ':' ' ' |awk '{print $[]1}'`
1589 m=`echo ${nm} |tr ':' ' ' |awk '{print $[]2}'`
1590 echo "${n}:${m}" >> "${f}"
1591 dnl Remove name from public_syms so that it isn't redefined later.
1592 public_syms=`for sym in ${public_syms}; do echo "${sym}"; done |grep -v "^${n}\$" |tr '\n' ' '`
1593 done
1594 for sym in ${public_syms} ; do
1595 n="${sym}"
1596 m="${JEMALLOC_PREFIX}${sym}"
1597 echo "${n}:${m}" >> "${f}"
1598 done
1599], [
1600 srcdir="${srcdir}"
1601 objroot="${objroot}"
1602 mangling_map="${mangling_map}"
1603 public_syms="${public_syms}"
1604 JEMALLOC_PREFIX="${JEMALLOC_PREFIX}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001605])
1606AC_CONFIG_COMMANDS([include/jemalloc/internal/public_namespace.h], [
1607 mkdir -p "${objroot}include/jemalloc/internal"
Jason Evansf234dc52014-01-16 17:38:01 -08001608 "${srcdir}/include/jemalloc/internal/public_namespace.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/internal/public_namespace.h"
1609], [
1610 srcdir="${srcdir}"
1611 objroot="${objroot}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001612])
1613AC_CONFIG_COMMANDS([include/jemalloc/internal/public_unnamespace.h], [
1614 mkdir -p "${objroot}include/jemalloc/internal"
Jason Evansf234dc52014-01-16 17:38:01 -08001615 "${srcdir}/include/jemalloc/internal/public_unnamespace.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/internal/public_unnamespace.h"
1616], [
1617 srcdir="${srcdir}"
1618 objroot="${objroot}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001619])
Jason Evansb1726102012-02-28 16:50:47 -08001620AC_CONFIG_COMMANDS([include/jemalloc/internal/size_classes.h], [
Jason Evans86abd0d2013-11-30 15:25:42 -08001621 mkdir -p "${objroot}include/jemalloc/internal"
Jason Evans81e54752014-10-10 22:34:25 -07001622 "${srcdir}/include/jemalloc/internal/size_classes.sh" "${LG_QUANTA}" ${LG_TINY_MIN} "${LG_PAGE_SIZES}" ${LG_SIZE_CLASS_GROUP} > "${objroot}include/jemalloc/internal/size_classes.h"
Jason Evansf234dc52014-01-16 17:38:01 -08001623], [
1624 srcdir="${srcdir}"
1625 objroot="${objroot}"
Jason Evans81e54752014-10-10 22:34:25 -07001626 LG_QUANTA="${LG_QUANTA}"
1627 LG_TINY_MIN=${LG_TINY_MIN}
1628 LG_PAGE_SIZES="${LG_PAGE_SIZES}"
Jason Evansfc0b3b72014-10-09 17:54:06 -07001629 LG_SIZE_CLASS_GROUP=${LG_SIZE_CLASS_GROUP}
Jason Evansb1726102012-02-28 16:50:47 -08001630])
Jason Evans86abd0d2013-11-30 15:25:42 -08001631AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_protos_jet.h], [
1632 mkdir -p "${objroot}include/jemalloc"
1633 cat "${srcdir}/include/jemalloc/jemalloc_protos.h.in" | sed -e 's/@je_@/jet_/g' > "${objroot}include/jemalloc/jemalloc_protos_jet.h"
Jason Evansf234dc52014-01-16 17:38:01 -08001634], [
1635 srcdir="${srcdir}"
1636 objroot="${objroot}"
1637])
1638AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_rename.h], [
1639 mkdir -p "${objroot}include/jemalloc"
1640 "${srcdir}/include/jemalloc/jemalloc_rename.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/jemalloc_rename.h"
1641], [
1642 srcdir="${srcdir}"
1643 objroot="${objroot}"
1644])
1645AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_mangle.h], [
1646 mkdir -p "${objroot}include/jemalloc"
1647 "${srcdir}/include/jemalloc/jemalloc_mangle.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" je_ > "${objroot}include/jemalloc/jemalloc_mangle.h"
1648], [
1649 srcdir="${srcdir}"
1650 objroot="${objroot}"
1651])
1652AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_mangle_jet.h], [
1653 mkdir -p "${objroot}include/jemalloc"
1654 "${srcdir}/include/jemalloc/jemalloc_mangle.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" jet_ > "${objroot}include/jemalloc/jemalloc_mangle_jet.h"
1655], [
1656 srcdir="${srcdir}"
1657 objroot="${objroot}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001658])
1659AC_CONFIG_COMMANDS([include/jemalloc/jemalloc.h], [
1660 mkdir -p "${objroot}include/jemalloc"
1661 "${srcdir}/include/jemalloc/jemalloc.sh" "${objroot}" > "${objroot}include/jemalloc/jemalloc${install_suffix}.h"
Jason Evansf234dc52014-01-16 17:38:01 -08001662], [
1663 srcdir="${srcdir}"
1664 objroot="${objroot}"
1665 install_suffix="${install_suffix}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001666])
Jason Evansb1726102012-02-28 16:50:47 -08001667
Jason Evansb7924f52009-06-23 19:01:18 -07001668dnl Process .in files.
Jason Evansb0fd5012010-01-17 01:49:20 -08001669AC_SUBST([cfghdrs_in])
1670AC_SUBST([cfghdrs_out])
Jason Evans0656ec02010-04-07 23:37:35 -07001671AC_CONFIG_HEADERS([$cfghdrs_tup])
Jason Evansb7924f52009-06-23 19:01:18 -07001672
1673dnl ============================================================================
1674dnl Generate outputs.
Jason Evans748dfac2013-12-06 18:27:33 -08001675
Jason Evans70417202015-05-01 12:31:12 -07001676AC_CONFIG_FILES([$cfgoutputs_tup config.stamp bin/jemalloc-config bin/jemalloc.sh bin/jeprof])
Jason Evansb0fd5012010-01-17 01:49:20 -08001677AC_SUBST([cfgoutputs_in])
1678AC_SUBST([cfgoutputs_out])
Jason Evansb7924f52009-06-23 19:01:18 -07001679AC_OUTPUT
1680
1681dnl ============================================================================
1682dnl Print out the results of configuration.
1683AC_MSG_RESULT([===============================================================================])
Jason Evansf576c632011-11-01 22:27:41 -07001684AC_MSG_RESULT([jemalloc version : ${jemalloc_version}])
1685AC_MSG_RESULT([library revision : ${rev}])
Jason Evansb7924f52009-06-23 19:01:18 -07001686AC_MSG_RESULT([])
Jason Evansbec6a8d2015-01-22 17:55:58 -08001687AC_MSG_RESULT([CONFIG : ${CONFIG}])
Jason Evansb7924f52009-06-23 19:01:18 -07001688AC_MSG_RESULT([CC : ${CC}])
Jason Evansb7924f52009-06-23 19:01:18 -07001689AC_MSG_RESULT([CFLAGS : ${CFLAGS}])
Jason Evansbec6a8d2015-01-22 17:55:58 -08001690AC_MSG_RESULT([CPPFLAGS : ${CPPFLAGS}])
Jason Evansb7924f52009-06-23 19:01:18 -07001691AC_MSG_RESULT([LDFLAGS : ${LDFLAGS}])
Jason Evans748dfac2013-12-06 18:27:33 -08001692AC_MSG_RESULT([EXTRA_LDFLAGS : ${EXTRA_LDFLAGS}])
Jason Evansb7924f52009-06-23 19:01:18 -07001693AC_MSG_RESULT([LIBS : ${LIBS}])
1694AC_MSG_RESULT([RPATH_EXTRA : ${RPATH_EXTRA}])
1695AC_MSG_RESULT([])
Jason Evansaee7fd22010-11-24 22:00:02 -08001696AC_MSG_RESULT([XSLTPROC : ${XSLTPROC}])
1697AC_MSG_RESULT([XSLROOT : ${XSLROOT}])
1698AC_MSG_RESULT([])
Jason Evansb7924f52009-06-23 19:01:18 -07001699AC_MSG_RESULT([PREFIX : ${PREFIX}])
1700AC_MSG_RESULT([BINDIR : ${BINDIR}])
Jason Evansbec6a8d2015-01-22 17:55:58 -08001701AC_MSG_RESULT([DATADIR : ${DATADIR}])
Jason Evans662a0172009-07-01 19:24:31 -07001702AC_MSG_RESULT([INCLUDEDIR : ${INCLUDEDIR}])
1703AC_MSG_RESULT([LIBDIR : ${LIBDIR}])
Jason Evansb7924f52009-06-23 19:01:18 -07001704AC_MSG_RESULT([MANDIR : ${MANDIR}])
1705AC_MSG_RESULT([])
1706AC_MSG_RESULT([srcroot : ${srcroot}])
1707AC_MSG_RESULT([abs_srcroot : ${abs_srcroot}])
1708AC_MSG_RESULT([objroot : ${objroot}])
1709AC_MSG_RESULT([abs_objroot : ${abs_objroot}])
1710AC_MSG_RESULT([])
Jason Evans90895cf2009-12-29 00:09:15 -08001711AC_MSG_RESULT([JEMALLOC_PREFIX : ${JEMALLOC_PREFIX}])
Jason Evans746e77a2011-07-30 16:40:52 -07001712AC_MSG_RESULT([JEMALLOC_PRIVATE_NAMESPACE])
1713AC_MSG_RESULT([ : ${JEMALLOC_PRIVATE_NAMESPACE}])
Jason Evansb0fd5012010-01-17 01:49:20 -08001714AC_MSG_RESULT([install_suffix : ${install_suffix}])
Jason Evansb7924f52009-06-23 19:01:18 -07001715AC_MSG_RESULT([autogen : ${enable_autogen}])
Jason Evans355b4382010-09-20 19:20:48 -07001716AC_MSG_RESULT([cc-silence : ${enable_cc_silence}])
Jason Evansb7924f52009-06-23 19:01:18 -07001717AC_MSG_RESULT([debug : ${enable_debug}])
Jason Evans748dfac2013-12-06 18:27:33 -08001718AC_MSG_RESULT([code-coverage : ${enable_code_coverage}])
Jason Evansb7924f52009-06-23 19:01:18 -07001719AC_MSG_RESULT([stats : ${enable_stats}])
Jason Evans6109fe02010-02-10 10:37:56 -08001720AC_MSG_RESULT([prof : ${enable_prof}])
1721AC_MSG_RESULT([prof-libunwind : ${enable_prof_libunwind}])
Jason Evans77f350b2011-03-15 22:23:12 -07001722AC_MSG_RESULT([prof-libgcc : ${enable_prof_libgcc}])
1723AC_MSG_RESULT([prof-gcc : ${enable_prof_gcc}])
Jason Evans84cbbcb2009-12-29 00:09:15 -08001724AC_MSG_RESULT([tcache : ${enable_tcache}])
Jason Evansb7924f52009-06-23 19:01:18 -07001725AC_MSG_RESULT([fill : ${enable_fill}])
Jason Evansb1476112012-04-05 13:36:17 -07001726AC_MSG_RESULT([utrace : ${enable_utrace}])
Jason Evans122449b2012-04-06 00:35:09 -07001727AC_MSG_RESULT([valgrind : ${enable_valgrind}])
1728AC_MSG_RESULT([xmalloc : ${enable_xmalloc}])
Jason Evans59ae2762012-04-16 17:52:27 -07001729AC_MSG_RESULT([munmap : ${enable_munmap}])
Jason Evansb7924f52009-06-23 19:01:18 -07001730AC_MSG_RESULT([lazy_lock : ${enable_lazy_lock}])
Jason Evans2dbecf12010-09-05 10:35:13 -07001731AC_MSG_RESULT([tls : ${enable_tls}])
Jason Evans8a03cf02015-05-04 09:58:36 -07001732AC_MSG_RESULT([cache-oblivious : ${enable_cache_oblivious}])
Jason Evansb7924f52009-06-23 19:01:18 -07001733AC_MSG_RESULT([===============================================================================])