blob: 7a1290e0db917f7d52b5d4db02953093c78412cc [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
Jason Evans345c1b02015-09-15 14:59:56 -07001193dnl Check whether clock_gettime(2) is in libc or librt. This function is only
1194dnl used in test code, so save the result to TESTLIBS to avoid poluting LIBS.
1195SAVED_LIBS="${LIBS}"
1196LIBS=
1197AC_SEARCH_LIBS([clock_gettime], [rt], [TESTLIBS="${LIBS}"])
1198AC_SUBST([TESTLIBS])
1199LIBS="${SAVED_LIBS}"
1200
Daniel Micayb74041f2014-12-09 17:41:34 -05001201dnl Check if the GNU-specific secure_getenv function exists.
1202AC_CHECK_FUNC([secure_getenv],
1203 [have_secure_getenv="1"],
1204 [have_secure_getenv="0"]
1205 )
1206if test "x$have_secure_getenv" = "x1" ; then
1207 AC_DEFINE([JEMALLOC_HAVE_SECURE_GETENV], [ ])
1208fi
1209
1210dnl Check if the Solaris/BSD issetugid function exists.
1211AC_CHECK_FUNC([issetugid],
1212 [have_issetugid="1"],
1213 [have_issetugid="0"]
1214 )
1215if test "x$have_issetugid" = "x1" ; then
1216 AC_DEFINE([JEMALLOC_HAVE_ISSETUGID], [ ])
1217fi
1218
Jason Evanscd9a1342012-03-21 18:33:03 -07001219dnl Check whether the BSD-specific _malloc_thread_cleanup() exists. If so, use
1220dnl it rather than pthreads TSD cleanup functions to support cleanup during
1221dnl thread exit, in order to avoid pthreads library recursion during
1222dnl bootstrapping.
Jason Evanscd9a1342012-03-21 18:33:03 -07001223AC_CHECK_FUNC([_malloc_thread_cleanup],
1224 [have__malloc_thread_cleanup="1"],
1225 [have__malloc_thread_cleanup="0"]
1226 )
1227if test "x$have__malloc_thread_cleanup" = "x1" ; then
1228 AC_DEFINE([JEMALLOC_MALLOC_THREAD_CLEANUP], [ ])
1229 force_tls="1"
1230fi
1231
Jason Evans41b6afb2012-02-02 22:04:57 -08001232dnl Check whether the BSD-specific _pthread_mutex_init_calloc_cb() exists. If
1233dnl so, mutex initialization causes allocation, and we need to implement this
1234dnl callback function in order to prevent recursive allocation.
1235AC_CHECK_FUNC([_pthread_mutex_init_calloc_cb],
1236 [have__pthread_mutex_init_calloc_cb="1"],
1237 [have__pthread_mutex_init_calloc_cb="0"]
1238 )
1239if test "x$have__pthread_mutex_init_calloc_cb" = "x1" ; then
1240 AC_DEFINE([JEMALLOC_MUTEX_INIT_CB])
1241fi
1242
Jason Evans0fee70d2012-02-13 12:36:11 -08001243dnl Disable lazy locking by default.
Jason Evansb7924f52009-06-23 19:01:18 -07001244AC_ARG_ENABLE([lazy_lock],
Jason Evans0fee70d2012-02-13 12:36:11 -08001245 [AS_HELP_STRING([--enable-lazy-lock],
1246 [Enable lazy locking (only lock when multi-threaded)])],
Jason Evansb7924f52009-06-23 19:01:18 -07001247[if test "x$enable_lazy_lock" = "xno" ; then
1248 enable_lazy_lock="0"
1249else
1250 enable_lazy_lock="1"
1251fi
1252],
Mike Hommeyac5db022015-08-11 14:01:59 +09001253[enable_lazy_lock=""]
Jason Evansb7924f52009-06-23 19:01:18 -07001254)
Mike Hommeyac5db022015-08-11 14:01:59 +09001255if test "x$enable_lazy_lock" = "x" -a "x${force_lazy_lock}" = "x1" ; then
Jason Evansfd4fcef2012-03-23 17:40:58 -07001256 AC_MSG_RESULT([Forcing lazy-lock to avoid allocator/threading bootstrap issues])
1257 enable_lazy_lock="1"
1258fi
Jason Evansb7924f52009-06-23 19:01:18 -07001259if test "x$enable_lazy_lock" = "x1" ; then
Mike Hommeya19e87f2012-04-21 21:27:46 -07001260 if test "x$abi" != "xpecoff" ; then
1261 AC_CHECK_HEADERS([dlfcn.h], , [AC_MSG_ERROR([dlfcn.h is missing])])
1262 AC_CHECK_FUNC([dlsym], [],
1263 [AC_CHECK_LIB([dl], [dlsym], [LIBS="$LIBS -ldl"],
1264 [AC_MSG_ERROR([libdl is missing])])
1265 ])
1266 fi
Jason Evansb7924f52009-06-23 19:01:18 -07001267 AC_DEFINE([JEMALLOC_LAZY_LOCK], [ ])
Mike Hommeyac5db022015-08-11 14:01:59 +09001268else
1269 enable_lazy_lock="0"
Jason Evansb7924f52009-06-23 19:01:18 -07001270fi
1271AC_SUBST([enable_lazy_lock])
1272
Jason Evans78d815c2010-01-17 14:06:20 -08001273AC_ARG_ENABLE([tls],
1274 [AS_HELP_STRING([--disable-tls], [Disable thread-local storage (__thread keyword)])],
1275if test "x$enable_tls" = "xno" ; then
1276 enable_tls="0"
1277else
1278 enable_tls="1"
1279fi
1280,
Mike Hommeyac5db022015-08-11 14:01:59 +09001281enable_tls=""
Jason Evans78d815c2010-01-17 14:06:20 -08001282)
Jason Evansc0f43b62015-09-02 12:46:35 -07001283if test "x${enable_tls}" = "x" ; then
1284 if test "x${force_tls}" = "x1" ; then
1285 AC_MSG_RESULT([Forcing TLS to avoid allocator/threading bootstrap issues])
1286 enable_tls="1"
1287 elif test "x${force_tls}" = "x0" ; then
1288 AC_MSG_RESULT([Forcing no TLS to avoid allocator/threading bootstrap issues])
1289 enable_tls="0"
1290 else
1291 enable_tls="1"
1292 fi
Jason Evansb80581d2012-03-23 16:17:43 -07001293fi
Jason Evans78d815c2010-01-17 14:06:20 -08001294if test "x${enable_tls}" = "x1" ; then
1295AC_MSG_CHECKING([for TLS])
Jason Evans6684cac2012-03-05 12:15:36 -08001296AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Jason Evans78d815c2010-01-17 14:06:20 -08001297[[
1298 __thread int x;
1299]], [[
1300 x = 42;
1301
1302 return 0;
1303]])],
1304 AC_MSG_RESULT([yes]),
1305 AC_MSG_RESULT([no])
1306 enable_tls="0")
Mike Hommeyac5db022015-08-11 14:01:59 +09001307else
1308 enable_tls="0"
Jason Evans78d815c2010-01-17 14:06:20 -08001309fi
Jason Evansb267d0f2010-08-13 15:42:29 -07001310AC_SUBST([enable_tls])
Jason Evanse24c7af2012-03-19 10:21:17 -07001311if test "x${enable_tls}" = "x1" ; then
Jason Evansc0f43b62015-09-02 12:46:35 -07001312 if test "x${force_tls}" = "x0" ; then
1313 AC_MSG_WARN([TLS enabled despite being marked unusable on this platform])
1314 fi
Jason Evanse24c7af2012-03-19 10:21:17 -07001315 AC_DEFINE_UNQUOTED([JEMALLOC_TLS], [ ])
Jason Evanscd9a1342012-03-21 18:33:03 -07001316elif test "x${force_tls}" = "x1" ; then
Jason Evansc0f43b62015-09-02 12:46:35 -07001317 AC_MSG_WARN([TLS disabled despite being marked critical on this platform])
Jason Evans78d815c2010-01-17 14:06:20 -08001318fi
1319
Jason Evans2dbecf12010-09-05 10:35:13 -07001320dnl ============================================================================
Chih-hung Hsieh59cd80e2014-12-05 17:42:41 -08001321dnl Check for C11 atomics.
1322
1323JE_COMPILABLE([C11 atomics], [
1324#include <stdint.h>
1325#if (__STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_ATOMICS__)
1326#include <stdatomic.h>
1327#else
1328#error Atomics not available
1329#endif
1330], [
1331 uint64_t *p = (uint64_t *)0;
1332 uint64_t x = 1;
1333 volatile atomic_uint_least64_t *a = (volatile atomic_uint_least64_t *)p;
1334 uint64_t r = atomic_fetch_add(a, x) + x;
1335 return (r == 0);
1336], [je_cv_c11atomics])
1337if test "x${je_cv_c11atomics}" = "xyes" ; then
1338 AC_DEFINE([JEMALLOC_C11ATOMICS])
1339fi
1340
1341dnl ============================================================================
Jason Evansb57d3ec2012-04-17 13:17:54 -07001342dnl Check for atomic(9) operations as provided on FreeBSD.
1343
1344JE_COMPILABLE([atomic(9)], [
1345#include <sys/types.h>
1346#include <machine/atomic.h>
1347#include <inttypes.h>
1348], [
1349 {
1350 uint32_t x32 = 0;
1351 volatile uint32_t *x32p = &x32;
1352 atomic_fetchadd_32(x32p, 1);
1353 }
1354 {
1355 unsigned long xlong = 0;
1356 volatile unsigned long *xlongp = &xlong;
1357 atomic_fetchadd_long(xlongp, 1);
1358 }
1359], [je_cv_atomic9])
1360if test "x${je_cv_atomic9}" = "xyes" ; then
1361 AC_DEFINE([JEMALLOC_ATOMIC9])
1362fi
1363
1364dnl ============================================================================
Jason Evans763baa62011-03-18 19:10:31 -07001365dnl Check for atomic(3) operations as provided on Darwin.
1366
1367JE_COMPILABLE([Darwin OSAtomic*()], [
1368#include <libkern/OSAtomic.h>
1369#include <inttypes.h>
1370], [
1371 {
1372 int32_t x32 = 0;
1373 volatile int32_t *x32p = &x32;
1374 OSAtomicAdd32(1, x32p);
1375 }
1376 {
1377 int64_t x64 = 0;
1378 volatile int64_t *x64p = &x64;
1379 OSAtomicAdd64(1, x64p);
1380 }
Jason Evans6684cac2012-03-05 12:15:36 -08001381], [je_cv_osatomic])
1382if test "x${je_cv_osatomic}" = "xyes" ; then
Jason Evanse24c7af2012-03-19 10:21:17 -07001383 AC_DEFINE([JEMALLOC_OSATOMIC], [ ])
Jason Evans763baa62011-03-18 19:10:31 -07001384fi
1385
1386dnl ============================================================================
Richard Diamond994fad92014-06-03 02:39:18 -05001387dnl Check for madvise(2).
1388
1389JE_COMPILABLE([madvise(2)], [
1390#include <sys/mman.h>
1391], [
1392 {
1393 madvise((void *)0, 0, 0);
1394 }
1395], [je_cv_madvise])
1396if test "x${je_cv_madvise}" = "xyes" ; then
1397 AC_DEFINE([JEMALLOC_HAVE_MADVISE], [ ])
1398fi
1399
1400dnl ============================================================================
Mike Hommeyc1e567b2012-03-26 17:03:41 +02001401dnl Check whether __sync_{add,sub}_and_fetch() are available despite
1402dnl __GCC_HAVE_SYNC_COMPARE_AND_SWAP_n macros being undefined.
1403
1404AC_DEFUN([JE_SYNC_COMPARE_AND_SWAP_CHECK],[
1405 AC_CACHE_CHECK([whether to force $1-bit __sync_{add,sub}_and_fetch()],
1406 [je_cv_sync_compare_and_swap_$2],
Mike Hommey2cfe6d62012-03-27 15:03:07 +02001407 [AC_LINK_IFELSE([AC_LANG_PROGRAM([
1408 #include <stdint.h>
1409 ],
1410 [
1411 #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2
1412 {
1413 uint$1_t x$1 = 0;
1414 __sync_add_and_fetch(&x$1, 42);
1415 __sync_sub_and_fetch(&x$1, 1);
1416 }
1417 #else
1418 #error __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2 is defined, no need to force
1419 #endif
1420 ])],
Mike Hommeyc1e567b2012-03-26 17:03:41 +02001421 [je_cv_sync_compare_and_swap_$2=yes],
1422 [je_cv_sync_compare_and_swap_$2=no])])
1423
1424 if test "x${je_cv_sync_compare_and_swap_$2}" = "xyes" ; then
1425 AC_DEFINE([JE_FORCE_SYNC_COMPARE_AND_SWAP_$2], [ ])
1426 fi
1427])
1428
Jason Evansb57d3ec2012-04-17 13:17:54 -07001429if test "x${je_cv_atomic9}" != "xyes" -a "x${je_cv_osatomic}" != "xyes" ; then
Mike Hommeyc1e567b2012-03-26 17:03:41 +02001430 JE_SYNC_COMPARE_AND_SWAP_CHECK(32, 4)
1431 JE_SYNC_COMPARE_AND_SWAP_CHECK(64, 8)
1432fi
1433
1434dnl ============================================================================
Jason Evansd04047c2014-05-28 16:11:55 -07001435dnl Check for __builtin_clz() and __builtin_clzl().
1436
1437AC_CACHE_CHECK([for __builtin_clz],
1438 [je_cv_builtin_clz],
1439 [AC_LINK_IFELSE([AC_LANG_PROGRAM([],
1440 [
1441 {
1442 unsigned x = 0;
1443 int y = __builtin_clz(x);
1444 }
1445 {
1446 unsigned long x = 0;
1447 int y = __builtin_clzl(x);
1448 }
1449 ])],
1450 [je_cv_builtin_clz=yes],
1451 [je_cv_builtin_clz=no])])
1452
1453if test "x${je_cv_builtin_clz}" = "xyes" ; then
1454 AC_DEFINE([JEMALLOC_HAVE_BUILTIN_CLZ], [ ])
1455fi
1456
1457dnl ============================================================================
Jason Evans893a0ed2011-03-18 19:30:18 -07001458dnl Check for spinlock(3) operations as provided on Darwin.
1459
1460JE_COMPILABLE([Darwin OSSpin*()], [
1461#include <libkern/OSAtomic.h>
1462#include <inttypes.h>
1463], [
1464 OSSpinLock lock = 0;
1465 OSSpinLockLock(&lock);
1466 OSSpinLockUnlock(&lock);
Jason Evans6684cac2012-03-05 12:15:36 -08001467], [je_cv_osspin])
1468if test "x${je_cv_osspin}" = "xyes" ; then
Jason Evanse24c7af2012-03-19 10:21:17 -07001469 AC_DEFINE([JEMALLOC_OSSPIN], [ ])
Jason Evans893a0ed2011-03-18 19:30:18 -07001470fi
1471
1472dnl ============================================================================
Jason Evans2dbecf12010-09-05 10:35:13 -07001473dnl Darwin-related configuration.
Jason Evans78d815c2010-01-17 14:06:20 -08001474
Mike Hommeyd0357f72012-11-26 18:52:41 +01001475AC_ARG_ENABLE([zone-allocator],
1476 [AS_HELP_STRING([--disable-zone-allocator],
1477 [Disable zone allocator for Darwin])],
1478[if test "x$enable_zone_allocator" = "xno" ; then
1479 enable_zone_allocator="0"
1480else
1481 enable_zone_allocator="1"
1482fi
1483],
1484[if test "x${abi}" = "xmacho"; then
1485 enable_zone_allocator="1"
1486fi
1487]
1488)
1489AC_SUBST([enable_zone_allocator])
1490
1491if test "x${enable_zone_allocator}" = "x1" ; then
1492 if test "x${abi}" != "xmacho"; then
1493 AC_MSG_ERROR([--enable-zone-allocator is only supported on Darwin])
1494 fi
Jason Evanse24c7af2012-03-19 10:21:17 -07001495 AC_DEFINE([JEMALLOC_ZONE], [ ])
Jason Evans6109fe02010-02-10 10:37:56 -08001496
Jason Evans2dbecf12010-09-05 10:35:13 -07001497 dnl The szone version jumped from 3 to 6 between the OS X 10.5.x and 10.6
1498 dnl releases. malloc_zone_t and malloc_introspection_t have new fields in
1499 dnl 10.6, which is the only source-level indication of the change.
1500 AC_MSG_CHECKING([malloc zone version])
Mike Hommey154829d2012-03-20 18:01:38 +01001501 AC_DEFUN([JE_ZONE_PROGRAM],
1502 [AC_LANG_PROGRAM(
1503 [#include <malloc/malloc.h>],
Guilherme Goncalves79725aa2014-10-20 14:08:37 -02001504 [static int foo[[sizeof($1) $2 sizeof(void *) * $3 ? 1 : -1]]]
Mike Hommey154829d2012-03-20 18:01:38 +01001505 )])
Jason Evans2dbecf12010-09-05 10:35:13 -07001506
Mike Hommey154829d2012-03-20 18:01:38 +01001507 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,14)],[JEMALLOC_ZONE_VERSION=3],[
1508 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,15)],[JEMALLOC_ZONE_VERSION=5],[
1509 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,16)],[
1510 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,9)],[JEMALLOC_ZONE_VERSION=6],[
1511 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,13)],[JEMALLOC_ZONE_VERSION=7],[JEMALLOC_ZONE_VERSION=]
1512 )])],[
1513 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,17)],[JEMALLOC_ZONE_VERSION=8],[
1514 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,>,17)],[JEMALLOC_ZONE_VERSION=9],[JEMALLOC_ZONE_VERSION=]
1515 )])])])])
1516 if test "x${JEMALLOC_ZONE_VERSION}" = "x"; then
1517 AC_MSG_RESULT([unsupported])
1518 AC_MSG_ERROR([Unsupported malloc zone version])
1519 fi
1520 if test "${JEMALLOC_ZONE_VERSION}" = 9; then
1521 JEMALLOC_ZONE_VERSION=8
1522 AC_MSG_RESULT([> 8])
1523 else
1524 AC_MSG_RESULT([$JEMALLOC_ZONE_VERSION])
1525 fi
1526 AC_DEFINE_UNQUOTED(JEMALLOC_ZONE_VERSION, [$JEMALLOC_ZONE_VERSION])
Jason Evansb27805b2010-02-10 18:15:53 -08001527fi
1528
Jason Evansb7924f52009-06-23 19:01:18 -07001529dnl ============================================================================
Sara Golemon3e24afa2014-08-18 13:06:39 -07001530dnl Check for glibc malloc hooks
1531
1532JE_COMPILABLE([glibc malloc hook], [
1533#include <stddef.h>
1534
1535extern void (* __free_hook)(void *ptr);
1536extern void *(* __malloc_hook)(size_t size);
1537extern void *(* __realloc_hook)(void *ptr, size_t size);
1538], [
1539 void *ptr = 0L;
1540 if (__malloc_hook) ptr = __malloc_hook(1);
1541 if (__realloc_hook) ptr = __realloc_hook(ptr, 2);
1542 if (__free_hook && ptr) __free_hook(ptr);
1543], [je_cv_glibc_malloc_hook])
1544if test "x${je_cv_glibc_malloc_hook}" = "xyes" ; then
1545 AC_DEFINE([JEMALLOC_GLIBC_MALLOC_HOOK], [ ])
1546fi
1547
1548JE_COMPILABLE([glibc memalign hook], [
1549#include <stddef.h>
1550
1551extern void *(* __memalign_hook)(size_t alignment, size_t size);
1552], [
1553 void *ptr = 0L;
1554 if (__memalign_hook) ptr = __memalign_hook(16, 7);
1555], [je_cv_glibc_memalign_hook])
1556if test "x${je_cv_glibc_memalign_hook}" = "xyes" ; then
1557 AC_DEFINE([JEMALLOC_GLIBC_MEMALIGN_HOOK], [ ])
1558fi
1559
Eric Wong4dcf04b2014-08-31 03:57:06 +00001560JE_COMPILABLE([pthreads adaptive mutexes], [
1561#include <pthread.h>
1562], [
1563 pthread_mutexattr_t attr;
1564 pthread_mutexattr_init(&attr);
1565 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ADAPTIVE_NP);
1566 pthread_mutexattr_destroy(&attr);
1567], [je_cv_pthread_mutex_adaptive_np])
1568if test "x${je_cv_pthread_mutex_adaptive_np}" = "xyes" ; then
1569 AC_DEFINE([JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], [ ])
1570fi
1571
Sara Golemon3e24afa2014-08-18 13:06:39 -07001572dnl ============================================================================
Jason Evansb7924f52009-06-23 19:01:18 -07001573dnl Check for typedefs, structures, and compiler characteristics.
1574AC_HEADER_STDBOOL
1575
Jason Evans748dfac2013-12-06 18:27:33 -08001576dnl ============================================================================
1577dnl Define commands that generate output files.
1578
Jason Evans86abd0d2013-11-30 15:25:42 -08001579AC_CONFIG_COMMANDS([include/jemalloc/internal/private_namespace.h], [
1580 mkdir -p "${objroot}include/jemalloc/internal"
1581 "${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 -08001582], [
1583 srcdir="${srcdir}"
1584 objroot="${objroot}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001585])
1586AC_CONFIG_COMMANDS([include/jemalloc/internal/private_unnamespace.h], [
1587 mkdir -p "${objroot}include/jemalloc/internal"
1588 "${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 -08001589], [
1590 srcdir="${srcdir}"
1591 objroot="${objroot}"
1592])
1593AC_CONFIG_COMMANDS([include/jemalloc/internal/public_symbols.txt], [
1594 f="${objroot}include/jemalloc/internal/public_symbols.txt"
1595 mkdir -p "${objroot}include/jemalloc/internal"
1596 cp /dev/null "${f}"
1597 for nm in `echo ${mangling_map} |tr ',' ' '` ; do
1598 n=`echo ${nm} |tr ':' ' ' |awk '{print $[]1}'`
1599 m=`echo ${nm} |tr ':' ' ' |awk '{print $[]2}'`
1600 echo "${n}:${m}" >> "${f}"
1601 dnl Remove name from public_syms so that it isn't redefined later.
1602 public_syms=`for sym in ${public_syms}; do echo "${sym}"; done |grep -v "^${n}\$" |tr '\n' ' '`
1603 done
1604 for sym in ${public_syms} ; do
1605 n="${sym}"
1606 m="${JEMALLOC_PREFIX}${sym}"
1607 echo "${n}:${m}" >> "${f}"
1608 done
1609], [
1610 srcdir="${srcdir}"
1611 objroot="${objroot}"
1612 mangling_map="${mangling_map}"
1613 public_syms="${public_syms}"
1614 JEMALLOC_PREFIX="${JEMALLOC_PREFIX}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001615])
1616AC_CONFIG_COMMANDS([include/jemalloc/internal/public_namespace.h], [
1617 mkdir -p "${objroot}include/jemalloc/internal"
Jason Evansf234dc52014-01-16 17:38:01 -08001618 "${srcdir}/include/jemalloc/internal/public_namespace.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/internal/public_namespace.h"
1619], [
1620 srcdir="${srcdir}"
1621 objroot="${objroot}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001622])
1623AC_CONFIG_COMMANDS([include/jemalloc/internal/public_unnamespace.h], [
1624 mkdir -p "${objroot}include/jemalloc/internal"
Jason Evansf234dc52014-01-16 17:38:01 -08001625 "${srcdir}/include/jemalloc/internal/public_unnamespace.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/internal/public_unnamespace.h"
1626], [
1627 srcdir="${srcdir}"
1628 objroot="${objroot}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001629])
Jason Evansb1726102012-02-28 16:50:47 -08001630AC_CONFIG_COMMANDS([include/jemalloc/internal/size_classes.h], [
Jason Evans86abd0d2013-11-30 15:25:42 -08001631 mkdir -p "${objroot}include/jemalloc/internal"
Jason Evans6d919292015-09-15 10:42:36 -07001632 "${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 -08001633], [
Jason Evans6d919292015-09-15 10:42:36 -07001634 SHELL="${SHELL}"
Jason Evansf234dc52014-01-16 17:38:01 -08001635 srcdir="${srcdir}"
1636 objroot="${objroot}"
Jason Evans81e54752014-10-10 22:34:25 -07001637 LG_QUANTA="${LG_QUANTA}"
1638 LG_TINY_MIN=${LG_TINY_MIN}
1639 LG_PAGE_SIZES="${LG_PAGE_SIZES}"
Jason Evansfc0b3b72014-10-09 17:54:06 -07001640 LG_SIZE_CLASS_GROUP=${LG_SIZE_CLASS_GROUP}
Jason Evansb1726102012-02-28 16:50:47 -08001641])
Jason Evans86abd0d2013-11-30 15:25:42 -08001642AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_protos_jet.h], [
1643 mkdir -p "${objroot}include/jemalloc"
1644 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 -08001645], [
1646 srcdir="${srcdir}"
1647 objroot="${objroot}"
1648])
1649AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_rename.h], [
1650 mkdir -p "${objroot}include/jemalloc"
1651 "${srcdir}/include/jemalloc/jemalloc_rename.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/jemalloc_rename.h"
1652], [
1653 srcdir="${srcdir}"
1654 objroot="${objroot}"
1655])
1656AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_mangle.h], [
1657 mkdir -p "${objroot}include/jemalloc"
1658 "${srcdir}/include/jemalloc/jemalloc_mangle.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" je_ > "${objroot}include/jemalloc/jemalloc_mangle.h"
1659], [
1660 srcdir="${srcdir}"
1661 objroot="${objroot}"
1662])
1663AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_mangle_jet.h], [
1664 mkdir -p "${objroot}include/jemalloc"
1665 "${srcdir}/include/jemalloc/jemalloc_mangle.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" jet_ > "${objroot}include/jemalloc/jemalloc_mangle_jet.h"
1666], [
1667 srcdir="${srcdir}"
1668 objroot="${objroot}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001669])
1670AC_CONFIG_COMMANDS([include/jemalloc/jemalloc.h], [
1671 mkdir -p "${objroot}include/jemalloc"
1672 "${srcdir}/include/jemalloc/jemalloc.sh" "${objroot}" > "${objroot}include/jemalloc/jemalloc${install_suffix}.h"
Jason Evansf234dc52014-01-16 17:38:01 -08001673], [
1674 srcdir="${srcdir}"
1675 objroot="${objroot}"
1676 install_suffix="${install_suffix}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001677])
Jason Evansb1726102012-02-28 16:50:47 -08001678
Jason Evansb7924f52009-06-23 19:01:18 -07001679dnl Process .in files.
Jason Evansb0fd5012010-01-17 01:49:20 -08001680AC_SUBST([cfghdrs_in])
1681AC_SUBST([cfghdrs_out])
Jason Evans0656ec02010-04-07 23:37:35 -07001682AC_CONFIG_HEADERS([$cfghdrs_tup])
Jason Evansb7924f52009-06-23 19:01:18 -07001683
1684dnl ============================================================================
1685dnl Generate outputs.
Jason Evans748dfac2013-12-06 18:27:33 -08001686
Jason Evans70417202015-05-01 12:31:12 -07001687AC_CONFIG_FILES([$cfgoutputs_tup config.stamp bin/jemalloc-config bin/jemalloc.sh bin/jeprof])
Jason Evansb0fd5012010-01-17 01:49:20 -08001688AC_SUBST([cfgoutputs_in])
1689AC_SUBST([cfgoutputs_out])
Jason Evansb7924f52009-06-23 19:01:18 -07001690AC_OUTPUT
1691
1692dnl ============================================================================
1693dnl Print out the results of configuration.
1694AC_MSG_RESULT([===============================================================================])
Jason Evansf576c632011-11-01 22:27:41 -07001695AC_MSG_RESULT([jemalloc version : ${jemalloc_version}])
1696AC_MSG_RESULT([library revision : ${rev}])
Jason Evansb7924f52009-06-23 19:01:18 -07001697AC_MSG_RESULT([])
Jason Evansbec6a8d2015-01-22 17:55:58 -08001698AC_MSG_RESULT([CONFIG : ${CONFIG}])
Jason Evansb7924f52009-06-23 19:01:18 -07001699AC_MSG_RESULT([CC : ${CC}])
Jason Evansb7924f52009-06-23 19:01:18 -07001700AC_MSG_RESULT([CFLAGS : ${CFLAGS}])
Jason Evansbec6a8d2015-01-22 17:55:58 -08001701AC_MSG_RESULT([CPPFLAGS : ${CPPFLAGS}])
Jason Evansb7924f52009-06-23 19:01:18 -07001702AC_MSG_RESULT([LDFLAGS : ${LDFLAGS}])
Jason Evans748dfac2013-12-06 18:27:33 -08001703AC_MSG_RESULT([EXTRA_LDFLAGS : ${EXTRA_LDFLAGS}])
Jason Evansb7924f52009-06-23 19:01:18 -07001704AC_MSG_RESULT([LIBS : ${LIBS}])
Jason Evans345c1b02015-09-15 14:59:56 -07001705AC_MSG_RESULT([TESTLIBS : ${TESTLIBS}])
Jason Evansb7924f52009-06-23 19:01:18 -07001706AC_MSG_RESULT([RPATH_EXTRA : ${RPATH_EXTRA}])
1707AC_MSG_RESULT([])
Jason Evansaee7fd22010-11-24 22:00:02 -08001708AC_MSG_RESULT([XSLTPROC : ${XSLTPROC}])
1709AC_MSG_RESULT([XSLROOT : ${XSLROOT}])
1710AC_MSG_RESULT([])
Jason Evansb7924f52009-06-23 19:01:18 -07001711AC_MSG_RESULT([PREFIX : ${PREFIX}])
1712AC_MSG_RESULT([BINDIR : ${BINDIR}])
Jason Evansbec6a8d2015-01-22 17:55:58 -08001713AC_MSG_RESULT([DATADIR : ${DATADIR}])
Jason Evans662a0172009-07-01 19:24:31 -07001714AC_MSG_RESULT([INCLUDEDIR : ${INCLUDEDIR}])
1715AC_MSG_RESULT([LIBDIR : ${LIBDIR}])
Jason Evansb7924f52009-06-23 19:01:18 -07001716AC_MSG_RESULT([MANDIR : ${MANDIR}])
1717AC_MSG_RESULT([])
1718AC_MSG_RESULT([srcroot : ${srcroot}])
1719AC_MSG_RESULT([abs_srcroot : ${abs_srcroot}])
1720AC_MSG_RESULT([objroot : ${objroot}])
1721AC_MSG_RESULT([abs_objroot : ${abs_objroot}])
1722AC_MSG_RESULT([])
Jason Evans90895cf2009-12-29 00:09:15 -08001723AC_MSG_RESULT([JEMALLOC_PREFIX : ${JEMALLOC_PREFIX}])
Jason Evans746e77a2011-07-30 16:40:52 -07001724AC_MSG_RESULT([JEMALLOC_PRIVATE_NAMESPACE])
1725AC_MSG_RESULT([ : ${JEMALLOC_PRIVATE_NAMESPACE}])
Jason Evansb0fd5012010-01-17 01:49:20 -08001726AC_MSG_RESULT([install_suffix : ${install_suffix}])
Jason Evansb7924f52009-06-23 19:01:18 -07001727AC_MSG_RESULT([autogen : ${enable_autogen}])
Jason Evans355b4382010-09-20 19:20:48 -07001728AC_MSG_RESULT([cc-silence : ${enable_cc_silence}])
Jason Evansb7924f52009-06-23 19:01:18 -07001729AC_MSG_RESULT([debug : ${enable_debug}])
Jason Evans748dfac2013-12-06 18:27:33 -08001730AC_MSG_RESULT([code-coverage : ${enable_code_coverage}])
Jason Evansb7924f52009-06-23 19:01:18 -07001731AC_MSG_RESULT([stats : ${enable_stats}])
Jason Evans6109fe02010-02-10 10:37:56 -08001732AC_MSG_RESULT([prof : ${enable_prof}])
1733AC_MSG_RESULT([prof-libunwind : ${enable_prof_libunwind}])
Jason Evans77f350b2011-03-15 22:23:12 -07001734AC_MSG_RESULT([prof-libgcc : ${enable_prof_libgcc}])
1735AC_MSG_RESULT([prof-gcc : ${enable_prof_gcc}])
Jason Evans84cbbcb2009-12-29 00:09:15 -08001736AC_MSG_RESULT([tcache : ${enable_tcache}])
Jason Evansb7924f52009-06-23 19:01:18 -07001737AC_MSG_RESULT([fill : ${enable_fill}])
Jason Evansb1476112012-04-05 13:36:17 -07001738AC_MSG_RESULT([utrace : ${enable_utrace}])
Jason Evans122449b2012-04-06 00:35:09 -07001739AC_MSG_RESULT([valgrind : ${enable_valgrind}])
1740AC_MSG_RESULT([xmalloc : ${enable_xmalloc}])
Jason Evans59ae2762012-04-16 17:52:27 -07001741AC_MSG_RESULT([munmap : ${enable_munmap}])
Jason Evansb7924f52009-06-23 19:01:18 -07001742AC_MSG_RESULT([lazy_lock : ${enable_lazy_lock}])
Jason Evans2dbecf12010-09-05 10:35:13 -07001743AC_MSG_RESULT([tls : ${enable_tls}])
Jason Evans8a03cf02015-05-04 09:58:36 -07001744AC_MSG_RESULT([cache-oblivious : ${enable_cache_oblivious}])
Jason Evansb7924f52009-06-23 19:01:18 -07001745AC_MSG_RESULT([===============================================================================])