blob: 2308b990df4d080c3d1997c361efe051f59366a5 [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)
884if test "x$enable_munmap" = "x1" ; then
885 AC_DEFINE([JEMALLOC_MUNMAP], [ ])
886fi
887AC_SUBST([enable_munmap])
888
Jason Evans4d434ad2014-04-15 12:09:48 -0700889dnl Enable allocation from DSS if supported by the OS.
890have_dss="1"
Mike Hommey83c324a2012-04-12 10:13:03 +0200891dnl Check whether the BSD/SUSv1 sbrk() exists. If not, disable DSS support.
892AC_CHECK_FUNC([sbrk], [have_sbrk="1"], [have_sbrk="0"])
893if test "x$have_sbrk" = "x1" ; then
Steven Stewart-Gallus79230fe2014-06-19 16:11:43 -0700894 if test "x$sbrk_deprecated" = "x1" ; then
Jason Evans66688532013-12-03 21:49:36 -0800895 AC_MSG_RESULT([Disabling dss allocation because sbrk is deprecated])
Jason Evans4d434ad2014-04-15 12:09:48 -0700896 have_dss="0"
Jason Evans66688532013-12-03 21:49:36 -0800897 fi
Mike Hommey83c324a2012-04-12 10:13:03 +0200898else
Jason Evans4d434ad2014-04-15 12:09:48 -0700899 have_dss="0"
Mike Hommey83c324a2012-04-12 10:13:03 +0200900fi
901
Jason Evans4d434ad2014-04-15 12:09:48 -0700902if test "x$have_dss" = "x1" ; then
Jason Evansb7924f52009-06-23 19:01:18 -0700903 AC_DEFINE([JEMALLOC_DSS], [ ])
904fi
Jason Evansb7924f52009-06-23 19:01:18 -0700905
Jason Evans777c1912012-02-28 20:49:22 -0800906dnl Support the junk/zero filling option by default.
Jason Evansb7924f52009-06-23 19:01:18 -0700907AC_ARG_ENABLE([fill],
Jason Evans122449b2012-04-06 00:35:09 -0700908 [AS_HELP_STRING([--disable-fill],
909 [Disable support for junk/zero filling, quarantine, and redzones])],
Jason Evansb7924f52009-06-23 19:01:18 -0700910[if test "x$enable_fill" = "xno" ; then
911 enable_fill="0"
912else
913 enable_fill="1"
914fi
915],
Jason Evans777c1912012-02-28 20:49:22 -0800916[enable_fill="1"]
Jason Evansb7924f52009-06-23 19:01:18 -0700917)
918if test "x$enable_fill" = "x1" ; then
919 AC_DEFINE([JEMALLOC_FILL], [ ])
920fi
921AC_SUBST([enable_fill])
922
Jason Evansb1476112012-04-05 13:36:17 -0700923dnl Disable utrace(2)-based tracing by default.
924AC_ARG_ENABLE([utrace],
925 [AS_HELP_STRING([--enable-utrace], [Enable utrace(2)-based tracing])],
926[if test "x$enable_utrace" = "xno" ; then
927 enable_utrace="0"
928else
929 enable_utrace="1"
930fi
931],
932[enable_utrace="0"]
933)
934JE_COMPILABLE([utrace(2)], [
935#include <sys/types.h>
936#include <sys/param.h>
937#include <sys/time.h>
938#include <sys/uio.h>
939#include <sys/ktrace.h>
940], [
941 utrace((void *)0, 0);
942], [je_cv_utrace])
943if test "x${je_cv_utrace}" = "xno" ; then
944 enable_utrace="0"
945fi
946if test "x$enable_utrace" = "x1" ; then
947 AC_DEFINE([JEMALLOC_UTRACE], [ ])
948fi
949AC_SUBST([enable_utrace])
950
Jason Evans122449b2012-04-06 00:35:09 -0700951dnl Support Valgrind by default.
952AC_ARG_ENABLE([valgrind],
953 [AS_HELP_STRING([--disable-valgrind], [Disable support for Valgrind])],
954[if test "x$enable_valgrind" = "xno" ; then
955 enable_valgrind="0"
956else
957 enable_valgrind="1"
958fi
959],
960[enable_valgrind="1"]
961)
962if test "x$enable_valgrind" = "x1" ; then
963 JE_COMPILABLE([valgrind], [
964#include <valgrind/valgrind.h>
965#include <valgrind/memcheck.h>
966
Mike Hommey7bfecf42012-04-30 15:15:15 +0200967#if !defined(VALGRIND_RESIZEINPLACE_BLOCK)
Jason Evans122449b2012-04-06 00:35:09 -0700968# error "Incompatible Valgrind version"
969#endif
970], [], [je_cv_valgrind])
971 if test "x${je_cv_valgrind}" = "xno" ; then
972 enable_valgrind="0"
973 fi
974 if test "x$enable_valgrind" = "x1" ; then
975 AC_DEFINE([JEMALLOC_VALGRIND], [ ])
976 fi
977fi
978AC_SUBST([enable_valgrind])
979
Jason Evansb7924f52009-06-23 19:01:18 -0700980dnl Do not support the xmalloc option by default.
981AC_ARG_ENABLE([xmalloc],
982 [AS_HELP_STRING([--enable-xmalloc], [Support xmalloc option])],
983[if test "x$enable_xmalloc" = "xno" ; then
984 enable_xmalloc="0"
985else
986 enable_xmalloc="1"
987fi
988],
989[enable_xmalloc="0"]
990)
991if test "x$enable_xmalloc" = "x1" ; then
992 AC_DEFINE([JEMALLOC_XMALLOC], [ ])
993fi
994AC_SUBST([enable_xmalloc])
995
Jason Evans8a03cf02015-05-04 09:58:36 -0700996dnl Support cache-oblivious allocation alignment by default.
997AC_ARG_ENABLE([cache-oblivious],
998 [AS_HELP_STRING([--disable-cache-oblivious],
999 [Disable support for cache-oblivious allocation alignment])],
1000[if test "x$enable_cache_oblivious" = "xno" ; then
1001 enable_cache_oblivious="0"
1002else
1003 enable_cache_oblivious="1"
1004fi
1005],
1006[enable_cache_oblivious="1"]
1007)
1008if test "x$enable_cache_oblivious" = "x1" ; then
1009 AC_DEFINE([JEMALLOC_CACHE_OBLIVIOUS], [ ])
1010fi
1011AC_SUBST([enable_cache_oblivious])
1012
Mike Hommey8f50ec82014-06-04 12:12:55 +09001013dnl ============================================================================
1014dnl Check for __builtin_ffsl(), then ffsl(3), and fail if neither are found.
1015dnl One of those two functions should (theoretically) exist on all platforms
1016dnl that jemalloc currently has a chance of functioning on without modification.
1017dnl We additionally assume ffs() or __builtin_ffs() are defined if
1018dnl ffsl() or __builtin_ffsl() are defined, respectively.
1019JE_COMPILABLE([a program using __builtin_ffsl], [
1020#include <stdio.h>
1021#include <strings.h>
1022#include <string.h>
1023], [
1024 {
1025 int rv = __builtin_ffsl(0x08);
1026 printf("%d\n", rv);
1027 }
1028], [je_cv_gcc_builtin_ffsl])
Steven Stewart-Gallus79230fe2014-06-19 16:11:43 -07001029if test "x${je_cv_gcc_builtin_ffsl}" = "xyes" ; then
Mike Hommey8f50ec82014-06-04 12:12:55 +09001030 AC_DEFINE([JEMALLOC_INTERNAL_FFSL], [__builtin_ffsl])
1031 AC_DEFINE([JEMALLOC_INTERNAL_FFS], [__builtin_ffs])
1032else
1033 JE_COMPILABLE([a program using ffsl], [
1034 #include <stdio.h>
1035 #include <strings.h>
1036 #include <string.h>
1037 ], [
1038 {
1039 int rv = ffsl(0x08);
1040 printf("%d\n", rv);
1041 }
1042 ], [je_cv_function_ffsl])
Steven Stewart-Gallus79230fe2014-06-19 16:11:43 -07001043 if test "x${je_cv_function_ffsl}" = "xyes" ; then
Mike Hommey8f50ec82014-06-04 12:12:55 +09001044 AC_DEFINE([JEMALLOC_INTERNAL_FFSL], [ffsl])
1045 AC_DEFINE([JEMALLOC_INTERNAL_FFS], [ffs])
1046 else
1047 AC_MSG_ERROR([Cannot build without ffsl(3) or __builtin_ffsl()])
1048 fi
1049fi
1050
Jason Evans81e54752014-10-10 22:34:25 -07001051AC_ARG_WITH([lg_tiny_min],
1052 [AS_HELP_STRING([--with-lg-tiny-min=<lg-tiny-min>],
1053 [Base 2 log of minimum tiny size class to support])],
1054 [LG_TINY_MIN="$with_lg_tiny_min"],
1055 [LG_TINY_MIN="3"])
1056AC_DEFINE_UNQUOTED([LG_TINY_MIN], [$LG_TINY_MIN])
1057
Jason Evansfc0b3b72014-10-09 17:54:06 -07001058AC_ARG_WITH([lg_quantum],
1059 [AS_HELP_STRING([--with-lg-quantum=<lg-quantum>],
1060 [Base 2 log of minimum allocation alignment])],
Jason Evans81e54752014-10-10 22:34:25 -07001061 [LG_QUANTA="$with_lg_quantum"],
1062 [LG_QUANTA="3 4"])
1063if test "x$with_lg_quantum" != "x" ; then
1064 AC_DEFINE_UNQUOTED([LG_QUANTUM], [$with_lg_quantum])
1065fi
Jason Evansfc0b3b72014-10-09 17:54:06 -07001066
1067AC_ARG_WITH([lg_page],
1068 [AS_HELP_STRING([--with-lg-page=<lg-page>], [Base 2 log of system page size])],
1069 [LG_PAGE="$with_lg_page"], [LG_PAGE="detect"])
Jason Evansb0808d52015-02-03 12:39:31 -08001070if test "x$LG_PAGE" = "xdetect"; then
Jason Evansfc0b3b72014-10-09 17:54:06 -07001071 AC_CACHE_CHECK([LG_PAGE],
1072 [je_cv_lg_page],
Jason Evans6684cac2012-03-05 12:15:36 -08001073 AC_RUN_IFELSE([AC_LANG_PROGRAM(
Mike Hommeya19e87f2012-04-21 21:27:46 -07001074[[
Mike Hommeyfd97b1d2012-04-30 12:38:31 +02001075#include <strings.h>
Mike Hommeya19e87f2012-04-21 21:27:46 -07001076#ifdef _WIN32
1077#include <windows.h>
1078#else
Jason Evansb7924f52009-06-23 19:01:18 -07001079#include <unistd.h>
Mike Hommeya19e87f2012-04-21 21:27:46 -07001080#endif
1081#include <stdio.h>
Jason Evans6684cac2012-03-05 12:15:36 -08001082]],
1083[[
Garrett Cooper72c1e592012-12-02 17:57:28 -08001084 int result;
Jason Evansb7924f52009-06-23 19:01:18 -07001085 FILE *f;
1086
Mike Hommeya19e87f2012-04-21 21:27:46 -07001087#ifdef _WIN32
1088 SYSTEM_INFO si;
1089 GetSystemInfo(&si);
1090 result = si.dwPageSize;
1091#else
Jason Evansb7924f52009-06-23 19:01:18 -07001092 result = sysconf(_SC_PAGESIZE);
Mike Hommeya19e87f2012-04-21 21:27:46 -07001093#endif
Jason Evansb7924f52009-06-23 19:01:18 -07001094 if (result == -1) {
1095 return 1;
1096 }
Mike Hommey8f50ec82014-06-04 12:12:55 +09001097 result = JEMALLOC_INTERNAL_FFSL(result) - 1;
Mike Hommeya19e87f2012-04-21 21:27:46 -07001098
Jason Evansb7924f52009-06-23 19:01:18 -07001099 f = fopen("conftest.out", "w");
1100 if (f == NULL) {
1101 return 1;
1102 }
Garrett Cooper72c1e592012-12-02 17:57:28 -08001103 fprintf(f, "%d\n", result);
Jason Evans3cc1f1a2012-04-03 22:30:05 -07001104 fclose(f);
Jason Evansb7924f52009-06-23 19:01:18 -07001105
1106 return 0;
1107]])],
Jason Evansfc0b3b72014-10-09 17:54:06 -07001108 [je_cv_lg_page=`cat conftest.out`],
1109 [je_cv_lg_page=undefined],
1110 [je_cv_lg_page=12]))
Jason Evans6684cac2012-03-05 12:15:36 -08001111fi
Jason Evansfc0b3b72014-10-09 17:54:06 -07001112if test "x${je_cv_lg_page}" != "x" ; then
1113 LG_PAGE="${je_cv_lg_page}"
1114fi
1115if test "x${LG_PAGE}" != "xundefined" ; then
1116 AC_DEFINE_UNQUOTED([LG_PAGE], [$LG_PAGE])
1117else
1118 AC_MSG_ERROR([cannot determine value for LG_PAGE])
1119fi
1120
1121AC_ARG_WITH([lg_page_sizes],
1122 [AS_HELP_STRING([--with-lg-page-sizes=<lg-page-sizes>],
1123 [Base 2 logs of system page sizes to support])],
1124 [LG_PAGE_SIZES="$with_lg_page_sizes"], [LG_PAGE_SIZES="$LG_PAGE"])
1125
1126AC_ARG_WITH([lg_size_class_group],
1127 [AS_HELP_STRING([--with-lg-size-class-group=<lg-size-class-group>],
1128 [Base 2 log of size classes per doubling])],
1129 [LG_SIZE_CLASS_GROUP="$with_lg_size_class_group"],
1130 [LG_SIZE_CLASS_GROUP="2"])
Jason Evansb7924f52009-06-23 19:01:18 -07001131
1132dnl ============================================================================
1133dnl jemalloc configuration.
1134dnl
Jason Evansa40bc7a2010-03-02 13:01:16 -08001135
Jason Evansa5a658a2014-09-02 15:07:07 -07001136dnl Set VERSION if source directory is inside a git repository.
Dan McGregorf8880312014-12-23 16:10:08 -06001137if 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 -07001138 dnl Pattern globs aren't powerful enough to match both single- and
1139 dnl double-digit version numbers, so iterate over patterns to support up to
1140 dnl version 99.99.99 without any accidental matches.
Dan McGregorf8880312014-12-23 16:10:08 -06001141 rm -f "${objroot}VERSION"
Jason Evansa5a658a2014-09-02 15:07:07 -07001142 for pattern in ['[0-9].[0-9].[0-9]' '[0-9].[0-9].[0-9][0-9]' \
1143 '[0-9].[0-9][0-9].[0-9]' '[0-9].[0-9][0-9].[0-9][0-9]' \
1144 '[0-9][0-9].[0-9].[0-9]' '[0-9][0-9].[0-9].[0-9][0-9]' \
1145 '[0-9][0-9].[0-9][0-9].[0-9]' \
1146 '[0-9][0-9].[0-9][0-9].[0-9][0-9]']; do
Dan McGregorf8880312014-12-23 16:10:08 -06001147 if test ! -e "${objroot}VERSION" ; then
1148 (test ! "${srcroot}" && cd "${srcroot}"; git describe --long --abbrev=40 --match="${pattern}") > "${objroot}VERSION.tmp" 2>/dev/null
Jason Evansa5a658a2014-09-02 15:07:07 -07001149 if test $? -eq 0 ; then
Dan McGregorf8880312014-12-23 16:10:08 -06001150 mv "${objroot}VERSION.tmp" "${objroot}VERSION"
Jason Evansa5a658a2014-09-02 15:07:07 -07001151 break
1152 fi
1153 fi
1154 done
Jason Evansa40bc7a2010-03-02 13:01:16 -08001155fi
Dan McGregorf8880312014-12-23 16:10:08 -06001156rm -f "${objroot}VERSION.tmp"
1157if test ! -e "${objroot}VERSION" ; then
1158 if test ! -e "${srcroot}VERSION" ; then
1159 AC_MSG_RESULT(
1160 [Missing VERSION file, and unable to generate it; creating bogus VERSION])
1161 echo "0.0.0-0-g0000000000000000000000000000000000000000" > "${objroot}VERSION"
1162 else
1163 cp ${srcroot}VERSION ${objroot}VERSION
1164 fi
Jason Evansa5a658a2014-09-02 15:07:07 -07001165fi
Dan McGregorf8880312014-12-23 16:10:08 -06001166jemalloc_version=`cat "${objroot}VERSION"`
Jason Evansa40bc7a2010-03-02 13:01:16 -08001167jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'`
1168jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'`
1169jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'`
1170jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'`
1171jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'`
Jason Evansb7924f52009-06-23 19:01:18 -07001172AC_SUBST([jemalloc_version])
Jason Evansa40bc7a2010-03-02 13:01:16 -08001173AC_SUBST([jemalloc_version_major])
1174AC_SUBST([jemalloc_version_minor])
1175AC_SUBST([jemalloc_version_bugfix])
1176AC_SUBST([jemalloc_version_nrev])
1177AC_SUBST([jemalloc_version_gid])
Jason Evansb7924f52009-06-23 19:01:18 -07001178
1179dnl ============================================================================
1180dnl Configure pthreads.
1181
Mike Hommeya19e87f2012-04-21 21:27:46 -07001182if test "x$abi" != "xpecoff" ; then
1183 AC_CHECK_HEADERS([pthread.h], , [AC_MSG_ERROR([pthread.h is missing])])
1184 dnl Some systems may embed pthreads functionality in libc; check for libpthread
1185 dnl first, but try libc too before failing.
1186 AC_CHECK_LIB([pthread], [pthread_create], [LIBS="$LIBS -lpthread"],
1187 [AC_SEARCH_LIBS([pthread_create], , ,
1188 AC_MSG_ERROR([libpthread is missing]))])
1189fi
Jason Evansb7924f52009-06-23 19:01:18 -07001190
1191CPPFLAGS="$CPPFLAGS -D_REENTRANT"
1192
Daniel Micayb74041f2014-12-09 17:41:34 -05001193dnl Check if the GNU-specific secure_getenv function exists.
1194AC_CHECK_FUNC([secure_getenv],
1195 [have_secure_getenv="1"],
1196 [have_secure_getenv="0"]
1197 )
1198if test "x$have_secure_getenv" = "x1" ; then
1199 AC_DEFINE([JEMALLOC_HAVE_SECURE_GETENV], [ ])
1200fi
1201
1202dnl Check if the Solaris/BSD issetugid function exists.
1203AC_CHECK_FUNC([issetugid],
1204 [have_issetugid="1"],
1205 [have_issetugid="0"]
1206 )
1207if test "x$have_issetugid" = "x1" ; then
1208 AC_DEFINE([JEMALLOC_HAVE_ISSETUGID], [ ])
1209fi
1210
Jason Evanscd9a1342012-03-21 18:33:03 -07001211dnl Check whether the BSD-specific _malloc_thread_cleanup() exists. If so, use
1212dnl it rather than pthreads TSD cleanup functions to support cleanup during
1213dnl thread exit, in order to avoid pthreads library recursion during
1214dnl bootstrapping.
Jason Evanscd9a1342012-03-21 18:33:03 -07001215AC_CHECK_FUNC([_malloc_thread_cleanup],
1216 [have__malloc_thread_cleanup="1"],
1217 [have__malloc_thread_cleanup="0"]
1218 )
1219if test "x$have__malloc_thread_cleanup" = "x1" ; then
1220 AC_DEFINE([JEMALLOC_MALLOC_THREAD_CLEANUP], [ ])
1221 force_tls="1"
1222fi
1223
Jason Evans41b6afb2012-02-02 22:04:57 -08001224dnl Check whether the BSD-specific _pthread_mutex_init_calloc_cb() exists. If
1225dnl so, mutex initialization causes allocation, and we need to implement this
1226dnl callback function in order to prevent recursive allocation.
1227AC_CHECK_FUNC([_pthread_mutex_init_calloc_cb],
1228 [have__pthread_mutex_init_calloc_cb="1"],
1229 [have__pthread_mutex_init_calloc_cb="0"]
1230 )
1231if test "x$have__pthread_mutex_init_calloc_cb" = "x1" ; then
1232 AC_DEFINE([JEMALLOC_MUTEX_INIT_CB])
1233fi
1234
Jason Evans0fee70d2012-02-13 12:36:11 -08001235dnl Disable lazy locking by default.
Jason Evansb7924f52009-06-23 19:01:18 -07001236AC_ARG_ENABLE([lazy_lock],
Jason Evans0fee70d2012-02-13 12:36:11 -08001237 [AS_HELP_STRING([--enable-lazy-lock],
1238 [Enable lazy locking (only lock when multi-threaded)])],
Jason Evansb7924f52009-06-23 19:01:18 -07001239[if test "x$enable_lazy_lock" = "xno" ; then
1240 enable_lazy_lock="0"
1241else
1242 enable_lazy_lock="1"
1243fi
1244],
Mike Hommeyac5db022015-08-11 14:01:59 +09001245[enable_lazy_lock=""]
Jason Evansb7924f52009-06-23 19:01:18 -07001246)
Mike Hommeyac5db022015-08-11 14:01:59 +09001247if test "x$enable_lazy_lock" = "x" -a "x${force_lazy_lock}" = "x1" ; then
Jason Evansfd4fcef2012-03-23 17:40:58 -07001248 AC_MSG_RESULT([Forcing lazy-lock to avoid allocator/threading bootstrap issues])
1249 enable_lazy_lock="1"
1250fi
Jason Evansb7924f52009-06-23 19:01:18 -07001251if test "x$enable_lazy_lock" = "x1" ; then
Mike Hommeya19e87f2012-04-21 21:27:46 -07001252 if test "x$abi" != "xpecoff" ; then
1253 AC_CHECK_HEADERS([dlfcn.h], , [AC_MSG_ERROR([dlfcn.h is missing])])
1254 AC_CHECK_FUNC([dlsym], [],
1255 [AC_CHECK_LIB([dl], [dlsym], [LIBS="$LIBS -ldl"],
1256 [AC_MSG_ERROR([libdl is missing])])
1257 ])
1258 fi
Jason Evansb7924f52009-06-23 19:01:18 -07001259 AC_DEFINE([JEMALLOC_LAZY_LOCK], [ ])
Mike Hommeyac5db022015-08-11 14:01:59 +09001260else
1261 enable_lazy_lock="0"
Jason Evansb7924f52009-06-23 19:01:18 -07001262fi
1263AC_SUBST([enable_lazy_lock])
1264
Jason Evans78d815c2010-01-17 14:06:20 -08001265AC_ARG_ENABLE([tls],
1266 [AS_HELP_STRING([--disable-tls], [Disable thread-local storage (__thread keyword)])],
1267if test "x$enable_tls" = "xno" ; then
1268 enable_tls="0"
1269else
1270 enable_tls="1"
1271fi
1272,
Mike Hommeyac5db022015-08-11 14:01:59 +09001273enable_tls=""
Jason Evans78d815c2010-01-17 14:06:20 -08001274)
Jason Evansc0f43b62015-09-02 12:46:35 -07001275if test "x${enable_tls}" = "x" ; then
1276 if test "x${force_tls}" = "x1" ; then
1277 AC_MSG_RESULT([Forcing TLS to avoid allocator/threading bootstrap issues])
1278 enable_tls="1"
1279 elif test "x${force_tls}" = "x0" ; then
1280 AC_MSG_RESULT([Forcing no TLS to avoid allocator/threading bootstrap issues])
1281 enable_tls="0"
1282 else
1283 enable_tls="1"
1284 fi
Jason Evansb80581d2012-03-23 16:17:43 -07001285fi
Jason Evans78d815c2010-01-17 14:06:20 -08001286if test "x${enable_tls}" = "x1" ; then
1287AC_MSG_CHECKING([for TLS])
Jason Evans6684cac2012-03-05 12:15:36 -08001288AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Jason Evans78d815c2010-01-17 14:06:20 -08001289[[
1290 __thread int x;
1291]], [[
1292 x = 42;
1293
1294 return 0;
1295]])],
1296 AC_MSG_RESULT([yes]),
1297 AC_MSG_RESULT([no])
1298 enable_tls="0")
Mike Hommeyac5db022015-08-11 14:01:59 +09001299else
1300 enable_tls="0"
Jason Evans78d815c2010-01-17 14:06:20 -08001301fi
Jason Evansb267d0f2010-08-13 15:42:29 -07001302AC_SUBST([enable_tls])
Jason Evanse24c7af2012-03-19 10:21:17 -07001303if test "x${enable_tls}" = "x1" ; then
Jason Evansc0f43b62015-09-02 12:46:35 -07001304 if test "x${force_tls}" = "x0" ; then
1305 AC_MSG_WARN([TLS enabled despite being marked unusable on this platform])
1306 fi
Jason Evanse24c7af2012-03-19 10:21:17 -07001307 AC_DEFINE_UNQUOTED([JEMALLOC_TLS], [ ])
Jason Evanscd9a1342012-03-21 18:33:03 -07001308elif test "x${force_tls}" = "x1" ; then
Jason Evansc0f43b62015-09-02 12:46:35 -07001309 AC_MSG_WARN([TLS disabled despite being marked critical on this platform])
Jason Evans78d815c2010-01-17 14:06:20 -08001310fi
1311
Jason Evans2dbecf12010-09-05 10:35:13 -07001312dnl ============================================================================
Chih-hung Hsieh59cd80e2014-12-05 17:42:41 -08001313dnl Check for C11 atomics.
1314
1315JE_COMPILABLE([C11 atomics], [
1316#include <stdint.h>
1317#if (__STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_ATOMICS__)
1318#include <stdatomic.h>
1319#else
1320#error Atomics not available
1321#endif
1322], [
1323 uint64_t *p = (uint64_t *)0;
1324 uint64_t x = 1;
1325 volatile atomic_uint_least64_t *a = (volatile atomic_uint_least64_t *)p;
1326 uint64_t r = atomic_fetch_add(a, x) + x;
1327 return (r == 0);
1328], [je_cv_c11atomics])
1329if test "x${je_cv_c11atomics}" = "xyes" ; then
1330 AC_DEFINE([JEMALLOC_C11ATOMICS])
1331fi
1332
1333dnl ============================================================================
Jason Evansb57d3ec2012-04-17 13:17:54 -07001334dnl Check for atomic(9) operations as provided on FreeBSD.
1335
1336JE_COMPILABLE([atomic(9)], [
1337#include <sys/types.h>
1338#include <machine/atomic.h>
1339#include <inttypes.h>
1340], [
1341 {
1342 uint32_t x32 = 0;
1343 volatile uint32_t *x32p = &x32;
1344 atomic_fetchadd_32(x32p, 1);
1345 }
1346 {
1347 unsigned long xlong = 0;
1348 volatile unsigned long *xlongp = &xlong;
1349 atomic_fetchadd_long(xlongp, 1);
1350 }
1351], [je_cv_atomic9])
1352if test "x${je_cv_atomic9}" = "xyes" ; then
1353 AC_DEFINE([JEMALLOC_ATOMIC9])
1354fi
1355
1356dnl ============================================================================
Jason Evans763baa62011-03-18 19:10:31 -07001357dnl Check for atomic(3) operations as provided on Darwin.
1358
1359JE_COMPILABLE([Darwin OSAtomic*()], [
1360#include <libkern/OSAtomic.h>
1361#include <inttypes.h>
1362], [
1363 {
1364 int32_t x32 = 0;
1365 volatile int32_t *x32p = &x32;
1366 OSAtomicAdd32(1, x32p);
1367 }
1368 {
1369 int64_t x64 = 0;
1370 volatile int64_t *x64p = &x64;
1371 OSAtomicAdd64(1, x64p);
1372 }
Jason Evans6684cac2012-03-05 12:15:36 -08001373], [je_cv_osatomic])
1374if test "x${je_cv_osatomic}" = "xyes" ; then
Jason Evanse24c7af2012-03-19 10:21:17 -07001375 AC_DEFINE([JEMALLOC_OSATOMIC], [ ])
Jason Evans763baa62011-03-18 19:10:31 -07001376fi
1377
1378dnl ============================================================================
Richard Diamond994fad92014-06-03 02:39:18 -05001379dnl Check for madvise(2).
1380
1381JE_COMPILABLE([madvise(2)], [
1382#include <sys/mman.h>
1383], [
1384 {
1385 madvise((void *)0, 0, 0);
1386 }
1387], [je_cv_madvise])
1388if test "x${je_cv_madvise}" = "xyes" ; then
1389 AC_DEFINE([JEMALLOC_HAVE_MADVISE], [ ])
1390fi
1391
1392dnl ============================================================================
Mike Hommeyc1e567b2012-03-26 17:03:41 +02001393dnl Check whether __sync_{add,sub}_and_fetch() are available despite
1394dnl __GCC_HAVE_SYNC_COMPARE_AND_SWAP_n macros being undefined.
1395
1396AC_DEFUN([JE_SYNC_COMPARE_AND_SWAP_CHECK],[
1397 AC_CACHE_CHECK([whether to force $1-bit __sync_{add,sub}_and_fetch()],
1398 [je_cv_sync_compare_and_swap_$2],
Mike Hommey2cfe6d62012-03-27 15:03:07 +02001399 [AC_LINK_IFELSE([AC_LANG_PROGRAM([
1400 #include <stdint.h>
1401 ],
1402 [
1403 #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2
1404 {
1405 uint$1_t x$1 = 0;
1406 __sync_add_and_fetch(&x$1, 42);
1407 __sync_sub_and_fetch(&x$1, 1);
1408 }
1409 #else
1410 #error __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2 is defined, no need to force
1411 #endif
1412 ])],
Mike Hommeyc1e567b2012-03-26 17:03:41 +02001413 [je_cv_sync_compare_and_swap_$2=yes],
1414 [je_cv_sync_compare_and_swap_$2=no])])
1415
1416 if test "x${je_cv_sync_compare_and_swap_$2}" = "xyes" ; then
1417 AC_DEFINE([JE_FORCE_SYNC_COMPARE_AND_SWAP_$2], [ ])
1418 fi
1419])
1420
Jason Evansb57d3ec2012-04-17 13:17:54 -07001421if test "x${je_cv_atomic9}" != "xyes" -a "x${je_cv_osatomic}" != "xyes" ; then
Mike Hommeyc1e567b2012-03-26 17:03:41 +02001422 JE_SYNC_COMPARE_AND_SWAP_CHECK(32, 4)
1423 JE_SYNC_COMPARE_AND_SWAP_CHECK(64, 8)
1424fi
1425
1426dnl ============================================================================
Jason Evansd04047c2014-05-28 16:11:55 -07001427dnl Check for __builtin_clz() and __builtin_clzl().
1428
1429AC_CACHE_CHECK([for __builtin_clz],
1430 [je_cv_builtin_clz],
1431 [AC_LINK_IFELSE([AC_LANG_PROGRAM([],
1432 [
1433 {
1434 unsigned x = 0;
1435 int y = __builtin_clz(x);
1436 }
1437 {
1438 unsigned long x = 0;
1439 int y = __builtin_clzl(x);
1440 }
1441 ])],
1442 [je_cv_builtin_clz=yes],
1443 [je_cv_builtin_clz=no])])
1444
1445if test "x${je_cv_builtin_clz}" = "xyes" ; then
1446 AC_DEFINE([JEMALLOC_HAVE_BUILTIN_CLZ], [ ])
1447fi
1448
1449dnl ============================================================================
Jason Evans893a0ed2011-03-18 19:30:18 -07001450dnl Check for spinlock(3) operations as provided on Darwin.
1451
1452JE_COMPILABLE([Darwin OSSpin*()], [
1453#include <libkern/OSAtomic.h>
1454#include <inttypes.h>
1455], [
1456 OSSpinLock lock = 0;
1457 OSSpinLockLock(&lock);
1458 OSSpinLockUnlock(&lock);
Jason Evans6684cac2012-03-05 12:15:36 -08001459], [je_cv_osspin])
1460if test "x${je_cv_osspin}" = "xyes" ; then
Jason Evanse24c7af2012-03-19 10:21:17 -07001461 AC_DEFINE([JEMALLOC_OSSPIN], [ ])
Jason Evans893a0ed2011-03-18 19:30:18 -07001462fi
1463
1464dnl ============================================================================
Jason Evans2dbecf12010-09-05 10:35:13 -07001465dnl Darwin-related configuration.
Jason Evans78d815c2010-01-17 14:06:20 -08001466
Mike Hommeyd0357f72012-11-26 18:52:41 +01001467AC_ARG_ENABLE([zone-allocator],
1468 [AS_HELP_STRING([--disable-zone-allocator],
1469 [Disable zone allocator for Darwin])],
1470[if test "x$enable_zone_allocator" = "xno" ; then
1471 enable_zone_allocator="0"
1472else
1473 enable_zone_allocator="1"
1474fi
1475],
1476[if test "x${abi}" = "xmacho"; then
1477 enable_zone_allocator="1"
1478fi
1479]
1480)
1481AC_SUBST([enable_zone_allocator])
1482
1483if test "x${enable_zone_allocator}" = "x1" ; then
1484 if test "x${abi}" != "xmacho"; then
1485 AC_MSG_ERROR([--enable-zone-allocator is only supported on Darwin])
1486 fi
Jason Evanse24c7af2012-03-19 10:21:17 -07001487 AC_DEFINE([JEMALLOC_ZONE], [ ])
Jason Evans6109fe02010-02-10 10:37:56 -08001488
Jason Evans2dbecf12010-09-05 10:35:13 -07001489 dnl The szone version jumped from 3 to 6 between the OS X 10.5.x and 10.6
1490 dnl releases. malloc_zone_t and malloc_introspection_t have new fields in
1491 dnl 10.6, which is the only source-level indication of the change.
1492 AC_MSG_CHECKING([malloc zone version])
Mike Hommey154829d2012-03-20 18:01:38 +01001493 AC_DEFUN([JE_ZONE_PROGRAM],
1494 [AC_LANG_PROGRAM(
1495 [#include <malloc/malloc.h>],
Guilherme Goncalves79725aa2014-10-20 14:08:37 -02001496 [static int foo[[sizeof($1) $2 sizeof(void *) * $3 ? 1 : -1]]]
Mike Hommey154829d2012-03-20 18:01:38 +01001497 )])
Jason Evans2dbecf12010-09-05 10:35:13 -07001498
Mike Hommey154829d2012-03-20 18:01:38 +01001499 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,14)],[JEMALLOC_ZONE_VERSION=3],[
1500 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,15)],[JEMALLOC_ZONE_VERSION=5],[
1501 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,16)],[
1502 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,9)],[JEMALLOC_ZONE_VERSION=6],[
1503 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,13)],[JEMALLOC_ZONE_VERSION=7],[JEMALLOC_ZONE_VERSION=]
1504 )])],[
1505 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,17)],[JEMALLOC_ZONE_VERSION=8],[
1506 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,>,17)],[JEMALLOC_ZONE_VERSION=9],[JEMALLOC_ZONE_VERSION=]
1507 )])])])])
1508 if test "x${JEMALLOC_ZONE_VERSION}" = "x"; then
1509 AC_MSG_RESULT([unsupported])
1510 AC_MSG_ERROR([Unsupported malloc zone version])
1511 fi
1512 if test "${JEMALLOC_ZONE_VERSION}" = 9; then
1513 JEMALLOC_ZONE_VERSION=8
1514 AC_MSG_RESULT([> 8])
1515 else
1516 AC_MSG_RESULT([$JEMALLOC_ZONE_VERSION])
1517 fi
1518 AC_DEFINE_UNQUOTED(JEMALLOC_ZONE_VERSION, [$JEMALLOC_ZONE_VERSION])
Jason Evansb27805b2010-02-10 18:15:53 -08001519fi
1520
Jason Evansb7924f52009-06-23 19:01:18 -07001521dnl ============================================================================
Sara Golemon3e24afa2014-08-18 13:06:39 -07001522dnl Check for glibc malloc hooks
1523
1524JE_COMPILABLE([glibc malloc hook], [
1525#include <stddef.h>
1526
1527extern void (* __free_hook)(void *ptr);
1528extern void *(* __malloc_hook)(size_t size);
1529extern void *(* __realloc_hook)(void *ptr, size_t size);
1530], [
1531 void *ptr = 0L;
1532 if (__malloc_hook) ptr = __malloc_hook(1);
1533 if (__realloc_hook) ptr = __realloc_hook(ptr, 2);
1534 if (__free_hook && ptr) __free_hook(ptr);
1535], [je_cv_glibc_malloc_hook])
1536if test "x${je_cv_glibc_malloc_hook}" = "xyes" ; then
1537 AC_DEFINE([JEMALLOC_GLIBC_MALLOC_HOOK], [ ])
1538fi
1539
1540JE_COMPILABLE([glibc memalign hook], [
1541#include <stddef.h>
1542
1543extern void *(* __memalign_hook)(size_t alignment, size_t size);
1544], [
1545 void *ptr = 0L;
1546 if (__memalign_hook) ptr = __memalign_hook(16, 7);
1547], [je_cv_glibc_memalign_hook])
1548if test "x${je_cv_glibc_memalign_hook}" = "xyes" ; then
1549 AC_DEFINE([JEMALLOC_GLIBC_MEMALIGN_HOOK], [ ])
1550fi
1551
Eric Wong4dcf04b2014-08-31 03:57:06 +00001552JE_COMPILABLE([pthreads adaptive mutexes], [
1553#include <pthread.h>
1554], [
1555 pthread_mutexattr_t attr;
1556 pthread_mutexattr_init(&attr);
1557 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ADAPTIVE_NP);
1558 pthread_mutexattr_destroy(&attr);
1559], [je_cv_pthread_mutex_adaptive_np])
1560if test "x${je_cv_pthread_mutex_adaptive_np}" = "xyes" ; then
1561 AC_DEFINE([JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], [ ])
1562fi
1563
Sara Golemon3e24afa2014-08-18 13:06:39 -07001564dnl ============================================================================
Jason Evansb7924f52009-06-23 19:01:18 -07001565dnl Check for typedefs, structures, and compiler characteristics.
1566AC_HEADER_STDBOOL
1567
Jason Evans748dfac2013-12-06 18:27:33 -08001568dnl ============================================================================
1569dnl Define commands that generate output files.
1570
Jason Evans86abd0d2013-11-30 15:25:42 -08001571AC_CONFIG_COMMANDS([include/jemalloc/internal/private_namespace.h], [
1572 mkdir -p "${objroot}include/jemalloc/internal"
1573 "${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 -08001574], [
1575 srcdir="${srcdir}"
1576 objroot="${objroot}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001577])
1578AC_CONFIG_COMMANDS([include/jemalloc/internal/private_unnamespace.h], [
1579 mkdir -p "${objroot}include/jemalloc/internal"
1580 "${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 -08001581], [
1582 srcdir="${srcdir}"
1583 objroot="${objroot}"
1584])
1585AC_CONFIG_COMMANDS([include/jemalloc/internal/public_symbols.txt], [
1586 f="${objroot}include/jemalloc/internal/public_symbols.txt"
1587 mkdir -p "${objroot}include/jemalloc/internal"
1588 cp /dev/null "${f}"
1589 for nm in `echo ${mangling_map} |tr ',' ' '` ; do
1590 n=`echo ${nm} |tr ':' ' ' |awk '{print $[]1}'`
1591 m=`echo ${nm} |tr ':' ' ' |awk '{print $[]2}'`
1592 echo "${n}:${m}" >> "${f}"
1593 dnl Remove name from public_syms so that it isn't redefined later.
1594 public_syms=`for sym in ${public_syms}; do echo "${sym}"; done |grep -v "^${n}\$" |tr '\n' ' '`
1595 done
1596 for sym in ${public_syms} ; do
1597 n="${sym}"
1598 m="${JEMALLOC_PREFIX}${sym}"
1599 echo "${n}:${m}" >> "${f}"
1600 done
1601], [
1602 srcdir="${srcdir}"
1603 objroot="${objroot}"
1604 mangling_map="${mangling_map}"
1605 public_syms="${public_syms}"
1606 JEMALLOC_PREFIX="${JEMALLOC_PREFIX}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001607])
1608AC_CONFIG_COMMANDS([include/jemalloc/internal/public_namespace.h], [
1609 mkdir -p "${objroot}include/jemalloc/internal"
Jason Evansf234dc52014-01-16 17:38:01 -08001610 "${srcdir}/include/jemalloc/internal/public_namespace.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/internal/public_namespace.h"
1611], [
1612 srcdir="${srcdir}"
1613 objroot="${objroot}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001614])
1615AC_CONFIG_COMMANDS([include/jemalloc/internal/public_unnamespace.h], [
1616 mkdir -p "${objroot}include/jemalloc/internal"
Jason Evansf234dc52014-01-16 17:38:01 -08001617 "${srcdir}/include/jemalloc/internal/public_unnamespace.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/internal/public_unnamespace.h"
1618], [
1619 srcdir="${srcdir}"
1620 objroot="${objroot}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001621])
Jason Evansb1726102012-02-28 16:50:47 -08001622AC_CONFIG_COMMANDS([include/jemalloc/internal/size_classes.h], [
Jason Evans86abd0d2013-11-30 15:25:42 -08001623 mkdir -p "${objroot}include/jemalloc/internal"
Jason Evans6d919292015-09-15 10:42:36 -07001624 "${SHELL}" "${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 -08001625], [
Jason Evans6d919292015-09-15 10:42:36 -07001626 SHELL="${SHELL}"
Jason Evansf234dc52014-01-16 17:38:01 -08001627 srcdir="${srcdir}"
1628 objroot="${objroot}"
Jason Evans81e54752014-10-10 22:34:25 -07001629 LG_QUANTA="${LG_QUANTA}"
1630 LG_TINY_MIN=${LG_TINY_MIN}
1631 LG_PAGE_SIZES="${LG_PAGE_SIZES}"
Jason Evansfc0b3b72014-10-09 17:54:06 -07001632 LG_SIZE_CLASS_GROUP=${LG_SIZE_CLASS_GROUP}
Jason Evansb1726102012-02-28 16:50:47 -08001633])
Jason Evans86abd0d2013-11-30 15:25:42 -08001634AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_protos_jet.h], [
1635 mkdir -p "${objroot}include/jemalloc"
1636 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 -08001637], [
1638 srcdir="${srcdir}"
1639 objroot="${objroot}"
1640])
1641AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_rename.h], [
1642 mkdir -p "${objroot}include/jemalloc"
1643 "${srcdir}/include/jemalloc/jemalloc_rename.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/jemalloc_rename.h"
1644], [
1645 srcdir="${srcdir}"
1646 objroot="${objroot}"
1647])
1648AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_mangle.h], [
1649 mkdir -p "${objroot}include/jemalloc"
1650 "${srcdir}/include/jemalloc/jemalloc_mangle.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" je_ > "${objroot}include/jemalloc/jemalloc_mangle.h"
1651], [
1652 srcdir="${srcdir}"
1653 objroot="${objroot}"
1654])
1655AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_mangle_jet.h], [
1656 mkdir -p "${objroot}include/jemalloc"
1657 "${srcdir}/include/jemalloc/jemalloc_mangle.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" jet_ > "${objroot}include/jemalloc/jemalloc_mangle_jet.h"
1658], [
1659 srcdir="${srcdir}"
1660 objroot="${objroot}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001661])
1662AC_CONFIG_COMMANDS([include/jemalloc/jemalloc.h], [
1663 mkdir -p "${objroot}include/jemalloc"
1664 "${srcdir}/include/jemalloc/jemalloc.sh" "${objroot}" > "${objroot}include/jemalloc/jemalloc${install_suffix}.h"
Jason Evansf234dc52014-01-16 17:38:01 -08001665], [
1666 srcdir="${srcdir}"
1667 objroot="${objroot}"
1668 install_suffix="${install_suffix}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001669])
Jason Evansb1726102012-02-28 16:50:47 -08001670
Jason Evansb7924f52009-06-23 19:01:18 -07001671dnl Process .in files.
Jason Evansb0fd5012010-01-17 01:49:20 -08001672AC_SUBST([cfghdrs_in])
1673AC_SUBST([cfghdrs_out])
Jason Evans0656ec02010-04-07 23:37:35 -07001674AC_CONFIG_HEADERS([$cfghdrs_tup])
Jason Evansb7924f52009-06-23 19:01:18 -07001675
1676dnl ============================================================================
1677dnl Generate outputs.
Jason Evans748dfac2013-12-06 18:27:33 -08001678
Jason Evans70417202015-05-01 12:31:12 -07001679AC_CONFIG_FILES([$cfgoutputs_tup config.stamp bin/jemalloc-config bin/jemalloc.sh bin/jeprof])
Jason Evansb0fd5012010-01-17 01:49:20 -08001680AC_SUBST([cfgoutputs_in])
1681AC_SUBST([cfgoutputs_out])
Jason Evansb7924f52009-06-23 19:01:18 -07001682AC_OUTPUT
1683
1684dnl ============================================================================
1685dnl Print out the results of configuration.
1686AC_MSG_RESULT([===============================================================================])
Jason Evansf576c632011-11-01 22:27:41 -07001687AC_MSG_RESULT([jemalloc version : ${jemalloc_version}])
1688AC_MSG_RESULT([library revision : ${rev}])
Jason Evansb7924f52009-06-23 19:01:18 -07001689AC_MSG_RESULT([])
Jason Evansbec6a8d2015-01-22 17:55:58 -08001690AC_MSG_RESULT([CONFIG : ${CONFIG}])
Jason Evansb7924f52009-06-23 19:01:18 -07001691AC_MSG_RESULT([CC : ${CC}])
Jason Evansb7924f52009-06-23 19:01:18 -07001692AC_MSG_RESULT([CFLAGS : ${CFLAGS}])
Jason Evansbec6a8d2015-01-22 17:55:58 -08001693AC_MSG_RESULT([CPPFLAGS : ${CPPFLAGS}])
Jason Evansb7924f52009-06-23 19:01:18 -07001694AC_MSG_RESULT([LDFLAGS : ${LDFLAGS}])
Jason Evans748dfac2013-12-06 18:27:33 -08001695AC_MSG_RESULT([EXTRA_LDFLAGS : ${EXTRA_LDFLAGS}])
Jason Evansb7924f52009-06-23 19:01:18 -07001696AC_MSG_RESULT([LIBS : ${LIBS}])
1697AC_MSG_RESULT([RPATH_EXTRA : ${RPATH_EXTRA}])
1698AC_MSG_RESULT([])
Jason Evansaee7fd22010-11-24 22:00:02 -08001699AC_MSG_RESULT([XSLTPROC : ${XSLTPROC}])
1700AC_MSG_RESULT([XSLROOT : ${XSLROOT}])
1701AC_MSG_RESULT([])
Jason Evansb7924f52009-06-23 19:01:18 -07001702AC_MSG_RESULT([PREFIX : ${PREFIX}])
1703AC_MSG_RESULT([BINDIR : ${BINDIR}])
Jason Evansbec6a8d2015-01-22 17:55:58 -08001704AC_MSG_RESULT([DATADIR : ${DATADIR}])
Jason Evans662a0172009-07-01 19:24:31 -07001705AC_MSG_RESULT([INCLUDEDIR : ${INCLUDEDIR}])
1706AC_MSG_RESULT([LIBDIR : ${LIBDIR}])
Jason Evansb7924f52009-06-23 19:01:18 -07001707AC_MSG_RESULT([MANDIR : ${MANDIR}])
1708AC_MSG_RESULT([])
1709AC_MSG_RESULT([srcroot : ${srcroot}])
1710AC_MSG_RESULT([abs_srcroot : ${abs_srcroot}])
1711AC_MSG_RESULT([objroot : ${objroot}])
1712AC_MSG_RESULT([abs_objroot : ${abs_objroot}])
1713AC_MSG_RESULT([])
Jason Evans90895cf2009-12-29 00:09:15 -08001714AC_MSG_RESULT([JEMALLOC_PREFIX : ${JEMALLOC_PREFIX}])
Jason Evans746e77a2011-07-30 16:40:52 -07001715AC_MSG_RESULT([JEMALLOC_PRIVATE_NAMESPACE])
1716AC_MSG_RESULT([ : ${JEMALLOC_PRIVATE_NAMESPACE}])
Jason Evansb0fd5012010-01-17 01:49:20 -08001717AC_MSG_RESULT([install_suffix : ${install_suffix}])
Jason Evansb7924f52009-06-23 19:01:18 -07001718AC_MSG_RESULT([autogen : ${enable_autogen}])
Jason Evans355b4382010-09-20 19:20:48 -07001719AC_MSG_RESULT([cc-silence : ${enable_cc_silence}])
Jason Evansb7924f52009-06-23 19:01:18 -07001720AC_MSG_RESULT([debug : ${enable_debug}])
Jason Evans748dfac2013-12-06 18:27:33 -08001721AC_MSG_RESULT([code-coverage : ${enable_code_coverage}])
Jason Evansb7924f52009-06-23 19:01:18 -07001722AC_MSG_RESULT([stats : ${enable_stats}])
Jason Evans6109fe02010-02-10 10:37:56 -08001723AC_MSG_RESULT([prof : ${enable_prof}])
1724AC_MSG_RESULT([prof-libunwind : ${enable_prof_libunwind}])
Jason Evans77f350b2011-03-15 22:23:12 -07001725AC_MSG_RESULT([prof-libgcc : ${enable_prof_libgcc}])
1726AC_MSG_RESULT([prof-gcc : ${enable_prof_gcc}])
Jason Evans84cbbcb2009-12-29 00:09:15 -08001727AC_MSG_RESULT([tcache : ${enable_tcache}])
Jason Evansb7924f52009-06-23 19:01:18 -07001728AC_MSG_RESULT([fill : ${enable_fill}])
Jason Evansb1476112012-04-05 13:36:17 -07001729AC_MSG_RESULT([utrace : ${enable_utrace}])
Jason Evans122449b2012-04-06 00:35:09 -07001730AC_MSG_RESULT([valgrind : ${enable_valgrind}])
1731AC_MSG_RESULT([xmalloc : ${enable_xmalloc}])
Jason Evans59ae2762012-04-16 17:52:27 -07001732AC_MSG_RESULT([munmap : ${enable_munmap}])
Jason Evansb7924f52009-06-23 19:01:18 -07001733AC_MSG_RESULT([lazy_lock : ${enable_lazy_lock}])
Jason Evans2dbecf12010-09-05 10:35:13 -07001734AC_MSG_RESULT([tls : ${enable_tls}])
Jason Evans8a03cf02015-05-04 09:58:36 -07001735AC_MSG_RESULT([cache-oblivious : ${enable_cache_oblivious}])
Jason Evansb7924f52009-06-23 19:01:18 -07001736AC_MSG_RESULT([===============================================================================])