blob: 570a7f562a00a214284a3f2c504ac7f620ff6339 [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
359if test "x$abi" != "xpecoff"; then
360 dnl Heap profiling uses the log(3) function.
361 LIBS="$LIBS -lm"
362fi
Jason Evansb7924f52009-06-23 19:01:18 -0700363
Jason Evansfa5d2452011-03-15 10:25:59 -0700364JE_COMPILABLE([__attribute__ syntax],
365 [static __attribute__((unused)) void foo(void){}],
366 [],
Jason Evans6684cac2012-03-05 12:15:36 -0800367 [je_cv_attribute])
368if test "x${je_cv_attribute}" = "xyes" ; then
Jason Evansfa5d2452011-03-15 10:25:59 -0700369 AC_DEFINE([JEMALLOC_HAVE_ATTR], [ ])
370 if test "x${GCC}" = "xyes" -a "x${abi}" = "xelf"; then
371 JE_CFLAGS_APPEND([-fvisibility=hidden])
372 fi
373fi
Jason Evans3cc1f1a2012-04-03 22:30:05 -0700374dnl Check for tls_model attribute support (clang 3.0 still lacks support).
375SAVED_CFLAGS="${CFLAGS}"
376JE_CFLAGS_APPEND([-Werror])
377JE_COMPILABLE([tls_model attribute], [],
378 [static __thread int
379 __attribute__((tls_model("initial-exec"))) foo;
380 foo = 0;],
381 [je_cv_tls_model])
382CFLAGS="${SAVED_CFLAGS}"
383if test "x${je_cv_tls_model}" = "xyes" ; then
384 AC_DEFINE([JEMALLOC_TLS_MODEL],
385 [__attribute__((tls_model("initial-exec")))])
386else
387 AC_DEFINE([JEMALLOC_TLS_MODEL], [ ])
388fi
Jason Evansfa5d2452011-03-15 10:25:59 -0700389
Jason Evansb7924f52009-06-23 19:01:18 -0700390dnl Support optional additions to rpath.
391AC_ARG_WITH([rpath],
Jason Evans90895cf2009-12-29 00:09:15 -0800392 [AS_HELP_STRING([--with-rpath=<rpath>], [Colon-separated rpath (ELF systems only)])],
Jason Evansb7924f52009-06-23 19:01:18 -0700393if test "x$with_rpath" = "xno" ; then
394 RPATH_EXTRA=
395else
396 RPATH_EXTRA="`echo $with_rpath | tr \":\" \" \"`"
397fi,
398 RPATH_EXTRA=
399)
400AC_SUBST([RPATH_EXTRA])
401
402dnl Disable rules that do automatic regeneration of configure output by default.
403AC_ARG_ENABLE([autogen],
Jason Evans78d815c2010-01-17 14:06:20 -0800404 [AS_HELP_STRING([--enable-autogen], [Automatically regenerate configure output])],
Jason Evansb7924f52009-06-23 19:01:18 -0700405if test "x$enable_autogen" = "xno" ; then
406 enable_autogen="0"
407else
408 enable_autogen="1"
409fi
410,
411enable_autogen="0"
412)
413AC_SUBST([enable_autogen])
414
415AC_PROG_INSTALL
416AC_PROG_RANLIB
Jason Evans7329a4f2013-01-22 10:53:29 -0800417AC_PATH_PROG([LD], [ld], [false], [$PATH])
418AC_PATH_PROG([AUTOCONF], [autoconf], [false], [$PATH])
Jason Evansb7924f52009-06-23 19:01:18 -0700419
Jason Evans0a0bbf62012-03-13 12:55:21 -0700420public_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 -0800421
422dnl Check for allocator-related functions that should be wrapped.
423AC_CHECK_FUNC([memalign],
Jason Evanse24c7af2012-03-19 10:21:17 -0700424 [AC_DEFINE([JEMALLOC_OVERRIDE_MEMALIGN], [ ])
Jason Evans7e77eaf2012-03-02 17:47:37 -0800425 public_syms="${public_syms} memalign"])
426AC_CHECK_FUNC([valloc],
Jason Evanse24c7af2012-03-19 10:21:17 -0700427 [AC_DEFINE([JEMALLOC_OVERRIDE_VALLOC], [ ])
Jason Evans7e77eaf2012-03-02 17:47:37 -0800428 public_syms="${public_syms} valloc"])
429
430dnl Support the experimental API by default.
431AC_ARG_ENABLE([experimental],
432 [AS_HELP_STRING([--disable-experimental],
433 [Disable support for the experimental API])],
434[if test "x$enable_experimental" = "xno" ; then
435 enable_experimental="0"
436else
437 enable_experimental="1"
438fi
439],
440[enable_experimental="1"]
441)
442if test "x$enable_experimental" = "x1" ; then
443 AC_DEFINE([JEMALLOC_EXPERIMENTAL], [ ])
444 public_syms="${public_syms} allocm dallocm nallocm rallocm sallocm"
445fi
446AC_SUBST([enable_experimental])
447
Jason Evans0a5489e2012-03-01 17:19:20 -0800448dnl Perform no name mangling by default.
449AC_ARG_WITH([mangling],
450 [AS_HELP_STRING([--with-mangling=<map>], [Mangle symbols in <map>])],
451 [mangling_map="$with_mangling"], [mangling_map=""])
452for nm in `echo ${mangling_map} |tr ',' ' '` ; do
Jason Evans08fc3b22012-03-12 15:07:53 -0700453 k="`echo ${nm} |tr ':' ' ' |awk '{print $1}'`"
454 n="je_${k}"
Jason Evans0a5489e2012-03-01 17:19:20 -0800455 m=`echo ${nm} |tr ':' ' ' |awk '{print $2}'`
456 AC_DEFINE_UNQUOTED([${n}], [${m}])
Jason Evans08fc3b22012-03-12 15:07:53 -0700457 dnl Remove key from public_syms so that it isn't redefined later.
458 public_syms=`for sym in ${public_syms}; do echo "${sym}"; done |grep -v "^${k}\$" |tr '\n' ' '`
Jason Evans0a5489e2012-03-01 17:19:20 -0800459done
460
Jason Evans90895cf2009-12-29 00:09:15 -0800461dnl Do not prefix public APIs by default.
462AC_ARG_WITH([jemalloc_prefix],
463 [AS_HELP_STRING([--with-jemalloc-prefix=<prefix>], [Prefix to prepend to all public APIs])],
Jason Evansb0fd5012010-01-17 01:49:20 -0800464 [JEMALLOC_PREFIX="$with_jemalloc_prefix"],
Mike Hommey7cdea392012-04-30 12:38:27 +0200465 [if test "x$abi" != "xmacho" -a "x$abi" != "xpecoff"; then
Jason Evans2dbecf12010-09-05 10:35:13 -0700466 JEMALLOC_PREFIX=""
467else
468 JEMALLOC_PREFIX="je_"
469fi]
Jason Evans90895cf2009-12-29 00:09:15 -0800470)
471if test "x$JEMALLOC_PREFIX" != "x" ; then
Jason Evanse7339702010-10-23 18:37:06 -0700472 JEMALLOC_CPREFIX=`echo ${JEMALLOC_PREFIX} | tr "a-z" "A-Z"`
473 AC_DEFINE_UNQUOTED([JEMALLOC_PREFIX], ["$JEMALLOC_PREFIX"])
474 AC_DEFINE_UNQUOTED([JEMALLOC_CPREFIX], ["$JEMALLOC_CPREFIX"])
Jason Evans90895cf2009-12-29 00:09:15 -0800475fi
Jason Evans0a5489e2012-03-01 17:19:20 -0800476dnl Generate macros to rename public symbols. All public symbols are prefixed
477dnl with je_ in the source code, so these macro definitions are needed even if
478dnl --with-jemalloc-prefix wasn't specified.
Jason Evans7e77eaf2012-03-02 17:47:37 -0800479for stem in ${public_syms}; do
Jason Evans0a5489e2012-03-01 17:19:20 -0800480 n="je_${stem}"
481 m="${JEMALLOC_PREFIX}${stem}"
482 AC_DEFINE_UNQUOTED([${n}], [${m}])
483done
Jason Evans90895cf2009-12-29 00:09:15 -0800484
Mike Hommey99066602012-11-19 10:55:26 +0100485AC_ARG_WITH([export],
486 [AS_HELP_STRING([--without-export], [disable exporting jemalloc public APIs])],
487 [if test "x$with_export" = "xno"; then
Jason Evans2625c892013-01-22 16:46:27 -0800488 AC_DEFINE([JEMALLOC_EXPORT],[])
Mike Hommey99066602012-11-19 10:55:26 +0100489fi]
490)
491
Jason Evans86abd0d2013-11-30 15:25:42 -0800492dnl Mangle library-private APIs.
Jason Evans746e77a2011-07-30 16:40:52 -0700493AC_ARG_WITH([private_namespace],
494 [AS_HELP_STRING([--with-private-namespace=<prefix>], [Prefix to prepend to all library-private APIs])],
Jason Evans86abd0d2013-11-30 15:25:42 -0800495 [JEMALLOC_PRIVATE_NAMESPACE="${with_private_namespace}je_"],
496 [JEMALLOC_PRIVATE_NAMESPACE="je_"]
Jason Evans746e77a2011-07-30 16:40:52 -0700497)
Jason Evans86abd0d2013-11-30 15:25:42 -0800498AC_DEFINE_UNQUOTED([JEMALLOC_PRIVATE_NAMESPACE], [$JEMALLOC_PRIVATE_NAMESPACE])
499private_namespace="$JEMALLOC_PRIVATE_NAMESPACE"
500AC_SUBST([private_namespace])
Jason Evans746e77a2011-07-30 16:40:52 -0700501
Jason Evansb0fd5012010-01-17 01:49:20 -0800502dnl Do not add suffix to installed files by default.
503AC_ARG_WITH([install_suffix],
504 [AS_HELP_STRING([--with-install-suffix=<suffix>], [Suffix to append to all installed files])],
505 [INSTALL_SUFFIX="$with_install_suffix"],
506 [INSTALL_SUFFIX=]
507)
508install_suffix="$INSTALL_SUFFIX"
509AC_SUBST([install_suffix])
510
Jason Evans86abd0d2013-11-30 15:25:42 -0800511dnl Substitute @je_@ in jemalloc_protos.h.in, primarily to make generation of
512dnl jemalloc_protos_jet.h easy.
513je_="je_"
514AC_SUBST([je_])
515
Jason Evansaee7fd22010-11-24 22:00:02 -0800516cfgoutputs_in="${srcroot}Makefile.in"
517cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/html.xsl.in"
518cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/manpages.xsl.in"
519cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/jemalloc.xml.in"
Jason Evans86abd0d2013-11-30 15:25:42 -0800520cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/jemalloc_macros.h.in"
521cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/jemalloc_protos.h.in"
522cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/jemalloc_mangle.h.in"
Jason Evans0656ec02010-04-07 23:37:35 -0700523cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/internal/jemalloc_internal.h.in"
Jason Evans86abd0d2013-11-30 15:25:42 -0800524cfgoutputs_in="${cfgoutputs_in} ${srcroot}test/test.sh.in"
525cfgoutputs_in="${cfgoutputs_in} ${srcroot}test/include/test/jemalloc_test.h.in"
Jason Evansb0fd5012010-01-17 01:49:20 -0800526
Jason Evansaee7fd22010-11-24 22:00:02 -0800527cfgoutputs_out="Makefile"
528cfgoutputs_out="${cfgoutputs_out} doc/html.xsl"
529cfgoutputs_out="${cfgoutputs_out} doc/manpages.xsl"
Jason Evans86abd0d2013-11-30 15:25:42 -0800530cfgoutputs_out="${cfgoutputs_out} doc/jemalloc.xml"
531cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_macros.h"
532cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_protos.h"
533cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_mangle.h"
Jason Evans376b1522010-02-11 14:45:59 -0800534cfgoutputs_out="${cfgoutputs_out} include/jemalloc/internal/jemalloc_internal.h"
Jason Evans86abd0d2013-11-30 15:25:42 -0800535cfgoutputs_out="${cfgoutputs_out} test/test.sh"
536cfgoutputs_out="${cfgoutputs_out} test/include/test/jemalloc_test.h"
Jason Evansb0fd5012010-01-17 01:49:20 -0800537
Jason Evansaee7fd22010-11-24 22:00:02 -0800538cfgoutputs_tup="Makefile"
539cfgoutputs_tup="${cfgoutputs_tup} doc/html.xsl:doc/html.xsl.in"
540cfgoutputs_tup="${cfgoutputs_tup} doc/manpages.xsl:doc/manpages.xsl.in"
Jason Evans86abd0d2013-11-30 15:25:42 -0800541cfgoutputs_tup="${cfgoutputs_tup} doc/jemalloc.xml:doc/jemalloc.xml.in"
542cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_macros.h:include/jemalloc/jemalloc_macros.h.in"
543cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_protos.h:include/jemalloc/jemalloc_protos.h.in"
544cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_mangle.h:include/jemalloc/jemalloc_mangle.h.in"
Jason Evans376b1522010-02-11 14:45:59 -0800545cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/internal/jemalloc_internal.h"
Jason Evans86abd0d2013-11-30 15:25:42 -0800546cfgoutputs_tup="${cfgoutputs_tup} test/test.sh:test/test.sh.in"
547cfgoutputs_tup="${cfgoutputs_tup} test/include/test/jemalloc_test.h:test/include/test/jemalloc_test.h.in"
Jason Evansb0fd5012010-01-17 01:49:20 -0800548
Jason Evans0656ec02010-04-07 23:37:35 -0700549cfghdrs_in="${srcroot}include/jemalloc/jemalloc_defs.h.in"
Jason Evans86abd0d2013-11-30 15:25:42 -0800550cfghdrs_in="${cfghdrs_in} ${srcroot}include/jemalloc/internal/jemalloc_internal_defs.h.in"
551cfghdrs_in="${cfghdrs_in} ${srcroot}include/jemalloc/internal/private_namespace.sh"
552cfghdrs_in="${cfghdrs_in} ${srcroot}include/jemalloc/internal/private_unnamespace.sh"
553cfghdrs_in="${cfghdrs_in} ${srcroot}include/jemalloc/internal/public_namespace.sh"
554cfghdrs_in="${cfghdrs_in} ${srcroot}include/jemalloc/internal/public_unnamespace.sh"
Jason Evansb1726102012-02-28 16:50:47 -0800555cfghdrs_in="${cfghdrs_in} ${srcroot}include/jemalloc/internal/size_classes.sh"
Jason Evansb0fd5012010-01-17 01:49:20 -0800556
Jason Evans86abd0d2013-11-30 15:25:42 -0800557cfghdrs_out="include/jemalloc/jemalloc_defs.h"
558cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc${install_suffix}.h"
559cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_protos_jet.h"
560cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/jemalloc_internal_defs.h"
561cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/private_namespace.h"
562cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/private_unnamespace.h"
563cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_namespace.h"
564cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_unnamespace.h"
Jason Evansb1726102012-02-28 16:50:47 -0800565cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/size_classes.h"
Jason Evansb0fd5012010-01-17 01:49:20 -0800566
Jason Evans86abd0d2013-11-30 15:25:42 -0800567cfghdrs_tup="include/jemalloc/jemalloc_defs.h:include/jemalloc/jemalloc_defs.h.in"
568cfghdrs_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 -0800569
Jason Evans355b4382010-09-20 19:20:48 -0700570dnl Do not silence irrelevant compiler warnings by default, since enabling this
571dnl option incurs a performance penalty.
572AC_ARG_ENABLE([cc-silence],
573 [AS_HELP_STRING([--enable-cc-silence],
574 [Silence irrelevant compiler warnings])],
575[if test "x$enable_cc_silence" = "xno" ; then
576 enable_cc_silence="0"
577else
578 enable_cc_silence="1"
579fi
580],
581[enable_cc_silence="0"]
582)
583if test "x$enable_cc_silence" = "x1" ; then
Jason Evanse24c7af2012-03-19 10:21:17 -0700584 AC_DEFINE([JEMALLOC_CC_SILENCE], [ ])
Jason Evans355b4382010-09-20 19:20:48 -0700585fi
586
Jason Evansb7924f52009-06-23 19:01:18 -0700587dnl Do not compile with debugging by default.
588AC_ARG_ENABLE([debug],
Mike Hommey5135e342012-12-06 22:16:26 +0100589 [AS_HELP_STRING([--enable-debug], [Build debugging code (implies --enable-ivsalloc)])],
Jason Evansb7924f52009-06-23 19:01:18 -0700590[if test "x$enable_debug" = "xno" ; then
591 enable_debug="0"
592else
593 enable_debug="1"
594fi
595],
596[enable_debug="0"]
597)
598if test "x$enable_debug" = "x1" ; then
599 AC_DEFINE([JEMALLOC_DEBUG], [ ])
Mike Hommey5135e342012-12-06 22:16:26 +0100600 enable_ivsalloc="1"
Jason Evansb7924f52009-06-23 19:01:18 -0700601fi
602AC_SUBST([enable_debug])
603
Mike Hommey5135e342012-12-06 22:16:26 +0100604dnl Do not validate pointers by default.
605AC_ARG_ENABLE([ivsalloc],
606 [AS_HELP_STRING([--enable-ivsalloc], [Validate pointers passed through the public API])],
607[if test "x$enable_ivsalloc" = "xno" ; then
608 enable_ivsalloc="0"
609else
610 enable_ivsalloc="1"
611fi
612],
613[enable_ivsalloc="0"]
614)
615if test "x$enable_ivsalloc" = "x1" ; then
616 AC_DEFINE([JEMALLOC_IVSALLOC], [ ])
617fi
618
Jason Evansb7924f52009-06-23 19:01:18 -0700619dnl Only optimize if not debugging.
620if test "x$enable_debug" = "x0" -a "x$no_CFLAGS" = "xyes" ; then
621 dnl Make sure that an optimization flag was not specified in EXTRA_CFLAGS.
Jason Evansf3340ca2009-06-30 16:17:05 -0700622 optimize="no"
623 echo "$EXTRA_CFLAGS" | grep "\-O" >/dev/null || optimize="yes"
624 if test "x${optimize}" = "xyes" ; then
625 if test "x$GCC" = "xyes" ; then
626 JE_CFLAGS_APPEND([-O3])
627 JE_CFLAGS_APPEND([-funroll-loops])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200628 elif test "x$je_cv_msvc" = "xyes" ; then
629 JE_CFLAGS_APPEND([-O2])
Jason Evansf3340ca2009-06-30 16:17:05 -0700630 else
631 JE_CFLAGS_APPEND([-O])
632 fi
Jason Evansb7924f52009-06-23 19:01:18 -0700633 fi
634fi
635
Jason Evansd073a322012-02-28 20:41:16 -0800636dnl Enable statistics calculation by default.
Jason Evansb7924f52009-06-23 19:01:18 -0700637AC_ARG_ENABLE([stats],
Jason Evans777c1912012-02-28 20:49:22 -0800638 [AS_HELP_STRING([--disable-stats],
639 [Disable statistics calculation/reporting])],
Jason Evansb7924f52009-06-23 19:01:18 -0700640[if test "x$enable_stats" = "xno" ; then
641 enable_stats="0"
642else
643 enable_stats="1"
644fi
645],
Jason Evansd073a322012-02-28 20:41:16 -0800646[enable_stats="1"]
Jason Evansb7924f52009-06-23 19:01:18 -0700647)
648if test "x$enable_stats" = "x1" ; then
649 AC_DEFINE([JEMALLOC_STATS], [ ])
650fi
651AC_SUBST([enable_stats])
652
Jason Evans6109fe02010-02-10 10:37:56 -0800653dnl Do not enable profiling by default.
654AC_ARG_ENABLE([prof],
655 [AS_HELP_STRING([--enable-prof], [Enable allocation profiling])],
656[if test "x$enable_prof" = "xno" ; then
657 enable_prof="0"
658else
659 enable_prof="1"
660fi
661],
662[enable_prof="0"]
663)
Jason Evans77f350b2011-03-15 22:23:12 -0700664if test "x$enable_prof" = "x1" ; then
665 backtrace_method=""
Jason Evansb27805b2010-02-10 18:15:53 -0800666else
Jason Evans77f350b2011-03-15 22:23:12 -0700667 backtrace_method="N/A"
Jason Evansb27805b2010-02-10 18:15:53 -0800668fi
Jason Evans77f350b2011-03-15 22:23:12 -0700669
Jason Evans6109fe02010-02-10 10:37:56 -0800670AC_ARG_ENABLE([prof-libunwind],
671 [AS_HELP_STRING([--enable-prof-libunwind], [Use libunwind for backtracing])],
672[if test "x$enable_prof_libunwind" = "xno" ; then
673 enable_prof_libunwind="0"
674else
675 enable_prof_libunwind="1"
676fi
677],
678[enable_prof_libunwind="0"]
679)
Jason Evansca6bd4f2010-03-02 14:12:58 -0800680AC_ARG_WITH([static_libunwind],
681 [AS_HELP_STRING([--with-static-libunwind=<libunwind.a>],
682 [Path to static libunwind library; use rather than dynamically linking])],
683if test "x$with_static_libunwind" = "xno" ; then
684 LUNWIND="-lunwind"
685else
686 if test ! -f "$with_static_libunwind" ; then
687 AC_MSG_ERROR([Static libunwind not found: $with_static_libunwind])
688 fi
689 LUNWIND="$with_static_libunwind"
690fi,
691 LUNWIND="-lunwind"
692)
Jason Evans77f350b2011-03-15 22:23:12 -0700693if test "x$backtrace_method" = "x" -a "x$enable_prof_libunwind" = "x1" ; then
694 AC_CHECK_HEADERS([libunwind.h], , [enable_prof_libunwind="0"])
695 if test "x$LUNWIND" = "x-lunwind" ; then
696 AC_CHECK_LIB([unwind], [backtrace], [LIBS="$LIBS $LUNWIND"],
697 [enable_prof_libunwind="0"])
698 else
699 LIBS="$LIBS $LUNWIND"
700 fi
701 if test "x${enable_prof_libunwind}" = "x1" ; then
702 backtrace_method="libunwind"
703 AC_DEFINE([JEMALLOC_PROF_LIBUNWIND], [ ])
704 fi
705fi
706
707AC_ARG_ENABLE([prof-libgcc],
708 [AS_HELP_STRING([--disable-prof-libgcc],
709 [Do not use libgcc for backtracing])],
710[if test "x$enable_prof_libgcc" = "xno" ; then
711 enable_prof_libgcc="0"
712else
713 enable_prof_libgcc="1"
714fi
715],
716[enable_prof_libgcc="1"]
717)
718if test "x$backtrace_method" = "x" -a "x$enable_prof_libgcc" = "x1" \
719 -a "x$GCC" = "xyes" ; then
720 AC_CHECK_HEADERS([unwind.h], , [enable_prof_libgcc="0"])
721 AC_CHECK_LIB([gcc], [_Unwind_Backtrace], [LIBS="$LIBS -lgcc"], [enable_prof_libgcc="0"])
722 dnl The following is conservative, in that it only has entries for CPUs on
723 dnl which jemalloc has been tested.
724 AC_MSG_CHECKING([libgcc-based backtracing reliability on ${host_cpu}])
725 case "${host_cpu}" in
726 i[[3456]]86)
727 AC_MSG_RESULT([unreliable])
728 enable_prof_libgcc="0";
729 ;;
730 x86_64)
731 AC_MSG_RESULT([reliable])
732 ;;
733 *)
734 AC_MSG_RESULT([unreliable])
735 enable_prof_libgcc="0";
736 ;;
737 esac
738 if test "x${enable_prof_libgcc}" = "x1" ; then
739 backtrace_method="libgcc"
740 AC_DEFINE([JEMALLOC_PROF_LIBGCC], [ ])
741 fi
742else
743 enable_prof_libgcc="0"
744fi
745
746AC_ARG_ENABLE([prof-gcc],
747 [AS_HELP_STRING([--disable-prof-gcc],
748 [Do not use gcc intrinsics for backtracing])],
749[if test "x$enable_prof_gcc" = "xno" ; then
750 enable_prof_gcc="0"
751else
752 enable_prof_gcc="1"
753fi
754],
755[enable_prof_gcc="1"]
756)
757if test "x$backtrace_method" = "x" -a "x$enable_prof_gcc" = "x1" \
758 -a "x$GCC" = "xyes" ; then
759 backtrace_method="gcc intrinsics"
760 AC_DEFINE([JEMALLOC_PROF_GCC], [ ])
761else
762 enable_prof_gcc="0"
763fi
764
765if test "x$backtrace_method" = "x" ; then
766 backtrace_method="none (disabling profiling)"
767 enable_prof="0"
768fi
769AC_MSG_CHECKING([configured backtracing method])
770AC_MSG_RESULT([$backtrace_method])
Jason Evans2dbecf12010-09-05 10:35:13 -0700771if test "x$enable_prof" = "x1" ; then
Jason Evans6716aa82012-04-23 13:04:55 -0700772 if test "x${force_tls}" = "x0" ; then
773 AC_MSG_ERROR([Heap profiling requires TLS]);
774 fi
775 force_tls="1"
Jason Evans2dbecf12010-09-05 10:35:13 -0700776 AC_DEFINE([JEMALLOC_PROF], [ ])
Jason Evans2dbecf12010-09-05 10:35:13 -0700777fi
778AC_SUBST([enable_prof])
Jason Evans2dbecf12010-09-05 10:35:13 -0700779
Jason Evans84cbbcb2009-12-29 00:09:15 -0800780dnl Enable thread-specific caching by default.
781AC_ARG_ENABLE([tcache],
782 [AS_HELP_STRING([--disable-tcache], [Disable per thread caches])],
783[if test "x$enable_tcache" = "xno" ; then
784 enable_tcache="0"
Jason Evansb7924f52009-06-23 19:01:18 -0700785else
Jason Evans84cbbcb2009-12-29 00:09:15 -0800786 enable_tcache="1"
Jason Evansb7924f52009-06-23 19:01:18 -0700787fi
788],
Jason Evans84cbbcb2009-12-29 00:09:15 -0800789[enable_tcache="1"]
Jason Evansb7924f52009-06-23 19:01:18 -0700790)
Jason Evans2dbecf12010-09-05 10:35:13 -0700791if test "x$enable_tcache" = "x1" ; then
792 AC_DEFINE([JEMALLOC_TCACHE], [ ])
793fi
794AC_SUBST([enable_tcache])
Jason Evansb7924f52009-06-23 19:01:18 -0700795
Jason Evans2e671ff2012-05-09 16:12:00 -0700796dnl Disable mremap() for huge realloc() by default.
797AC_ARG_ENABLE([mremap],
798 [AS_HELP_STRING([--enable-mremap], [Enable mremap(2) for huge realloc()])],
799[if test "x$enable_mremap" = "xno" ; then
800 enable_mremap="0"
801else
802 enable_mremap="1"
803fi
804],
805[enable_mremap="0"]
806)
807if test "x$enable_mremap" = "x1" ; then
808 JE_COMPILABLE([mremap(...MREMAP_FIXED...)], [
809#define _GNU_SOURCE
810#include <sys/mman.h>
811], [
812void *p = mremap((void *)0, 0, 0, MREMAP_MAYMOVE|MREMAP_FIXED, (void *)0);
813], [je_cv_mremap_fixed])
814 if test "x${je_cv_mremap_fixed}" = "xno" ; then
815 enable_mremap="0"
816 fi
817fi
818if test "x$enable_mremap" = "x1" ; then
819 AC_DEFINE([JEMALLOC_MREMAP], [ ])
820fi
821AC_SUBST([enable_mremap])
822
Jason Evans59ae2762012-04-16 17:52:27 -0700823dnl Enable VM deallocation via munmap() by default.
824AC_ARG_ENABLE([munmap],
825 [AS_HELP_STRING([--disable-munmap], [Disable VM deallocation via munmap(2)])],
826[if test "x$enable_munmap" = "xno" ; then
827 enable_munmap="0"
828else
829 enable_munmap="1"
830fi
831],
832[enable_munmap="${default_munmap}"]
833)
834if test "x$enable_munmap" = "x1" ; then
835 AC_DEFINE([JEMALLOC_MUNMAP], [ ])
836fi
837AC_SUBST([enable_munmap])
838
Jason Evansb7924f52009-06-23 19:01:18 -0700839dnl Do not enable allocation from DSS by default.
840AC_ARG_ENABLE([dss],
841 [AS_HELP_STRING([--enable-dss], [Enable allocation from DSS])],
842[if test "x$enable_dss" = "xno" ; then
843 enable_dss="0"
844else
845 enable_dss="1"
846fi
847],
848[enable_dss="0"]
849)
Mike Hommey83c324a2012-04-12 10:13:03 +0200850dnl Check whether the BSD/SUSv1 sbrk() exists. If not, disable DSS support.
851AC_CHECK_FUNC([sbrk], [have_sbrk="1"], [have_sbrk="0"])
852if test "x$have_sbrk" = "x1" ; then
Jason Evans66688532013-12-03 21:49:36 -0800853 if test "x$sbrk_deprecated" == "x1" ; then
854 AC_MSG_RESULT([Disabling dss allocation because sbrk is deprecated])
855 enable_dss="0"
856 else
857 AC_DEFINE([JEMALLOC_HAVE_SBRK], [ ])
858 fi
Mike Hommey83c324a2012-04-12 10:13:03 +0200859else
860 enable_dss="0"
861fi
862
Jason Evansb7924f52009-06-23 19:01:18 -0700863if test "x$enable_dss" = "x1" ; then
864 AC_DEFINE([JEMALLOC_DSS], [ ])
865fi
866AC_SUBST([enable_dss])
867
Jason Evans777c1912012-02-28 20:49:22 -0800868dnl Support the junk/zero filling option by default.
Jason Evansb7924f52009-06-23 19:01:18 -0700869AC_ARG_ENABLE([fill],
Jason Evans122449b2012-04-06 00:35:09 -0700870 [AS_HELP_STRING([--disable-fill],
871 [Disable support for junk/zero filling, quarantine, and redzones])],
Jason Evansb7924f52009-06-23 19:01:18 -0700872[if test "x$enable_fill" = "xno" ; then
873 enable_fill="0"
874else
875 enable_fill="1"
876fi
877],
Jason Evans777c1912012-02-28 20:49:22 -0800878[enable_fill="1"]
Jason Evansb7924f52009-06-23 19:01:18 -0700879)
880if test "x$enable_fill" = "x1" ; then
881 AC_DEFINE([JEMALLOC_FILL], [ ])
882fi
883AC_SUBST([enable_fill])
884
Jason Evansb1476112012-04-05 13:36:17 -0700885dnl Disable utrace(2)-based tracing by default.
886AC_ARG_ENABLE([utrace],
887 [AS_HELP_STRING([--enable-utrace], [Enable utrace(2)-based tracing])],
888[if test "x$enable_utrace" = "xno" ; then
889 enable_utrace="0"
890else
891 enable_utrace="1"
892fi
893],
894[enable_utrace="0"]
895)
896JE_COMPILABLE([utrace(2)], [
897#include <sys/types.h>
898#include <sys/param.h>
899#include <sys/time.h>
900#include <sys/uio.h>
901#include <sys/ktrace.h>
902], [
903 utrace((void *)0, 0);
904], [je_cv_utrace])
905if test "x${je_cv_utrace}" = "xno" ; then
906 enable_utrace="0"
907fi
908if test "x$enable_utrace" = "x1" ; then
909 AC_DEFINE([JEMALLOC_UTRACE], [ ])
910fi
911AC_SUBST([enable_utrace])
912
Jason Evans122449b2012-04-06 00:35:09 -0700913dnl Support Valgrind by default.
914AC_ARG_ENABLE([valgrind],
915 [AS_HELP_STRING([--disable-valgrind], [Disable support for Valgrind])],
916[if test "x$enable_valgrind" = "xno" ; then
917 enable_valgrind="0"
918else
919 enable_valgrind="1"
920fi
921],
922[enable_valgrind="1"]
923)
924if test "x$enable_valgrind" = "x1" ; then
925 JE_COMPILABLE([valgrind], [
926#include <valgrind/valgrind.h>
927#include <valgrind/memcheck.h>
928
Mike Hommey7bfecf42012-04-30 15:15:15 +0200929#if !defined(VALGRIND_RESIZEINPLACE_BLOCK)
Jason Evans122449b2012-04-06 00:35:09 -0700930# error "Incompatible Valgrind version"
931#endif
932], [], [je_cv_valgrind])
933 if test "x${je_cv_valgrind}" = "xno" ; then
934 enable_valgrind="0"
935 fi
936 if test "x$enable_valgrind" = "x1" ; then
937 AC_DEFINE([JEMALLOC_VALGRIND], [ ])
938 fi
939fi
940AC_SUBST([enable_valgrind])
941
Jason Evansb7924f52009-06-23 19:01:18 -0700942dnl Do not support the xmalloc option by default.
943AC_ARG_ENABLE([xmalloc],
944 [AS_HELP_STRING([--enable-xmalloc], [Support xmalloc option])],
945[if test "x$enable_xmalloc" = "xno" ; then
946 enable_xmalloc="0"
947else
948 enable_xmalloc="1"
949fi
950],
951[enable_xmalloc="0"]
952)
953if test "x$enable_xmalloc" = "x1" ; then
954 AC_DEFINE([JEMALLOC_XMALLOC], [ ])
955fi
956AC_SUBST([enable_xmalloc])
957
Jason Evans6684cac2012-03-05 12:15:36 -0800958AC_CACHE_CHECK([STATIC_PAGE_SHIFT],
959 [je_cv_static_page_shift],
960 AC_RUN_IFELSE([AC_LANG_PROGRAM(
Mike Hommeya19e87f2012-04-21 21:27:46 -0700961[[
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200962#include <strings.h>
Mike Hommeya19e87f2012-04-21 21:27:46 -0700963#ifdef _WIN32
964#include <windows.h>
965#else
Jason Evansb7924f52009-06-23 19:01:18 -0700966#include <unistd.h>
Mike Hommeya19e87f2012-04-21 21:27:46 -0700967#endif
968#include <stdio.h>
Jason Evans6684cac2012-03-05 12:15:36 -0800969]],
970[[
Garrett Cooper72c1e592012-12-02 17:57:28 -0800971 int result;
Jason Evansb7924f52009-06-23 19:01:18 -0700972 FILE *f;
973
Mike Hommeya19e87f2012-04-21 21:27:46 -0700974#ifdef _WIN32
975 SYSTEM_INFO si;
976 GetSystemInfo(&si);
977 result = si.dwPageSize;
978#else
Jason Evansb7924f52009-06-23 19:01:18 -0700979 result = sysconf(_SC_PAGESIZE);
Mike Hommeya19e87f2012-04-21 21:27:46 -0700980#endif
Jason Evansb7924f52009-06-23 19:01:18 -0700981 if (result == -1) {
982 return 1;
983 }
Mike Hommeya19e87f2012-04-21 21:27:46 -0700984 result = ffsl(result) - 1;
985
Jason Evansb7924f52009-06-23 19:01:18 -0700986 f = fopen("conftest.out", "w");
987 if (f == NULL) {
988 return 1;
989 }
Garrett Cooper72c1e592012-12-02 17:57:28 -0800990 fprintf(f, "%d\n", result);
Jason Evans3cc1f1a2012-04-03 22:30:05 -0700991 fclose(f);
Jason Evansb7924f52009-06-23 19:01:18 -0700992
993 return 0;
994]])],
Jason Evans6684cac2012-03-05 12:15:36 -0800995 [je_cv_static_page_shift=`cat conftest.out`],
996 [je_cv_static_page_shift=undefined]))
997
998if test "x$je_cv_static_page_shift" != "xundefined"; then
999 AC_DEFINE_UNQUOTED([STATIC_PAGE_SHIFT], [$je_cv_static_page_shift])
1000else
1001 AC_MSG_ERROR([cannot determine value for STATIC_PAGE_SHIFT])
1002fi
Jason Evansb7924f52009-06-23 19:01:18 -07001003
1004dnl ============================================================================
1005dnl jemalloc configuration.
1006dnl
Jason Evansa40bc7a2010-03-02 13:01:16 -08001007
1008dnl Set VERSION if source directory has an embedded git repository.
Jason Evans955851f2011-03-31 22:38:51 -07001009if test -d "${srcroot}.git" ; then
Jason Evans79d660d2010-09-17 17:38:24 -07001010 git describe --long --abbrev=40 > ${srcroot}VERSION
Jason Evansa40bc7a2010-03-02 13:01:16 -08001011fi
Jason Evansb7924f52009-06-23 19:01:18 -07001012jemalloc_version=`cat ${srcroot}VERSION`
Jason Evansa40bc7a2010-03-02 13:01:16 -08001013jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'`
1014jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'`
1015jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'`
1016jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'`
1017jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'`
Jason Evansb7924f52009-06-23 19:01:18 -07001018AC_SUBST([jemalloc_version])
Jason Evansa40bc7a2010-03-02 13:01:16 -08001019AC_SUBST([jemalloc_version_major])
1020AC_SUBST([jemalloc_version_minor])
1021AC_SUBST([jemalloc_version_bugfix])
1022AC_SUBST([jemalloc_version_nrev])
1023AC_SUBST([jemalloc_version_gid])
Jason Evansb7924f52009-06-23 19:01:18 -07001024
1025dnl ============================================================================
1026dnl Configure pthreads.
1027
Mike Hommeya19e87f2012-04-21 21:27:46 -07001028if test "x$abi" != "xpecoff" ; then
1029 AC_CHECK_HEADERS([pthread.h], , [AC_MSG_ERROR([pthread.h is missing])])
1030 dnl Some systems may embed pthreads functionality in libc; check for libpthread
1031 dnl first, but try libc too before failing.
1032 AC_CHECK_LIB([pthread], [pthread_create], [LIBS="$LIBS -lpthread"],
1033 [AC_SEARCH_LIBS([pthread_create], , ,
1034 AC_MSG_ERROR([libpthread is missing]))])
1035fi
Jason Evansb7924f52009-06-23 19:01:18 -07001036
1037CPPFLAGS="$CPPFLAGS -D_REENTRANT"
1038
Jason Evanscd9a1342012-03-21 18:33:03 -07001039dnl Check whether the BSD-specific _malloc_thread_cleanup() exists. If so, use
1040dnl it rather than pthreads TSD cleanup functions to support cleanup during
1041dnl thread exit, in order to avoid pthreads library recursion during
1042dnl bootstrapping.
Jason Evanscd9a1342012-03-21 18:33:03 -07001043AC_CHECK_FUNC([_malloc_thread_cleanup],
1044 [have__malloc_thread_cleanup="1"],
1045 [have__malloc_thread_cleanup="0"]
1046 )
1047if test "x$have__malloc_thread_cleanup" = "x1" ; then
1048 AC_DEFINE([JEMALLOC_MALLOC_THREAD_CLEANUP], [ ])
1049 force_tls="1"
1050fi
1051
Jason Evans41b6afb2012-02-02 22:04:57 -08001052dnl Check whether the BSD-specific _pthread_mutex_init_calloc_cb() exists. If
1053dnl so, mutex initialization causes allocation, and we need to implement this
1054dnl callback function in order to prevent recursive allocation.
1055AC_CHECK_FUNC([_pthread_mutex_init_calloc_cb],
1056 [have__pthread_mutex_init_calloc_cb="1"],
1057 [have__pthread_mutex_init_calloc_cb="0"]
1058 )
1059if test "x$have__pthread_mutex_init_calloc_cb" = "x1" ; then
1060 AC_DEFINE([JEMALLOC_MUTEX_INIT_CB])
1061fi
1062
Jason Evans0fee70d2012-02-13 12:36:11 -08001063dnl Disable lazy locking by default.
Jason Evansb7924f52009-06-23 19:01:18 -07001064AC_ARG_ENABLE([lazy_lock],
Jason Evans0fee70d2012-02-13 12:36:11 -08001065 [AS_HELP_STRING([--enable-lazy-lock],
1066 [Enable lazy locking (only lock when multi-threaded)])],
Jason Evansb7924f52009-06-23 19:01:18 -07001067[if test "x$enable_lazy_lock" = "xno" ; then
1068 enable_lazy_lock="0"
1069else
1070 enable_lazy_lock="1"
1071fi
1072],
Jason Evans0fee70d2012-02-13 12:36:11 -08001073[enable_lazy_lock="0"]
Jason Evansb7924f52009-06-23 19:01:18 -07001074)
Jason Evansfd4fcef2012-03-23 17:40:58 -07001075if test "x$enable_lazy_lock" = "x0" -a "x${force_lazy_lock}" = "x1" ; then
1076 AC_MSG_RESULT([Forcing lazy-lock to avoid allocator/threading bootstrap issues])
1077 enable_lazy_lock="1"
1078fi
Jason Evansb7924f52009-06-23 19:01:18 -07001079if test "x$enable_lazy_lock" = "x1" ; then
Mike Hommeya19e87f2012-04-21 21:27:46 -07001080 if test "x$abi" != "xpecoff" ; then
1081 AC_CHECK_HEADERS([dlfcn.h], , [AC_MSG_ERROR([dlfcn.h is missing])])
1082 AC_CHECK_FUNC([dlsym], [],
1083 [AC_CHECK_LIB([dl], [dlsym], [LIBS="$LIBS -ldl"],
1084 [AC_MSG_ERROR([libdl is missing])])
1085 ])
1086 fi
Jason Evansb7924f52009-06-23 19:01:18 -07001087 AC_DEFINE([JEMALLOC_LAZY_LOCK], [ ])
1088fi
1089AC_SUBST([enable_lazy_lock])
1090
Jason Evans78d815c2010-01-17 14:06:20 -08001091AC_ARG_ENABLE([tls],
1092 [AS_HELP_STRING([--disable-tls], [Disable thread-local storage (__thread keyword)])],
1093if test "x$enable_tls" = "xno" ; then
1094 enable_tls="0"
1095else
1096 enable_tls="1"
1097fi
1098,
1099enable_tls="1"
1100)
Jason Evanscd9a1342012-03-21 18:33:03 -07001101if test "x${enable_tls}" = "x0" -a "x${force_tls}" = "x1" ; then
1102 AC_MSG_RESULT([Forcing TLS to avoid allocator/threading bootstrap issues])
1103 enable_tls="1"
1104fi
Jason Evansb80581d2012-03-23 16:17:43 -07001105if test "x${enable_tls}" = "x1" -a "x${force_tls}" = "x0" ; then
1106 AC_MSG_RESULT([Forcing no TLS to avoid allocator/threading bootstrap issues])
1107 enable_tls="0"
1108fi
Jason Evans78d815c2010-01-17 14:06:20 -08001109if test "x${enable_tls}" = "x1" ; then
1110AC_MSG_CHECKING([for TLS])
Jason Evans6684cac2012-03-05 12:15:36 -08001111AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Jason Evans78d815c2010-01-17 14:06:20 -08001112[[
1113 __thread int x;
1114]], [[
1115 x = 42;
1116
1117 return 0;
1118]])],
1119 AC_MSG_RESULT([yes]),
1120 AC_MSG_RESULT([no])
1121 enable_tls="0")
1122fi
Jason Evansb267d0f2010-08-13 15:42:29 -07001123AC_SUBST([enable_tls])
Jason Evanse24c7af2012-03-19 10:21:17 -07001124if test "x${enable_tls}" = "x1" ; then
1125 AC_DEFINE_UNQUOTED([JEMALLOC_TLS], [ ])
Jason Evanscd9a1342012-03-21 18:33:03 -07001126elif test "x${force_tls}" = "x1" ; then
1127 AC_MSG_ERROR([Failed to configure TLS, which is mandatory for correct function])
Jason Evans78d815c2010-01-17 14:06:20 -08001128fi
1129
Jason Evans2dbecf12010-09-05 10:35:13 -07001130dnl ============================================================================
Jason Evans84c8eef2011-03-16 10:30:13 -07001131dnl Check for ffsl(3), and fail if not found. This function exists on all
1132dnl platforms that jemalloc currently has a chance of functioning on without
1133dnl modification.
Jason Evans4c2faa82012-03-13 11:09:23 -07001134JE_COMPILABLE([a program using ffsl], [
Garrett Cooper72c1e592012-12-02 17:57:28 -08001135#include <stdio.h>
Jason Evans382132e2012-04-04 15:25:43 -07001136#include <strings.h>
Jason Evans4c2faa82012-03-13 11:09:23 -07001137#include <string.h>
1138], [
1139 {
1140 int rv = ffsl(0x08);
Garrett Cooper72c1e592012-12-02 17:57:28 -08001141 printf("%d\n", rv);
Jason Evans4c2faa82012-03-13 11:09:23 -07001142 }
1143], [je_cv_function_ffsl])
Jason Evans6684cac2012-03-05 12:15:36 -08001144if test "x${je_cv_function_ffsl}" != "xyes" ; then
1145 AC_MSG_ERROR([Cannot build without ffsl(3)])
1146fi
Jason Evans84c8eef2011-03-16 10:30:13 -07001147
1148dnl ============================================================================
Jason Evansb57d3ec2012-04-17 13:17:54 -07001149dnl Check for atomic(9) operations as provided on FreeBSD.
1150
1151JE_COMPILABLE([atomic(9)], [
1152#include <sys/types.h>
1153#include <machine/atomic.h>
1154#include <inttypes.h>
1155], [
1156 {
1157 uint32_t x32 = 0;
1158 volatile uint32_t *x32p = &x32;
1159 atomic_fetchadd_32(x32p, 1);
1160 }
1161 {
1162 unsigned long xlong = 0;
1163 volatile unsigned long *xlongp = &xlong;
1164 atomic_fetchadd_long(xlongp, 1);
1165 }
1166], [je_cv_atomic9])
1167if test "x${je_cv_atomic9}" = "xyes" ; then
1168 AC_DEFINE([JEMALLOC_ATOMIC9])
1169fi
1170
1171dnl ============================================================================
Jason Evans763baa62011-03-18 19:10:31 -07001172dnl Check for atomic(3) operations as provided on Darwin.
1173
1174JE_COMPILABLE([Darwin OSAtomic*()], [
1175#include <libkern/OSAtomic.h>
1176#include <inttypes.h>
1177], [
1178 {
1179 int32_t x32 = 0;
1180 volatile int32_t *x32p = &x32;
1181 OSAtomicAdd32(1, x32p);
1182 }
1183 {
1184 int64_t x64 = 0;
1185 volatile int64_t *x64p = &x64;
1186 OSAtomicAdd64(1, x64p);
1187 }
Jason Evans6684cac2012-03-05 12:15:36 -08001188], [je_cv_osatomic])
1189if test "x${je_cv_osatomic}" = "xyes" ; then
Jason Evanse24c7af2012-03-19 10:21:17 -07001190 AC_DEFINE([JEMALLOC_OSATOMIC], [ ])
Jason Evans763baa62011-03-18 19:10:31 -07001191fi
1192
1193dnl ============================================================================
Mike Hommeyc1e567b2012-03-26 17:03:41 +02001194dnl Check whether __sync_{add,sub}_and_fetch() are available despite
1195dnl __GCC_HAVE_SYNC_COMPARE_AND_SWAP_n macros being undefined.
1196
1197AC_DEFUN([JE_SYNC_COMPARE_AND_SWAP_CHECK],[
1198 AC_CACHE_CHECK([whether to force $1-bit __sync_{add,sub}_and_fetch()],
1199 [je_cv_sync_compare_and_swap_$2],
Mike Hommey2cfe6d62012-03-27 15:03:07 +02001200 [AC_LINK_IFELSE([AC_LANG_PROGRAM([
1201 #include <stdint.h>
1202 ],
1203 [
1204 #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2
1205 {
1206 uint$1_t x$1 = 0;
1207 __sync_add_and_fetch(&x$1, 42);
1208 __sync_sub_and_fetch(&x$1, 1);
1209 }
1210 #else
1211 #error __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2 is defined, no need to force
1212 #endif
1213 ])],
Mike Hommeyc1e567b2012-03-26 17:03:41 +02001214 [je_cv_sync_compare_and_swap_$2=yes],
1215 [je_cv_sync_compare_and_swap_$2=no])])
1216
1217 if test "x${je_cv_sync_compare_and_swap_$2}" = "xyes" ; then
1218 AC_DEFINE([JE_FORCE_SYNC_COMPARE_AND_SWAP_$2], [ ])
1219 fi
1220])
1221
Jason Evansb57d3ec2012-04-17 13:17:54 -07001222if test "x${je_cv_atomic9}" != "xyes" -a "x${je_cv_osatomic}" != "xyes" ; then
Mike Hommeyc1e567b2012-03-26 17:03:41 +02001223 JE_SYNC_COMPARE_AND_SWAP_CHECK(32, 4)
1224 JE_SYNC_COMPARE_AND_SWAP_CHECK(64, 8)
1225fi
1226
1227dnl ============================================================================
Jason Evans893a0ed2011-03-18 19:30:18 -07001228dnl Check for spinlock(3) operations as provided on Darwin.
1229
1230JE_COMPILABLE([Darwin OSSpin*()], [
1231#include <libkern/OSAtomic.h>
1232#include <inttypes.h>
1233], [
1234 OSSpinLock lock = 0;
1235 OSSpinLockLock(&lock);
1236 OSSpinLockUnlock(&lock);
Jason Evans6684cac2012-03-05 12:15:36 -08001237], [je_cv_osspin])
1238if test "x${je_cv_osspin}" = "xyes" ; then
Jason Evanse24c7af2012-03-19 10:21:17 -07001239 AC_DEFINE([JEMALLOC_OSSPIN], [ ])
Jason Evans893a0ed2011-03-18 19:30:18 -07001240fi
1241
1242dnl ============================================================================
Jason Evans2dbecf12010-09-05 10:35:13 -07001243dnl Darwin-related configuration.
Jason Evans78d815c2010-01-17 14:06:20 -08001244
Mike Hommeyd0357f72012-11-26 18:52:41 +01001245AC_ARG_ENABLE([zone-allocator],
1246 [AS_HELP_STRING([--disable-zone-allocator],
1247 [Disable zone allocator for Darwin])],
1248[if test "x$enable_zone_allocator" = "xno" ; then
1249 enable_zone_allocator="0"
1250else
1251 enable_zone_allocator="1"
1252fi
1253],
1254[if test "x${abi}" = "xmacho"; then
1255 enable_zone_allocator="1"
1256fi
1257]
1258)
1259AC_SUBST([enable_zone_allocator])
1260
1261if test "x${enable_zone_allocator}" = "x1" ; then
1262 if test "x${abi}" != "xmacho"; then
1263 AC_MSG_ERROR([--enable-zone-allocator is only supported on Darwin])
1264 fi
Jason Evanse24c7af2012-03-19 10:21:17 -07001265 AC_DEFINE([JEMALLOC_IVSALLOC], [ ])
1266 AC_DEFINE([JEMALLOC_ZONE], [ ])
Jason Evans6109fe02010-02-10 10:37:56 -08001267
Jason Evans2dbecf12010-09-05 10:35:13 -07001268 dnl The szone version jumped from 3 to 6 between the OS X 10.5.x and 10.6
1269 dnl releases. malloc_zone_t and malloc_introspection_t have new fields in
1270 dnl 10.6, which is the only source-level indication of the change.
1271 AC_MSG_CHECKING([malloc zone version])
Mike Hommey154829d2012-03-20 18:01:38 +01001272 AC_DEFUN([JE_ZONE_PROGRAM],
1273 [AC_LANG_PROGRAM(
1274 [#include <malloc/malloc.h>],
1275 [static foo[[sizeof($1) $2 sizeof(void *) * $3 ? 1 : -1]]]
1276 )])
Jason Evans2dbecf12010-09-05 10:35:13 -07001277
Mike Hommey154829d2012-03-20 18:01:38 +01001278 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,14)],[JEMALLOC_ZONE_VERSION=3],[
1279 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,15)],[JEMALLOC_ZONE_VERSION=5],[
1280 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,16)],[
1281 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,9)],[JEMALLOC_ZONE_VERSION=6],[
1282 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,13)],[JEMALLOC_ZONE_VERSION=7],[JEMALLOC_ZONE_VERSION=]
1283 )])],[
1284 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,17)],[JEMALLOC_ZONE_VERSION=8],[
1285 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,>,17)],[JEMALLOC_ZONE_VERSION=9],[JEMALLOC_ZONE_VERSION=]
1286 )])])])])
1287 if test "x${JEMALLOC_ZONE_VERSION}" = "x"; then
1288 AC_MSG_RESULT([unsupported])
1289 AC_MSG_ERROR([Unsupported malloc zone version])
1290 fi
1291 if test "${JEMALLOC_ZONE_VERSION}" = 9; then
1292 JEMALLOC_ZONE_VERSION=8
1293 AC_MSG_RESULT([> 8])
1294 else
1295 AC_MSG_RESULT([$JEMALLOC_ZONE_VERSION])
1296 fi
1297 AC_DEFINE_UNQUOTED(JEMALLOC_ZONE_VERSION, [$JEMALLOC_ZONE_VERSION])
Jason Evansb27805b2010-02-10 18:15:53 -08001298fi
1299
Jason Evansb7924f52009-06-23 19:01:18 -07001300dnl ============================================================================
1301dnl Check for typedefs, structures, and compiler characteristics.
1302AC_HEADER_STDBOOL
1303
Jason Evans86abd0d2013-11-30 15:25:42 -08001304AC_CONFIG_COMMANDS([include/jemalloc/internal/private_namespace.h], [
1305 mkdir -p "${objroot}include/jemalloc/internal"
1306 "${srcdir}/include/jemalloc/internal/private_namespace.sh" "${srcdir}/include/jemalloc/internal/private_symbols.txt" > "${objroot}include/jemalloc/internal/private_namespace.h"
1307])
1308AC_CONFIG_COMMANDS([include/jemalloc/internal/private_unnamespace.h], [
1309 mkdir -p "${objroot}include/jemalloc/internal"
1310 "${srcdir}/include/jemalloc/internal/private_unnamespace.sh" "${srcdir}/include/jemalloc/internal/private_symbols.txt" > "${objroot}include/jemalloc/internal/private_unnamespace.h"
1311])
1312AC_CONFIG_COMMANDS([include/jemalloc/internal/public_namespace.h], [
1313 mkdir -p "${objroot}include/jemalloc/internal"
1314 "${srcdir}/include/jemalloc/internal/public_namespace.sh" "${srcdir}/include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/internal/public_namespace.h"
1315])
1316AC_CONFIG_COMMANDS([include/jemalloc/internal/public_unnamespace.h], [
1317 mkdir -p "${objroot}include/jemalloc/internal"
1318 "${srcdir}/include/jemalloc/internal/public_unnamespace.sh" "${srcdir}/include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/internal/public_unnamespace.h"
1319])
Jason Evansb1726102012-02-28 16:50:47 -08001320AC_CONFIG_COMMANDS([include/jemalloc/internal/size_classes.h], [
Jason Evans86abd0d2013-11-30 15:25:42 -08001321 mkdir -p "${objroot}include/jemalloc/internal"
Jason Evansb1726102012-02-28 16:50:47 -08001322 "${srcdir}/include/jemalloc/internal/size_classes.sh" > "${objroot}include/jemalloc/internal/size_classes.h"
1323])
Jason Evans86abd0d2013-11-30 15:25:42 -08001324AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_protos_jet.h], [
1325 mkdir -p "${objroot}include/jemalloc"
1326 cat "${srcdir}/include/jemalloc/jemalloc_protos.h.in" | sed -e 's/@je_@/jet_/g' > "${objroot}include/jemalloc/jemalloc_protos_jet.h"
1327])
1328AC_CONFIG_COMMANDS([include/jemalloc/jemalloc.h], [
1329 mkdir -p "${objroot}include/jemalloc"
1330 "${srcdir}/include/jemalloc/jemalloc.sh" "${objroot}" > "${objroot}include/jemalloc/jemalloc${install_suffix}.h"
1331])
Jason Evansb1726102012-02-28 16:50:47 -08001332
Jason Evansb7924f52009-06-23 19:01:18 -07001333dnl Process .in files.
Jason Evansb0fd5012010-01-17 01:49:20 -08001334AC_SUBST([cfghdrs_in])
1335AC_SUBST([cfghdrs_out])
Jason Evans0656ec02010-04-07 23:37:35 -07001336AC_CONFIG_HEADERS([$cfghdrs_tup])
Jason Evansb7924f52009-06-23 19:01:18 -07001337
1338dnl ============================================================================
1339dnl Generate outputs.
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +04001340AC_CONFIG_FILES([$cfgoutputs_tup config.stamp bin/jemalloc.sh])
Jason Evansb0fd5012010-01-17 01:49:20 -08001341AC_SUBST([cfgoutputs_in])
1342AC_SUBST([cfgoutputs_out])
Jason Evansb7924f52009-06-23 19:01:18 -07001343AC_OUTPUT
1344
1345dnl ============================================================================
1346dnl Print out the results of configuration.
1347AC_MSG_RESULT([===============================================================================])
Jason Evansf576c632011-11-01 22:27:41 -07001348AC_MSG_RESULT([jemalloc version : ${jemalloc_version}])
1349AC_MSG_RESULT([library revision : ${rev}])
Jason Evansb7924f52009-06-23 19:01:18 -07001350AC_MSG_RESULT([])
1351AC_MSG_RESULT([CC : ${CC}])
1352AC_MSG_RESULT([CPPFLAGS : ${CPPFLAGS}])
1353AC_MSG_RESULT([CFLAGS : ${CFLAGS}])
1354AC_MSG_RESULT([LDFLAGS : ${LDFLAGS}])
1355AC_MSG_RESULT([LIBS : ${LIBS}])
1356AC_MSG_RESULT([RPATH_EXTRA : ${RPATH_EXTRA}])
1357AC_MSG_RESULT([])
Jason Evansaee7fd22010-11-24 22:00:02 -08001358AC_MSG_RESULT([XSLTPROC : ${XSLTPROC}])
1359AC_MSG_RESULT([XSLROOT : ${XSLROOT}])
1360AC_MSG_RESULT([])
Jason Evansb7924f52009-06-23 19:01:18 -07001361AC_MSG_RESULT([PREFIX : ${PREFIX}])
1362AC_MSG_RESULT([BINDIR : ${BINDIR}])
Jason Evans662a0172009-07-01 19:24:31 -07001363AC_MSG_RESULT([INCLUDEDIR : ${INCLUDEDIR}])
1364AC_MSG_RESULT([LIBDIR : ${LIBDIR}])
Jason Evansb7924f52009-06-23 19:01:18 -07001365AC_MSG_RESULT([DATADIR : ${DATADIR}])
1366AC_MSG_RESULT([MANDIR : ${MANDIR}])
1367AC_MSG_RESULT([])
1368AC_MSG_RESULT([srcroot : ${srcroot}])
1369AC_MSG_RESULT([abs_srcroot : ${abs_srcroot}])
1370AC_MSG_RESULT([objroot : ${objroot}])
1371AC_MSG_RESULT([abs_objroot : ${abs_objroot}])
1372AC_MSG_RESULT([])
Jason Evans90895cf2009-12-29 00:09:15 -08001373AC_MSG_RESULT([JEMALLOC_PREFIX : ${JEMALLOC_PREFIX}])
Jason Evans746e77a2011-07-30 16:40:52 -07001374AC_MSG_RESULT([JEMALLOC_PRIVATE_NAMESPACE])
1375AC_MSG_RESULT([ : ${JEMALLOC_PRIVATE_NAMESPACE}])
Jason Evansb0fd5012010-01-17 01:49:20 -08001376AC_MSG_RESULT([install_suffix : ${install_suffix}])
Jason Evansb7924f52009-06-23 19:01:18 -07001377AC_MSG_RESULT([autogen : ${enable_autogen}])
Jason Evans7e77eaf2012-03-02 17:47:37 -08001378AC_MSG_RESULT([experimental : ${enable_experimental}])
Jason Evans355b4382010-09-20 19:20:48 -07001379AC_MSG_RESULT([cc-silence : ${enable_cc_silence}])
Jason Evansb7924f52009-06-23 19:01:18 -07001380AC_MSG_RESULT([debug : ${enable_debug}])
1381AC_MSG_RESULT([stats : ${enable_stats}])
Jason Evans6109fe02010-02-10 10:37:56 -08001382AC_MSG_RESULT([prof : ${enable_prof}])
1383AC_MSG_RESULT([prof-libunwind : ${enable_prof_libunwind}])
Jason Evans77f350b2011-03-15 22:23:12 -07001384AC_MSG_RESULT([prof-libgcc : ${enable_prof_libgcc}])
1385AC_MSG_RESULT([prof-gcc : ${enable_prof_gcc}])
Jason Evans84cbbcb2009-12-29 00:09:15 -08001386AC_MSG_RESULT([tcache : ${enable_tcache}])
Jason Evansb7924f52009-06-23 19:01:18 -07001387AC_MSG_RESULT([fill : ${enable_fill}])
Jason Evansb1476112012-04-05 13:36:17 -07001388AC_MSG_RESULT([utrace : ${enable_utrace}])
Jason Evans122449b2012-04-06 00:35:09 -07001389AC_MSG_RESULT([valgrind : ${enable_valgrind}])
1390AC_MSG_RESULT([xmalloc : ${enable_xmalloc}])
Jason Evans2e671ff2012-05-09 16:12:00 -07001391AC_MSG_RESULT([mremap : ${enable_mremap}])
Jason Evans59ae2762012-04-16 17:52:27 -07001392AC_MSG_RESULT([munmap : ${enable_munmap}])
Jason Evansb7924f52009-06-23 19:01:18 -07001393AC_MSG_RESULT([dss : ${enable_dss}])
Jason Evansb7924f52009-06-23 19:01:18 -07001394AC_MSG_RESULT([lazy_lock : ${enable_lazy_lock}])
Jason Evans2dbecf12010-09-05 10:35:13 -07001395AC_MSG_RESULT([tls : ${enable_tls}])
Jason Evansb7924f52009-06-23 19:01:18 -07001396AC_MSG_RESULT([===============================================================================])