blob: 73d3f94fa360b1200739ba747720803985aeeb5b [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=
Jason Evans80ddf492013-08-20 11:48:19 +0100229ARFLAGS='crus'
230AROUT=' $@'
Mike Hommey79c4bca2012-05-02 21:30:51 +0200231CC_MM=1
Jason Evans7372b152012-02-10 20:22:09 -0800232
Jory A. Prattad505e02013-08-11 09:44:59 -0500233AN_MAKEVAR([AR], [AC_PROG_AR])
234AN_PROGRAM([ar], [AC_PROG_AR])
235AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL(AR, ar, :)])
236AC_PROG_AR
237
Jason Evansb7924f52009-06-23 19:01:18 -0700238dnl Platform-specific settings. abi and RPATH can probably be determined
239dnl programmatically, but doing so is error-prone, which makes it generally
240dnl not worth the trouble.
241dnl
242dnl Define cpp macros in CPPFLAGS, rather than doing AC_DEFINE(macro), since the
243dnl definitions need to be seen before any headers are included, which is a pain
244dnl to make happen otherwise.
Jason Evans59ae2762012-04-16 17:52:27 -0700245default_munmap="1"
Jason Evans247d1242012-10-09 16:20:10 -0700246JEMALLOC_USABLE_SIZE_CONST="const"
Jason Evansb7924f52009-06-23 19:01:18 -0700247case "${host}" in
248 *-*-darwin*)
Mike Hommeya6770a72012-05-03 14:12:49 +0200249 CFLAGS="$CFLAGS"
Jason Evansb7924f52009-06-23 19:01:18 -0700250 abi="macho"
Jason Evanse24c7af2012-03-19 10:21:17 -0700251 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
Jason Evansb7924f52009-06-23 19:01:18 -0700252 RPATH=""
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +0400253 LD_PRELOAD_VAR="DYLD_INSERT_LIBRARIES"
Jason Evansf576c632011-11-01 22:27:41 -0700254 so="dylib"
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200255 importlib="${so}"
Jason Evansb80581d2012-03-23 16:17:43 -0700256 force_tls="0"
Mike Hommeyfa08da72012-04-16 16:30:25 +0200257 DSO_LDFLAGS='-shared -Wl,-dylib_install_name,$(@F)'
Mike Hommey7cdea392012-04-30 12:38:27 +0200258 SOREV="${rev}.${so}"
Jason Evansb7924f52009-06-23 19:01:18 -0700259 ;;
260 *-*-freebsd*)
261 CFLAGS="$CFLAGS"
262 abi="elf"
Jason Evanse24c7af2012-03-19 10:21:17 -0700263 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
Jason Evansfd4fcef2012-03-23 17:40:58 -0700264 force_lazy_lock="1"
Jason Evansb7924f52009-06-23 19:01:18 -0700265 ;;
266 *-*-linux*)
267 CFLAGS="$CFLAGS"
268 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
269 abi="elf"
Garrett Cooper13e4e242012-12-02 17:58:40 -0800270 AC_DEFINE([JEMALLOC_HAS_ALLOCA_H])
Jason Evanse24c7af2012-03-19 10:21:17 -0700271 AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED], [ ])
Jason Evans02b23122012-04-05 11:06:23 -0700272 AC_DEFINE([JEMALLOC_THREADED_INIT], [ ])
Jason Evans247d1242012-10-09 16:20:10 -0700273 JEMALLOC_USABLE_SIZE_CONST=""
Jason Evans59ae2762012-04-16 17:52:27 -0700274 default_munmap="0"
Jason Evansb7924f52009-06-23 19:01:18 -0700275 ;;
276 *-*-netbsd*)
277 AC_MSG_CHECKING([ABI])
278 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
279[[#ifdef __ELF__
280/* ELF */
281#else
282#error aout
283#endif
284]])],
285 [CFLAGS="$CFLAGS"; abi="elf"],
286 [abi="aout"])
287 AC_MSG_RESULT([$abi])
Jason Evanse24c7af2012-03-19 10:21:17 -0700288 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
Jason Evansb7924f52009-06-23 19:01:18 -0700289 ;;
290 *-*-solaris2*)
291 CFLAGS="$CFLAGS"
292 abi="elf"
Mike Hommeyfa08da72012-04-16 16:30:25 +0200293 RPATH='-Wl,-R,$(1)'
Jason Evansb7924f52009-06-23 19:01:18 -0700294 dnl Solaris needs this for sigwait().
295 CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
296 LIBS="$LIBS -lposix4 -lsocket -lnsl"
297 ;;
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +0400298 *-ibm-aix*)
299 if "$LG_SIZEOF_PTR" = "8"; then
300 dnl 64bit AIX
301 LD_PRELOAD_VAR="LDR_PRELOAD64"
302 else
303 dnl 32bit AIX
304 LD_PRELOAD_VAR="LDR_PRELOAD"
305 fi
306 abi="xcoff"
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +0400307 ;;
Mike Hommeya19e87f2012-04-21 21:27:46 -0700308 *-*-mingw*)
309 abi="pecoff"
310 force_tls="0"
311 RPATH=""
312 so="dll"
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200313 if test "x$je_cv_msvc" = "xyes" ; then
314 importlib="lib"
315 DSO_LDFLAGS="-LD"
316 EXTRA_LDFLAGS="-link -DEBUG"
317 CTARGET='-Fo$@'
318 LDTARGET='-Fe$@'
Jory A. Prattad505e02013-08-11 09:44:59 -0500319 AR='lib'
320 ARFLAGS='-nologo -out:'
Jason Evans80ddf492013-08-20 11:48:19 +0100321 AROUT='$@'
Mike Hommey79c4bca2012-05-02 21:30:51 +0200322 CC_MM=
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200323 else
324 importlib="${so}"
325 DSO_LDFLAGS="-shared"
326 fi
Mike Hommeya19e87f2012-04-21 21:27:46 -0700327 a="lib"
328 libprefix=""
Mike Hommey7cdea392012-04-30 12:38:27 +0200329 SOREV="${so}"
Mike Hommeya19e87f2012-04-21 21:27:46 -0700330 PIC_CFLAGS=""
331 ;;
Jason Evansb7924f52009-06-23 19:01:18 -0700332 *)
333 AC_MSG_RESULT([Unsupported operating system: ${host}])
334 abi="elf"
Jason Evansb7924f52009-06-23 19:01:18 -0700335 ;;
336esac
Jason Evans247d1242012-10-09 16:20:10 -0700337AC_DEFINE_UNQUOTED([JEMALLOC_USABLE_SIZE_CONST], [$JEMALLOC_USABLE_SIZE_CONST])
Jason Evansb7924f52009-06-23 19:01:18 -0700338AC_SUBST([abi])
339AC_SUBST([RPATH])
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +0400340AC_SUBST([LD_PRELOAD_VAR])
Jason Evansf576c632011-11-01 22:27:41 -0700341AC_SUBST([so])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200342AC_SUBST([importlib])
Mike Hommey5bee66d2012-04-16 16:30:24 +0200343AC_SUBST([o])
344AC_SUBST([a])
345AC_SUBST([exe])
Mike Hommeya19e87f2012-04-21 21:27:46 -0700346AC_SUBST([libprefix])
Mike Hommeyfa08da72012-04-16 16:30:25 +0200347AC_SUBST([DSO_LDFLAGS])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200348AC_SUBST([EXTRA_LDFLAGS])
Mike Hommey85221d52012-04-18 18:29:40 +0200349AC_SUBST([SOREV])
Mike Hommey188da7c2012-04-18 18:29:41 +0200350AC_SUBST([PIC_CFLAGS])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200351AC_SUBST([CTARGET])
352AC_SUBST([LDTARGET])
353AC_SUBST([MKLIB])
Jason Evans80ddf492013-08-20 11:48:19 +0100354AC_SUBST([ARFLAGS])
355AC_SUBST([AROUT])
Mike Hommey79c4bca2012-05-02 21:30:51 +0200356AC_SUBST([CC_MM])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200357
358if test "x$abi" != "xpecoff"; then
359 dnl Heap profiling uses the log(3) function.
360 LIBS="$LIBS -lm"
361fi
Jason Evansb7924f52009-06-23 19:01:18 -0700362
Jason Evansfa5d2452011-03-15 10:25:59 -0700363JE_COMPILABLE([__attribute__ syntax],
364 [static __attribute__((unused)) void foo(void){}],
365 [],
Jason Evans6684cac2012-03-05 12:15:36 -0800366 [je_cv_attribute])
367if test "x${je_cv_attribute}" = "xyes" ; then
Jason Evansfa5d2452011-03-15 10:25:59 -0700368 AC_DEFINE([JEMALLOC_HAVE_ATTR], [ ])
369 if test "x${GCC}" = "xyes" -a "x${abi}" = "xelf"; then
370 JE_CFLAGS_APPEND([-fvisibility=hidden])
371 fi
372fi
Jason Evans3cc1f1a2012-04-03 22:30:05 -0700373dnl Check for tls_model attribute support (clang 3.0 still lacks support).
374SAVED_CFLAGS="${CFLAGS}"
375JE_CFLAGS_APPEND([-Werror])
376JE_COMPILABLE([tls_model attribute], [],
377 [static __thread int
378 __attribute__((tls_model("initial-exec"))) foo;
379 foo = 0;],
380 [je_cv_tls_model])
381CFLAGS="${SAVED_CFLAGS}"
382if test "x${je_cv_tls_model}" = "xyes" ; then
383 AC_DEFINE([JEMALLOC_TLS_MODEL],
384 [__attribute__((tls_model("initial-exec")))])
385else
386 AC_DEFINE([JEMALLOC_TLS_MODEL], [ ])
387fi
Jason Evansfa5d2452011-03-15 10:25:59 -0700388
Jason Evansb7924f52009-06-23 19:01:18 -0700389dnl Support optional additions to rpath.
390AC_ARG_WITH([rpath],
Jason Evans90895cf2009-12-29 00:09:15 -0800391 [AS_HELP_STRING([--with-rpath=<rpath>], [Colon-separated rpath (ELF systems only)])],
Jason Evansb7924f52009-06-23 19:01:18 -0700392if test "x$with_rpath" = "xno" ; then
393 RPATH_EXTRA=
394else
395 RPATH_EXTRA="`echo $with_rpath | tr \":\" \" \"`"
396fi,
397 RPATH_EXTRA=
398)
399AC_SUBST([RPATH_EXTRA])
400
401dnl Disable rules that do automatic regeneration of configure output by default.
402AC_ARG_ENABLE([autogen],
Jason Evans78d815c2010-01-17 14:06:20 -0800403 [AS_HELP_STRING([--enable-autogen], [Automatically regenerate configure output])],
Jason Evansb7924f52009-06-23 19:01:18 -0700404if test "x$enable_autogen" = "xno" ; then
405 enable_autogen="0"
406else
407 enable_autogen="1"
408fi
409,
410enable_autogen="0"
411)
412AC_SUBST([enable_autogen])
413
414AC_PROG_INSTALL
415AC_PROG_RANLIB
Jason Evans7329a4f2013-01-22 10:53:29 -0800416AC_PATH_PROG([LD], [ld], [false], [$PATH])
417AC_PATH_PROG([AUTOCONF], [autoconf], [false], [$PATH])
Jason Evansb7924f52009-06-23 19:01:18 -0700418
Jason Evans0a0bbf62012-03-13 12:55:21 -0700419public_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 -0800420
421dnl Check for allocator-related functions that should be wrapped.
422AC_CHECK_FUNC([memalign],
Jason Evanse24c7af2012-03-19 10:21:17 -0700423 [AC_DEFINE([JEMALLOC_OVERRIDE_MEMALIGN], [ ])
Jason Evans7e77eaf2012-03-02 17:47:37 -0800424 public_syms="${public_syms} memalign"])
425AC_CHECK_FUNC([valloc],
Jason Evanse24c7af2012-03-19 10:21:17 -0700426 [AC_DEFINE([JEMALLOC_OVERRIDE_VALLOC], [ ])
Jason Evans7e77eaf2012-03-02 17:47:37 -0800427 public_syms="${public_syms} valloc"])
428
429dnl Support the experimental API by default.
430AC_ARG_ENABLE([experimental],
431 [AS_HELP_STRING([--disable-experimental],
432 [Disable support for the experimental API])],
433[if test "x$enable_experimental" = "xno" ; then
434 enable_experimental="0"
435else
436 enable_experimental="1"
437fi
438],
439[enable_experimental="1"]
440)
441if test "x$enable_experimental" = "x1" ; then
442 AC_DEFINE([JEMALLOC_EXPERIMENTAL], [ ])
443 public_syms="${public_syms} allocm dallocm nallocm rallocm sallocm"
444fi
445AC_SUBST([enable_experimental])
446
Jason Evans0a5489e2012-03-01 17:19:20 -0800447dnl Perform no name mangling by default.
448AC_ARG_WITH([mangling],
449 [AS_HELP_STRING([--with-mangling=<map>], [Mangle symbols in <map>])],
450 [mangling_map="$with_mangling"], [mangling_map=""])
451for nm in `echo ${mangling_map} |tr ',' ' '` ; do
Jason Evans08fc3b22012-03-12 15:07:53 -0700452 k="`echo ${nm} |tr ':' ' ' |awk '{print $1}'`"
453 n="je_${k}"
Jason Evans0a5489e2012-03-01 17:19:20 -0800454 m=`echo ${nm} |tr ':' ' ' |awk '{print $2}'`
455 AC_DEFINE_UNQUOTED([${n}], [${m}])
Jason Evans08fc3b22012-03-12 15:07:53 -0700456 dnl Remove key from public_syms so that it isn't redefined later.
457 public_syms=`for sym in ${public_syms}; do echo "${sym}"; done |grep -v "^${k}\$" |tr '\n' ' '`
Jason Evans0a5489e2012-03-01 17:19:20 -0800458done
459
Jason Evans90895cf2009-12-29 00:09:15 -0800460dnl Do not prefix public APIs by default.
461AC_ARG_WITH([jemalloc_prefix],
462 [AS_HELP_STRING([--with-jemalloc-prefix=<prefix>], [Prefix to prepend to all public APIs])],
Jason Evansb0fd5012010-01-17 01:49:20 -0800463 [JEMALLOC_PREFIX="$with_jemalloc_prefix"],
Mike Hommey7cdea392012-04-30 12:38:27 +0200464 [if test "x$abi" != "xmacho" -a "x$abi" != "xpecoff"; then
Jason Evans2dbecf12010-09-05 10:35:13 -0700465 JEMALLOC_PREFIX=""
466else
467 JEMALLOC_PREFIX="je_"
468fi]
Jason Evans90895cf2009-12-29 00:09:15 -0800469)
470if test "x$JEMALLOC_PREFIX" != "x" ; then
Jason Evanse7339702010-10-23 18:37:06 -0700471 JEMALLOC_CPREFIX=`echo ${JEMALLOC_PREFIX} | tr "a-z" "A-Z"`
472 AC_DEFINE_UNQUOTED([JEMALLOC_PREFIX], ["$JEMALLOC_PREFIX"])
473 AC_DEFINE_UNQUOTED([JEMALLOC_CPREFIX], ["$JEMALLOC_CPREFIX"])
Jason Evans90895cf2009-12-29 00:09:15 -0800474fi
Jason Evans0a5489e2012-03-01 17:19:20 -0800475dnl Generate macros to rename public symbols. All public symbols are prefixed
476dnl with je_ in the source code, so these macro definitions are needed even if
477dnl --with-jemalloc-prefix wasn't specified.
Jason Evans7e77eaf2012-03-02 17:47:37 -0800478for stem in ${public_syms}; do
Jason Evans0a5489e2012-03-01 17:19:20 -0800479 n="je_${stem}"
480 m="${JEMALLOC_PREFIX}${stem}"
481 AC_DEFINE_UNQUOTED([${n}], [${m}])
482done
Jason Evans90895cf2009-12-29 00:09:15 -0800483
Mike Hommey99066602012-11-19 10:55:26 +0100484AC_ARG_WITH([export],
485 [AS_HELP_STRING([--without-export], [disable exporting jemalloc public APIs])],
486 [if test "x$with_export" = "xno"; then
Jason Evans2625c892013-01-22 16:46:27 -0800487 AC_DEFINE([JEMALLOC_EXPORT],[])
Mike Hommey99066602012-11-19 10:55:26 +0100488fi]
489)
490
Jason Evans746e77a2011-07-30 16:40:52 -0700491dnl Do not mangle library-private APIs by default.
492AC_ARG_WITH([private_namespace],
493 [AS_HELP_STRING([--with-private-namespace=<prefix>], [Prefix to prepend to all library-private APIs])],
494 [JEMALLOC_PRIVATE_NAMESPACE="$with_private_namespace"],
495 [JEMALLOC_PRIVATE_NAMESPACE=""]
496)
497AC_DEFINE_UNQUOTED([JEMALLOC_PRIVATE_NAMESPACE], ["$JEMALLOC_PRIVATE_NAMESPACE"])
498if test "x$JEMALLOC_PRIVATE_NAMESPACE" != "x" ; then
499 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])
500else
501 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])
502fi
503
Jason Evansb0fd5012010-01-17 01:49:20 -0800504dnl Do not add suffix to installed files by default.
505AC_ARG_WITH([install_suffix],
506 [AS_HELP_STRING([--with-install-suffix=<suffix>], [Suffix to append to all installed files])],
507 [INSTALL_SUFFIX="$with_install_suffix"],
508 [INSTALL_SUFFIX=]
509)
510install_suffix="$INSTALL_SUFFIX"
511AC_SUBST([install_suffix])
512
Jason Evansaee7fd22010-11-24 22:00:02 -0800513cfgoutputs_in="${srcroot}Makefile.in"
514cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/html.xsl.in"
515cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/manpages.xsl.in"
516cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/jemalloc.xml.in"
Jason Evans0656ec02010-04-07 23:37:35 -0700517cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/jemalloc.h.in"
518cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/internal/jemalloc_internal.h.in"
Jason Evans9f3b0a72010-10-07 09:53:26 -0700519cfgoutputs_in="${cfgoutputs_in} ${srcroot}test/jemalloc_test.h.in"
Jason Evansb0fd5012010-01-17 01:49:20 -0800520
Jason Evansaee7fd22010-11-24 22:00:02 -0800521cfgoutputs_out="Makefile"
522cfgoutputs_out="${cfgoutputs_out} doc/html.xsl"
523cfgoutputs_out="${cfgoutputs_out} doc/manpages.xsl"
524cfgoutputs_out="${cfgoutputs_out} doc/jemalloc${install_suffix}.xml"
Jason Evans376b1522010-02-11 14:45:59 -0800525cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc${install_suffix}.h"
526cfgoutputs_out="${cfgoutputs_out} include/jemalloc/internal/jemalloc_internal.h"
Jason Evans9f3b0a72010-10-07 09:53:26 -0700527cfgoutputs_out="${cfgoutputs_out} test/jemalloc_test.h"
Jason Evansb0fd5012010-01-17 01:49:20 -0800528
Jason Evansaee7fd22010-11-24 22:00:02 -0800529cfgoutputs_tup="Makefile"
530cfgoutputs_tup="${cfgoutputs_tup} doc/html.xsl:doc/html.xsl.in"
531cfgoutputs_tup="${cfgoutputs_tup} doc/manpages.xsl:doc/manpages.xsl.in"
532cfgoutputs_tup="${cfgoutputs_tup} doc/jemalloc${install_suffix}.xml:doc/jemalloc.xml.in"
Jason Evans376b1522010-02-11 14:45:59 -0800533cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc${install_suffix}.h:include/jemalloc/jemalloc.h.in"
534cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/internal/jemalloc_internal.h"
Jason Evans9f3b0a72010-10-07 09:53:26 -0700535cfgoutputs_tup="${cfgoutputs_tup} test/jemalloc_test.h:test/jemalloc_test.h.in"
Jason Evansb0fd5012010-01-17 01:49:20 -0800536
Jason Evans0656ec02010-04-07 23:37:35 -0700537cfghdrs_in="${srcroot}include/jemalloc/jemalloc_defs.h.in"
Jason Evansb1726102012-02-28 16:50:47 -0800538cfghdrs_in="${cfghdrs_in} ${srcroot}include/jemalloc/internal/size_classes.sh"
Jason Evansb0fd5012010-01-17 01:49:20 -0800539
Jason Evans376b1522010-02-11 14:45:59 -0800540cfghdrs_out="include/jemalloc/jemalloc_defs${install_suffix}.h"
Jason Evansb1726102012-02-28 16:50:47 -0800541cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/size_classes.h"
Jason Evansb0fd5012010-01-17 01:49:20 -0800542
Jason Evans376b1522010-02-11 14:45:59 -0800543cfghdrs_tup="include/jemalloc/jemalloc_defs${install_suffix}.h:include/jemalloc/jemalloc_defs.h.in"
Jason Evansb0fd5012010-01-17 01:49:20 -0800544
Jason Evans355b4382010-09-20 19:20:48 -0700545dnl Do not silence irrelevant compiler warnings by default, since enabling this
546dnl option incurs a performance penalty.
547AC_ARG_ENABLE([cc-silence],
548 [AS_HELP_STRING([--enable-cc-silence],
549 [Silence irrelevant compiler warnings])],
550[if test "x$enable_cc_silence" = "xno" ; then
551 enable_cc_silence="0"
552else
553 enable_cc_silence="1"
554fi
555],
556[enable_cc_silence="0"]
557)
558if test "x$enable_cc_silence" = "x1" ; then
Jason Evanse24c7af2012-03-19 10:21:17 -0700559 AC_DEFINE([JEMALLOC_CC_SILENCE], [ ])
Jason Evans355b4382010-09-20 19:20:48 -0700560fi
561
Jason Evansb7924f52009-06-23 19:01:18 -0700562dnl Do not compile with debugging by default.
563AC_ARG_ENABLE([debug],
Mike Hommey5135e342012-12-06 22:16:26 +0100564 [AS_HELP_STRING([--enable-debug], [Build debugging code (implies --enable-ivsalloc)])],
Jason Evansb7924f52009-06-23 19:01:18 -0700565[if test "x$enable_debug" = "xno" ; then
566 enable_debug="0"
567else
568 enable_debug="1"
569fi
570],
571[enable_debug="0"]
572)
573if test "x$enable_debug" = "x1" ; then
574 AC_DEFINE([JEMALLOC_DEBUG], [ ])
Mike Hommey5135e342012-12-06 22:16:26 +0100575 enable_ivsalloc="1"
Jason Evansb7924f52009-06-23 19:01:18 -0700576fi
577AC_SUBST([enable_debug])
578
Mike Hommey5135e342012-12-06 22:16:26 +0100579dnl Do not validate pointers by default.
580AC_ARG_ENABLE([ivsalloc],
581 [AS_HELP_STRING([--enable-ivsalloc], [Validate pointers passed through the public API])],
582[if test "x$enable_ivsalloc" = "xno" ; then
583 enable_ivsalloc="0"
584else
585 enable_ivsalloc="1"
586fi
587],
588[enable_ivsalloc="0"]
589)
590if test "x$enable_ivsalloc" = "x1" ; then
591 AC_DEFINE([JEMALLOC_IVSALLOC], [ ])
592fi
593
Jason Evansb7924f52009-06-23 19:01:18 -0700594dnl Only optimize if not debugging.
595if test "x$enable_debug" = "x0" -a "x$no_CFLAGS" = "xyes" ; then
596 dnl Make sure that an optimization flag was not specified in EXTRA_CFLAGS.
Jason Evansf3340ca2009-06-30 16:17:05 -0700597 optimize="no"
598 echo "$EXTRA_CFLAGS" | grep "\-O" >/dev/null || optimize="yes"
599 if test "x${optimize}" = "xyes" ; then
600 if test "x$GCC" = "xyes" ; then
601 JE_CFLAGS_APPEND([-O3])
602 JE_CFLAGS_APPEND([-funroll-loops])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200603 elif test "x$je_cv_msvc" = "xyes" ; then
604 JE_CFLAGS_APPEND([-O2])
Jason Evansf3340ca2009-06-30 16:17:05 -0700605 else
606 JE_CFLAGS_APPEND([-O])
607 fi
Jason Evansb7924f52009-06-23 19:01:18 -0700608 fi
609fi
610
Jason Evansd073a322012-02-28 20:41:16 -0800611dnl Enable statistics calculation by default.
Jason Evansb7924f52009-06-23 19:01:18 -0700612AC_ARG_ENABLE([stats],
Jason Evans777c1912012-02-28 20:49:22 -0800613 [AS_HELP_STRING([--disable-stats],
614 [Disable statistics calculation/reporting])],
Jason Evansb7924f52009-06-23 19:01:18 -0700615[if test "x$enable_stats" = "xno" ; then
616 enable_stats="0"
617else
618 enable_stats="1"
619fi
620],
Jason Evansd073a322012-02-28 20:41:16 -0800621[enable_stats="1"]
Jason Evansb7924f52009-06-23 19:01:18 -0700622)
623if test "x$enable_stats" = "x1" ; then
624 AC_DEFINE([JEMALLOC_STATS], [ ])
625fi
626AC_SUBST([enable_stats])
627
Jason Evans6109fe02010-02-10 10:37:56 -0800628dnl Do not enable profiling by default.
629AC_ARG_ENABLE([prof],
630 [AS_HELP_STRING([--enable-prof], [Enable allocation profiling])],
631[if test "x$enable_prof" = "xno" ; then
632 enable_prof="0"
633else
634 enable_prof="1"
635fi
636],
637[enable_prof="0"]
638)
Jason Evans77f350b2011-03-15 22:23:12 -0700639if test "x$enable_prof" = "x1" ; then
640 backtrace_method=""
Jason Evansb27805b2010-02-10 18:15:53 -0800641else
Jason Evans77f350b2011-03-15 22:23:12 -0700642 backtrace_method="N/A"
Jason Evansb27805b2010-02-10 18:15:53 -0800643fi
Jason Evans77f350b2011-03-15 22:23:12 -0700644
Jason Evans6109fe02010-02-10 10:37:56 -0800645AC_ARG_ENABLE([prof-libunwind],
646 [AS_HELP_STRING([--enable-prof-libunwind], [Use libunwind for backtracing])],
647[if test "x$enable_prof_libunwind" = "xno" ; then
648 enable_prof_libunwind="0"
649else
650 enable_prof_libunwind="1"
651fi
652],
653[enable_prof_libunwind="0"]
654)
Jason Evansca6bd4f2010-03-02 14:12:58 -0800655AC_ARG_WITH([static_libunwind],
656 [AS_HELP_STRING([--with-static-libunwind=<libunwind.a>],
657 [Path to static libunwind library; use rather than dynamically linking])],
658if test "x$with_static_libunwind" = "xno" ; then
659 LUNWIND="-lunwind"
660else
661 if test ! -f "$with_static_libunwind" ; then
662 AC_MSG_ERROR([Static libunwind not found: $with_static_libunwind])
663 fi
664 LUNWIND="$with_static_libunwind"
665fi,
666 LUNWIND="-lunwind"
667)
Jason Evans77f350b2011-03-15 22:23:12 -0700668if test "x$backtrace_method" = "x" -a "x$enable_prof_libunwind" = "x1" ; then
669 AC_CHECK_HEADERS([libunwind.h], , [enable_prof_libunwind="0"])
670 if test "x$LUNWIND" = "x-lunwind" ; then
671 AC_CHECK_LIB([unwind], [backtrace], [LIBS="$LIBS $LUNWIND"],
672 [enable_prof_libunwind="0"])
673 else
674 LIBS="$LIBS $LUNWIND"
675 fi
676 if test "x${enable_prof_libunwind}" = "x1" ; then
677 backtrace_method="libunwind"
678 AC_DEFINE([JEMALLOC_PROF_LIBUNWIND], [ ])
679 fi
680fi
681
682AC_ARG_ENABLE([prof-libgcc],
683 [AS_HELP_STRING([--disable-prof-libgcc],
684 [Do not use libgcc for backtracing])],
685[if test "x$enable_prof_libgcc" = "xno" ; then
686 enable_prof_libgcc="0"
687else
688 enable_prof_libgcc="1"
689fi
690],
691[enable_prof_libgcc="1"]
692)
693if test "x$backtrace_method" = "x" -a "x$enable_prof_libgcc" = "x1" \
694 -a "x$GCC" = "xyes" ; then
695 AC_CHECK_HEADERS([unwind.h], , [enable_prof_libgcc="0"])
696 AC_CHECK_LIB([gcc], [_Unwind_Backtrace], [LIBS="$LIBS -lgcc"], [enable_prof_libgcc="0"])
697 dnl The following is conservative, in that it only has entries for CPUs on
698 dnl which jemalloc has been tested.
699 AC_MSG_CHECKING([libgcc-based backtracing reliability on ${host_cpu}])
700 case "${host_cpu}" in
701 i[[3456]]86)
702 AC_MSG_RESULT([unreliable])
703 enable_prof_libgcc="0";
704 ;;
705 x86_64)
706 AC_MSG_RESULT([reliable])
707 ;;
708 *)
709 AC_MSG_RESULT([unreliable])
710 enable_prof_libgcc="0";
711 ;;
712 esac
713 if test "x${enable_prof_libgcc}" = "x1" ; then
714 backtrace_method="libgcc"
715 AC_DEFINE([JEMALLOC_PROF_LIBGCC], [ ])
716 fi
717else
718 enable_prof_libgcc="0"
719fi
720
721AC_ARG_ENABLE([prof-gcc],
722 [AS_HELP_STRING([--disable-prof-gcc],
723 [Do not use gcc intrinsics for backtracing])],
724[if test "x$enable_prof_gcc" = "xno" ; then
725 enable_prof_gcc="0"
726else
727 enable_prof_gcc="1"
728fi
729],
730[enable_prof_gcc="1"]
731)
732if test "x$backtrace_method" = "x" -a "x$enable_prof_gcc" = "x1" \
733 -a "x$GCC" = "xyes" ; then
734 backtrace_method="gcc intrinsics"
735 AC_DEFINE([JEMALLOC_PROF_GCC], [ ])
736else
737 enable_prof_gcc="0"
738fi
739
740if test "x$backtrace_method" = "x" ; then
741 backtrace_method="none (disabling profiling)"
742 enable_prof="0"
743fi
744AC_MSG_CHECKING([configured backtracing method])
745AC_MSG_RESULT([$backtrace_method])
Jason Evans2dbecf12010-09-05 10:35:13 -0700746if test "x$enable_prof" = "x1" ; then
Jason Evans6716aa82012-04-23 13:04:55 -0700747 if test "x${force_tls}" = "x0" ; then
748 AC_MSG_ERROR([Heap profiling requires TLS]);
749 fi
750 force_tls="1"
Jason Evans2dbecf12010-09-05 10:35:13 -0700751 AC_DEFINE([JEMALLOC_PROF], [ ])
Jason Evans2dbecf12010-09-05 10:35:13 -0700752fi
753AC_SUBST([enable_prof])
Jason Evans2dbecf12010-09-05 10:35:13 -0700754
Jason Evans84cbbcb2009-12-29 00:09:15 -0800755dnl Enable thread-specific caching by default.
756AC_ARG_ENABLE([tcache],
757 [AS_HELP_STRING([--disable-tcache], [Disable per thread caches])],
758[if test "x$enable_tcache" = "xno" ; then
759 enable_tcache="0"
Jason Evansb7924f52009-06-23 19:01:18 -0700760else
Jason Evans84cbbcb2009-12-29 00:09:15 -0800761 enable_tcache="1"
Jason Evansb7924f52009-06-23 19:01:18 -0700762fi
763],
Jason Evans84cbbcb2009-12-29 00:09:15 -0800764[enable_tcache="1"]
Jason Evansb7924f52009-06-23 19:01:18 -0700765)
Jason Evans2dbecf12010-09-05 10:35:13 -0700766if test "x$enable_tcache" = "x1" ; then
767 AC_DEFINE([JEMALLOC_TCACHE], [ ])
768fi
769AC_SUBST([enable_tcache])
Jason Evansb7924f52009-06-23 19:01:18 -0700770
Jason Evans2e671ff2012-05-09 16:12:00 -0700771dnl Disable mremap() for huge realloc() by default.
772AC_ARG_ENABLE([mremap],
773 [AS_HELP_STRING([--enable-mremap], [Enable mremap(2) for huge realloc()])],
774[if test "x$enable_mremap" = "xno" ; then
775 enable_mremap="0"
776else
777 enable_mremap="1"
778fi
779],
780[enable_mremap="0"]
781)
782if test "x$enable_mremap" = "x1" ; then
783 JE_COMPILABLE([mremap(...MREMAP_FIXED...)], [
784#define _GNU_SOURCE
785#include <sys/mman.h>
786], [
787void *p = mremap((void *)0, 0, 0, MREMAP_MAYMOVE|MREMAP_FIXED, (void *)0);
788], [je_cv_mremap_fixed])
789 if test "x${je_cv_mremap_fixed}" = "xno" ; then
790 enable_mremap="0"
791 fi
792fi
793if test "x$enable_mremap" = "x1" ; then
794 AC_DEFINE([JEMALLOC_MREMAP], [ ])
795fi
796AC_SUBST([enable_mremap])
797
Jason Evans59ae2762012-04-16 17:52:27 -0700798dnl Enable VM deallocation via munmap() by default.
799AC_ARG_ENABLE([munmap],
800 [AS_HELP_STRING([--disable-munmap], [Disable VM deallocation via munmap(2)])],
801[if test "x$enable_munmap" = "xno" ; then
802 enable_munmap="0"
803else
804 enable_munmap="1"
805fi
806],
807[enable_munmap="${default_munmap}"]
808)
809if test "x$enable_munmap" = "x1" ; then
810 AC_DEFINE([JEMALLOC_MUNMAP], [ ])
811fi
812AC_SUBST([enable_munmap])
813
Jason Evansb7924f52009-06-23 19:01:18 -0700814dnl Do not enable allocation from DSS by default.
815AC_ARG_ENABLE([dss],
816 [AS_HELP_STRING([--enable-dss], [Enable allocation from DSS])],
817[if test "x$enable_dss" = "xno" ; then
818 enable_dss="0"
819else
820 enable_dss="1"
821fi
822],
823[enable_dss="0"]
824)
Mike Hommey83c324a2012-04-12 10:13:03 +0200825dnl Check whether the BSD/SUSv1 sbrk() exists. If not, disable DSS support.
826AC_CHECK_FUNC([sbrk], [have_sbrk="1"], [have_sbrk="0"])
827if test "x$have_sbrk" = "x1" ; then
828 AC_DEFINE([JEMALLOC_HAVE_SBRK], [ ])
829else
830 enable_dss="0"
831fi
832
Jason Evansb7924f52009-06-23 19:01:18 -0700833if test "x$enable_dss" = "x1" ; then
834 AC_DEFINE([JEMALLOC_DSS], [ ])
835fi
836AC_SUBST([enable_dss])
837
Jason Evans777c1912012-02-28 20:49:22 -0800838dnl Support the junk/zero filling option by default.
Jason Evansb7924f52009-06-23 19:01:18 -0700839AC_ARG_ENABLE([fill],
Jason Evans122449b2012-04-06 00:35:09 -0700840 [AS_HELP_STRING([--disable-fill],
841 [Disable support for junk/zero filling, quarantine, and redzones])],
Jason Evansb7924f52009-06-23 19:01:18 -0700842[if test "x$enable_fill" = "xno" ; then
843 enable_fill="0"
844else
845 enable_fill="1"
846fi
847],
Jason Evans777c1912012-02-28 20:49:22 -0800848[enable_fill="1"]
Jason Evansb7924f52009-06-23 19:01:18 -0700849)
850if test "x$enable_fill" = "x1" ; then
851 AC_DEFINE([JEMALLOC_FILL], [ ])
852fi
853AC_SUBST([enable_fill])
854
Jason Evansb1476112012-04-05 13:36:17 -0700855dnl Disable utrace(2)-based tracing by default.
856AC_ARG_ENABLE([utrace],
857 [AS_HELP_STRING([--enable-utrace], [Enable utrace(2)-based tracing])],
858[if test "x$enable_utrace" = "xno" ; then
859 enable_utrace="0"
860else
861 enable_utrace="1"
862fi
863],
864[enable_utrace="0"]
865)
866JE_COMPILABLE([utrace(2)], [
867#include <sys/types.h>
868#include <sys/param.h>
869#include <sys/time.h>
870#include <sys/uio.h>
871#include <sys/ktrace.h>
872], [
873 utrace((void *)0, 0);
874], [je_cv_utrace])
875if test "x${je_cv_utrace}" = "xno" ; then
876 enable_utrace="0"
877fi
878if test "x$enable_utrace" = "x1" ; then
879 AC_DEFINE([JEMALLOC_UTRACE], [ ])
880fi
881AC_SUBST([enable_utrace])
882
Jason Evans122449b2012-04-06 00:35:09 -0700883dnl Support Valgrind by default.
884AC_ARG_ENABLE([valgrind],
885 [AS_HELP_STRING([--disable-valgrind], [Disable support for Valgrind])],
886[if test "x$enable_valgrind" = "xno" ; then
887 enable_valgrind="0"
888else
889 enable_valgrind="1"
890fi
891],
892[enable_valgrind="1"]
893)
894if test "x$enable_valgrind" = "x1" ; then
895 JE_COMPILABLE([valgrind], [
896#include <valgrind/valgrind.h>
897#include <valgrind/memcheck.h>
898
Mike Hommey7bfecf42012-04-30 15:15:15 +0200899#if !defined(VALGRIND_RESIZEINPLACE_BLOCK)
Jason Evans122449b2012-04-06 00:35:09 -0700900# error "Incompatible Valgrind version"
901#endif
902], [], [je_cv_valgrind])
903 if test "x${je_cv_valgrind}" = "xno" ; then
904 enable_valgrind="0"
905 fi
906 if test "x$enable_valgrind" = "x1" ; then
907 AC_DEFINE([JEMALLOC_VALGRIND], [ ])
908 fi
909fi
910AC_SUBST([enable_valgrind])
911
Jason Evansb7924f52009-06-23 19:01:18 -0700912dnl Do not support the xmalloc option by default.
913AC_ARG_ENABLE([xmalloc],
914 [AS_HELP_STRING([--enable-xmalloc], [Support xmalloc option])],
915[if test "x$enable_xmalloc" = "xno" ; then
916 enable_xmalloc="0"
917else
918 enable_xmalloc="1"
919fi
920],
921[enable_xmalloc="0"]
922)
923if test "x$enable_xmalloc" = "x1" ; then
924 AC_DEFINE([JEMALLOC_XMALLOC], [ ])
925fi
926AC_SUBST([enable_xmalloc])
927
Jason Evans6684cac2012-03-05 12:15:36 -0800928AC_CACHE_CHECK([STATIC_PAGE_SHIFT],
929 [je_cv_static_page_shift],
930 AC_RUN_IFELSE([AC_LANG_PROGRAM(
Mike Hommeya19e87f2012-04-21 21:27:46 -0700931[[
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200932#include <strings.h>
Mike Hommeya19e87f2012-04-21 21:27:46 -0700933#ifdef _WIN32
934#include <windows.h>
935#else
Jason Evansb7924f52009-06-23 19:01:18 -0700936#include <unistd.h>
Mike Hommeya19e87f2012-04-21 21:27:46 -0700937#endif
938#include <stdio.h>
Jason Evans6684cac2012-03-05 12:15:36 -0800939]],
940[[
Garrett Cooper72c1e592012-12-02 17:57:28 -0800941 int result;
Jason Evansb7924f52009-06-23 19:01:18 -0700942 FILE *f;
943
Mike Hommeya19e87f2012-04-21 21:27:46 -0700944#ifdef _WIN32
945 SYSTEM_INFO si;
946 GetSystemInfo(&si);
947 result = si.dwPageSize;
948#else
Jason Evansb7924f52009-06-23 19:01:18 -0700949 result = sysconf(_SC_PAGESIZE);
Mike Hommeya19e87f2012-04-21 21:27:46 -0700950#endif
Jason Evansb7924f52009-06-23 19:01:18 -0700951 if (result == -1) {
952 return 1;
953 }
Mike Hommeya19e87f2012-04-21 21:27:46 -0700954 result = ffsl(result) - 1;
955
Jason Evansb7924f52009-06-23 19:01:18 -0700956 f = fopen("conftest.out", "w");
957 if (f == NULL) {
958 return 1;
959 }
Garrett Cooper72c1e592012-12-02 17:57:28 -0800960 fprintf(f, "%d\n", result);
Jason Evans3cc1f1a2012-04-03 22:30:05 -0700961 fclose(f);
Jason Evansb7924f52009-06-23 19:01:18 -0700962
963 return 0;
964]])],
Jason Evans6684cac2012-03-05 12:15:36 -0800965 [je_cv_static_page_shift=`cat conftest.out`],
966 [je_cv_static_page_shift=undefined]))
967
968if test "x$je_cv_static_page_shift" != "xundefined"; then
969 AC_DEFINE_UNQUOTED([STATIC_PAGE_SHIFT], [$je_cv_static_page_shift])
970else
971 AC_MSG_ERROR([cannot determine value for STATIC_PAGE_SHIFT])
972fi
Jason Evansb7924f52009-06-23 19:01:18 -0700973
974dnl ============================================================================
975dnl jemalloc configuration.
976dnl
Jason Evansa40bc7a2010-03-02 13:01:16 -0800977
978dnl Set VERSION if source directory has an embedded git repository.
Jason Evans955851f2011-03-31 22:38:51 -0700979if test -d "${srcroot}.git" ; then
Jason Evans79d660d2010-09-17 17:38:24 -0700980 git describe --long --abbrev=40 > ${srcroot}VERSION
Jason Evansa40bc7a2010-03-02 13:01:16 -0800981fi
Jason Evansb7924f52009-06-23 19:01:18 -0700982jemalloc_version=`cat ${srcroot}VERSION`
Jason Evansa40bc7a2010-03-02 13:01:16 -0800983jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'`
984jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'`
985jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'`
986jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'`
987jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'`
Jason Evansb7924f52009-06-23 19:01:18 -0700988AC_SUBST([jemalloc_version])
Jason Evansa40bc7a2010-03-02 13:01:16 -0800989AC_SUBST([jemalloc_version_major])
990AC_SUBST([jemalloc_version_minor])
991AC_SUBST([jemalloc_version_bugfix])
992AC_SUBST([jemalloc_version_nrev])
993AC_SUBST([jemalloc_version_gid])
Jason Evansb7924f52009-06-23 19:01:18 -0700994
995dnl ============================================================================
996dnl Configure pthreads.
997
Mike Hommeya19e87f2012-04-21 21:27:46 -0700998if test "x$abi" != "xpecoff" ; then
999 AC_CHECK_HEADERS([pthread.h], , [AC_MSG_ERROR([pthread.h is missing])])
1000 dnl Some systems may embed pthreads functionality in libc; check for libpthread
1001 dnl first, but try libc too before failing.
1002 AC_CHECK_LIB([pthread], [pthread_create], [LIBS="$LIBS -lpthread"],
1003 [AC_SEARCH_LIBS([pthread_create], , ,
1004 AC_MSG_ERROR([libpthread is missing]))])
1005fi
Jason Evansb7924f52009-06-23 19:01:18 -07001006
1007CPPFLAGS="$CPPFLAGS -D_REENTRANT"
1008
Jason Evanscd9a1342012-03-21 18:33:03 -07001009dnl Check whether the BSD-specific _malloc_thread_cleanup() exists. If so, use
1010dnl it rather than pthreads TSD cleanup functions to support cleanup during
1011dnl thread exit, in order to avoid pthreads library recursion during
1012dnl bootstrapping.
Jason Evanscd9a1342012-03-21 18:33:03 -07001013AC_CHECK_FUNC([_malloc_thread_cleanup],
1014 [have__malloc_thread_cleanup="1"],
1015 [have__malloc_thread_cleanup="0"]
1016 )
1017if test "x$have__malloc_thread_cleanup" = "x1" ; then
1018 AC_DEFINE([JEMALLOC_MALLOC_THREAD_CLEANUP], [ ])
1019 force_tls="1"
1020fi
1021
Jason Evans41b6afb2012-02-02 22:04:57 -08001022dnl Check whether the BSD-specific _pthread_mutex_init_calloc_cb() exists. If
1023dnl so, mutex initialization causes allocation, and we need to implement this
1024dnl callback function in order to prevent recursive allocation.
1025AC_CHECK_FUNC([_pthread_mutex_init_calloc_cb],
1026 [have__pthread_mutex_init_calloc_cb="1"],
1027 [have__pthread_mutex_init_calloc_cb="0"]
1028 )
1029if test "x$have__pthread_mutex_init_calloc_cb" = "x1" ; then
1030 AC_DEFINE([JEMALLOC_MUTEX_INIT_CB])
1031fi
1032
Jason Evans0fee70d2012-02-13 12:36:11 -08001033dnl Disable lazy locking by default.
Jason Evansb7924f52009-06-23 19:01:18 -07001034AC_ARG_ENABLE([lazy_lock],
Jason Evans0fee70d2012-02-13 12:36:11 -08001035 [AS_HELP_STRING([--enable-lazy-lock],
1036 [Enable lazy locking (only lock when multi-threaded)])],
Jason Evansb7924f52009-06-23 19:01:18 -07001037[if test "x$enable_lazy_lock" = "xno" ; then
1038 enable_lazy_lock="0"
1039else
1040 enable_lazy_lock="1"
1041fi
1042],
Jason Evans0fee70d2012-02-13 12:36:11 -08001043[enable_lazy_lock="0"]
Jason Evansb7924f52009-06-23 19:01:18 -07001044)
Jason Evansfd4fcef2012-03-23 17:40:58 -07001045if test "x$enable_lazy_lock" = "x0" -a "x${force_lazy_lock}" = "x1" ; then
1046 AC_MSG_RESULT([Forcing lazy-lock to avoid allocator/threading bootstrap issues])
1047 enable_lazy_lock="1"
1048fi
Jason Evansb7924f52009-06-23 19:01:18 -07001049if test "x$enable_lazy_lock" = "x1" ; then
Mike Hommeya19e87f2012-04-21 21:27:46 -07001050 if test "x$abi" != "xpecoff" ; then
1051 AC_CHECK_HEADERS([dlfcn.h], , [AC_MSG_ERROR([dlfcn.h is missing])])
1052 AC_CHECK_FUNC([dlsym], [],
1053 [AC_CHECK_LIB([dl], [dlsym], [LIBS="$LIBS -ldl"],
1054 [AC_MSG_ERROR([libdl is missing])])
1055 ])
1056 fi
Jason Evansb7924f52009-06-23 19:01:18 -07001057 AC_DEFINE([JEMALLOC_LAZY_LOCK], [ ])
1058fi
1059AC_SUBST([enable_lazy_lock])
1060
Jason Evans78d815c2010-01-17 14:06:20 -08001061AC_ARG_ENABLE([tls],
1062 [AS_HELP_STRING([--disable-tls], [Disable thread-local storage (__thread keyword)])],
1063if test "x$enable_tls" = "xno" ; then
1064 enable_tls="0"
1065else
1066 enable_tls="1"
1067fi
1068,
1069enable_tls="1"
1070)
Jason Evanscd9a1342012-03-21 18:33:03 -07001071if test "x${enable_tls}" = "x0" -a "x${force_tls}" = "x1" ; then
1072 AC_MSG_RESULT([Forcing TLS to avoid allocator/threading bootstrap issues])
1073 enable_tls="1"
1074fi
Jason Evansb80581d2012-03-23 16:17:43 -07001075if test "x${enable_tls}" = "x1" -a "x${force_tls}" = "x0" ; then
1076 AC_MSG_RESULT([Forcing no TLS to avoid allocator/threading bootstrap issues])
1077 enable_tls="0"
1078fi
Jason Evans78d815c2010-01-17 14:06:20 -08001079if test "x${enable_tls}" = "x1" ; then
1080AC_MSG_CHECKING([for TLS])
Jason Evans6684cac2012-03-05 12:15:36 -08001081AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Jason Evans78d815c2010-01-17 14:06:20 -08001082[[
1083 __thread int x;
1084]], [[
1085 x = 42;
1086
1087 return 0;
1088]])],
1089 AC_MSG_RESULT([yes]),
1090 AC_MSG_RESULT([no])
1091 enable_tls="0")
1092fi
Jason Evansb267d0f2010-08-13 15:42:29 -07001093AC_SUBST([enable_tls])
Jason Evanse24c7af2012-03-19 10:21:17 -07001094if test "x${enable_tls}" = "x1" ; then
1095 AC_DEFINE_UNQUOTED([JEMALLOC_TLS], [ ])
Jason Evanscd9a1342012-03-21 18:33:03 -07001096elif test "x${force_tls}" = "x1" ; then
1097 AC_MSG_ERROR([Failed to configure TLS, which is mandatory for correct function])
Jason Evans78d815c2010-01-17 14:06:20 -08001098fi
1099
Jason Evans2dbecf12010-09-05 10:35:13 -07001100dnl ============================================================================
Jason Evans84c8eef2011-03-16 10:30:13 -07001101dnl Check for ffsl(3), and fail if not found. This function exists on all
1102dnl platforms that jemalloc currently has a chance of functioning on without
1103dnl modification.
Jason Evans4c2faa82012-03-13 11:09:23 -07001104JE_COMPILABLE([a program using ffsl], [
Garrett Cooper72c1e592012-12-02 17:57:28 -08001105#include <stdio.h>
Jason Evans382132e2012-04-04 15:25:43 -07001106#include <strings.h>
Jason Evans4c2faa82012-03-13 11:09:23 -07001107#include <string.h>
1108], [
1109 {
1110 int rv = ffsl(0x08);
Garrett Cooper72c1e592012-12-02 17:57:28 -08001111 printf("%d\n", rv);
Jason Evans4c2faa82012-03-13 11:09:23 -07001112 }
1113], [je_cv_function_ffsl])
Jason Evans6684cac2012-03-05 12:15:36 -08001114if test "x${je_cv_function_ffsl}" != "xyes" ; then
1115 AC_MSG_ERROR([Cannot build without ffsl(3)])
1116fi
Jason Evans84c8eef2011-03-16 10:30:13 -07001117
1118dnl ============================================================================
Jason Evansb57d3ec2012-04-17 13:17:54 -07001119dnl Check for atomic(9) operations as provided on FreeBSD.
1120
1121JE_COMPILABLE([atomic(9)], [
1122#include <sys/types.h>
1123#include <machine/atomic.h>
1124#include <inttypes.h>
1125], [
1126 {
1127 uint32_t x32 = 0;
1128 volatile uint32_t *x32p = &x32;
1129 atomic_fetchadd_32(x32p, 1);
1130 }
1131 {
1132 unsigned long xlong = 0;
1133 volatile unsigned long *xlongp = &xlong;
1134 atomic_fetchadd_long(xlongp, 1);
1135 }
1136], [je_cv_atomic9])
1137if test "x${je_cv_atomic9}" = "xyes" ; then
1138 AC_DEFINE([JEMALLOC_ATOMIC9])
1139fi
1140
1141dnl ============================================================================
Jason Evans763baa62011-03-18 19:10:31 -07001142dnl Check for atomic(3) operations as provided on Darwin.
1143
1144JE_COMPILABLE([Darwin OSAtomic*()], [
1145#include <libkern/OSAtomic.h>
1146#include <inttypes.h>
1147], [
1148 {
1149 int32_t x32 = 0;
1150 volatile int32_t *x32p = &x32;
1151 OSAtomicAdd32(1, x32p);
1152 }
1153 {
1154 int64_t x64 = 0;
1155 volatile int64_t *x64p = &x64;
1156 OSAtomicAdd64(1, x64p);
1157 }
Jason Evans6684cac2012-03-05 12:15:36 -08001158], [je_cv_osatomic])
1159if test "x${je_cv_osatomic}" = "xyes" ; then
Jason Evanse24c7af2012-03-19 10:21:17 -07001160 AC_DEFINE([JEMALLOC_OSATOMIC], [ ])
Jason Evans763baa62011-03-18 19:10:31 -07001161fi
1162
1163dnl ============================================================================
Mike Hommeyc1e567b2012-03-26 17:03:41 +02001164dnl Check whether __sync_{add,sub}_and_fetch() are available despite
1165dnl __GCC_HAVE_SYNC_COMPARE_AND_SWAP_n macros being undefined.
1166
1167AC_DEFUN([JE_SYNC_COMPARE_AND_SWAP_CHECK],[
1168 AC_CACHE_CHECK([whether to force $1-bit __sync_{add,sub}_and_fetch()],
1169 [je_cv_sync_compare_and_swap_$2],
Mike Hommey2cfe6d62012-03-27 15:03:07 +02001170 [AC_LINK_IFELSE([AC_LANG_PROGRAM([
1171 #include <stdint.h>
1172 ],
1173 [
1174 #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2
1175 {
1176 uint$1_t x$1 = 0;
1177 __sync_add_and_fetch(&x$1, 42);
1178 __sync_sub_and_fetch(&x$1, 1);
1179 }
1180 #else
1181 #error __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2 is defined, no need to force
1182 #endif
1183 ])],
Mike Hommeyc1e567b2012-03-26 17:03:41 +02001184 [je_cv_sync_compare_and_swap_$2=yes],
1185 [je_cv_sync_compare_and_swap_$2=no])])
1186
1187 if test "x${je_cv_sync_compare_and_swap_$2}" = "xyes" ; then
1188 AC_DEFINE([JE_FORCE_SYNC_COMPARE_AND_SWAP_$2], [ ])
1189 fi
1190])
1191
Jason Evansb57d3ec2012-04-17 13:17:54 -07001192if test "x${je_cv_atomic9}" != "xyes" -a "x${je_cv_osatomic}" != "xyes" ; then
Mike Hommeyc1e567b2012-03-26 17:03:41 +02001193 JE_SYNC_COMPARE_AND_SWAP_CHECK(32, 4)
1194 JE_SYNC_COMPARE_AND_SWAP_CHECK(64, 8)
1195fi
1196
1197dnl ============================================================================
Jason Evans893a0ed2011-03-18 19:30:18 -07001198dnl Check for spinlock(3) operations as provided on Darwin.
1199
1200JE_COMPILABLE([Darwin OSSpin*()], [
1201#include <libkern/OSAtomic.h>
1202#include <inttypes.h>
1203], [
1204 OSSpinLock lock = 0;
1205 OSSpinLockLock(&lock);
1206 OSSpinLockUnlock(&lock);
Jason Evans6684cac2012-03-05 12:15:36 -08001207], [je_cv_osspin])
1208if test "x${je_cv_osspin}" = "xyes" ; then
Jason Evanse24c7af2012-03-19 10:21:17 -07001209 AC_DEFINE([JEMALLOC_OSSPIN], [ ])
Jason Evans893a0ed2011-03-18 19:30:18 -07001210fi
1211
1212dnl ============================================================================
Jason Evans2dbecf12010-09-05 10:35:13 -07001213dnl Darwin-related configuration.
Jason Evans78d815c2010-01-17 14:06:20 -08001214
Mike Hommeyd0357f72012-11-26 18:52:41 +01001215AC_ARG_ENABLE([zone-allocator],
1216 [AS_HELP_STRING([--disable-zone-allocator],
1217 [Disable zone allocator for Darwin])],
1218[if test "x$enable_zone_allocator" = "xno" ; then
1219 enable_zone_allocator="0"
1220else
1221 enable_zone_allocator="1"
1222fi
1223],
1224[if test "x${abi}" = "xmacho"; then
1225 enable_zone_allocator="1"
1226fi
1227]
1228)
1229AC_SUBST([enable_zone_allocator])
1230
1231if test "x${enable_zone_allocator}" = "x1" ; then
1232 if test "x${abi}" != "xmacho"; then
1233 AC_MSG_ERROR([--enable-zone-allocator is only supported on Darwin])
1234 fi
Jason Evanse24c7af2012-03-19 10:21:17 -07001235 AC_DEFINE([JEMALLOC_IVSALLOC], [ ])
1236 AC_DEFINE([JEMALLOC_ZONE], [ ])
Jason Evans6109fe02010-02-10 10:37:56 -08001237
Jason Evans2dbecf12010-09-05 10:35:13 -07001238 dnl The szone version jumped from 3 to 6 between the OS X 10.5.x and 10.6
1239 dnl releases. malloc_zone_t and malloc_introspection_t have new fields in
1240 dnl 10.6, which is the only source-level indication of the change.
1241 AC_MSG_CHECKING([malloc zone version])
Mike Hommey154829d2012-03-20 18:01:38 +01001242 AC_DEFUN([JE_ZONE_PROGRAM],
1243 [AC_LANG_PROGRAM(
1244 [#include <malloc/malloc.h>],
1245 [static foo[[sizeof($1) $2 sizeof(void *) * $3 ? 1 : -1]]]
1246 )])
Jason Evans2dbecf12010-09-05 10:35:13 -07001247
Mike Hommey154829d2012-03-20 18:01:38 +01001248 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,14)],[JEMALLOC_ZONE_VERSION=3],[
1249 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,15)],[JEMALLOC_ZONE_VERSION=5],[
1250 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,16)],[
1251 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,9)],[JEMALLOC_ZONE_VERSION=6],[
1252 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,13)],[JEMALLOC_ZONE_VERSION=7],[JEMALLOC_ZONE_VERSION=]
1253 )])],[
1254 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,17)],[JEMALLOC_ZONE_VERSION=8],[
1255 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,>,17)],[JEMALLOC_ZONE_VERSION=9],[JEMALLOC_ZONE_VERSION=]
1256 )])])])])
1257 if test "x${JEMALLOC_ZONE_VERSION}" = "x"; then
1258 AC_MSG_RESULT([unsupported])
1259 AC_MSG_ERROR([Unsupported malloc zone version])
1260 fi
1261 if test "${JEMALLOC_ZONE_VERSION}" = 9; then
1262 JEMALLOC_ZONE_VERSION=8
1263 AC_MSG_RESULT([> 8])
1264 else
1265 AC_MSG_RESULT([$JEMALLOC_ZONE_VERSION])
1266 fi
1267 AC_DEFINE_UNQUOTED(JEMALLOC_ZONE_VERSION, [$JEMALLOC_ZONE_VERSION])
Jason Evansb27805b2010-02-10 18:15:53 -08001268fi
1269
Jason Evansb7924f52009-06-23 19:01:18 -07001270dnl ============================================================================
1271dnl Check for typedefs, structures, and compiler characteristics.
1272AC_HEADER_STDBOOL
1273
Jason Evansb1726102012-02-28 16:50:47 -08001274AC_CONFIG_COMMANDS([include/jemalloc/internal/size_classes.h], [
1275 mkdir -p "include/jemalloc/internal"
1276 "${srcdir}/include/jemalloc/internal/size_classes.sh" > "${objroot}include/jemalloc/internal/size_classes.h"
1277])
1278
Jason Evansb7924f52009-06-23 19:01:18 -07001279dnl Process .in files.
Jason Evansb0fd5012010-01-17 01:49:20 -08001280AC_SUBST([cfghdrs_in])
1281AC_SUBST([cfghdrs_out])
Jason Evans0656ec02010-04-07 23:37:35 -07001282AC_CONFIG_HEADERS([$cfghdrs_tup])
Jason Evansb7924f52009-06-23 19:01:18 -07001283
1284dnl ============================================================================
1285dnl Generate outputs.
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +04001286AC_CONFIG_FILES([$cfgoutputs_tup config.stamp bin/jemalloc.sh])
Jason Evansb0fd5012010-01-17 01:49:20 -08001287AC_SUBST([cfgoutputs_in])
1288AC_SUBST([cfgoutputs_out])
Jason Evansb7924f52009-06-23 19:01:18 -07001289AC_OUTPUT
1290
1291dnl ============================================================================
1292dnl Print out the results of configuration.
1293AC_MSG_RESULT([===============================================================================])
Jason Evansf576c632011-11-01 22:27:41 -07001294AC_MSG_RESULT([jemalloc version : ${jemalloc_version}])
1295AC_MSG_RESULT([library revision : ${rev}])
Jason Evansb7924f52009-06-23 19:01:18 -07001296AC_MSG_RESULT([])
1297AC_MSG_RESULT([CC : ${CC}])
1298AC_MSG_RESULT([CPPFLAGS : ${CPPFLAGS}])
1299AC_MSG_RESULT([CFLAGS : ${CFLAGS}])
1300AC_MSG_RESULT([LDFLAGS : ${LDFLAGS}])
1301AC_MSG_RESULT([LIBS : ${LIBS}])
1302AC_MSG_RESULT([RPATH_EXTRA : ${RPATH_EXTRA}])
1303AC_MSG_RESULT([])
Jason Evansaee7fd22010-11-24 22:00:02 -08001304AC_MSG_RESULT([XSLTPROC : ${XSLTPROC}])
1305AC_MSG_RESULT([XSLROOT : ${XSLROOT}])
1306AC_MSG_RESULT([])
Jason Evansb7924f52009-06-23 19:01:18 -07001307AC_MSG_RESULT([PREFIX : ${PREFIX}])
1308AC_MSG_RESULT([BINDIR : ${BINDIR}])
Jason Evans662a0172009-07-01 19:24:31 -07001309AC_MSG_RESULT([INCLUDEDIR : ${INCLUDEDIR}])
1310AC_MSG_RESULT([LIBDIR : ${LIBDIR}])
Jason Evansb7924f52009-06-23 19:01:18 -07001311AC_MSG_RESULT([DATADIR : ${DATADIR}])
1312AC_MSG_RESULT([MANDIR : ${MANDIR}])
1313AC_MSG_RESULT([])
1314AC_MSG_RESULT([srcroot : ${srcroot}])
1315AC_MSG_RESULT([abs_srcroot : ${abs_srcroot}])
1316AC_MSG_RESULT([objroot : ${objroot}])
1317AC_MSG_RESULT([abs_objroot : ${abs_objroot}])
1318AC_MSG_RESULT([])
Jason Evans90895cf2009-12-29 00:09:15 -08001319AC_MSG_RESULT([JEMALLOC_PREFIX : ${JEMALLOC_PREFIX}])
Jason Evans746e77a2011-07-30 16:40:52 -07001320AC_MSG_RESULT([JEMALLOC_PRIVATE_NAMESPACE])
1321AC_MSG_RESULT([ : ${JEMALLOC_PRIVATE_NAMESPACE}])
Jason Evansb0fd5012010-01-17 01:49:20 -08001322AC_MSG_RESULT([install_suffix : ${install_suffix}])
Jason Evansb7924f52009-06-23 19:01:18 -07001323AC_MSG_RESULT([autogen : ${enable_autogen}])
Jason Evans7e77eaf2012-03-02 17:47:37 -08001324AC_MSG_RESULT([experimental : ${enable_experimental}])
Jason Evans355b4382010-09-20 19:20:48 -07001325AC_MSG_RESULT([cc-silence : ${enable_cc_silence}])
Jason Evansb7924f52009-06-23 19:01:18 -07001326AC_MSG_RESULT([debug : ${enable_debug}])
1327AC_MSG_RESULT([stats : ${enable_stats}])
Jason Evans6109fe02010-02-10 10:37:56 -08001328AC_MSG_RESULT([prof : ${enable_prof}])
1329AC_MSG_RESULT([prof-libunwind : ${enable_prof_libunwind}])
Jason Evans77f350b2011-03-15 22:23:12 -07001330AC_MSG_RESULT([prof-libgcc : ${enable_prof_libgcc}])
1331AC_MSG_RESULT([prof-gcc : ${enable_prof_gcc}])
Jason Evans84cbbcb2009-12-29 00:09:15 -08001332AC_MSG_RESULT([tcache : ${enable_tcache}])
Jason Evansb7924f52009-06-23 19:01:18 -07001333AC_MSG_RESULT([fill : ${enable_fill}])
Jason Evansb1476112012-04-05 13:36:17 -07001334AC_MSG_RESULT([utrace : ${enable_utrace}])
Jason Evans122449b2012-04-06 00:35:09 -07001335AC_MSG_RESULT([valgrind : ${enable_valgrind}])
1336AC_MSG_RESULT([xmalloc : ${enable_xmalloc}])
Jason Evans2e671ff2012-05-09 16:12:00 -07001337AC_MSG_RESULT([mremap : ${enable_mremap}])
Jason Evans59ae2762012-04-16 17:52:27 -07001338AC_MSG_RESULT([munmap : ${enable_munmap}])
Jason Evansb7924f52009-06-23 19:01:18 -07001339AC_MSG_RESULT([dss : ${enable_dss}])
Jason Evansb7924f52009-06-23 19:01:18 -07001340AC_MSG_RESULT([lazy_lock : ${enable_lazy_lock}])
Jason Evans2dbecf12010-09-05 10:35:13 -07001341AC_MSG_RESULT([tls : ${enable_tls}])
Jason Evansb7924f52009-06-23 19:01:18 -07001342AC_MSG_RESULT([===============================================================================])