blob: 1103cc772e286371bdde9cabdabbd2b993218e4c [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 Evans66688532013-12-03 21:49:36 -0800259 sbrk_deprecated="1"
Jason Evansb7924f52009-06-23 19:01:18 -0700260 ;;
261 *-*-freebsd*)
262 CFLAGS="$CFLAGS"
263 abi="elf"
Jason Evanse24c7af2012-03-19 10:21:17 -0700264 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
Jason Evansfd4fcef2012-03-23 17:40:58 -0700265 force_lazy_lock="1"
Jason Evansb7924f52009-06-23 19:01:18 -0700266 ;;
267 *-*-linux*)
268 CFLAGS="$CFLAGS"
269 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
270 abi="elf"
Garrett Cooper13e4e242012-12-02 17:58:40 -0800271 AC_DEFINE([JEMALLOC_HAS_ALLOCA_H])
Jason Evanse24c7af2012-03-19 10:21:17 -0700272 AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED], [ ])
Jason Evans02b23122012-04-05 11:06:23 -0700273 AC_DEFINE([JEMALLOC_THREADED_INIT], [ ])
Jason Evans247d1242012-10-09 16:20:10 -0700274 JEMALLOC_USABLE_SIZE_CONST=""
Jason Evans59ae2762012-04-16 17:52:27 -0700275 default_munmap="0"
Jason Evansb7924f52009-06-23 19:01:18 -0700276 ;;
277 *-*-netbsd*)
278 AC_MSG_CHECKING([ABI])
279 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
280[[#ifdef __ELF__
281/* ELF */
282#else
283#error aout
284#endif
285]])],
286 [CFLAGS="$CFLAGS"; abi="elf"],
287 [abi="aout"])
288 AC_MSG_RESULT([$abi])
Jason Evanse24c7af2012-03-19 10:21:17 -0700289 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
Jason Evansb7924f52009-06-23 19:01:18 -0700290 ;;
291 *-*-solaris2*)
292 CFLAGS="$CFLAGS"
293 abi="elf"
Mike Hommeyfa08da72012-04-16 16:30:25 +0200294 RPATH='-Wl,-R,$(1)'
Jason Evansb7924f52009-06-23 19:01:18 -0700295 dnl Solaris needs this for sigwait().
296 CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
297 LIBS="$LIBS -lposix4 -lsocket -lnsl"
298 ;;
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +0400299 *-ibm-aix*)
300 if "$LG_SIZEOF_PTR" = "8"; then
301 dnl 64bit AIX
302 LD_PRELOAD_VAR="LDR_PRELOAD64"
303 else
304 dnl 32bit AIX
305 LD_PRELOAD_VAR="LDR_PRELOAD"
306 fi
307 abi="xcoff"
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +0400308 ;;
Mike Hommeya19e87f2012-04-21 21:27:46 -0700309 *-*-mingw*)
310 abi="pecoff"
311 force_tls="0"
312 RPATH=""
313 so="dll"
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200314 if test "x$je_cv_msvc" = "xyes" ; then
315 importlib="lib"
316 DSO_LDFLAGS="-LD"
317 EXTRA_LDFLAGS="-link -DEBUG"
318 CTARGET='-Fo$@'
319 LDTARGET='-Fe$@'
Jory A. Prattad505e02013-08-11 09:44:59 -0500320 AR='lib'
321 ARFLAGS='-nologo -out:'
Jason Evans80ddf492013-08-20 11:48:19 +0100322 AROUT='$@'
Mike Hommey79c4bca2012-05-02 21:30:51 +0200323 CC_MM=
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200324 else
325 importlib="${so}"
326 DSO_LDFLAGS="-shared"
327 fi
Mike Hommeya19e87f2012-04-21 21:27:46 -0700328 a="lib"
329 libprefix=""
Mike Hommey7cdea392012-04-30 12:38:27 +0200330 SOREV="${so}"
Mike Hommeya19e87f2012-04-21 21:27:46 -0700331 PIC_CFLAGS=""
332 ;;
Jason Evansb7924f52009-06-23 19:01:18 -0700333 *)
334 AC_MSG_RESULT([Unsupported operating system: ${host}])
335 abi="elf"
Jason Evansb7924f52009-06-23 19:01:18 -0700336 ;;
337esac
Jason Evans247d1242012-10-09 16:20:10 -0700338AC_DEFINE_UNQUOTED([JEMALLOC_USABLE_SIZE_CONST], [$JEMALLOC_USABLE_SIZE_CONST])
Jason Evansb7924f52009-06-23 19:01:18 -0700339AC_SUBST([abi])
340AC_SUBST([RPATH])
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +0400341AC_SUBST([LD_PRELOAD_VAR])
Jason Evansf576c632011-11-01 22:27:41 -0700342AC_SUBST([so])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200343AC_SUBST([importlib])
Mike Hommey5bee66d2012-04-16 16:30:24 +0200344AC_SUBST([o])
345AC_SUBST([a])
346AC_SUBST([exe])
Mike Hommeya19e87f2012-04-21 21:27:46 -0700347AC_SUBST([libprefix])
Mike Hommeyfa08da72012-04-16 16:30:25 +0200348AC_SUBST([DSO_LDFLAGS])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200349AC_SUBST([EXTRA_LDFLAGS])
Mike Hommey85221d52012-04-18 18:29:40 +0200350AC_SUBST([SOREV])
Mike Hommey188da7c2012-04-18 18:29:41 +0200351AC_SUBST([PIC_CFLAGS])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200352AC_SUBST([CTARGET])
353AC_SUBST([LDTARGET])
354AC_SUBST([MKLIB])
Jason Evans80ddf492013-08-20 11:48:19 +0100355AC_SUBST([ARFLAGS])
356AC_SUBST([AROUT])
Mike Hommey79c4bca2012-05-02 21:30:51 +0200357AC_SUBST([CC_MM])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200358
Jason Evansfa5d2452011-03-15 10:25:59 -0700359JE_COMPILABLE([__attribute__ syntax],
360 [static __attribute__((unused)) void foo(void){}],
361 [],
Jason Evans6684cac2012-03-05 12:15:36 -0800362 [je_cv_attribute])
363if test "x${je_cv_attribute}" = "xyes" ; then
Jason Evansfa5d2452011-03-15 10:25:59 -0700364 AC_DEFINE([JEMALLOC_HAVE_ATTR], [ ])
365 if test "x${GCC}" = "xyes" -a "x${abi}" = "xelf"; then
366 JE_CFLAGS_APPEND([-fvisibility=hidden])
367 fi
368fi
Jason Evans3cc1f1a2012-04-03 22:30:05 -0700369dnl Check for tls_model attribute support (clang 3.0 still lacks support).
370SAVED_CFLAGS="${CFLAGS}"
371JE_CFLAGS_APPEND([-Werror])
372JE_COMPILABLE([tls_model attribute], [],
373 [static __thread int
374 __attribute__((tls_model("initial-exec"))) foo;
375 foo = 0;],
376 [je_cv_tls_model])
377CFLAGS="${SAVED_CFLAGS}"
378if test "x${je_cv_tls_model}" = "xyes" ; then
379 AC_DEFINE([JEMALLOC_TLS_MODEL],
380 [__attribute__((tls_model("initial-exec")))])
381else
382 AC_DEFINE([JEMALLOC_TLS_MODEL], [ ])
383fi
Jason Evansfa5d2452011-03-15 10:25:59 -0700384
Jason Evansb7924f52009-06-23 19:01:18 -0700385dnl Support optional additions to rpath.
386AC_ARG_WITH([rpath],
Jason Evans90895cf2009-12-29 00:09:15 -0800387 [AS_HELP_STRING([--with-rpath=<rpath>], [Colon-separated rpath (ELF systems only)])],
Jason Evansb7924f52009-06-23 19:01:18 -0700388if test "x$with_rpath" = "xno" ; then
389 RPATH_EXTRA=
390else
391 RPATH_EXTRA="`echo $with_rpath | tr \":\" \" \"`"
392fi,
393 RPATH_EXTRA=
394)
395AC_SUBST([RPATH_EXTRA])
396
397dnl Disable rules that do automatic regeneration of configure output by default.
398AC_ARG_ENABLE([autogen],
Jason Evans78d815c2010-01-17 14:06:20 -0800399 [AS_HELP_STRING([--enable-autogen], [Automatically regenerate configure output])],
Jason Evansb7924f52009-06-23 19:01:18 -0700400if test "x$enable_autogen" = "xno" ; then
401 enable_autogen="0"
402else
403 enable_autogen="1"
404fi
405,
406enable_autogen="0"
407)
408AC_SUBST([enable_autogen])
409
410AC_PROG_INSTALL
411AC_PROG_RANLIB
Jason Evans7329a4f2013-01-22 10:53:29 -0800412AC_PATH_PROG([LD], [ld], [false], [$PATH])
413AC_PATH_PROG([AUTOCONF], [autoconf], [false], [$PATH])
Jason Evansb7924f52009-06-23 19:01:18 -0700414
Jason Evans0a0bbf62012-03-13 12:55:21 -0700415public_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 -0800416
417dnl Check for allocator-related functions that should be wrapped.
418AC_CHECK_FUNC([memalign],
Jason Evanse24c7af2012-03-19 10:21:17 -0700419 [AC_DEFINE([JEMALLOC_OVERRIDE_MEMALIGN], [ ])
Jason Evans7e77eaf2012-03-02 17:47:37 -0800420 public_syms="${public_syms} memalign"])
421AC_CHECK_FUNC([valloc],
Jason Evanse24c7af2012-03-19 10:21:17 -0700422 [AC_DEFINE([JEMALLOC_OVERRIDE_VALLOC], [ ])
Jason Evans7e77eaf2012-03-02 17:47:37 -0800423 public_syms="${public_syms} valloc"])
424
425dnl Support the experimental API by default.
426AC_ARG_ENABLE([experimental],
427 [AS_HELP_STRING([--disable-experimental],
428 [Disable support for the experimental API])],
429[if test "x$enable_experimental" = "xno" ; then
430 enable_experimental="0"
431else
432 enable_experimental="1"
433fi
434],
435[enable_experimental="1"]
436)
437if test "x$enable_experimental" = "x1" ; then
438 AC_DEFINE([JEMALLOC_EXPERIMENTAL], [ ])
439 public_syms="${public_syms} allocm dallocm nallocm rallocm sallocm"
440fi
441AC_SUBST([enable_experimental])
442
Jason Evans0a5489e2012-03-01 17:19:20 -0800443dnl Perform no name mangling by default.
444AC_ARG_WITH([mangling],
445 [AS_HELP_STRING([--with-mangling=<map>], [Mangle symbols in <map>])],
446 [mangling_map="$with_mangling"], [mangling_map=""])
447for nm in `echo ${mangling_map} |tr ',' ' '` ; do
Jason Evans08fc3b22012-03-12 15:07:53 -0700448 k="`echo ${nm} |tr ':' ' ' |awk '{print $1}'`"
449 n="je_${k}"
Jason Evans0a5489e2012-03-01 17:19:20 -0800450 m=`echo ${nm} |tr ':' ' ' |awk '{print $2}'`
451 AC_DEFINE_UNQUOTED([${n}], [${m}])
Jason Evans08fc3b22012-03-12 15:07:53 -0700452 dnl Remove key from public_syms so that it isn't redefined later.
453 public_syms=`for sym in ${public_syms}; do echo "${sym}"; done |grep -v "^${k}\$" |tr '\n' ' '`
Jason Evans0a5489e2012-03-01 17:19:20 -0800454done
455
Jason Evans90895cf2009-12-29 00:09:15 -0800456dnl Do not prefix public APIs by default.
457AC_ARG_WITH([jemalloc_prefix],
458 [AS_HELP_STRING([--with-jemalloc-prefix=<prefix>], [Prefix to prepend to all public APIs])],
Jason Evansb0fd5012010-01-17 01:49:20 -0800459 [JEMALLOC_PREFIX="$with_jemalloc_prefix"],
Mike Hommey7cdea392012-04-30 12:38:27 +0200460 [if test "x$abi" != "xmacho" -a "x$abi" != "xpecoff"; then
Jason Evans2dbecf12010-09-05 10:35:13 -0700461 JEMALLOC_PREFIX=""
462else
463 JEMALLOC_PREFIX="je_"
464fi]
Jason Evans90895cf2009-12-29 00:09:15 -0800465)
466if test "x$JEMALLOC_PREFIX" != "x" ; then
Jason Evanse7339702010-10-23 18:37:06 -0700467 JEMALLOC_CPREFIX=`echo ${JEMALLOC_PREFIX} | tr "a-z" "A-Z"`
468 AC_DEFINE_UNQUOTED([JEMALLOC_PREFIX], ["$JEMALLOC_PREFIX"])
469 AC_DEFINE_UNQUOTED([JEMALLOC_CPREFIX], ["$JEMALLOC_CPREFIX"])
Jason Evans90895cf2009-12-29 00:09:15 -0800470fi
Jason Evans0a5489e2012-03-01 17:19:20 -0800471dnl Generate macros to rename public symbols. All public symbols are prefixed
472dnl with je_ in the source code, so these macro definitions are needed even if
473dnl --with-jemalloc-prefix wasn't specified.
Jason Evans7e77eaf2012-03-02 17:47:37 -0800474for stem in ${public_syms}; do
Jason Evans0a5489e2012-03-01 17:19:20 -0800475 n="je_${stem}"
476 m="${JEMALLOC_PREFIX}${stem}"
477 AC_DEFINE_UNQUOTED([${n}], [${m}])
478done
Jason Evans90895cf2009-12-29 00:09:15 -0800479
Mike Hommey99066602012-11-19 10:55:26 +0100480AC_ARG_WITH([export],
481 [AS_HELP_STRING([--without-export], [disable exporting jemalloc public APIs])],
482 [if test "x$with_export" = "xno"; then
Jason Evans2625c892013-01-22 16:46:27 -0800483 AC_DEFINE([JEMALLOC_EXPORT],[])
Mike Hommey99066602012-11-19 10:55:26 +0100484fi]
485)
486
Jason Evans86abd0d2013-11-30 15:25:42 -0800487dnl Mangle library-private APIs.
Jason Evans746e77a2011-07-30 16:40:52 -0700488AC_ARG_WITH([private_namespace],
489 [AS_HELP_STRING([--with-private-namespace=<prefix>], [Prefix to prepend to all library-private APIs])],
Jason Evans86abd0d2013-11-30 15:25:42 -0800490 [JEMALLOC_PRIVATE_NAMESPACE="${with_private_namespace}je_"],
491 [JEMALLOC_PRIVATE_NAMESPACE="je_"]
Jason Evans746e77a2011-07-30 16:40:52 -0700492)
Jason Evans86abd0d2013-11-30 15:25:42 -0800493AC_DEFINE_UNQUOTED([JEMALLOC_PRIVATE_NAMESPACE], [$JEMALLOC_PRIVATE_NAMESPACE])
494private_namespace="$JEMALLOC_PRIVATE_NAMESPACE"
495AC_SUBST([private_namespace])
Jason Evans746e77a2011-07-30 16:40:52 -0700496
Jason Evansb0fd5012010-01-17 01:49:20 -0800497dnl Do not add suffix to installed files by default.
498AC_ARG_WITH([install_suffix],
499 [AS_HELP_STRING([--with-install-suffix=<suffix>], [Suffix to append to all installed files])],
500 [INSTALL_SUFFIX="$with_install_suffix"],
501 [INSTALL_SUFFIX=]
502)
503install_suffix="$INSTALL_SUFFIX"
504AC_SUBST([install_suffix])
505
Jason Evans86abd0d2013-11-30 15:25:42 -0800506dnl Substitute @je_@ in jemalloc_protos.h.in, primarily to make generation of
507dnl jemalloc_protos_jet.h easy.
508je_="je_"
509AC_SUBST([je_])
510
Jason Evansaee7fd22010-11-24 22:00:02 -0800511cfgoutputs_in="${srcroot}Makefile.in"
512cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/html.xsl.in"
513cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/manpages.xsl.in"
514cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/jemalloc.xml.in"
Jason Evans86abd0d2013-11-30 15:25:42 -0800515cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/jemalloc_macros.h.in"
516cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/jemalloc_protos.h.in"
517cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/jemalloc_mangle.h.in"
Jason Evans0656ec02010-04-07 23:37:35 -0700518cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/internal/jemalloc_internal.h.in"
Jason Evans86abd0d2013-11-30 15:25:42 -0800519cfgoutputs_in="${cfgoutputs_in} ${srcroot}test/test.sh.in"
520cfgoutputs_in="${cfgoutputs_in} ${srcroot}test/include/test/jemalloc_test.h.in"
Jason Evansb0fd5012010-01-17 01:49:20 -0800521
Jason Evansaee7fd22010-11-24 22:00:02 -0800522cfgoutputs_out="Makefile"
523cfgoutputs_out="${cfgoutputs_out} doc/html.xsl"
524cfgoutputs_out="${cfgoutputs_out} doc/manpages.xsl"
Jason Evans86abd0d2013-11-30 15:25:42 -0800525cfgoutputs_out="${cfgoutputs_out} doc/jemalloc.xml"
526cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_macros.h"
527cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_protos.h"
528cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_mangle.h"
Jason Evans376b1522010-02-11 14:45:59 -0800529cfgoutputs_out="${cfgoutputs_out} include/jemalloc/internal/jemalloc_internal.h"
Jason Evans86abd0d2013-11-30 15:25:42 -0800530cfgoutputs_out="${cfgoutputs_out} test/test.sh"
531cfgoutputs_out="${cfgoutputs_out} test/include/test/jemalloc_test.h"
Jason Evansb0fd5012010-01-17 01:49:20 -0800532
Jason Evansaee7fd22010-11-24 22:00:02 -0800533cfgoutputs_tup="Makefile"
534cfgoutputs_tup="${cfgoutputs_tup} doc/html.xsl:doc/html.xsl.in"
535cfgoutputs_tup="${cfgoutputs_tup} doc/manpages.xsl:doc/manpages.xsl.in"
Jason Evans86abd0d2013-11-30 15:25:42 -0800536cfgoutputs_tup="${cfgoutputs_tup} doc/jemalloc.xml:doc/jemalloc.xml.in"
537cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_macros.h:include/jemalloc/jemalloc_macros.h.in"
538cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_protos.h:include/jemalloc/jemalloc_protos.h.in"
539cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_mangle.h:include/jemalloc/jemalloc_mangle.h.in"
Jason Evans376b1522010-02-11 14:45:59 -0800540cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/internal/jemalloc_internal.h"
Jason Evans86abd0d2013-11-30 15:25:42 -0800541cfgoutputs_tup="${cfgoutputs_tup} test/test.sh:test/test.sh.in"
542cfgoutputs_tup="${cfgoutputs_tup} test/include/test/jemalloc_test.h:test/include/test/jemalloc_test.h.in"
Jason Evansb0fd5012010-01-17 01:49:20 -0800543
Jason Evans0656ec02010-04-07 23:37:35 -0700544cfghdrs_in="${srcroot}include/jemalloc/jemalloc_defs.h.in"
Jason Evans86abd0d2013-11-30 15:25:42 -0800545cfghdrs_in="${cfghdrs_in} ${srcroot}include/jemalloc/internal/jemalloc_internal_defs.h.in"
546cfghdrs_in="${cfghdrs_in} ${srcroot}include/jemalloc/internal/private_namespace.sh"
547cfghdrs_in="${cfghdrs_in} ${srcroot}include/jemalloc/internal/private_unnamespace.sh"
548cfghdrs_in="${cfghdrs_in} ${srcroot}include/jemalloc/internal/public_namespace.sh"
549cfghdrs_in="${cfghdrs_in} ${srcroot}include/jemalloc/internal/public_unnamespace.sh"
Jason Evansb1726102012-02-28 16:50:47 -0800550cfghdrs_in="${cfghdrs_in} ${srcroot}include/jemalloc/internal/size_classes.sh"
Jason Evansdc1bed62013-12-05 21:43:46 -0800551cfghdrs_in="${cfghdrs_in} ${srcroot}include/jemalloc/jemalloc.sh"
Jason Evansb0fd5012010-01-17 01:49:20 -0800552
Jason Evans86abd0d2013-11-30 15:25:42 -0800553cfghdrs_out="include/jemalloc/jemalloc_defs.h"
554cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc${install_suffix}.h"
555cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_protos_jet.h"
556cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/jemalloc_internal_defs.h"
557cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/private_namespace.h"
558cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/private_unnamespace.h"
559cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_namespace.h"
560cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_unnamespace.h"
Jason Evansb1726102012-02-28 16:50:47 -0800561cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/size_classes.h"
Jason Evansb0fd5012010-01-17 01:49:20 -0800562
Jason Evans86abd0d2013-11-30 15:25:42 -0800563cfghdrs_tup="include/jemalloc/jemalloc_defs.h:include/jemalloc/jemalloc_defs.h.in"
564cfghdrs_tup="${cfghdrs_tup} include/jemalloc/internal/jemalloc_internal_defs.h:${srcroot}include/jemalloc/internal/jemalloc_internal_defs.h.in"
Jason Evansb0fd5012010-01-17 01:49:20 -0800565
Jason Evans355b4382010-09-20 19:20:48 -0700566dnl Do not silence irrelevant compiler warnings by default, since enabling this
567dnl option incurs a performance penalty.
568AC_ARG_ENABLE([cc-silence],
569 [AS_HELP_STRING([--enable-cc-silence],
570 [Silence irrelevant compiler warnings])],
571[if test "x$enable_cc_silence" = "xno" ; then
572 enable_cc_silence="0"
573else
574 enable_cc_silence="1"
575fi
576],
577[enable_cc_silence="0"]
578)
579if test "x$enable_cc_silence" = "x1" ; then
Jason Evanse24c7af2012-03-19 10:21:17 -0700580 AC_DEFINE([JEMALLOC_CC_SILENCE], [ ])
Jason Evans355b4382010-09-20 19:20:48 -0700581fi
582
Jason Evansb7924f52009-06-23 19:01:18 -0700583dnl Do not compile with debugging by default.
584AC_ARG_ENABLE([debug],
Mike Hommey5135e342012-12-06 22:16:26 +0100585 [AS_HELP_STRING([--enable-debug], [Build debugging code (implies --enable-ivsalloc)])],
Jason Evansb7924f52009-06-23 19:01:18 -0700586[if test "x$enable_debug" = "xno" ; then
587 enable_debug="0"
588else
589 enable_debug="1"
590fi
591],
592[enable_debug="0"]
593)
594if test "x$enable_debug" = "x1" ; then
595 AC_DEFINE([JEMALLOC_DEBUG], [ ])
Mike Hommey5135e342012-12-06 22:16:26 +0100596 enable_ivsalloc="1"
Jason Evansb7924f52009-06-23 19:01:18 -0700597fi
598AC_SUBST([enable_debug])
599
Mike Hommey5135e342012-12-06 22:16:26 +0100600dnl Do not validate pointers by default.
601AC_ARG_ENABLE([ivsalloc],
602 [AS_HELP_STRING([--enable-ivsalloc], [Validate pointers passed through the public API])],
603[if test "x$enable_ivsalloc" = "xno" ; then
604 enable_ivsalloc="0"
605else
606 enable_ivsalloc="1"
607fi
608],
609[enable_ivsalloc="0"]
610)
611if test "x$enable_ivsalloc" = "x1" ; then
612 AC_DEFINE([JEMALLOC_IVSALLOC], [ ])
613fi
614
Jason Evansb7924f52009-06-23 19:01:18 -0700615dnl Only optimize if not debugging.
616if test "x$enable_debug" = "x0" -a "x$no_CFLAGS" = "xyes" ; then
617 dnl Make sure that an optimization flag was not specified in EXTRA_CFLAGS.
Jason Evansf3340ca2009-06-30 16:17:05 -0700618 optimize="no"
619 echo "$EXTRA_CFLAGS" | grep "\-O" >/dev/null || optimize="yes"
620 if test "x${optimize}" = "xyes" ; then
621 if test "x$GCC" = "xyes" ; then
622 JE_CFLAGS_APPEND([-O3])
623 JE_CFLAGS_APPEND([-funroll-loops])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200624 elif test "x$je_cv_msvc" = "xyes" ; then
625 JE_CFLAGS_APPEND([-O2])
Jason Evansf3340ca2009-06-30 16:17:05 -0700626 else
627 JE_CFLAGS_APPEND([-O])
628 fi
Jason Evansb7924f52009-06-23 19:01:18 -0700629 fi
630fi
631
Jason Evansd073a322012-02-28 20:41:16 -0800632dnl Enable statistics calculation by default.
Jason Evansb7924f52009-06-23 19:01:18 -0700633AC_ARG_ENABLE([stats],
Jason Evans777c1912012-02-28 20:49:22 -0800634 [AS_HELP_STRING([--disable-stats],
635 [Disable statistics calculation/reporting])],
Jason Evansb7924f52009-06-23 19:01:18 -0700636[if test "x$enable_stats" = "xno" ; then
637 enable_stats="0"
638else
639 enable_stats="1"
640fi
641],
Jason Evansd073a322012-02-28 20:41:16 -0800642[enable_stats="1"]
Jason Evansb7924f52009-06-23 19:01:18 -0700643)
644if test "x$enable_stats" = "x1" ; then
645 AC_DEFINE([JEMALLOC_STATS], [ ])
646fi
647AC_SUBST([enable_stats])
648
Jason Evans6109fe02010-02-10 10:37:56 -0800649dnl Do not enable profiling by default.
650AC_ARG_ENABLE([prof],
651 [AS_HELP_STRING([--enable-prof], [Enable allocation profiling])],
652[if test "x$enable_prof" = "xno" ; then
653 enable_prof="0"
654else
655 enable_prof="1"
656fi
657],
658[enable_prof="0"]
659)
Jason Evans77f350b2011-03-15 22:23:12 -0700660if test "x$enable_prof" = "x1" ; then
661 backtrace_method=""
Jason Evansb27805b2010-02-10 18:15:53 -0800662else
Jason Evans77f350b2011-03-15 22:23:12 -0700663 backtrace_method="N/A"
Jason Evansb27805b2010-02-10 18:15:53 -0800664fi
Jason Evans77f350b2011-03-15 22:23:12 -0700665
Jason Evans6109fe02010-02-10 10:37:56 -0800666AC_ARG_ENABLE([prof-libunwind],
667 [AS_HELP_STRING([--enable-prof-libunwind], [Use libunwind for backtracing])],
668[if test "x$enable_prof_libunwind" = "xno" ; then
669 enable_prof_libunwind="0"
670else
671 enable_prof_libunwind="1"
672fi
673],
674[enable_prof_libunwind="0"]
675)
Jason Evansca6bd4f2010-03-02 14:12:58 -0800676AC_ARG_WITH([static_libunwind],
677 [AS_HELP_STRING([--with-static-libunwind=<libunwind.a>],
678 [Path to static libunwind library; use rather than dynamically linking])],
679if test "x$with_static_libunwind" = "xno" ; then
680 LUNWIND="-lunwind"
681else
682 if test ! -f "$with_static_libunwind" ; then
683 AC_MSG_ERROR([Static libunwind not found: $with_static_libunwind])
684 fi
685 LUNWIND="$with_static_libunwind"
686fi,
687 LUNWIND="-lunwind"
688)
Jason Evans77f350b2011-03-15 22:23:12 -0700689if test "x$backtrace_method" = "x" -a "x$enable_prof_libunwind" = "x1" ; then
690 AC_CHECK_HEADERS([libunwind.h], , [enable_prof_libunwind="0"])
691 if test "x$LUNWIND" = "x-lunwind" ; then
692 AC_CHECK_LIB([unwind], [backtrace], [LIBS="$LIBS $LUNWIND"],
693 [enable_prof_libunwind="0"])
694 else
695 LIBS="$LIBS $LUNWIND"
696 fi
697 if test "x${enable_prof_libunwind}" = "x1" ; then
698 backtrace_method="libunwind"
699 AC_DEFINE([JEMALLOC_PROF_LIBUNWIND], [ ])
700 fi
701fi
702
703AC_ARG_ENABLE([prof-libgcc],
704 [AS_HELP_STRING([--disable-prof-libgcc],
705 [Do not use libgcc for backtracing])],
706[if test "x$enable_prof_libgcc" = "xno" ; then
707 enable_prof_libgcc="0"
708else
709 enable_prof_libgcc="1"
710fi
711],
712[enable_prof_libgcc="1"]
713)
714if test "x$backtrace_method" = "x" -a "x$enable_prof_libgcc" = "x1" \
715 -a "x$GCC" = "xyes" ; then
716 AC_CHECK_HEADERS([unwind.h], , [enable_prof_libgcc="0"])
717 AC_CHECK_LIB([gcc], [_Unwind_Backtrace], [LIBS="$LIBS -lgcc"], [enable_prof_libgcc="0"])
718 dnl The following is conservative, in that it only has entries for CPUs on
719 dnl which jemalloc has been tested.
720 AC_MSG_CHECKING([libgcc-based backtracing reliability on ${host_cpu}])
721 case "${host_cpu}" in
722 i[[3456]]86)
723 AC_MSG_RESULT([unreliable])
724 enable_prof_libgcc="0";
725 ;;
726 x86_64)
727 AC_MSG_RESULT([reliable])
728 ;;
729 *)
730 AC_MSG_RESULT([unreliable])
731 enable_prof_libgcc="0";
732 ;;
733 esac
734 if test "x${enable_prof_libgcc}" = "x1" ; then
735 backtrace_method="libgcc"
736 AC_DEFINE([JEMALLOC_PROF_LIBGCC], [ ])
737 fi
738else
739 enable_prof_libgcc="0"
740fi
741
742AC_ARG_ENABLE([prof-gcc],
743 [AS_HELP_STRING([--disable-prof-gcc],
744 [Do not use gcc intrinsics for backtracing])],
745[if test "x$enable_prof_gcc" = "xno" ; then
746 enable_prof_gcc="0"
747else
748 enable_prof_gcc="1"
749fi
750],
751[enable_prof_gcc="1"]
752)
753if test "x$backtrace_method" = "x" -a "x$enable_prof_gcc" = "x1" \
754 -a "x$GCC" = "xyes" ; then
755 backtrace_method="gcc intrinsics"
756 AC_DEFINE([JEMALLOC_PROF_GCC], [ ])
757else
758 enable_prof_gcc="0"
759fi
760
761if test "x$backtrace_method" = "x" ; then
762 backtrace_method="none (disabling profiling)"
763 enable_prof="0"
764fi
765AC_MSG_CHECKING([configured backtracing method])
766AC_MSG_RESULT([$backtrace_method])
Jason Evans2dbecf12010-09-05 10:35:13 -0700767if test "x$enable_prof" = "x1" ; then
Jason Evans6716aa82012-04-23 13:04:55 -0700768 if test "x${force_tls}" = "x0" ; then
769 AC_MSG_ERROR([Heap profiling requires TLS]);
770 fi
771 force_tls="1"
Jason Evansd37d5ad2013-12-05 23:01:50 -0800772
773 if test "x$abi" != "xpecoff"; then
774 dnl Heap profiling uses the log(3) function.
775 LIBS="$LIBS -lm"
776 fi
777
Jason Evans2dbecf12010-09-05 10:35:13 -0700778 AC_DEFINE([JEMALLOC_PROF], [ ])
Jason Evans2dbecf12010-09-05 10:35:13 -0700779fi
780AC_SUBST([enable_prof])
Jason Evans2dbecf12010-09-05 10:35:13 -0700781
Jason Evans84cbbcb2009-12-29 00:09:15 -0800782dnl Enable thread-specific caching by default.
783AC_ARG_ENABLE([tcache],
784 [AS_HELP_STRING([--disable-tcache], [Disable per thread caches])],
785[if test "x$enable_tcache" = "xno" ; then
786 enable_tcache="0"
Jason Evansb7924f52009-06-23 19:01:18 -0700787else
Jason Evans84cbbcb2009-12-29 00:09:15 -0800788 enable_tcache="1"
Jason Evansb7924f52009-06-23 19:01:18 -0700789fi
790],
Jason Evans84cbbcb2009-12-29 00:09:15 -0800791[enable_tcache="1"]
Jason Evansb7924f52009-06-23 19:01:18 -0700792)
Jason Evans2dbecf12010-09-05 10:35:13 -0700793if test "x$enable_tcache" = "x1" ; then
794 AC_DEFINE([JEMALLOC_TCACHE], [ ])
795fi
796AC_SUBST([enable_tcache])
Jason Evansb7924f52009-06-23 19:01:18 -0700797
Jason Evans2e671ff2012-05-09 16:12:00 -0700798dnl Disable mremap() for huge realloc() by default.
799AC_ARG_ENABLE([mremap],
800 [AS_HELP_STRING([--enable-mremap], [Enable mremap(2) for huge realloc()])],
801[if test "x$enable_mremap" = "xno" ; then
802 enable_mremap="0"
803else
804 enable_mremap="1"
805fi
806],
807[enable_mremap="0"]
808)
809if test "x$enable_mremap" = "x1" ; then
810 JE_COMPILABLE([mremap(...MREMAP_FIXED...)], [
811#define _GNU_SOURCE
812#include <sys/mman.h>
813], [
814void *p = mremap((void *)0, 0, 0, MREMAP_MAYMOVE|MREMAP_FIXED, (void *)0);
815], [je_cv_mremap_fixed])
816 if test "x${je_cv_mremap_fixed}" = "xno" ; then
817 enable_mremap="0"
818 fi
819fi
820if test "x$enable_mremap" = "x1" ; then
821 AC_DEFINE([JEMALLOC_MREMAP], [ ])
822fi
823AC_SUBST([enable_mremap])
824
Jason Evans59ae2762012-04-16 17:52:27 -0700825dnl Enable VM deallocation via munmap() by default.
826AC_ARG_ENABLE([munmap],
827 [AS_HELP_STRING([--disable-munmap], [Disable VM deallocation via munmap(2)])],
828[if test "x$enable_munmap" = "xno" ; then
829 enable_munmap="0"
830else
831 enable_munmap="1"
832fi
833],
834[enable_munmap="${default_munmap}"]
835)
836if test "x$enable_munmap" = "x1" ; then
837 AC_DEFINE([JEMALLOC_MUNMAP], [ ])
838fi
839AC_SUBST([enable_munmap])
840
Jason Evansb7924f52009-06-23 19:01:18 -0700841dnl Do not enable allocation from DSS by default.
842AC_ARG_ENABLE([dss],
843 [AS_HELP_STRING([--enable-dss], [Enable allocation from DSS])],
844[if test "x$enable_dss" = "xno" ; then
845 enable_dss="0"
846else
847 enable_dss="1"
848fi
849],
850[enable_dss="0"]
851)
Mike Hommey83c324a2012-04-12 10:13:03 +0200852dnl Check whether the BSD/SUSv1 sbrk() exists. If not, disable DSS support.
853AC_CHECK_FUNC([sbrk], [have_sbrk="1"], [have_sbrk="0"])
854if test "x$have_sbrk" = "x1" ; then
Jason Evans66688532013-12-03 21:49:36 -0800855 if test "x$sbrk_deprecated" == "x1" ; then
856 AC_MSG_RESULT([Disabling dss allocation because sbrk is deprecated])
857 enable_dss="0"
858 else
859 AC_DEFINE([JEMALLOC_HAVE_SBRK], [ ])
860 fi
Mike Hommey83c324a2012-04-12 10:13:03 +0200861else
862 enable_dss="0"
863fi
864
Jason Evansb7924f52009-06-23 19:01:18 -0700865if test "x$enable_dss" = "x1" ; then
866 AC_DEFINE([JEMALLOC_DSS], [ ])
867fi
868AC_SUBST([enable_dss])
869
Jason Evans777c1912012-02-28 20:49:22 -0800870dnl Support the junk/zero filling option by default.
Jason Evansb7924f52009-06-23 19:01:18 -0700871AC_ARG_ENABLE([fill],
Jason Evans122449b2012-04-06 00:35:09 -0700872 [AS_HELP_STRING([--disable-fill],
873 [Disable support for junk/zero filling, quarantine, and redzones])],
Jason Evansb7924f52009-06-23 19:01:18 -0700874[if test "x$enable_fill" = "xno" ; then
875 enable_fill="0"
876else
877 enable_fill="1"
878fi
879],
Jason Evans777c1912012-02-28 20:49:22 -0800880[enable_fill="1"]
Jason Evansb7924f52009-06-23 19:01:18 -0700881)
882if test "x$enable_fill" = "x1" ; then
883 AC_DEFINE([JEMALLOC_FILL], [ ])
884fi
885AC_SUBST([enable_fill])
886
Jason Evansb1476112012-04-05 13:36:17 -0700887dnl Disable utrace(2)-based tracing by default.
888AC_ARG_ENABLE([utrace],
889 [AS_HELP_STRING([--enable-utrace], [Enable utrace(2)-based tracing])],
890[if test "x$enable_utrace" = "xno" ; then
891 enable_utrace="0"
892else
893 enable_utrace="1"
894fi
895],
896[enable_utrace="0"]
897)
898JE_COMPILABLE([utrace(2)], [
899#include <sys/types.h>
900#include <sys/param.h>
901#include <sys/time.h>
902#include <sys/uio.h>
903#include <sys/ktrace.h>
904], [
905 utrace((void *)0, 0);
906], [je_cv_utrace])
907if test "x${je_cv_utrace}" = "xno" ; then
908 enable_utrace="0"
909fi
910if test "x$enable_utrace" = "x1" ; then
911 AC_DEFINE([JEMALLOC_UTRACE], [ ])
912fi
913AC_SUBST([enable_utrace])
914
Jason Evans122449b2012-04-06 00:35:09 -0700915dnl Support Valgrind by default.
916AC_ARG_ENABLE([valgrind],
917 [AS_HELP_STRING([--disable-valgrind], [Disable support for Valgrind])],
918[if test "x$enable_valgrind" = "xno" ; then
919 enable_valgrind="0"
920else
921 enable_valgrind="1"
922fi
923],
924[enable_valgrind="1"]
925)
926if test "x$enable_valgrind" = "x1" ; then
927 JE_COMPILABLE([valgrind], [
928#include <valgrind/valgrind.h>
929#include <valgrind/memcheck.h>
930
Mike Hommey7bfecf42012-04-30 15:15:15 +0200931#if !defined(VALGRIND_RESIZEINPLACE_BLOCK)
Jason Evans122449b2012-04-06 00:35:09 -0700932# error "Incompatible Valgrind version"
933#endif
934], [], [je_cv_valgrind])
935 if test "x${je_cv_valgrind}" = "xno" ; then
936 enable_valgrind="0"
937 fi
938 if test "x$enable_valgrind" = "x1" ; then
939 AC_DEFINE([JEMALLOC_VALGRIND], [ ])
940 fi
941fi
942AC_SUBST([enable_valgrind])
943
Jason Evansb7924f52009-06-23 19:01:18 -0700944dnl Do not support the xmalloc option by default.
945AC_ARG_ENABLE([xmalloc],
946 [AS_HELP_STRING([--enable-xmalloc], [Support xmalloc option])],
947[if test "x$enable_xmalloc" = "xno" ; then
948 enable_xmalloc="0"
949else
950 enable_xmalloc="1"
951fi
952],
953[enable_xmalloc="0"]
954)
955if test "x$enable_xmalloc" = "x1" ; then
956 AC_DEFINE([JEMALLOC_XMALLOC], [ ])
957fi
958AC_SUBST([enable_xmalloc])
959
Jason Evans6684cac2012-03-05 12:15:36 -0800960AC_CACHE_CHECK([STATIC_PAGE_SHIFT],
961 [je_cv_static_page_shift],
962 AC_RUN_IFELSE([AC_LANG_PROGRAM(
Mike Hommeya19e87f2012-04-21 21:27:46 -0700963[[
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200964#include <strings.h>
Mike Hommeya19e87f2012-04-21 21:27:46 -0700965#ifdef _WIN32
966#include <windows.h>
967#else
Jason Evansb7924f52009-06-23 19:01:18 -0700968#include <unistd.h>
Mike Hommeya19e87f2012-04-21 21:27:46 -0700969#endif
970#include <stdio.h>
Jason Evans6684cac2012-03-05 12:15:36 -0800971]],
972[[
Garrett Cooper72c1e592012-12-02 17:57:28 -0800973 int result;
Jason Evansb7924f52009-06-23 19:01:18 -0700974 FILE *f;
975
Mike Hommeya19e87f2012-04-21 21:27:46 -0700976#ifdef _WIN32
977 SYSTEM_INFO si;
978 GetSystemInfo(&si);
979 result = si.dwPageSize;
980#else
Jason Evansb7924f52009-06-23 19:01:18 -0700981 result = sysconf(_SC_PAGESIZE);
Mike Hommeya19e87f2012-04-21 21:27:46 -0700982#endif
Jason Evansb7924f52009-06-23 19:01:18 -0700983 if (result == -1) {
984 return 1;
985 }
Mike Hommeya19e87f2012-04-21 21:27:46 -0700986 result = ffsl(result) - 1;
987
Jason Evansb7924f52009-06-23 19:01:18 -0700988 f = fopen("conftest.out", "w");
989 if (f == NULL) {
990 return 1;
991 }
Garrett Cooper72c1e592012-12-02 17:57:28 -0800992 fprintf(f, "%d\n", result);
Jason Evans3cc1f1a2012-04-03 22:30:05 -0700993 fclose(f);
Jason Evansb7924f52009-06-23 19:01:18 -0700994
995 return 0;
996]])],
Jason Evans6684cac2012-03-05 12:15:36 -0800997 [je_cv_static_page_shift=`cat conftest.out`],
998 [je_cv_static_page_shift=undefined]))
999
1000if test "x$je_cv_static_page_shift" != "xundefined"; then
1001 AC_DEFINE_UNQUOTED([STATIC_PAGE_SHIFT], [$je_cv_static_page_shift])
1002else
1003 AC_MSG_ERROR([cannot determine value for STATIC_PAGE_SHIFT])
1004fi
Jason Evansb7924f52009-06-23 19:01:18 -07001005
1006dnl ============================================================================
1007dnl jemalloc configuration.
1008dnl
Jason Evansa40bc7a2010-03-02 13:01:16 -08001009
1010dnl Set VERSION if source directory has an embedded git repository.
Jason Evans955851f2011-03-31 22:38:51 -07001011if test -d "${srcroot}.git" ; then
Jason Evans79d660d2010-09-17 17:38:24 -07001012 git describe --long --abbrev=40 > ${srcroot}VERSION
Jason Evansa40bc7a2010-03-02 13:01:16 -08001013fi
Jason Evansb7924f52009-06-23 19:01:18 -07001014jemalloc_version=`cat ${srcroot}VERSION`
Jason Evansa40bc7a2010-03-02 13:01:16 -08001015jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'`
1016jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'`
1017jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'`
1018jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'`
1019jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'`
Jason Evansb7924f52009-06-23 19:01:18 -07001020AC_SUBST([jemalloc_version])
Jason Evansa40bc7a2010-03-02 13:01:16 -08001021AC_SUBST([jemalloc_version_major])
1022AC_SUBST([jemalloc_version_minor])
1023AC_SUBST([jemalloc_version_bugfix])
1024AC_SUBST([jemalloc_version_nrev])
1025AC_SUBST([jemalloc_version_gid])
Jason Evansb7924f52009-06-23 19:01:18 -07001026
1027dnl ============================================================================
1028dnl Configure pthreads.
1029
Mike Hommeya19e87f2012-04-21 21:27:46 -07001030if test "x$abi" != "xpecoff" ; then
1031 AC_CHECK_HEADERS([pthread.h], , [AC_MSG_ERROR([pthread.h is missing])])
1032 dnl Some systems may embed pthreads functionality in libc; check for libpthread
1033 dnl first, but try libc too before failing.
1034 AC_CHECK_LIB([pthread], [pthread_create], [LIBS="$LIBS -lpthread"],
1035 [AC_SEARCH_LIBS([pthread_create], , ,
1036 AC_MSG_ERROR([libpthread is missing]))])
1037fi
Jason Evansb7924f52009-06-23 19:01:18 -07001038
1039CPPFLAGS="$CPPFLAGS -D_REENTRANT"
1040
Jason Evanscd9a1342012-03-21 18:33:03 -07001041dnl Check whether the BSD-specific _malloc_thread_cleanup() exists. If so, use
1042dnl it rather than pthreads TSD cleanup functions to support cleanup during
1043dnl thread exit, in order to avoid pthreads library recursion during
1044dnl bootstrapping.
Jason Evanscd9a1342012-03-21 18:33:03 -07001045AC_CHECK_FUNC([_malloc_thread_cleanup],
1046 [have__malloc_thread_cleanup="1"],
1047 [have__malloc_thread_cleanup="0"]
1048 )
1049if test "x$have__malloc_thread_cleanup" = "x1" ; then
1050 AC_DEFINE([JEMALLOC_MALLOC_THREAD_CLEANUP], [ ])
1051 force_tls="1"
1052fi
1053
Jason Evans41b6afb2012-02-02 22:04:57 -08001054dnl Check whether the BSD-specific _pthread_mutex_init_calloc_cb() exists. If
1055dnl so, mutex initialization causes allocation, and we need to implement this
1056dnl callback function in order to prevent recursive allocation.
1057AC_CHECK_FUNC([_pthread_mutex_init_calloc_cb],
1058 [have__pthread_mutex_init_calloc_cb="1"],
1059 [have__pthread_mutex_init_calloc_cb="0"]
1060 )
1061if test "x$have__pthread_mutex_init_calloc_cb" = "x1" ; then
1062 AC_DEFINE([JEMALLOC_MUTEX_INIT_CB])
1063fi
1064
Jason Evans0fee70d2012-02-13 12:36:11 -08001065dnl Disable lazy locking by default.
Jason Evansb7924f52009-06-23 19:01:18 -07001066AC_ARG_ENABLE([lazy_lock],
Jason Evans0fee70d2012-02-13 12:36:11 -08001067 [AS_HELP_STRING([--enable-lazy-lock],
1068 [Enable lazy locking (only lock when multi-threaded)])],
Jason Evansb7924f52009-06-23 19:01:18 -07001069[if test "x$enable_lazy_lock" = "xno" ; then
1070 enable_lazy_lock="0"
1071else
1072 enable_lazy_lock="1"
1073fi
1074],
Jason Evans0fee70d2012-02-13 12:36:11 -08001075[enable_lazy_lock="0"]
Jason Evansb7924f52009-06-23 19:01:18 -07001076)
Jason Evansfd4fcef2012-03-23 17:40:58 -07001077if test "x$enable_lazy_lock" = "x0" -a "x${force_lazy_lock}" = "x1" ; then
1078 AC_MSG_RESULT([Forcing lazy-lock to avoid allocator/threading bootstrap issues])
1079 enable_lazy_lock="1"
1080fi
Jason Evansb7924f52009-06-23 19:01:18 -07001081if test "x$enable_lazy_lock" = "x1" ; then
Mike Hommeya19e87f2012-04-21 21:27:46 -07001082 if test "x$abi" != "xpecoff" ; then
1083 AC_CHECK_HEADERS([dlfcn.h], , [AC_MSG_ERROR([dlfcn.h is missing])])
1084 AC_CHECK_FUNC([dlsym], [],
1085 [AC_CHECK_LIB([dl], [dlsym], [LIBS="$LIBS -ldl"],
1086 [AC_MSG_ERROR([libdl is missing])])
1087 ])
1088 fi
Jason Evansb7924f52009-06-23 19:01:18 -07001089 AC_DEFINE([JEMALLOC_LAZY_LOCK], [ ])
1090fi
1091AC_SUBST([enable_lazy_lock])
1092
Jason Evans78d815c2010-01-17 14:06:20 -08001093AC_ARG_ENABLE([tls],
1094 [AS_HELP_STRING([--disable-tls], [Disable thread-local storage (__thread keyword)])],
1095if test "x$enable_tls" = "xno" ; then
1096 enable_tls="0"
1097else
1098 enable_tls="1"
1099fi
1100,
1101enable_tls="1"
1102)
Jason Evanscd9a1342012-03-21 18:33:03 -07001103if test "x${enable_tls}" = "x0" -a "x${force_tls}" = "x1" ; then
1104 AC_MSG_RESULT([Forcing TLS to avoid allocator/threading bootstrap issues])
1105 enable_tls="1"
1106fi
Jason Evansb80581d2012-03-23 16:17:43 -07001107if test "x${enable_tls}" = "x1" -a "x${force_tls}" = "x0" ; then
1108 AC_MSG_RESULT([Forcing no TLS to avoid allocator/threading bootstrap issues])
1109 enable_tls="0"
1110fi
Jason Evans78d815c2010-01-17 14:06:20 -08001111if test "x${enable_tls}" = "x1" ; then
1112AC_MSG_CHECKING([for TLS])
Jason Evans6684cac2012-03-05 12:15:36 -08001113AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Jason Evans78d815c2010-01-17 14:06:20 -08001114[[
1115 __thread int x;
1116]], [[
1117 x = 42;
1118
1119 return 0;
1120]])],
1121 AC_MSG_RESULT([yes]),
1122 AC_MSG_RESULT([no])
1123 enable_tls="0")
1124fi
Jason Evansb267d0f2010-08-13 15:42:29 -07001125AC_SUBST([enable_tls])
Jason Evanse24c7af2012-03-19 10:21:17 -07001126if test "x${enable_tls}" = "x1" ; then
1127 AC_DEFINE_UNQUOTED([JEMALLOC_TLS], [ ])
Jason Evanscd9a1342012-03-21 18:33:03 -07001128elif test "x${force_tls}" = "x1" ; then
1129 AC_MSG_ERROR([Failed to configure TLS, which is mandatory for correct function])
Jason Evans78d815c2010-01-17 14:06:20 -08001130fi
1131
Jason Evans2dbecf12010-09-05 10:35:13 -07001132dnl ============================================================================
Jason Evans84c8eef2011-03-16 10:30:13 -07001133dnl Check for ffsl(3), and fail if not found. This function exists on all
1134dnl platforms that jemalloc currently has a chance of functioning on without
1135dnl modification.
Jason Evans4c2faa82012-03-13 11:09:23 -07001136JE_COMPILABLE([a program using ffsl], [
Garrett Cooper72c1e592012-12-02 17:57:28 -08001137#include <stdio.h>
Jason Evans382132e2012-04-04 15:25:43 -07001138#include <strings.h>
Jason Evans4c2faa82012-03-13 11:09:23 -07001139#include <string.h>
1140], [
1141 {
1142 int rv = ffsl(0x08);
Garrett Cooper72c1e592012-12-02 17:57:28 -08001143 printf("%d\n", rv);
Jason Evans4c2faa82012-03-13 11:09:23 -07001144 }
1145], [je_cv_function_ffsl])
Jason Evans6684cac2012-03-05 12:15:36 -08001146if test "x${je_cv_function_ffsl}" != "xyes" ; then
1147 AC_MSG_ERROR([Cannot build without ffsl(3)])
1148fi
Jason Evans84c8eef2011-03-16 10:30:13 -07001149
1150dnl ============================================================================
Jason Evansb57d3ec2012-04-17 13:17:54 -07001151dnl Check for atomic(9) operations as provided on FreeBSD.
1152
1153JE_COMPILABLE([atomic(9)], [
1154#include <sys/types.h>
1155#include <machine/atomic.h>
1156#include <inttypes.h>
1157], [
1158 {
1159 uint32_t x32 = 0;
1160 volatile uint32_t *x32p = &x32;
1161 atomic_fetchadd_32(x32p, 1);
1162 }
1163 {
1164 unsigned long xlong = 0;
1165 volatile unsigned long *xlongp = &xlong;
1166 atomic_fetchadd_long(xlongp, 1);
1167 }
1168], [je_cv_atomic9])
1169if test "x${je_cv_atomic9}" = "xyes" ; then
1170 AC_DEFINE([JEMALLOC_ATOMIC9])
1171fi
1172
1173dnl ============================================================================
Jason Evans763baa62011-03-18 19:10:31 -07001174dnl Check for atomic(3) operations as provided on Darwin.
1175
1176JE_COMPILABLE([Darwin OSAtomic*()], [
1177#include <libkern/OSAtomic.h>
1178#include <inttypes.h>
1179], [
1180 {
1181 int32_t x32 = 0;
1182 volatile int32_t *x32p = &x32;
1183 OSAtomicAdd32(1, x32p);
1184 }
1185 {
1186 int64_t x64 = 0;
1187 volatile int64_t *x64p = &x64;
1188 OSAtomicAdd64(1, x64p);
1189 }
Jason Evans6684cac2012-03-05 12:15:36 -08001190], [je_cv_osatomic])
1191if test "x${je_cv_osatomic}" = "xyes" ; then
Jason Evanse24c7af2012-03-19 10:21:17 -07001192 AC_DEFINE([JEMALLOC_OSATOMIC], [ ])
Jason Evans763baa62011-03-18 19:10:31 -07001193fi
1194
1195dnl ============================================================================
Mike Hommeyc1e567b2012-03-26 17:03:41 +02001196dnl Check whether __sync_{add,sub}_and_fetch() are available despite
1197dnl __GCC_HAVE_SYNC_COMPARE_AND_SWAP_n macros being undefined.
1198
1199AC_DEFUN([JE_SYNC_COMPARE_AND_SWAP_CHECK],[
1200 AC_CACHE_CHECK([whether to force $1-bit __sync_{add,sub}_and_fetch()],
1201 [je_cv_sync_compare_and_swap_$2],
Mike Hommey2cfe6d62012-03-27 15:03:07 +02001202 [AC_LINK_IFELSE([AC_LANG_PROGRAM([
1203 #include <stdint.h>
1204 ],
1205 [
1206 #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2
1207 {
1208 uint$1_t x$1 = 0;
1209 __sync_add_and_fetch(&x$1, 42);
1210 __sync_sub_and_fetch(&x$1, 1);
1211 }
1212 #else
1213 #error __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2 is defined, no need to force
1214 #endif
1215 ])],
Mike Hommeyc1e567b2012-03-26 17:03:41 +02001216 [je_cv_sync_compare_and_swap_$2=yes],
1217 [je_cv_sync_compare_and_swap_$2=no])])
1218
1219 if test "x${je_cv_sync_compare_and_swap_$2}" = "xyes" ; then
1220 AC_DEFINE([JE_FORCE_SYNC_COMPARE_AND_SWAP_$2], [ ])
1221 fi
1222])
1223
Jason Evansb57d3ec2012-04-17 13:17:54 -07001224if test "x${je_cv_atomic9}" != "xyes" -a "x${je_cv_osatomic}" != "xyes" ; then
Mike Hommeyc1e567b2012-03-26 17:03:41 +02001225 JE_SYNC_COMPARE_AND_SWAP_CHECK(32, 4)
1226 JE_SYNC_COMPARE_AND_SWAP_CHECK(64, 8)
1227fi
1228
1229dnl ============================================================================
Jason Evans893a0ed2011-03-18 19:30:18 -07001230dnl Check for spinlock(3) operations as provided on Darwin.
1231
1232JE_COMPILABLE([Darwin OSSpin*()], [
1233#include <libkern/OSAtomic.h>
1234#include <inttypes.h>
1235], [
1236 OSSpinLock lock = 0;
1237 OSSpinLockLock(&lock);
1238 OSSpinLockUnlock(&lock);
Jason Evans6684cac2012-03-05 12:15:36 -08001239], [je_cv_osspin])
1240if test "x${je_cv_osspin}" = "xyes" ; then
Jason Evanse24c7af2012-03-19 10:21:17 -07001241 AC_DEFINE([JEMALLOC_OSSPIN], [ ])
Jason Evans893a0ed2011-03-18 19:30:18 -07001242fi
1243
1244dnl ============================================================================
Jason Evans2dbecf12010-09-05 10:35:13 -07001245dnl Darwin-related configuration.
Jason Evans78d815c2010-01-17 14:06:20 -08001246
Mike Hommeyd0357f72012-11-26 18:52:41 +01001247AC_ARG_ENABLE([zone-allocator],
1248 [AS_HELP_STRING([--disable-zone-allocator],
1249 [Disable zone allocator for Darwin])],
1250[if test "x$enable_zone_allocator" = "xno" ; then
1251 enable_zone_allocator="0"
1252else
1253 enable_zone_allocator="1"
1254fi
1255],
1256[if test "x${abi}" = "xmacho"; then
1257 enable_zone_allocator="1"
1258fi
1259]
1260)
1261AC_SUBST([enable_zone_allocator])
1262
1263if test "x${enable_zone_allocator}" = "x1" ; then
1264 if test "x${abi}" != "xmacho"; then
1265 AC_MSG_ERROR([--enable-zone-allocator is only supported on Darwin])
1266 fi
Jason Evanse24c7af2012-03-19 10:21:17 -07001267 AC_DEFINE([JEMALLOC_IVSALLOC], [ ])
1268 AC_DEFINE([JEMALLOC_ZONE], [ ])
Jason Evans6109fe02010-02-10 10:37:56 -08001269
Jason Evans2dbecf12010-09-05 10:35:13 -07001270 dnl The szone version jumped from 3 to 6 between the OS X 10.5.x and 10.6
1271 dnl releases. malloc_zone_t and malloc_introspection_t have new fields in
1272 dnl 10.6, which is the only source-level indication of the change.
1273 AC_MSG_CHECKING([malloc zone version])
Mike Hommey154829d2012-03-20 18:01:38 +01001274 AC_DEFUN([JE_ZONE_PROGRAM],
1275 [AC_LANG_PROGRAM(
1276 [#include <malloc/malloc.h>],
1277 [static foo[[sizeof($1) $2 sizeof(void *) * $3 ? 1 : -1]]]
1278 )])
Jason Evans2dbecf12010-09-05 10:35:13 -07001279
Mike Hommey154829d2012-03-20 18:01:38 +01001280 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,14)],[JEMALLOC_ZONE_VERSION=3],[
1281 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,15)],[JEMALLOC_ZONE_VERSION=5],[
1282 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,16)],[
1283 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,9)],[JEMALLOC_ZONE_VERSION=6],[
1284 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,13)],[JEMALLOC_ZONE_VERSION=7],[JEMALLOC_ZONE_VERSION=]
1285 )])],[
1286 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,17)],[JEMALLOC_ZONE_VERSION=8],[
1287 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,>,17)],[JEMALLOC_ZONE_VERSION=9],[JEMALLOC_ZONE_VERSION=]
1288 )])])])])
1289 if test "x${JEMALLOC_ZONE_VERSION}" = "x"; then
1290 AC_MSG_RESULT([unsupported])
1291 AC_MSG_ERROR([Unsupported malloc zone version])
1292 fi
1293 if test "${JEMALLOC_ZONE_VERSION}" = 9; then
1294 JEMALLOC_ZONE_VERSION=8
1295 AC_MSG_RESULT([> 8])
1296 else
1297 AC_MSG_RESULT([$JEMALLOC_ZONE_VERSION])
1298 fi
1299 AC_DEFINE_UNQUOTED(JEMALLOC_ZONE_VERSION, [$JEMALLOC_ZONE_VERSION])
Jason Evansb27805b2010-02-10 18:15:53 -08001300fi
1301
Jason Evansb7924f52009-06-23 19:01:18 -07001302dnl ============================================================================
1303dnl Check for typedefs, structures, and compiler characteristics.
1304AC_HEADER_STDBOOL
1305
Jason Evans86abd0d2013-11-30 15:25:42 -08001306AC_CONFIG_COMMANDS([include/jemalloc/internal/private_namespace.h], [
1307 mkdir -p "${objroot}include/jemalloc/internal"
1308 "${srcdir}/include/jemalloc/internal/private_namespace.sh" "${srcdir}/include/jemalloc/internal/private_symbols.txt" > "${objroot}include/jemalloc/internal/private_namespace.h"
1309])
1310AC_CONFIG_COMMANDS([include/jemalloc/internal/private_unnamespace.h], [
1311 mkdir -p "${objroot}include/jemalloc/internal"
1312 "${srcdir}/include/jemalloc/internal/private_unnamespace.sh" "${srcdir}/include/jemalloc/internal/private_symbols.txt" > "${objroot}include/jemalloc/internal/private_unnamespace.h"
1313])
1314AC_CONFIG_COMMANDS([include/jemalloc/internal/public_namespace.h], [
1315 mkdir -p "${objroot}include/jemalloc/internal"
1316 "${srcdir}/include/jemalloc/internal/public_namespace.sh" "${srcdir}/include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/internal/public_namespace.h"
1317])
1318AC_CONFIG_COMMANDS([include/jemalloc/internal/public_unnamespace.h], [
1319 mkdir -p "${objroot}include/jemalloc/internal"
1320 "${srcdir}/include/jemalloc/internal/public_unnamespace.sh" "${srcdir}/include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/internal/public_unnamespace.h"
1321])
Jason Evansb1726102012-02-28 16:50:47 -08001322AC_CONFIG_COMMANDS([include/jemalloc/internal/size_classes.h], [
Jason Evans86abd0d2013-11-30 15:25:42 -08001323 mkdir -p "${objroot}include/jemalloc/internal"
Jason Evansb1726102012-02-28 16:50:47 -08001324 "${srcdir}/include/jemalloc/internal/size_classes.sh" > "${objroot}include/jemalloc/internal/size_classes.h"
1325])
Jason Evans86abd0d2013-11-30 15:25:42 -08001326AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_protos_jet.h], [
1327 mkdir -p "${objroot}include/jemalloc"
1328 cat "${srcdir}/include/jemalloc/jemalloc_protos.h.in" | sed -e 's/@je_@/jet_/g' > "${objroot}include/jemalloc/jemalloc_protos_jet.h"
1329])
1330AC_CONFIG_COMMANDS([include/jemalloc/jemalloc.h], [
1331 mkdir -p "${objroot}include/jemalloc"
1332 "${srcdir}/include/jemalloc/jemalloc.sh" "${objroot}" > "${objroot}include/jemalloc/jemalloc${install_suffix}.h"
1333])
Jason Evansb1726102012-02-28 16:50:47 -08001334
Jason Evansb7924f52009-06-23 19:01:18 -07001335dnl Process .in files.
Jason Evansb0fd5012010-01-17 01:49:20 -08001336AC_SUBST([cfghdrs_in])
1337AC_SUBST([cfghdrs_out])
Jason Evans0656ec02010-04-07 23:37:35 -07001338AC_CONFIG_HEADERS([$cfghdrs_tup])
Jason Evansb7924f52009-06-23 19:01:18 -07001339
1340dnl ============================================================================
1341dnl Generate outputs.
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +04001342AC_CONFIG_FILES([$cfgoutputs_tup config.stamp bin/jemalloc.sh])
Jason Evansb0fd5012010-01-17 01:49:20 -08001343AC_SUBST([cfgoutputs_in])
1344AC_SUBST([cfgoutputs_out])
Jason Evansb7924f52009-06-23 19:01:18 -07001345AC_OUTPUT
1346
1347dnl ============================================================================
1348dnl Print out the results of configuration.
1349AC_MSG_RESULT([===============================================================================])
Jason Evansf576c632011-11-01 22:27:41 -07001350AC_MSG_RESULT([jemalloc version : ${jemalloc_version}])
1351AC_MSG_RESULT([library revision : ${rev}])
Jason Evansb7924f52009-06-23 19:01:18 -07001352AC_MSG_RESULT([])
1353AC_MSG_RESULT([CC : ${CC}])
1354AC_MSG_RESULT([CPPFLAGS : ${CPPFLAGS}])
1355AC_MSG_RESULT([CFLAGS : ${CFLAGS}])
1356AC_MSG_RESULT([LDFLAGS : ${LDFLAGS}])
1357AC_MSG_RESULT([LIBS : ${LIBS}])
1358AC_MSG_RESULT([RPATH_EXTRA : ${RPATH_EXTRA}])
1359AC_MSG_RESULT([])
Jason Evansaee7fd22010-11-24 22:00:02 -08001360AC_MSG_RESULT([XSLTPROC : ${XSLTPROC}])
1361AC_MSG_RESULT([XSLROOT : ${XSLROOT}])
1362AC_MSG_RESULT([])
Jason Evansb7924f52009-06-23 19:01:18 -07001363AC_MSG_RESULT([PREFIX : ${PREFIX}])
1364AC_MSG_RESULT([BINDIR : ${BINDIR}])
Jason Evans662a0172009-07-01 19:24:31 -07001365AC_MSG_RESULT([INCLUDEDIR : ${INCLUDEDIR}])
1366AC_MSG_RESULT([LIBDIR : ${LIBDIR}])
Jason Evansb7924f52009-06-23 19:01:18 -07001367AC_MSG_RESULT([DATADIR : ${DATADIR}])
1368AC_MSG_RESULT([MANDIR : ${MANDIR}])
1369AC_MSG_RESULT([])
1370AC_MSG_RESULT([srcroot : ${srcroot}])
1371AC_MSG_RESULT([abs_srcroot : ${abs_srcroot}])
1372AC_MSG_RESULT([objroot : ${objroot}])
1373AC_MSG_RESULT([abs_objroot : ${abs_objroot}])
1374AC_MSG_RESULT([])
Jason Evans90895cf2009-12-29 00:09:15 -08001375AC_MSG_RESULT([JEMALLOC_PREFIX : ${JEMALLOC_PREFIX}])
Jason Evans746e77a2011-07-30 16:40:52 -07001376AC_MSG_RESULT([JEMALLOC_PRIVATE_NAMESPACE])
1377AC_MSG_RESULT([ : ${JEMALLOC_PRIVATE_NAMESPACE}])
Jason Evansb0fd5012010-01-17 01:49:20 -08001378AC_MSG_RESULT([install_suffix : ${install_suffix}])
Jason Evansb7924f52009-06-23 19:01:18 -07001379AC_MSG_RESULT([autogen : ${enable_autogen}])
Jason Evans7e77eaf2012-03-02 17:47:37 -08001380AC_MSG_RESULT([experimental : ${enable_experimental}])
Jason Evans355b4382010-09-20 19:20:48 -07001381AC_MSG_RESULT([cc-silence : ${enable_cc_silence}])
Jason Evansb7924f52009-06-23 19:01:18 -07001382AC_MSG_RESULT([debug : ${enable_debug}])
1383AC_MSG_RESULT([stats : ${enable_stats}])
Jason Evans6109fe02010-02-10 10:37:56 -08001384AC_MSG_RESULT([prof : ${enable_prof}])
1385AC_MSG_RESULT([prof-libunwind : ${enable_prof_libunwind}])
Jason Evans77f350b2011-03-15 22:23:12 -07001386AC_MSG_RESULT([prof-libgcc : ${enable_prof_libgcc}])
1387AC_MSG_RESULT([prof-gcc : ${enable_prof_gcc}])
Jason Evans84cbbcb2009-12-29 00:09:15 -08001388AC_MSG_RESULT([tcache : ${enable_tcache}])
Jason Evansb7924f52009-06-23 19:01:18 -07001389AC_MSG_RESULT([fill : ${enable_fill}])
Jason Evansb1476112012-04-05 13:36:17 -07001390AC_MSG_RESULT([utrace : ${enable_utrace}])
Jason Evans122449b2012-04-06 00:35:09 -07001391AC_MSG_RESULT([valgrind : ${enable_valgrind}])
1392AC_MSG_RESULT([xmalloc : ${enable_xmalloc}])
Jason Evans2e671ff2012-05-09 16:12:00 -07001393AC_MSG_RESULT([mremap : ${enable_mremap}])
Jason Evans59ae2762012-04-16 17:52:27 -07001394AC_MSG_RESULT([munmap : ${enable_munmap}])
Jason Evansb7924f52009-06-23 19:01:18 -07001395AC_MSG_RESULT([dss : ${enable_dss}])
Jason Evansb7924f52009-06-23 19:01:18 -07001396AC_MSG_RESULT([lazy_lock : ${enable_lazy_lock}])
Jason Evans2dbecf12010-09-05 10:35:13 -07001397AC_MSG_RESULT([tls : ${enable_tls}])
Jason Evansb7924f52009-06-23 19:01:18 -07001398AC_MSG_RESULT([===============================================================================])