blob: f4b4c21f16d108ec4a86e0af68d54ac7e2ec61d4 [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]])],
22 AC_MSG_RESULT([yes]),
23 AC_MSG_RESULT([no])
24 [CFLAGS="${TCFLAGS}"]
25)
26])
27
28dnl JE_COMPILABLE(label, hcode, mcode, rvar)
Jason Evans4c2faa82012-03-13 11:09:23 -070029dnl
Jason Evansf3e139a2012-03-19 09:54:20 -070030dnl Use AC_LINK_IFELSE() rather than AC_COMPILE_IFELSE() so that linker errors
Jason Evans4c2faa82012-03-13 11:09:23 -070031dnl cause failure.
Jason Evansf3340ca2009-06-30 16:17:05 -070032AC_DEFUN([JE_COMPILABLE],
33[
Jason Evans6684cac2012-03-05 12:15:36 -080034AC_CACHE_CHECK([whether $1 is compilable],
35 [$4],
Jason Evansf3e139a2012-03-19 09:54:20 -070036 [AC_LINK_IFELSE([AC_LANG_PROGRAM([$2],
37 [$3])],
38 [$4=yes],
39 [$4=no])])
Jason Evansf3340ca2009-06-30 16:17:05 -070040])
41
42dnl ============================================================================
43
Jason Evansf576c632011-11-01 22:27:41 -070044dnl Library revision.
45rev=1
46AC_SUBST([rev])
47
Jason Evansb7924f52009-06-23 19:01:18 -070048srcroot=$srcdir
49if test "x${srcroot}" = "x." ; then
50 srcroot=""
51else
52 srcroot="${srcroot}/"
53fi
54AC_SUBST([srcroot])
55abs_srcroot="`cd \"${srcdir}\"; pwd`/"
56AC_SUBST([abs_srcroot])
57
58objroot=""
59AC_SUBST([objroot])
60abs_objroot="`pwd`/"
61AC_SUBST([abs_objroot])
62
63dnl Munge install path variables.
64if test "x$prefix" = "xNONE" ; then
65 prefix="/usr/local"
66fi
67if test "x$exec_prefix" = "xNONE" ; then
68 exec_prefix=$prefix
69fi
70PREFIX=$prefix
71AC_SUBST([PREFIX])
72BINDIR=`eval echo $bindir`
73BINDIR=`eval echo $BINDIR`
74AC_SUBST([BINDIR])
75INCLUDEDIR=`eval echo $includedir`
76INCLUDEDIR=`eval echo $INCLUDEDIR`
77AC_SUBST([INCLUDEDIR])
78LIBDIR=`eval echo $libdir`
79LIBDIR=`eval echo $LIBDIR`
80AC_SUBST([LIBDIR])
81DATADIR=`eval echo $datadir`
82DATADIR=`eval echo $DATADIR`
83AC_SUBST([DATADIR])
84MANDIR=`eval echo $mandir`
85MANDIR=`eval echo $MANDIR`
86AC_SUBST([MANDIR])
87
Jason Evansaee7fd22010-11-24 22:00:02 -080088dnl Support for building documentation.
Jason Evans7329a4f2013-01-22 10:53:29 -080089AC_PATH_PROG([XSLTPROC], [xsltproc], [false], [$PATH])
Jason Evans7091b412012-03-19 09:36:44 -070090if test -d "/usr/share/xml/docbook/stylesheet/docbook-xsl" ; then
91 DEFAULT_XSLROOT="/usr/share/xml/docbook/stylesheet/docbook-xsl"
92elif test -d "/usr/share/sgml/docbook/xsl-stylesheets" ; then
93 DEFAULT_XSLROOT="/usr/share/sgml/docbook/xsl-stylesheets"
94else
95 dnl Documentation building will fail if this default gets used.
96 DEFAULT_XSLROOT=""
97fi
Jason Evansaee7fd22010-11-24 22:00:02 -080098AC_ARG_WITH([xslroot],
Jason Evans7091b412012-03-19 09:36:44 -070099 [AS_HELP_STRING([--with-xslroot=<path>], [XSL stylesheet root path])], [
Jason Evansaee7fd22010-11-24 22:00:02 -0800100if test "x$with_xslroot" = "xno" ; then
Jason Evans7091b412012-03-19 09:36:44 -0700101 XSLROOT="${DEFAULT_XSLROOT}"
Jason Evansaee7fd22010-11-24 22:00:02 -0800102else
103 XSLROOT="${with_xslroot}"
Jason Evans7091b412012-03-19 09:36:44 -0700104fi
105],
106 XSLROOT="${DEFAULT_XSLROOT}"
Jason Evansaee7fd22010-11-24 22:00:02 -0800107)
108AC_SUBST([XSLROOT])
109
Jason Evansf3340ca2009-06-30 16:17:05 -0700110dnl If CFLAGS isn't defined, set CFLAGS to something reasonable. Otherwise,
111dnl just prevent autoconf from molesting CFLAGS.
Jason Evansb7924f52009-06-23 19:01:18 -0700112CFLAGS=$CFLAGS
113AC_PROG_CC
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200114if test "x$GCC" != "xyes" ; then
115 AC_CACHE_CHECK([whether compiler is MSVC],
116 [je_cv_msvc],
117 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
118 [
119#ifndef _MSC_VER
120 int fail[-1];
121#endif
122])],
123 [je_cv_msvc=yes],
124 [je_cv_msvc=no])])
125fi
126
Jason Evansb7924f52009-06-23 19:01:18 -0700127if test "x$CFLAGS" = "x" ; then
128 no_CFLAGS="yes"
Jason Evanscfeccd32010-03-03 15:48:20 -0800129 if test "x$GCC" = "xyes" ; then
130 JE_CFLAGS_APPEND([-std=gnu99])
131 JE_CFLAGS_APPEND([-Wall])
132 JE_CFLAGS_APPEND([-pipe])
133 JE_CFLAGS_APPEND([-g3])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200134 elif test "x$je_cv_msvc" = "xyes" ; then
135 CC="$CC -nologo"
136 JE_CFLAGS_APPEND([-Zi])
137 JE_CFLAGS_APPEND([-MT])
138 JE_CFLAGS_APPEND([-W3])
139 CPPFLAGS="$CPPFLAGS -I${srcroot}/include/msvc_compat"
Jason Evanscfeccd32010-03-03 15:48:20 -0800140 fi
Jason Evansb7924f52009-06-23 19:01:18 -0700141fi
142dnl Append EXTRA_CFLAGS to CFLAGS, if defined.
143if test "x$EXTRA_CFLAGS" != "x" ; then
Jason Evansf3340ca2009-06-30 16:17:05 -0700144 JE_CFLAGS_APPEND([$EXTRA_CFLAGS])
Jason Evansb7924f52009-06-23 19:01:18 -0700145fi
146AC_PROG_CPP
147
Jason Evansb7924f52009-06-23 19:01:18 -0700148AC_CHECK_SIZEOF([void *])
149if test "x${ac_cv_sizeof_void_p}" = "x8" ; then
Jason Evans94ad2b52009-12-29 00:09:15 -0800150 LG_SIZEOF_PTR=3
Jason Evansb7924f52009-06-23 19:01:18 -0700151elif test "x${ac_cv_sizeof_void_p}" = "x4" ; then
Jason Evans94ad2b52009-12-29 00:09:15 -0800152 LG_SIZEOF_PTR=2
Jason Evansb7924f52009-06-23 19:01:18 -0700153else
154 AC_MSG_ERROR([Unsupported pointer size: ${ac_cv_sizeof_void_p}])
155fi
Jason Evans94ad2b52009-12-29 00:09:15 -0800156AC_DEFINE_UNQUOTED([LG_SIZEOF_PTR], [$LG_SIZEOF_PTR])
157
158AC_CHECK_SIZEOF([int])
159if test "x${ac_cv_sizeof_int}" = "x8" ; then
160 LG_SIZEOF_INT=3
161elif test "x${ac_cv_sizeof_int}" = "x4" ; then
162 LG_SIZEOF_INT=2
163else
164 AC_MSG_ERROR([Unsupported int size: ${ac_cv_sizeof_int}])
165fi
166AC_DEFINE_UNQUOTED([LG_SIZEOF_INT], [$LG_SIZEOF_INT])
Jason Evansb7924f52009-06-23 19:01:18 -0700167
Jason Evans84c8eef2011-03-16 10:30:13 -0700168AC_CHECK_SIZEOF([long])
169if test "x${ac_cv_sizeof_long}" = "x8" ; then
170 LG_SIZEOF_LONG=3
171elif test "x${ac_cv_sizeof_long}" = "x4" ; then
172 LG_SIZEOF_LONG=2
173else
174 AC_MSG_ERROR([Unsupported long size: ${ac_cv_sizeof_long}])
175fi
176AC_DEFINE_UNQUOTED([LG_SIZEOF_LONG], [$LG_SIZEOF_LONG])
177
Jason Evansd81e4bd2012-03-06 14:57:45 -0800178AC_CHECK_SIZEOF([intmax_t])
179if test "x${ac_cv_sizeof_intmax_t}" = "x16" ; then
180 LG_SIZEOF_INTMAX_T=4
181elif test "x${ac_cv_sizeof_intmax_t}" = "x8" ; then
182 LG_SIZEOF_INTMAX_T=3
183elif test "x${ac_cv_sizeof_intmax_t}" = "x4" ; then
184 LG_SIZEOF_INTMAX_T=2
185else
Mike Hommey14103d32012-04-20 08:38:39 +0200186 AC_MSG_ERROR([Unsupported intmax_t size: ${ac_cv_sizeof_intmax_t}])
Jason Evansd81e4bd2012-03-06 14:57:45 -0800187fi
188AC_DEFINE_UNQUOTED([LG_SIZEOF_INTMAX_T], [$LG_SIZEOF_INTMAX_T])
189
Jason Evansb7924f52009-06-23 19:01:18 -0700190AC_CANONICAL_HOST
191dnl CPU-specific settings.
192CPU_SPINWAIT=""
193case "${host_cpu}" in
194 i[[345]]86)
195 ;;
196 i686)
Jason Evansf3340ca2009-06-30 16:17:05 -0700197 JE_COMPILABLE([__asm__], [], [[__asm__ volatile("pause"); return 0;]],
Jason Evans6684cac2012-03-05 12:15:36 -0800198 [je_cv_asm])
199 if test "x${je_cv_asm}" = "xyes" ; then
Jason Evansf3340ca2009-06-30 16:17:05 -0700200 CPU_SPINWAIT='__asm__ volatile("pause")'
201 fi
Jason Evansb7924f52009-06-23 19:01:18 -0700202 ;;
203 x86_64)
Jason Evansf3340ca2009-06-30 16:17:05 -0700204 JE_COMPILABLE([__asm__ syntax], [],
Jason Evans6684cac2012-03-05 12:15:36 -0800205 [[__asm__ volatile("pause"); return 0;]], [je_cv_asm])
206 if test "x${je_cv_asm}" = "xyes" ; then
Jason Evansf3340ca2009-06-30 16:17:05 -0700207 CPU_SPINWAIT='__asm__ volatile("pause")'
208 fi
Jason Evansb7924f52009-06-23 19:01:18 -0700209 ;;
210 *)
211 ;;
212esac
213AC_DEFINE_UNQUOTED([CPU_SPINWAIT], [$CPU_SPINWAIT])
214
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +0400215LD_PRELOAD_VAR="LD_PRELOAD"
Jason Evansf576c632011-11-01 22:27:41 -0700216so="so"
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200217importlib="${so}"
Mike Hommey7cdea392012-04-30 12:38:27 +0200218o="$ac_objext"
Mike Hommey5bee66d2012-04-16 16:30:24 +0200219a="a"
Mike Hommey7cdea392012-04-30 12:38:27 +0200220exe="$ac_exeext"
Mike Hommeya19e87f2012-04-21 21:27:46 -0700221libprefix="lib"
Mike Hommeyfa08da72012-04-16 16:30:25 +0200222DSO_LDFLAGS='-shared -Wl,-soname,$(@F)'
223RPATH='-Wl,-rpath,$(1)'
Mike Hommey7cdea392012-04-30 12:38:27 +0200224SOREV="${so}.${rev}"
Mike Hommey188da7c2012-04-18 18:29:41 +0200225PIC_CFLAGS='-fPIC -DPIC'
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200226CTARGET='-o $@'
227LDTARGET='-o $@'
228EXTRA_LDFLAGS=
Mike Hommey79c4bca2012-05-02 21:30:51 +0200229CC_MM=1
Jason Evans7372b152012-02-10 20:22:09 -0800230
Jory A. Prattad505e02013-08-11 09:44:59 -0500231AN_MAKEVAR([AR], [AC_PROG_AR])
232AN_PROGRAM([ar], [AC_PROG_AR])
233AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL(AR, ar, :)])
234AC_PROG_AR
235
Jason Evansb7924f52009-06-23 19:01:18 -0700236dnl Platform-specific settings. abi and RPATH can probably be determined
237dnl programmatically, but doing so is error-prone, which makes it generally
238dnl not worth the trouble.
239dnl
240dnl Define cpp macros in CPPFLAGS, rather than doing AC_DEFINE(macro), since the
241dnl definitions need to be seen before any headers are included, which is a pain
242dnl to make happen otherwise.
Jason Evans59ae2762012-04-16 17:52:27 -0700243default_munmap="1"
Jason Evans247d1242012-10-09 16:20:10 -0700244JEMALLOC_USABLE_SIZE_CONST="const"
Jason Evansb7924f52009-06-23 19:01:18 -0700245case "${host}" in
246 *-*-darwin*)
Mike Hommeya6770a72012-05-03 14:12:49 +0200247 CFLAGS="$CFLAGS"
Jason Evansb7924f52009-06-23 19:01:18 -0700248 abi="macho"
Jason Evanse24c7af2012-03-19 10:21:17 -0700249 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
Jason Evansb7924f52009-06-23 19:01:18 -0700250 RPATH=""
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +0400251 LD_PRELOAD_VAR="DYLD_INSERT_LIBRARIES"
Jason Evansf576c632011-11-01 22:27:41 -0700252 so="dylib"
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200253 importlib="${so}"
Jason Evansb80581d2012-03-23 16:17:43 -0700254 force_tls="0"
Mike Hommeyfa08da72012-04-16 16:30:25 +0200255 DSO_LDFLAGS='-shared -Wl,-dylib_install_name,$(@F)'
Mike Hommey7cdea392012-04-30 12:38:27 +0200256 SOREV="${rev}.${so}"
Jason Evansb7924f52009-06-23 19:01:18 -0700257 ;;
258 *-*-freebsd*)
259 CFLAGS="$CFLAGS"
260 abi="elf"
Jason Evanse24c7af2012-03-19 10:21:17 -0700261 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
Jason Evansfd4fcef2012-03-23 17:40:58 -0700262 force_lazy_lock="1"
Jason Evansb7924f52009-06-23 19:01:18 -0700263 ;;
264 *-*-linux*)
265 CFLAGS="$CFLAGS"
266 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
267 abi="elf"
Garrett Cooper13e4e242012-12-02 17:58:40 -0800268 AC_DEFINE([JEMALLOC_HAS_ALLOCA_H])
Jason Evanse24c7af2012-03-19 10:21:17 -0700269 AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED], [ ])
Jason Evans02b23122012-04-05 11:06:23 -0700270 AC_DEFINE([JEMALLOC_THREADED_INIT], [ ])
Jason Evans247d1242012-10-09 16:20:10 -0700271 JEMALLOC_USABLE_SIZE_CONST=""
Jason Evans59ae2762012-04-16 17:52:27 -0700272 default_munmap="0"
Jason Evansb7924f52009-06-23 19:01:18 -0700273 ;;
274 *-*-netbsd*)
275 AC_MSG_CHECKING([ABI])
276 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
277[[#ifdef __ELF__
278/* ELF */
279#else
280#error aout
281#endif
282]])],
283 [CFLAGS="$CFLAGS"; abi="elf"],
284 [abi="aout"])
285 AC_MSG_RESULT([$abi])
Jason Evanse24c7af2012-03-19 10:21:17 -0700286 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
Jason Evansb7924f52009-06-23 19:01:18 -0700287 ;;
288 *-*-solaris2*)
289 CFLAGS="$CFLAGS"
290 abi="elf"
Mike Hommeyfa08da72012-04-16 16:30:25 +0200291 RPATH='-Wl,-R,$(1)'
Jason Evansb7924f52009-06-23 19:01:18 -0700292 dnl Solaris needs this for sigwait().
293 CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
294 LIBS="$LIBS -lposix4 -lsocket -lnsl"
295 ;;
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +0400296 *-ibm-aix*)
297 if "$LG_SIZEOF_PTR" = "8"; then
298 dnl 64bit AIX
299 LD_PRELOAD_VAR="LDR_PRELOAD64"
300 else
301 dnl 32bit AIX
302 LD_PRELOAD_VAR="LDR_PRELOAD"
303 fi
304 abi="xcoff"
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +0400305 ;;
Mike Hommeya19e87f2012-04-21 21:27:46 -0700306 *-*-mingw*)
307 abi="pecoff"
308 force_tls="0"
309 RPATH=""
310 so="dll"
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200311 if test "x$je_cv_msvc" = "xyes" ; then
312 importlib="lib"
313 DSO_LDFLAGS="-LD"
314 EXTRA_LDFLAGS="-link -DEBUG"
315 CTARGET='-Fo$@'
316 LDTARGET='-Fe$@'
Jory A. Prattad505e02013-08-11 09:44:59 -0500317 AR='lib'
318 ARFLAGS='-nologo -out:'
Mike Hommey79c4bca2012-05-02 21:30:51 +0200319 CC_MM=
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200320 else
321 importlib="${so}"
322 DSO_LDFLAGS="-shared"
323 fi
Mike Hommeya19e87f2012-04-21 21:27:46 -0700324 a="lib"
325 libprefix=""
Mike Hommey7cdea392012-04-30 12:38:27 +0200326 SOREV="${so}"
Mike Hommeya19e87f2012-04-21 21:27:46 -0700327 PIC_CFLAGS=""
328 ;;
Jason Evansb7924f52009-06-23 19:01:18 -0700329 *)
330 AC_MSG_RESULT([Unsupported operating system: ${host}])
331 abi="elf"
Jason Evansb7924f52009-06-23 19:01:18 -0700332 ;;
333esac
Jason Evans247d1242012-10-09 16:20:10 -0700334AC_DEFINE_UNQUOTED([JEMALLOC_USABLE_SIZE_CONST], [$JEMALLOC_USABLE_SIZE_CONST])
Jason Evansb7924f52009-06-23 19:01:18 -0700335AC_SUBST([abi])
336AC_SUBST([RPATH])
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +0400337AC_SUBST([LD_PRELOAD_VAR])
Jason Evansf576c632011-11-01 22:27:41 -0700338AC_SUBST([so])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200339AC_SUBST([importlib])
Mike Hommey5bee66d2012-04-16 16:30:24 +0200340AC_SUBST([o])
341AC_SUBST([a])
342AC_SUBST([exe])
Mike Hommeya19e87f2012-04-21 21:27:46 -0700343AC_SUBST([libprefix])
Mike Hommeyfa08da72012-04-16 16:30:25 +0200344AC_SUBST([DSO_LDFLAGS])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200345AC_SUBST([EXTRA_LDFLAGS])
Mike Hommey85221d52012-04-18 18:29:40 +0200346AC_SUBST([SOREV])
Mike Hommey188da7c2012-04-18 18:29:41 +0200347AC_SUBST([PIC_CFLAGS])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200348AC_SUBST([CTARGET])
349AC_SUBST([LDTARGET])
350AC_SUBST([MKLIB])
Mike Hommey79c4bca2012-05-02 21:30:51 +0200351AC_SUBST([CC_MM])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200352
353if test "x$abi" != "xpecoff"; then
354 dnl Heap profiling uses the log(3) function.
355 LIBS="$LIBS -lm"
356fi
Jason Evansb7924f52009-06-23 19:01:18 -0700357
Jason Evansfa5d2452011-03-15 10:25:59 -0700358JE_COMPILABLE([__attribute__ syntax],
359 [static __attribute__((unused)) void foo(void){}],
360 [],
Jason Evans6684cac2012-03-05 12:15:36 -0800361 [je_cv_attribute])
362if test "x${je_cv_attribute}" = "xyes" ; then
Jason Evansfa5d2452011-03-15 10:25:59 -0700363 AC_DEFINE([JEMALLOC_HAVE_ATTR], [ ])
364 if test "x${GCC}" = "xyes" -a "x${abi}" = "xelf"; then
365 JE_CFLAGS_APPEND([-fvisibility=hidden])
366 fi
367fi
Jason Evans3cc1f1a2012-04-03 22:30:05 -0700368dnl Check for tls_model attribute support (clang 3.0 still lacks support).
369SAVED_CFLAGS="${CFLAGS}"
370JE_CFLAGS_APPEND([-Werror])
371JE_COMPILABLE([tls_model attribute], [],
372 [static __thread int
373 __attribute__((tls_model("initial-exec"))) foo;
374 foo = 0;],
375 [je_cv_tls_model])
376CFLAGS="${SAVED_CFLAGS}"
377if test "x${je_cv_tls_model}" = "xyes" ; then
378 AC_DEFINE([JEMALLOC_TLS_MODEL],
379 [__attribute__((tls_model("initial-exec")))])
380else
381 AC_DEFINE([JEMALLOC_TLS_MODEL], [ ])
382fi
Jason Evansfa5d2452011-03-15 10:25:59 -0700383
Jason Evansb7924f52009-06-23 19:01:18 -0700384dnl Support optional additions to rpath.
385AC_ARG_WITH([rpath],
Jason Evans90895cf2009-12-29 00:09:15 -0800386 [AS_HELP_STRING([--with-rpath=<rpath>], [Colon-separated rpath (ELF systems only)])],
Jason Evansb7924f52009-06-23 19:01:18 -0700387if test "x$with_rpath" = "xno" ; then
388 RPATH_EXTRA=
389else
390 RPATH_EXTRA="`echo $with_rpath | tr \":\" \" \"`"
391fi,
392 RPATH_EXTRA=
393)
394AC_SUBST([RPATH_EXTRA])
395
396dnl Disable rules that do automatic regeneration of configure output by default.
397AC_ARG_ENABLE([autogen],
Jason Evans78d815c2010-01-17 14:06:20 -0800398 [AS_HELP_STRING([--enable-autogen], [Automatically regenerate configure output])],
Jason Evansb7924f52009-06-23 19:01:18 -0700399if test "x$enable_autogen" = "xno" ; then
400 enable_autogen="0"
401else
402 enable_autogen="1"
403fi
404,
405enable_autogen="0"
406)
407AC_SUBST([enable_autogen])
408
409AC_PROG_INSTALL
410AC_PROG_RANLIB
Jason Evans7329a4f2013-01-22 10:53:29 -0800411AC_PATH_PROG([LD], [ld], [false], [$PATH])
412AC_PATH_PROG([AUTOCONF], [autoconf], [false], [$PATH])
Jason Evansb7924f52009-06-23 19:01:18 -0700413
Jason Evans0a0bbf62012-03-13 12:55:21 -0700414public_syms="malloc_conf malloc_message malloc calloc posix_memalign aligned_alloc realloc free malloc_usable_size malloc_stats_print mallctl mallctlnametomib mallctlbymib"
Jason Evans7e77eaf2012-03-02 17:47:37 -0800415
416dnl Check for allocator-related functions that should be wrapped.
417AC_CHECK_FUNC([memalign],
Jason Evanse24c7af2012-03-19 10:21:17 -0700418 [AC_DEFINE([JEMALLOC_OVERRIDE_MEMALIGN], [ ])
Jason Evans7e77eaf2012-03-02 17:47:37 -0800419 public_syms="${public_syms} memalign"])
420AC_CHECK_FUNC([valloc],
Jason Evanse24c7af2012-03-19 10:21:17 -0700421 [AC_DEFINE([JEMALLOC_OVERRIDE_VALLOC], [ ])
Jason Evans7e77eaf2012-03-02 17:47:37 -0800422 public_syms="${public_syms} valloc"])
423
424dnl Support the experimental API by default.
425AC_ARG_ENABLE([experimental],
426 [AS_HELP_STRING([--disable-experimental],
427 [Disable support for the experimental API])],
428[if test "x$enable_experimental" = "xno" ; then
429 enable_experimental="0"
430else
431 enable_experimental="1"
432fi
433],
434[enable_experimental="1"]
435)
436if test "x$enable_experimental" = "x1" ; then
437 AC_DEFINE([JEMALLOC_EXPERIMENTAL], [ ])
438 public_syms="${public_syms} allocm dallocm nallocm rallocm sallocm"
439fi
440AC_SUBST([enable_experimental])
441
Jason Evans0a5489e2012-03-01 17:19:20 -0800442dnl Perform no name mangling by default.
443AC_ARG_WITH([mangling],
444 [AS_HELP_STRING([--with-mangling=<map>], [Mangle symbols in <map>])],
445 [mangling_map="$with_mangling"], [mangling_map=""])
446for nm in `echo ${mangling_map} |tr ',' ' '` ; do
Jason Evans08fc3b22012-03-12 15:07:53 -0700447 k="`echo ${nm} |tr ':' ' ' |awk '{print $1}'`"
448 n="je_${k}"
Jason Evans0a5489e2012-03-01 17:19:20 -0800449 m=`echo ${nm} |tr ':' ' ' |awk '{print $2}'`
450 AC_DEFINE_UNQUOTED([${n}], [${m}])
Jason Evans08fc3b22012-03-12 15:07:53 -0700451 dnl Remove key from public_syms so that it isn't redefined later.
452 public_syms=`for sym in ${public_syms}; do echo "${sym}"; done |grep -v "^${k}\$" |tr '\n' ' '`
Jason Evans0a5489e2012-03-01 17:19:20 -0800453done
454
Jason Evans90895cf2009-12-29 00:09:15 -0800455dnl Do not prefix public APIs by default.
456AC_ARG_WITH([jemalloc_prefix],
457 [AS_HELP_STRING([--with-jemalloc-prefix=<prefix>], [Prefix to prepend to all public APIs])],
Jason Evansb0fd5012010-01-17 01:49:20 -0800458 [JEMALLOC_PREFIX="$with_jemalloc_prefix"],
Mike Hommey7cdea392012-04-30 12:38:27 +0200459 [if test "x$abi" != "xmacho" -a "x$abi" != "xpecoff"; then
Jason Evans2dbecf12010-09-05 10:35:13 -0700460 JEMALLOC_PREFIX=""
461else
462 JEMALLOC_PREFIX="je_"
463fi]
Jason Evans90895cf2009-12-29 00:09:15 -0800464)
465if test "x$JEMALLOC_PREFIX" != "x" ; then
Jason Evanse7339702010-10-23 18:37:06 -0700466 JEMALLOC_CPREFIX=`echo ${JEMALLOC_PREFIX} | tr "a-z" "A-Z"`
467 AC_DEFINE_UNQUOTED([JEMALLOC_PREFIX], ["$JEMALLOC_PREFIX"])
468 AC_DEFINE_UNQUOTED([JEMALLOC_CPREFIX], ["$JEMALLOC_CPREFIX"])
Jason Evans90895cf2009-12-29 00:09:15 -0800469fi
Jason Evans0a5489e2012-03-01 17:19:20 -0800470dnl Generate macros to rename public symbols. All public symbols are prefixed
471dnl with je_ in the source code, so these macro definitions are needed even if
472dnl --with-jemalloc-prefix wasn't specified.
Jason Evans7e77eaf2012-03-02 17:47:37 -0800473for stem in ${public_syms}; do
Jason Evans0a5489e2012-03-01 17:19:20 -0800474 n="je_${stem}"
475 m="${JEMALLOC_PREFIX}${stem}"
476 AC_DEFINE_UNQUOTED([${n}], [${m}])
477done
Jason Evans90895cf2009-12-29 00:09:15 -0800478
Mike Hommey99066602012-11-19 10:55:26 +0100479AC_ARG_WITH([export],
480 [AS_HELP_STRING([--without-export], [disable exporting jemalloc public APIs])],
481 [if test "x$with_export" = "xno"; then
Jason Evans2625c892013-01-22 16:46:27 -0800482 AC_DEFINE([JEMALLOC_EXPORT],[])
Mike Hommey99066602012-11-19 10:55:26 +0100483fi]
484)
485
Jason Evans746e77a2011-07-30 16:40:52 -0700486dnl Do not mangle library-private APIs by default.
487AC_ARG_WITH([private_namespace],
488 [AS_HELP_STRING([--with-private-namespace=<prefix>], [Prefix to prepend to all library-private APIs])],
489 [JEMALLOC_PRIVATE_NAMESPACE="$with_private_namespace"],
490 [JEMALLOC_PRIVATE_NAMESPACE=""]
491)
492AC_DEFINE_UNQUOTED([JEMALLOC_PRIVATE_NAMESPACE], ["$JEMALLOC_PRIVATE_NAMESPACE"])
493if test "x$JEMALLOC_PRIVATE_NAMESPACE" != "x" ; then
494 AC_DEFINE_UNQUOTED([JEMALLOC_N(string_that_no_one_should_want_to_use_as_a_jemalloc_private_namespace_prefix)], [${JEMALLOC_PRIVATE_NAMESPACE}##string_that_no_one_should_want_to_use_as_a_jemalloc_private_namespace_prefix])
495else
496 AC_DEFINE_UNQUOTED([JEMALLOC_N(string_that_no_one_should_want_to_use_as_a_jemalloc_private_namespace_prefix)], [string_that_no_one_should_want_to_use_as_a_jemalloc_private_namespace_prefix])
497fi
498
Jason Evansb0fd5012010-01-17 01:49:20 -0800499dnl Do not add suffix to installed files by default.
500AC_ARG_WITH([install_suffix],
501 [AS_HELP_STRING([--with-install-suffix=<suffix>], [Suffix to append to all installed files])],
502 [INSTALL_SUFFIX="$with_install_suffix"],
503 [INSTALL_SUFFIX=]
504)
505install_suffix="$INSTALL_SUFFIX"
506AC_SUBST([install_suffix])
507
Jason Evansaee7fd22010-11-24 22:00:02 -0800508cfgoutputs_in="${srcroot}Makefile.in"
509cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/html.xsl.in"
510cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/manpages.xsl.in"
511cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/jemalloc.xml.in"
Jason Evans0656ec02010-04-07 23:37:35 -0700512cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/jemalloc.h.in"
513cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/internal/jemalloc_internal.h.in"
Jason Evans9f3b0a72010-10-07 09:53:26 -0700514cfgoutputs_in="${cfgoutputs_in} ${srcroot}test/jemalloc_test.h.in"
Jason Evansb0fd5012010-01-17 01:49:20 -0800515
Jason Evansaee7fd22010-11-24 22:00:02 -0800516cfgoutputs_out="Makefile"
517cfgoutputs_out="${cfgoutputs_out} doc/html.xsl"
518cfgoutputs_out="${cfgoutputs_out} doc/manpages.xsl"
519cfgoutputs_out="${cfgoutputs_out} doc/jemalloc${install_suffix}.xml"
Jason Evans376b1522010-02-11 14:45:59 -0800520cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc${install_suffix}.h"
521cfgoutputs_out="${cfgoutputs_out} include/jemalloc/internal/jemalloc_internal.h"
Jason Evans9f3b0a72010-10-07 09:53:26 -0700522cfgoutputs_out="${cfgoutputs_out} test/jemalloc_test.h"
Jason Evansb0fd5012010-01-17 01:49:20 -0800523
Jason Evansaee7fd22010-11-24 22:00:02 -0800524cfgoutputs_tup="Makefile"
525cfgoutputs_tup="${cfgoutputs_tup} doc/html.xsl:doc/html.xsl.in"
526cfgoutputs_tup="${cfgoutputs_tup} doc/manpages.xsl:doc/manpages.xsl.in"
527cfgoutputs_tup="${cfgoutputs_tup} doc/jemalloc${install_suffix}.xml:doc/jemalloc.xml.in"
Jason Evans376b1522010-02-11 14:45:59 -0800528cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc${install_suffix}.h:include/jemalloc/jemalloc.h.in"
529cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/internal/jemalloc_internal.h"
Jason Evans9f3b0a72010-10-07 09:53:26 -0700530cfgoutputs_tup="${cfgoutputs_tup} test/jemalloc_test.h:test/jemalloc_test.h.in"
Jason Evansb0fd5012010-01-17 01:49:20 -0800531
Jason Evans0656ec02010-04-07 23:37:35 -0700532cfghdrs_in="${srcroot}include/jemalloc/jemalloc_defs.h.in"
Jason Evansb1726102012-02-28 16:50:47 -0800533cfghdrs_in="${cfghdrs_in} ${srcroot}include/jemalloc/internal/size_classes.sh"
Jason Evansb0fd5012010-01-17 01:49:20 -0800534
Jason Evans376b1522010-02-11 14:45:59 -0800535cfghdrs_out="include/jemalloc/jemalloc_defs${install_suffix}.h"
Jason Evansb1726102012-02-28 16:50:47 -0800536cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/size_classes.h"
Jason Evansb0fd5012010-01-17 01:49:20 -0800537
Jason Evans376b1522010-02-11 14:45:59 -0800538cfghdrs_tup="include/jemalloc/jemalloc_defs${install_suffix}.h:include/jemalloc/jemalloc_defs.h.in"
Jason Evansb0fd5012010-01-17 01:49:20 -0800539
Jason Evans355b4382010-09-20 19:20:48 -0700540dnl Do not silence irrelevant compiler warnings by default, since enabling this
541dnl option incurs a performance penalty.
542AC_ARG_ENABLE([cc-silence],
543 [AS_HELP_STRING([--enable-cc-silence],
544 [Silence irrelevant compiler warnings])],
545[if test "x$enable_cc_silence" = "xno" ; then
546 enable_cc_silence="0"
547else
548 enable_cc_silence="1"
549fi
550],
551[enable_cc_silence="0"]
552)
553if test "x$enable_cc_silence" = "x1" ; then
Jason Evanse24c7af2012-03-19 10:21:17 -0700554 AC_DEFINE([JEMALLOC_CC_SILENCE], [ ])
Jason Evans355b4382010-09-20 19:20:48 -0700555fi
556
Jason Evansb7924f52009-06-23 19:01:18 -0700557dnl Do not compile with debugging by default.
558AC_ARG_ENABLE([debug],
Mike Hommey5135e342012-12-06 22:16:26 +0100559 [AS_HELP_STRING([--enable-debug], [Build debugging code (implies --enable-ivsalloc)])],
Jason Evansb7924f52009-06-23 19:01:18 -0700560[if test "x$enable_debug" = "xno" ; then
561 enable_debug="0"
562else
563 enable_debug="1"
564fi
565],
566[enable_debug="0"]
567)
568if test "x$enable_debug" = "x1" ; then
569 AC_DEFINE([JEMALLOC_DEBUG], [ ])
Mike Hommey5135e342012-12-06 22:16:26 +0100570 enable_ivsalloc="1"
Jason Evansb7924f52009-06-23 19:01:18 -0700571fi
572AC_SUBST([enable_debug])
573
Mike Hommey5135e342012-12-06 22:16:26 +0100574dnl Do not validate pointers by default.
575AC_ARG_ENABLE([ivsalloc],
576 [AS_HELP_STRING([--enable-ivsalloc], [Validate pointers passed through the public API])],
577[if test "x$enable_ivsalloc" = "xno" ; then
578 enable_ivsalloc="0"
579else
580 enable_ivsalloc="1"
581fi
582],
583[enable_ivsalloc="0"]
584)
585if test "x$enable_ivsalloc" = "x1" ; then
586 AC_DEFINE([JEMALLOC_IVSALLOC], [ ])
587fi
588
Jason Evansb7924f52009-06-23 19:01:18 -0700589dnl Only optimize if not debugging.
590if test "x$enable_debug" = "x0" -a "x$no_CFLAGS" = "xyes" ; then
591 dnl Make sure that an optimization flag was not specified in EXTRA_CFLAGS.
Jason Evansf3340ca2009-06-30 16:17:05 -0700592 optimize="no"
593 echo "$EXTRA_CFLAGS" | grep "\-O" >/dev/null || optimize="yes"
594 if test "x${optimize}" = "xyes" ; then
595 if test "x$GCC" = "xyes" ; then
596 JE_CFLAGS_APPEND([-O3])
597 JE_CFLAGS_APPEND([-funroll-loops])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200598 elif test "x$je_cv_msvc" = "xyes" ; then
599 JE_CFLAGS_APPEND([-O2])
Jason Evansf3340ca2009-06-30 16:17:05 -0700600 else
601 JE_CFLAGS_APPEND([-O])
602 fi
Jason Evansb7924f52009-06-23 19:01:18 -0700603 fi
604fi
605
Jason Evansd073a322012-02-28 20:41:16 -0800606dnl Enable statistics calculation by default.
Jason Evansb7924f52009-06-23 19:01:18 -0700607AC_ARG_ENABLE([stats],
Jason Evans777c1912012-02-28 20:49:22 -0800608 [AS_HELP_STRING([--disable-stats],
609 [Disable statistics calculation/reporting])],
Jason Evansb7924f52009-06-23 19:01:18 -0700610[if test "x$enable_stats" = "xno" ; then
611 enable_stats="0"
612else
613 enable_stats="1"
614fi
615],
Jason Evansd073a322012-02-28 20:41:16 -0800616[enable_stats="1"]
Jason Evansb7924f52009-06-23 19:01:18 -0700617)
618if test "x$enable_stats" = "x1" ; then
619 AC_DEFINE([JEMALLOC_STATS], [ ])
620fi
621AC_SUBST([enable_stats])
622
Jason Evans6109fe02010-02-10 10:37:56 -0800623dnl Do not enable profiling by default.
624AC_ARG_ENABLE([prof],
625 [AS_HELP_STRING([--enable-prof], [Enable allocation profiling])],
626[if test "x$enable_prof" = "xno" ; then
627 enable_prof="0"
628else
629 enable_prof="1"
630fi
631],
632[enable_prof="0"]
633)
Jason Evans77f350b2011-03-15 22:23:12 -0700634if test "x$enable_prof" = "x1" ; then
635 backtrace_method=""
Jason Evansb27805b2010-02-10 18:15:53 -0800636else
Jason Evans77f350b2011-03-15 22:23:12 -0700637 backtrace_method="N/A"
Jason Evansb27805b2010-02-10 18:15:53 -0800638fi
Jason Evans77f350b2011-03-15 22:23:12 -0700639
Jason Evans6109fe02010-02-10 10:37:56 -0800640AC_ARG_ENABLE([prof-libunwind],
641 [AS_HELP_STRING([--enable-prof-libunwind], [Use libunwind for backtracing])],
642[if test "x$enable_prof_libunwind" = "xno" ; then
643 enable_prof_libunwind="0"
644else
645 enable_prof_libunwind="1"
646fi
647],
648[enable_prof_libunwind="0"]
649)
Jason Evansca6bd4f2010-03-02 14:12:58 -0800650AC_ARG_WITH([static_libunwind],
651 [AS_HELP_STRING([--with-static-libunwind=<libunwind.a>],
652 [Path to static libunwind library; use rather than dynamically linking])],
653if test "x$with_static_libunwind" = "xno" ; then
654 LUNWIND="-lunwind"
655else
656 if test ! -f "$with_static_libunwind" ; then
657 AC_MSG_ERROR([Static libunwind not found: $with_static_libunwind])
658 fi
659 LUNWIND="$with_static_libunwind"
660fi,
661 LUNWIND="-lunwind"
662)
Jason Evans77f350b2011-03-15 22:23:12 -0700663if test "x$backtrace_method" = "x" -a "x$enable_prof_libunwind" = "x1" ; then
664 AC_CHECK_HEADERS([libunwind.h], , [enable_prof_libunwind="0"])
665 if test "x$LUNWIND" = "x-lunwind" ; then
666 AC_CHECK_LIB([unwind], [backtrace], [LIBS="$LIBS $LUNWIND"],
667 [enable_prof_libunwind="0"])
668 else
669 LIBS="$LIBS $LUNWIND"
670 fi
671 if test "x${enable_prof_libunwind}" = "x1" ; then
672 backtrace_method="libunwind"
673 AC_DEFINE([JEMALLOC_PROF_LIBUNWIND], [ ])
674 fi
675fi
676
677AC_ARG_ENABLE([prof-libgcc],
678 [AS_HELP_STRING([--disable-prof-libgcc],
679 [Do not use libgcc for backtracing])],
680[if test "x$enable_prof_libgcc" = "xno" ; then
681 enable_prof_libgcc="0"
682else
683 enable_prof_libgcc="1"
684fi
685],
686[enable_prof_libgcc="1"]
687)
688if test "x$backtrace_method" = "x" -a "x$enable_prof_libgcc" = "x1" \
689 -a "x$GCC" = "xyes" ; then
690 AC_CHECK_HEADERS([unwind.h], , [enable_prof_libgcc="0"])
691 AC_CHECK_LIB([gcc], [_Unwind_Backtrace], [LIBS="$LIBS -lgcc"], [enable_prof_libgcc="0"])
692 dnl The following is conservative, in that it only has entries for CPUs on
693 dnl which jemalloc has been tested.
694 AC_MSG_CHECKING([libgcc-based backtracing reliability on ${host_cpu}])
695 case "${host_cpu}" in
696 i[[3456]]86)
697 AC_MSG_RESULT([unreliable])
698 enable_prof_libgcc="0";
699 ;;
700 x86_64)
701 AC_MSG_RESULT([reliable])
702 ;;
703 *)
704 AC_MSG_RESULT([unreliable])
705 enable_prof_libgcc="0";
706 ;;
707 esac
708 if test "x${enable_prof_libgcc}" = "x1" ; then
709 backtrace_method="libgcc"
710 AC_DEFINE([JEMALLOC_PROF_LIBGCC], [ ])
711 fi
712else
713 enable_prof_libgcc="0"
714fi
715
716AC_ARG_ENABLE([prof-gcc],
717 [AS_HELP_STRING([--disable-prof-gcc],
718 [Do not use gcc intrinsics for backtracing])],
719[if test "x$enable_prof_gcc" = "xno" ; then
720 enable_prof_gcc="0"
721else
722 enable_prof_gcc="1"
723fi
724],
725[enable_prof_gcc="1"]
726)
727if test "x$backtrace_method" = "x" -a "x$enable_prof_gcc" = "x1" \
728 -a "x$GCC" = "xyes" ; then
729 backtrace_method="gcc intrinsics"
730 AC_DEFINE([JEMALLOC_PROF_GCC], [ ])
731else
732 enable_prof_gcc="0"
733fi
734
735if test "x$backtrace_method" = "x" ; then
736 backtrace_method="none (disabling profiling)"
737 enable_prof="0"
738fi
739AC_MSG_CHECKING([configured backtracing method])
740AC_MSG_RESULT([$backtrace_method])
Jason Evans2dbecf12010-09-05 10:35:13 -0700741if test "x$enable_prof" = "x1" ; then
Jason Evans6716aa82012-04-23 13:04:55 -0700742 if test "x${force_tls}" = "x0" ; then
743 AC_MSG_ERROR([Heap profiling requires TLS]);
744 fi
745 force_tls="1"
Jason Evans2dbecf12010-09-05 10:35:13 -0700746 AC_DEFINE([JEMALLOC_PROF], [ ])
Jason Evans2dbecf12010-09-05 10:35:13 -0700747fi
748AC_SUBST([enable_prof])
Jason Evans2dbecf12010-09-05 10:35:13 -0700749
Jason Evans84cbbcb2009-12-29 00:09:15 -0800750dnl Enable thread-specific caching by default.
751AC_ARG_ENABLE([tcache],
752 [AS_HELP_STRING([--disable-tcache], [Disable per thread caches])],
753[if test "x$enable_tcache" = "xno" ; then
754 enable_tcache="0"
Jason Evansb7924f52009-06-23 19:01:18 -0700755else
Jason Evans84cbbcb2009-12-29 00:09:15 -0800756 enable_tcache="1"
Jason Evansb7924f52009-06-23 19:01:18 -0700757fi
758],
Jason Evans84cbbcb2009-12-29 00:09:15 -0800759[enable_tcache="1"]
Jason Evansb7924f52009-06-23 19:01:18 -0700760)
Jason Evans2dbecf12010-09-05 10:35:13 -0700761if test "x$enable_tcache" = "x1" ; then
762 AC_DEFINE([JEMALLOC_TCACHE], [ ])
763fi
764AC_SUBST([enable_tcache])
Jason Evansb7924f52009-06-23 19:01:18 -0700765
Jason Evans2e671ff2012-05-09 16:12:00 -0700766dnl Disable mremap() for huge realloc() by default.
767AC_ARG_ENABLE([mremap],
768 [AS_HELP_STRING([--enable-mremap], [Enable mremap(2) for huge realloc()])],
769[if test "x$enable_mremap" = "xno" ; then
770 enable_mremap="0"
771else
772 enable_mremap="1"
773fi
774],
775[enable_mremap="0"]
776)
777if test "x$enable_mremap" = "x1" ; then
778 JE_COMPILABLE([mremap(...MREMAP_FIXED...)], [
779#define _GNU_SOURCE
780#include <sys/mman.h>
781], [
782void *p = mremap((void *)0, 0, 0, MREMAP_MAYMOVE|MREMAP_FIXED, (void *)0);
783], [je_cv_mremap_fixed])
784 if test "x${je_cv_mremap_fixed}" = "xno" ; then
785 enable_mremap="0"
786 fi
787fi
788if test "x$enable_mremap" = "x1" ; then
789 AC_DEFINE([JEMALLOC_MREMAP], [ ])
790fi
791AC_SUBST([enable_mremap])
792
Jason Evans59ae2762012-04-16 17:52:27 -0700793dnl Enable VM deallocation via munmap() by default.
794AC_ARG_ENABLE([munmap],
795 [AS_HELP_STRING([--disable-munmap], [Disable VM deallocation via munmap(2)])],
796[if test "x$enable_munmap" = "xno" ; then
797 enable_munmap="0"
798else
799 enable_munmap="1"
800fi
801],
802[enable_munmap="${default_munmap}"]
803)
804if test "x$enable_munmap" = "x1" ; then
805 AC_DEFINE([JEMALLOC_MUNMAP], [ ])
806fi
807AC_SUBST([enable_munmap])
808
Jason Evansb7924f52009-06-23 19:01:18 -0700809dnl Do not enable allocation from DSS by default.
810AC_ARG_ENABLE([dss],
811 [AS_HELP_STRING([--enable-dss], [Enable allocation from DSS])],
812[if test "x$enable_dss" = "xno" ; then
813 enable_dss="0"
814else
815 enable_dss="1"
816fi
817],
818[enable_dss="0"]
819)
Mike Hommey83c324a2012-04-12 10:13:03 +0200820dnl Check whether the BSD/SUSv1 sbrk() exists. If not, disable DSS support.
821AC_CHECK_FUNC([sbrk], [have_sbrk="1"], [have_sbrk="0"])
822if test "x$have_sbrk" = "x1" ; then
823 AC_DEFINE([JEMALLOC_HAVE_SBRK], [ ])
824else
825 enable_dss="0"
826fi
827
Jason Evansb7924f52009-06-23 19:01:18 -0700828if test "x$enable_dss" = "x1" ; then
829 AC_DEFINE([JEMALLOC_DSS], [ ])
830fi
831AC_SUBST([enable_dss])
832
Jason Evans777c1912012-02-28 20:49:22 -0800833dnl Support the junk/zero filling option by default.
Jason Evansb7924f52009-06-23 19:01:18 -0700834AC_ARG_ENABLE([fill],
Jason Evans122449b2012-04-06 00:35:09 -0700835 [AS_HELP_STRING([--disable-fill],
836 [Disable support for junk/zero filling, quarantine, and redzones])],
Jason Evansb7924f52009-06-23 19:01:18 -0700837[if test "x$enable_fill" = "xno" ; then
838 enable_fill="0"
839else
840 enable_fill="1"
841fi
842],
Jason Evans777c1912012-02-28 20:49:22 -0800843[enable_fill="1"]
Jason Evansb7924f52009-06-23 19:01:18 -0700844)
845if test "x$enable_fill" = "x1" ; then
846 AC_DEFINE([JEMALLOC_FILL], [ ])
847fi
848AC_SUBST([enable_fill])
849
Jason Evansb1476112012-04-05 13:36:17 -0700850dnl Disable utrace(2)-based tracing by default.
851AC_ARG_ENABLE([utrace],
852 [AS_HELP_STRING([--enable-utrace], [Enable utrace(2)-based tracing])],
853[if test "x$enable_utrace" = "xno" ; then
854 enable_utrace="0"
855else
856 enable_utrace="1"
857fi
858],
859[enable_utrace="0"]
860)
861JE_COMPILABLE([utrace(2)], [
862#include <sys/types.h>
863#include <sys/param.h>
864#include <sys/time.h>
865#include <sys/uio.h>
866#include <sys/ktrace.h>
867], [
868 utrace((void *)0, 0);
869], [je_cv_utrace])
870if test "x${je_cv_utrace}" = "xno" ; then
871 enable_utrace="0"
872fi
873if test "x$enable_utrace" = "x1" ; then
874 AC_DEFINE([JEMALLOC_UTRACE], [ ])
875fi
876AC_SUBST([enable_utrace])
877
Jason Evans122449b2012-04-06 00:35:09 -0700878dnl Support Valgrind by default.
879AC_ARG_ENABLE([valgrind],
880 [AS_HELP_STRING([--disable-valgrind], [Disable support for Valgrind])],
881[if test "x$enable_valgrind" = "xno" ; then
882 enable_valgrind="0"
883else
884 enable_valgrind="1"
885fi
886],
887[enable_valgrind="1"]
888)
889if test "x$enable_valgrind" = "x1" ; then
890 JE_COMPILABLE([valgrind], [
891#include <valgrind/valgrind.h>
892#include <valgrind/memcheck.h>
893
Mike Hommey7bfecf42012-04-30 15:15:15 +0200894#if !defined(VALGRIND_RESIZEINPLACE_BLOCK)
Jason Evans122449b2012-04-06 00:35:09 -0700895# error "Incompatible Valgrind version"
896#endif
897], [], [je_cv_valgrind])
898 if test "x${je_cv_valgrind}" = "xno" ; then
899 enable_valgrind="0"
900 fi
901 if test "x$enable_valgrind" = "x1" ; then
902 AC_DEFINE([JEMALLOC_VALGRIND], [ ])
903 fi
904fi
905AC_SUBST([enable_valgrind])
906
Jason Evansb7924f52009-06-23 19:01:18 -0700907dnl Do not support the xmalloc option by default.
908AC_ARG_ENABLE([xmalloc],
909 [AS_HELP_STRING([--enable-xmalloc], [Support xmalloc option])],
910[if test "x$enable_xmalloc" = "xno" ; then
911 enable_xmalloc="0"
912else
913 enable_xmalloc="1"
914fi
915],
916[enable_xmalloc="0"]
917)
918if test "x$enable_xmalloc" = "x1" ; then
919 AC_DEFINE([JEMALLOC_XMALLOC], [ ])
920fi
921AC_SUBST([enable_xmalloc])
922
Jason Evans6684cac2012-03-05 12:15:36 -0800923AC_CACHE_CHECK([STATIC_PAGE_SHIFT],
924 [je_cv_static_page_shift],
925 AC_RUN_IFELSE([AC_LANG_PROGRAM(
Mike Hommeya19e87f2012-04-21 21:27:46 -0700926[[
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200927#include <strings.h>
Mike Hommeya19e87f2012-04-21 21:27:46 -0700928#ifdef _WIN32
929#include <windows.h>
930#else
Jason Evansb7924f52009-06-23 19:01:18 -0700931#include <unistd.h>
Mike Hommeya19e87f2012-04-21 21:27:46 -0700932#endif
933#include <stdio.h>
Jason Evans6684cac2012-03-05 12:15:36 -0800934]],
935[[
Garrett Cooper72c1e592012-12-02 17:57:28 -0800936 int result;
Jason Evansb7924f52009-06-23 19:01:18 -0700937 FILE *f;
938
Mike Hommeya19e87f2012-04-21 21:27:46 -0700939#ifdef _WIN32
940 SYSTEM_INFO si;
941 GetSystemInfo(&si);
942 result = si.dwPageSize;
943#else
Jason Evansb7924f52009-06-23 19:01:18 -0700944 result = sysconf(_SC_PAGESIZE);
Mike Hommeya19e87f2012-04-21 21:27:46 -0700945#endif
Jason Evansb7924f52009-06-23 19:01:18 -0700946 if (result == -1) {
947 return 1;
948 }
Mike Hommeya19e87f2012-04-21 21:27:46 -0700949 result = ffsl(result) - 1;
950
Jason Evansb7924f52009-06-23 19:01:18 -0700951 f = fopen("conftest.out", "w");
952 if (f == NULL) {
953 return 1;
954 }
Garrett Cooper72c1e592012-12-02 17:57:28 -0800955 fprintf(f, "%d\n", result);
Jason Evans3cc1f1a2012-04-03 22:30:05 -0700956 fclose(f);
Jason Evansb7924f52009-06-23 19:01:18 -0700957
958 return 0;
959]])],
Jason Evans6684cac2012-03-05 12:15:36 -0800960 [je_cv_static_page_shift=`cat conftest.out`],
961 [je_cv_static_page_shift=undefined]))
962
963if test "x$je_cv_static_page_shift" != "xundefined"; then
964 AC_DEFINE_UNQUOTED([STATIC_PAGE_SHIFT], [$je_cv_static_page_shift])
965else
966 AC_MSG_ERROR([cannot determine value for STATIC_PAGE_SHIFT])
967fi
Jason Evansb7924f52009-06-23 19:01:18 -0700968
969dnl ============================================================================
970dnl jemalloc configuration.
971dnl
Jason Evansa40bc7a2010-03-02 13:01:16 -0800972
973dnl Set VERSION if source directory has an embedded git repository.
Jason Evans955851f2011-03-31 22:38:51 -0700974if test -d "${srcroot}.git" ; then
Jason Evans79d660d2010-09-17 17:38:24 -0700975 git describe --long --abbrev=40 > ${srcroot}VERSION
Jason Evansa40bc7a2010-03-02 13:01:16 -0800976fi
Jason Evansb7924f52009-06-23 19:01:18 -0700977jemalloc_version=`cat ${srcroot}VERSION`
Jason Evansa40bc7a2010-03-02 13:01:16 -0800978jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'`
979jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'`
980jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'`
981jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'`
982jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'`
Jason Evansb7924f52009-06-23 19:01:18 -0700983AC_SUBST([jemalloc_version])
Jason Evansa40bc7a2010-03-02 13:01:16 -0800984AC_SUBST([jemalloc_version_major])
985AC_SUBST([jemalloc_version_minor])
986AC_SUBST([jemalloc_version_bugfix])
987AC_SUBST([jemalloc_version_nrev])
988AC_SUBST([jemalloc_version_gid])
Jason Evansb7924f52009-06-23 19:01:18 -0700989
990dnl ============================================================================
991dnl Configure pthreads.
992
Mike Hommeya19e87f2012-04-21 21:27:46 -0700993if test "x$abi" != "xpecoff" ; then
994 AC_CHECK_HEADERS([pthread.h], , [AC_MSG_ERROR([pthread.h is missing])])
995 dnl Some systems may embed pthreads functionality in libc; check for libpthread
996 dnl first, but try libc too before failing.
997 AC_CHECK_LIB([pthread], [pthread_create], [LIBS="$LIBS -lpthread"],
998 [AC_SEARCH_LIBS([pthread_create], , ,
999 AC_MSG_ERROR([libpthread is missing]))])
1000fi
Jason Evansb7924f52009-06-23 19:01:18 -07001001
1002CPPFLAGS="$CPPFLAGS -D_REENTRANT"
1003
Jason Evanscd9a1342012-03-21 18:33:03 -07001004dnl Check whether the BSD-specific _malloc_thread_cleanup() exists. If so, use
1005dnl it rather than pthreads TSD cleanup functions to support cleanup during
1006dnl thread exit, in order to avoid pthreads library recursion during
1007dnl bootstrapping.
Jason Evanscd9a1342012-03-21 18:33:03 -07001008AC_CHECK_FUNC([_malloc_thread_cleanup],
1009 [have__malloc_thread_cleanup="1"],
1010 [have__malloc_thread_cleanup="0"]
1011 )
1012if test "x$have__malloc_thread_cleanup" = "x1" ; then
1013 AC_DEFINE([JEMALLOC_MALLOC_THREAD_CLEANUP], [ ])
1014 force_tls="1"
1015fi
1016
Jason Evans41b6afb2012-02-02 22:04:57 -08001017dnl Check whether the BSD-specific _pthread_mutex_init_calloc_cb() exists. If
1018dnl so, mutex initialization causes allocation, and we need to implement this
1019dnl callback function in order to prevent recursive allocation.
1020AC_CHECK_FUNC([_pthread_mutex_init_calloc_cb],
1021 [have__pthread_mutex_init_calloc_cb="1"],
1022 [have__pthread_mutex_init_calloc_cb="0"]
1023 )
1024if test "x$have__pthread_mutex_init_calloc_cb" = "x1" ; then
1025 AC_DEFINE([JEMALLOC_MUTEX_INIT_CB])
1026fi
1027
Jason Evans0fee70d2012-02-13 12:36:11 -08001028dnl Disable lazy locking by default.
Jason Evansb7924f52009-06-23 19:01:18 -07001029AC_ARG_ENABLE([lazy_lock],
Jason Evans0fee70d2012-02-13 12:36:11 -08001030 [AS_HELP_STRING([--enable-lazy-lock],
1031 [Enable lazy locking (only lock when multi-threaded)])],
Jason Evansb7924f52009-06-23 19:01:18 -07001032[if test "x$enable_lazy_lock" = "xno" ; then
1033 enable_lazy_lock="0"
1034else
1035 enable_lazy_lock="1"
1036fi
1037],
Jason Evans0fee70d2012-02-13 12:36:11 -08001038[enable_lazy_lock="0"]
Jason Evansb7924f52009-06-23 19:01:18 -07001039)
Jason Evansfd4fcef2012-03-23 17:40:58 -07001040if test "x$enable_lazy_lock" = "x0" -a "x${force_lazy_lock}" = "x1" ; then
1041 AC_MSG_RESULT([Forcing lazy-lock to avoid allocator/threading bootstrap issues])
1042 enable_lazy_lock="1"
1043fi
Jason Evansb7924f52009-06-23 19:01:18 -07001044if test "x$enable_lazy_lock" = "x1" ; then
Mike Hommeya19e87f2012-04-21 21:27:46 -07001045 if test "x$abi" != "xpecoff" ; then
1046 AC_CHECK_HEADERS([dlfcn.h], , [AC_MSG_ERROR([dlfcn.h is missing])])
1047 AC_CHECK_FUNC([dlsym], [],
1048 [AC_CHECK_LIB([dl], [dlsym], [LIBS="$LIBS -ldl"],
1049 [AC_MSG_ERROR([libdl is missing])])
1050 ])
1051 fi
Jason Evansb7924f52009-06-23 19:01:18 -07001052 AC_DEFINE([JEMALLOC_LAZY_LOCK], [ ])
1053fi
1054AC_SUBST([enable_lazy_lock])
1055
Jason Evans78d815c2010-01-17 14:06:20 -08001056AC_ARG_ENABLE([tls],
1057 [AS_HELP_STRING([--disable-tls], [Disable thread-local storage (__thread keyword)])],
1058if test "x$enable_tls" = "xno" ; then
1059 enable_tls="0"
1060else
1061 enable_tls="1"
1062fi
1063,
1064enable_tls="1"
1065)
Jason Evanscd9a1342012-03-21 18:33:03 -07001066if test "x${enable_tls}" = "x0" -a "x${force_tls}" = "x1" ; then
1067 AC_MSG_RESULT([Forcing TLS to avoid allocator/threading bootstrap issues])
1068 enable_tls="1"
1069fi
Jason Evansb80581d2012-03-23 16:17:43 -07001070if test "x${enable_tls}" = "x1" -a "x${force_tls}" = "x0" ; then
1071 AC_MSG_RESULT([Forcing no TLS to avoid allocator/threading bootstrap issues])
1072 enable_tls="0"
1073fi
Jason Evans78d815c2010-01-17 14:06:20 -08001074if test "x${enable_tls}" = "x1" ; then
1075AC_MSG_CHECKING([for TLS])
Jason Evans6684cac2012-03-05 12:15:36 -08001076AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Jason Evans78d815c2010-01-17 14:06:20 -08001077[[
1078 __thread int x;
1079]], [[
1080 x = 42;
1081
1082 return 0;
1083]])],
1084 AC_MSG_RESULT([yes]),
1085 AC_MSG_RESULT([no])
1086 enable_tls="0")
1087fi
Jason Evansb267d0f2010-08-13 15:42:29 -07001088AC_SUBST([enable_tls])
Jason Evanse24c7af2012-03-19 10:21:17 -07001089if test "x${enable_tls}" = "x1" ; then
1090 AC_DEFINE_UNQUOTED([JEMALLOC_TLS], [ ])
Jason Evanscd9a1342012-03-21 18:33:03 -07001091elif test "x${force_tls}" = "x1" ; then
1092 AC_MSG_ERROR([Failed to configure TLS, which is mandatory for correct function])
Jason Evans78d815c2010-01-17 14:06:20 -08001093fi
1094
Jason Evans2dbecf12010-09-05 10:35:13 -07001095dnl ============================================================================
Jason Evans84c8eef2011-03-16 10:30:13 -07001096dnl Check for ffsl(3), and fail if not found. This function exists on all
1097dnl platforms that jemalloc currently has a chance of functioning on without
1098dnl modification.
Jason Evans4c2faa82012-03-13 11:09:23 -07001099JE_COMPILABLE([a program using ffsl], [
Garrett Cooper72c1e592012-12-02 17:57:28 -08001100#include <stdio.h>
Jason Evans382132e2012-04-04 15:25:43 -07001101#include <strings.h>
Jason Evans4c2faa82012-03-13 11:09:23 -07001102#include <string.h>
1103], [
1104 {
1105 int rv = ffsl(0x08);
Garrett Cooper72c1e592012-12-02 17:57:28 -08001106 printf("%d\n", rv);
Jason Evans4c2faa82012-03-13 11:09:23 -07001107 }
1108], [je_cv_function_ffsl])
Jason Evans6684cac2012-03-05 12:15:36 -08001109if test "x${je_cv_function_ffsl}" != "xyes" ; then
1110 AC_MSG_ERROR([Cannot build without ffsl(3)])
1111fi
Jason Evans84c8eef2011-03-16 10:30:13 -07001112
1113dnl ============================================================================
Jason Evansb57d3ec2012-04-17 13:17:54 -07001114dnl Check for atomic(9) operations as provided on FreeBSD.
1115
1116JE_COMPILABLE([atomic(9)], [
1117#include <sys/types.h>
1118#include <machine/atomic.h>
1119#include <inttypes.h>
1120], [
1121 {
1122 uint32_t x32 = 0;
1123 volatile uint32_t *x32p = &x32;
1124 atomic_fetchadd_32(x32p, 1);
1125 }
1126 {
1127 unsigned long xlong = 0;
1128 volatile unsigned long *xlongp = &xlong;
1129 atomic_fetchadd_long(xlongp, 1);
1130 }
1131], [je_cv_atomic9])
1132if test "x${je_cv_atomic9}" = "xyes" ; then
1133 AC_DEFINE([JEMALLOC_ATOMIC9])
1134fi
1135
1136dnl ============================================================================
Jason Evans763baa62011-03-18 19:10:31 -07001137dnl Check for atomic(3) operations as provided on Darwin.
1138
1139JE_COMPILABLE([Darwin OSAtomic*()], [
1140#include <libkern/OSAtomic.h>
1141#include <inttypes.h>
1142], [
1143 {
1144 int32_t x32 = 0;
1145 volatile int32_t *x32p = &x32;
1146 OSAtomicAdd32(1, x32p);
1147 }
1148 {
1149 int64_t x64 = 0;
1150 volatile int64_t *x64p = &x64;
1151 OSAtomicAdd64(1, x64p);
1152 }
Jason Evans6684cac2012-03-05 12:15:36 -08001153], [je_cv_osatomic])
1154if test "x${je_cv_osatomic}" = "xyes" ; then
Jason Evanse24c7af2012-03-19 10:21:17 -07001155 AC_DEFINE([JEMALLOC_OSATOMIC], [ ])
Jason Evans763baa62011-03-18 19:10:31 -07001156fi
1157
1158dnl ============================================================================
Mike Hommeyc1e567b2012-03-26 17:03:41 +02001159dnl Check whether __sync_{add,sub}_and_fetch() are available despite
1160dnl __GCC_HAVE_SYNC_COMPARE_AND_SWAP_n macros being undefined.
1161
1162AC_DEFUN([JE_SYNC_COMPARE_AND_SWAP_CHECK],[
1163 AC_CACHE_CHECK([whether to force $1-bit __sync_{add,sub}_and_fetch()],
1164 [je_cv_sync_compare_and_swap_$2],
Mike Hommey2cfe6d62012-03-27 15:03:07 +02001165 [AC_LINK_IFELSE([AC_LANG_PROGRAM([
1166 #include <stdint.h>
1167 ],
1168 [
1169 #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2
1170 {
1171 uint$1_t x$1 = 0;
1172 __sync_add_and_fetch(&x$1, 42);
1173 __sync_sub_and_fetch(&x$1, 1);
1174 }
1175 #else
1176 #error __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2 is defined, no need to force
1177 #endif
1178 ])],
Mike Hommeyc1e567b2012-03-26 17:03:41 +02001179 [je_cv_sync_compare_and_swap_$2=yes],
1180 [je_cv_sync_compare_and_swap_$2=no])])
1181
1182 if test "x${je_cv_sync_compare_and_swap_$2}" = "xyes" ; then
1183 AC_DEFINE([JE_FORCE_SYNC_COMPARE_AND_SWAP_$2], [ ])
1184 fi
1185])
1186
Jason Evansb57d3ec2012-04-17 13:17:54 -07001187if test "x${je_cv_atomic9}" != "xyes" -a "x${je_cv_osatomic}" != "xyes" ; then
Mike Hommeyc1e567b2012-03-26 17:03:41 +02001188 JE_SYNC_COMPARE_AND_SWAP_CHECK(32, 4)
1189 JE_SYNC_COMPARE_AND_SWAP_CHECK(64, 8)
1190fi
1191
1192dnl ============================================================================
Jason Evans893a0ed2011-03-18 19:30:18 -07001193dnl Check for spinlock(3) operations as provided on Darwin.
1194
1195JE_COMPILABLE([Darwin OSSpin*()], [
1196#include <libkern/OSAtomic.h>
1197#include <inttypes.h>
1198], [
1199 OSSpinLock lock = 0;
1200 OSSpinLockLock(&lock);
1201 OSSpinLockUnlock(&lock);
Jason Evans6684cac2012-03-05 12:15:36 -08001202], [je_cv_osspin])
1203if test "x${je_cv_osspin}" = "xyes" ; then
Jason Evanse24c7af2012-03-19 10:21:17 -07001204 AC_DEFINE([JEMALLOC_OSSPIN], [ ])
Jason Evans893a0ed2011-03-18 19:30:18 -07001205fi
1206
1207dnl ============================================================================
Jason Evans2dbecf12010-09-05 10:35:13 -07001208dnl Darwin-related configuration.
Jason Evans78d815c2010-01-17 14:06:20 -08001209
Mike Hommeyd0357f72012-11-26 18:52:41 +01001210AC_ARG_ENABLE([zone-allocator],
1211 [AS_HELP_STRING([--disable-zone-allocator],
1212 [Disable zone allocator for Darwin])],
1213[if test "x$enable_zone_allocator" = "xno" ; then
1214 enable_zone_allocator="0"
1215else
1216 enable_zone_allocator="1"
1217fi
1218],
1219[if test "x${abi}" = "xmacho"; then
1220 enable_zone_allocator="1"
1221fi
1222]
1223)
1224AC_SUBST([enable_zone_allocator])
1225
1226if test "x${enable_zone_allocator}" = "x1" ; then
1227 if test "x${abi}" != "xmacho"; then
1228 AC_MSG_ERROR([--enable-zone-allocator is only supported on Darwin])
1229 fi
Jason Evanse24c7af2012-03-19 10:21:17 -07001230 AC_DEFINE([JEMALLOC_IVSALLOC], [ ])
1231 AC_DEFINE([JEMALLOC_ZONE], [ ])
Jason Evans6109fe02010-02-10 10:37:56 -08001232
Jason Evans2dbecf12010-09-05 10:35:13 -07001233 dnl The szone version jumped from 3 to 6 between the OS X 10.5.x and 10.6
1234 dnl releases. malloc_zone_t and malloc_introspection_t have new fields in
1235 dnl 10.6, which is the only source-level indication of the change.
1236 AC_MSG_CHECKING([malloc zone version])
Mike Hommey154829d2012-03-20 18:01:38 +01001237 AC_DEFUN([JE_ZONE_PROGRAM],
1238 [AC_LANG_PROGRAM(
1239 [#include <malloc/malloc.h>],
1240 [static foo[[sizeof($1) $2 sizeof(void *) * $3 ? 1 : -1]]]
1241 )])
Jason Evans2dbecf12010-09-05 10:35:13 -07001242
Mike Hommey154829d2012-03-20 18:01:38 +01001243 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,14)],[JEMALLOC_ZONE_VERSION=3],[
1244 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,15)],[JEMALLOC_ZONE_VERSION=5],[
1245 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,16)],[
1246 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,9)],[JEMALLOC_ZONE_VERSION=6],[
1247 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,13)],[JEMALLOC_ZONE_VERSION=7],[JEMALLOC_ZONE_VERSION=]
1248 )])],[
1249 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,17)],[JEMALLOC_ZONE_VERSION=8],[
1250 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,>,17)],[JEMALLOC_ZONE_VERSION=9],[JEMALLOC_ZONE_VERSION=]
1251 )])])])])
1252 if test "x${JEMALLOC_ZONE_VERSION}" = "x"; then
1253 AC_MSG_RESULT([unsupported])
1254 AC_MSG_ERROR([Unsupported malloc zone version])
1255 fi
1256 if test "${JEMALLOC_ZONE_VERSION}" = 9; then
1257 JEMALLOC_ZONE_VERSION=8
1258 AC_MSG_RESULT([> 8])
1259 else
1260 AC_MSG_RESULT([$JEMALLOC_ZONE_VERSION])
1261 fi
1262 AC_DEFINE_UNQUOTED(JEMALLOC_ZONE_VERSION, [$JEMALLOC_ZONE_VERSION])
Jason Evansb27805b2010-02-10 18:15:53 -08001263fi
1264
Jason Evansb7924f52009-06-23 19:01:18 -07001265dnl ============================================================================
1266dnl Check for typedefs, structures, and compiler characteristics.
1267AC_HEADER_STDBOOL
1268
Jason Evansb1726102012-02-28 16:50:47 -08001269AC_CONFIG_COMMANDS([include/jemalloc/internal/size_classes.h], [
1270 mkdir -p "include/jemalloc/internal"
1271 "${srcdir}/include/jemalloc/internal/size_classes.sh" > "${objroot}include/jemalloc/internal/size_classes.h"
1272])
1273
Jason Evansb7924f52009-06-23 19:01:18 -07001274dnl Process .in files.
Jason Evansb0fd5012010-01-17 01:49:20 -08001275AC_SUBST([cfghdrs_in])
1276AC_SUBST([cfghdrs_out])
Jason Evans0656ec02010-04-07 23:37:35 -07001277AC_CONFIG_HEADERS([$cfghdrs_tup])
Jason Evansb7924f52009-06-23 19:01:18 -07001278
1279dnl ============================================================================
1280dnl Generate outputs.
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +04001281AC_CONFIG_FILES([$cfgoutputs_tup config.stamp bin/jemalloc.sh])
Jason Evansb0fd5012010-01-17 01:49:20 -08001282AC_SUBST([cfgoutputs_in])
1283AC_SUBST([cfgoutputs_out])
Jason Evansb7924f52009-06-23 19:01:18 -07001284AC_OUTPUT
1285
1286dnl ============================================================================
1287dnl Print out the results of configuration.
1288AC_MSG_RESULT([===============================================================================])
Jason Evansf576c632011-11-01 22:27:41 -07001289AC_MSG_RESULT([jemalloc version : ${jemalloc_version}])
1290AC_MSG_RESULT([library revision : ${rev}])
Jason Evansb7924f52009-06-23 19:01:18 -07001291AC_MSG_RESULT([])
1292AC_MSG_RESULT([CC : ${CC}])
1293AC_MSG_RESULT([CPPFLAGS : ${CPPFLAGS}])
1294AC_MSG_RESULT([CFLAGS : ${CFLAGS}])
1295AC_MSG_RESULT([LDFLAGS : ${LDFLAGS}])
1296AC_MSG_RESULT([LIBS : ${LIBS}])
1297AC_MSG_RESULT([RPATH_EXTRA : ${RPATH_EXTRA}])
1298AC_MSG_RESULT([])
Jason Evansaee7fd22010-11-24 22:00:02 -08001299AC_MSG_RESULT([XSLTPROC : ${XSLTPROC}])
1300AC_MSG_RESULT([XSLROOT : ${XSLROOT}])
1301AC_MSG_RESULT([])
Jason Evansb7924f52009-06-23 19:01:18 -07001302AC_MSG_RESULT([PREFIX : ${PREFIX}])
1303AC_MSG_RESULT([BINDIR : ${BINDIR}])
Jason Evans662a0172009-07-01 19:24:31 -07001304AC_MSG_RESULT([INCLUDEDIR : ${INCLUDEDIR}])
1305AC_MSG_RESULT([LIBDIR : ${LIBDIR}])
Jason Evansb7924f52009-06-23 19:01:18 -07001306AC_MSG_RESULT([DATADIR : ${DATADIR}])
1307AC_MSG_RESULT([MANDIR : ${MANDIR}])
1308AC_MSG_RESULT([])
1309AC_MSG_RESULT([srcroot : ${srcroot}])
1310AC_MSG_RESULT([abs_srcroot : ${abs_srcroot}])
1311AC_MSG_RESULT([objroot : ${objroot}])
1312AC_MSG_RESULT([abs_objroot : ${abs_objroot}])
1313AC_MSG_RESULT([])
Jason Evans90895cf2009-12-29 00:09:15 -08001314AC_MSG_RESULT([JEMALLOC_PREFIX : ${JEMALLOC_PREFIX}])
Jason Evans746e77a2011-07-30 16:40:52 -07001315AC_MSG_RESULT([JEMALLOC_PRIVATE_NAMESPACE])
1316AC_MSG_RESULT([ : ${JEMALLOC_PRIVATE_NAMESPACE}])
Jason Evansb0fd5012010-01-17 01:49:20 -08001317AC_MSG_RESULT([install_suffix : ${install_suffix}])
Jason Evansb7924f52009-06-23 19:01:18 -07001318AC_MSG_RESULT([autogen : ${enable_autogen}])
Jason Evans7e77eaf2012-03-02 17:47:37 -08001319AC_MSG_RESULT([experimental : ${enable_experimental}])
Jason Evans355b4382010-09-20 19:20:48 -07001320AC_MSG_RESULT([cc-silence : ${enable_cc_silence}])
Jason Evansb7924f52009-06-23 19:01:18 -07001321AC_MSG_RESULT([debug : ${enable_debug}])
1322AC_MSG_RESULT([stats : ${enable_stats}])
Jason Evans6109fe02010-02-10 10:37:56 -08001323AC_MSG_RESULT([prof : ${enable_prof}])
1324AC_MSG_RESULT([prof-libunwind : ${enable_prof_libunwind}])
Jason Evans77f350b2011-03-15 22:23:12 -07001325AC_MSG_RESULT([prof-libgcc : ${enable_prof_libgcc}])
1326AC_MSG_RESULT([prof-gcc : ${enable_prof_gcc}])
Jason Evans84cbbcb2009-12-29 00:09:15 -08001327AC_MSG_RESULT([tcache : ${enable_tcache}])
Jason Evansb7924f52009-06-23 19:01:18 -07001328AC_MSG_RESULT([fill : ${enable_fill}])
Jason Evansb1476112012-04-05 13:36:17 -07001329AC_MSG_RESULT([utrace : ${enable_utrace}])
Jason Evans122449b2012-04-06 00:35:09 -07001330AC_MSG_RESULT([valgrind : ${enable_valgrind}])
1331AC_MSG_RESULT([xmalloc : ${enable_xmalloc}])
Jason Evans2e671ff2012-05-09 16:12:00 -07001332AC_MSG_RESULT([mremap : ${enable_mremap}])
Jason Evans59ae2762012-04-16 17:52:27 -07001333AC_MSG_RESULT([munmap : ${enable_munmap}])
Jason Evansb7924f52009-06-23 19:01:18 -07001334AC_MSG_RESULT([dss : ${enable_dss}])
Jason Evansb7924f52009-06-23 19:01:18 -07001335AC_MSG_RESULT([lazy_lock : ${enable_lazy_lock}])
Jason Evans2dbecf12010-09-05 10:35:13 -07001336AC_MSG_RESULT([tls : ${enable_tls}])
Jason Evansb7924f52009-06-23 19:01:18 -07001337AC_MSG_RESULT([===============================================================================])