configure.ac revision a398a6b46e53035a4ef660b4c7a1c406f3abe645
1dnl Process this file with autoconf to produce a configure script.
2AC_INIT([Makefile.in])
3
4dnl ============================================================================
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
17AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
18[[
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)
29dnl 
30dnl Use AC_LINK_IFELSE() rather than AC_COMPILE_IFELSE() so that linker errors
31dnl cause failure.
32AC_DEFUN([JE_COMPILABLE],
33[
34AC_CACHE_CHECK([whether $1 is compilable],
35               [$4],
36               [AC_LINK_IFELSE([AC_LANG_PROGRAM([$2],
37                                                [$3])],
38                               [$4=yes],
39                               [$4=no])])
40])
41
42dnl ============================================================================
43
44dnl Library revision.
45rev=1
46AC_SUBST([rev])
47
48srcroot=$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
88dnl Support for building documentation.
89AC_PATH_PROG([XSLTPROC], [xsltproc], , [$PATH])
90if 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
98AC_ARG_WITH([xslroot],
99  [AS_HELP_STRING([--with-xslroot=<path>], [XSL stylesheet root path])], [
100if test "x$with_xslroot" = "xno" ; then
101  XSLROOT="${DEFAULT_XSLROOT}"
102else
103  XSLROOT="${with_xslroot}"
104fi
105],
106  XSLROOT="${DEFAULT_XSLROOT}"
107)
108AC_SUBST([XSLROOT])
109
110dnl If CFLAGS isn't defined, set CFLAGS to something reasonable.  Otherwise,
111dnl just prevent autoconf from molesting CFLAGS.
112CFLAGS=$CFLAGS
113AC_PROG_CC
114if test "x$CFLAGS" = "x" ; then
115  no_CFLAGS="yes"
116  if test "x$GCC" = "xyes" ; then
117    JE_CFLAGS_APPEND([-std=gnu99])
118    JE_CFLAGS_APPEND([-Wall])
119    JE_CFLAGS_APPEND([-pipe])
120    JE_CFLAGS_APPEND([-g3])
121  fi
122fi
123dnl Append EXTRA_CFLAGS to CFLAGS, if defined.
124if test "x$EXTRA_CFLAGS" != "x" ; then
125  JE_CFLAGS_APPEND([$EXTRA_CFLAGS])
126fi
127AC_PROG_CPP
128
129AC_CHECK_SIZEOF([void *])
130if test "x${ac_cv_sizeof_void_p}" = "x8" ; then
131  LG_SIZEOF_PTR=3
132elif test "x${ac_cv_sizeof_void_p}" = "x4" ; then
133  LG_SIZEOF_PTR=2
134else
135  AC_MSG_ERROR([Unsupported pointer size: ${ac_cv_sizeof_void_p}])
136fi
137AC_DEFINE_UNQUOTED([LG_SIZEOF_PTR], [$LG_SIZEOF_PTR])
138
139AC_CHECK_SIZEOF([int])
140if test "x${ac_cv_sizeof_int}" = "x8" ; then
141  LG_SIZEOF_INT=3
142elif test "x${ac_cv_sizeof_int}" = "x4" ; then
143  LG_SIZEOF_INT=2
144else
145  AC_MSG_ERROR([Unsupported int size: ${ac_cv_sizeof_int}])
146fi
147AC_DEFINE_UNQUOTED([LG_SIZEOF_INT], [$LG_SIZEOF_INT])
148
149AC_CHECK_SIZEOF([long])
150if test "x${ac_cv_sizeof_long}" = "x8" ; then
151  LG_SIZEOF_LONG=3
152elif test "x${ac_cv_sizeof_long}" = "x4" ; then
153  LG_SIZEOF_LONG=2
154else
155  AC_MSG_ERROR([Unsupported long size: ${ac_cv_sizeof_long}])
156fi
157AC_DEFINE_UNQUOTED([LG_SIZEOF_LONG], [$LG_SIZEOF_LONG])
158
159AC_CHECK_SIZEOF([intmax_t])
160if test "x${ac_cv_sizeof_intmax_t}" = "x16" ; then
161  LG_SIZEOF_INTMAX_T=4
162elif test "x${ac_cv_sizeof_intmax_t}" = "x8" ; then
163  LG_SIZEOF_INTMAX_T=3
164elif test "x${ac_cv_sizeof_intmax_t}" = "x4" ; then
165  LG_SIZEOF_INTMAX_T=2
166else
167  AC_MSG_ERROR([Unsupported intmax_t size: ${ac_cv_sizeof_long}])
168fi
169AC_DEFINE_UNQUOTED([LG_SIZEOF_INTMAX_T], [$LG_SIZEOF_INTMAX_T])
170
171AC_CANONICAL_HOST
172dnl CPU-specific settings.
173CPU_SPINWAIT=""
174case "${host_cpu}" in
175  i[[345]]86)
176	;;
177  i686)
178	JE_COMPILABLE([__asm__], [], [[__asm__ volatile("pause"); return 0;]],
179	              [je_cv_asm])
180	if test "x${je_cv_asm}" = "xyes" ; then
181	    CPU_SPINWAIT='__asm__ volatile("pause")'
182	fi
183	;;
184  x86_64)
185	JE_COMPILABLE([__asm__ syntax], [],
186	              [[__asm__ volatile("pause"); return 0;]], [je_cv_asm])
187	if test "x${je_cv_asm}" = "xyes" ; then
188	    CPU_SPINWAIT='__asm__ volatile("pause")'
189	fi
190	;;
191  *)
192	;;
193esac
194AC_DEFINE_UNQUOTED([CPU_SPINWAIT], [$CPU_SPINWAIT])
195
196LD_PRELOAD_VAR="LD_PRELOAD"
197so="so"
198
199dnl Heap profiling uses the log(3) function.
200LIBS="$LIBS -lm"
201
202dnl Platform-specific settings.  abi and RPATH can probably be determined
203dnl programmatically, but doing so is error-prone, which makes it generally
204dnl not worth the trouble.
205dnl 
206dnl Define cpp macros in CPPFLAGS, rather than doing AC_DEFINE(macro), since the
207dnl definitions need to be seen before any headers are included, which is a pain
208dnl to make happen otherwise.
209case "${host}" in
210  *-*-darwin*)
211	CFLAGS="$CFLAGS -fno-common"
212	abi="macho"
213	AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
214	RPATH=""
215	LD_PRELOAD_VAR="DYLD_INSERT_LIBRARIES"
216	so="dylib"
217	force_tls="0"
218	;;
219  *-*-freebsd*)
220	CFLAGS="$CFLAGS"
221	abi="elf"
222	AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
223	RPATH="-Wl,-rpath,"
224	force_lazy_lock="1"
225	;;
226  *-*-linux*)
227	CFLAGS="$CFLAGS"
228	CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
229	abi="elf"
230	AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED], [ ])
231	AC_DEFINE([JEMALLOC_THREADED_INIT], [ ])
232	RPATH="-Wl,-rpath,"
233	;;
234  *-*-netbsd*)
235	AC_MSG_CHECKING([ABI])
236        AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
237[[#ifdef __ELF__
238/* ELF */
239#else
240#error aout
241#endif
242]])],
243                          [CFLAGS="$CFLAGS"; abi="elf"],
244                          [abi="aout"])
245	AC_MSG_RESULT([$abi])
246	AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
247	RPATH="-Wl,-rpath,"
248	;;
249  *-*-solaris2*)
250	CFLAGS="$CFLAGS"
251	abi="elf"
252	RPATH="-Wl,-R,"
253	dnl Solaris needs this for sigwait().
254	CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
255	LIBS="$LIBS -lposix4 -lsocket -lnsl"
256	;;
257  *-ibm-aix*)
258	if "$LG_SIZEOF_PTR" = "8"; then
259	  dnl 64bit AIX
260	  LD_PRELOAD_VAR="LDR_PRELOAD64"
261	else
262	  dnl 32bit AIX
263	  LD_PRELOAD_VAR="LDR_PRELOAD"
264	fi
265	abi="xcoff"
266	RPATH="-Wl,-rpath,"
267	;;
268  *)
269	AC_MSG_RESULT([Unsupported operating system: ${host}])
270	abi="elf"
271	RPATH="-Wl,-rpath,"
272	;;
273esac
274AC_SUBST([abi])
275AC_SUBST([RPATH])
276AC_SUBST([LD_PRELOAD_VAR])
277AC_SUBST([so])
278
279JE_COMPILABLE([__attribute__ syntax],
280              [static __attribute__((unused)) void foo(void){}],
281              [],
282              [je_cv_attribute])
283if test "x${je_cv_attribute}" = "xyes" ; then
284  AC_DEFINE([JEMALLOC_HAVE_ATTR], [ ])
285  if test "x${GCC}" = "xyes" -a "x${abi}" = "xelf"; then
286    JE_CFLAGS_APPEND([-fvisibility=hidden])
287  fi
288fi
289dnl Check for tls_model attribute support (clang 3.0 still lacks support).
290SAVED_CFLAGS="${CFLAGS}"
291JE_CFLAGS_APPEND([-Werror])
292JE_COMPILABLE([tls_model attribute], [],
293              [static __thread int
294               __attribute__((tls_model("initial-exec"))) foo;
295               foo = 0;],
296              [je_cv_tls_model])
297CFLAGS="${SAVED_CFLAGS}"
298if test "x${je_cv_tls_model}" = "xyes" ; then
299  AC_DEFINE([JEMALLOC_TLS_MODEL],
300            [__attribute__((tls_model("initial-exec")))])
301else
302  AC_DEFINE([JEMALLOC_TLS_MODEL], [ ])
303fi
304
305JE_COMPILABLE([mremap(...MREMAP_FIXED...)], [
306#define _GNU_SOURCE
307#include <sys/mman.h>
308], [
309void *p = mremap((void *)0, 0, 0, MREMAP_MAYMOVE|MREMAP_FIXED, (void *)0);
310], [je_cv_mremap_fixed])
311if test "x${je_cv_mremap_fixed}" = "xyes" ; then
312  AC_DEFINE([JEMALLOC_MREMAP_FIXED], [ ])
313fi
314
315dnl Support optional additions to rpath.
316AC_ARG_WITH([rpath],
317  [AS_HELP_STRING([--with-rpath=<rpath>], [Colon-separated rpath (ELF systems only)])],
318if test "x$with_rpath" = "xno" ; then
319  RPATH_EXTRA=
320else
321  RPATH_EXTRA="`echo $with_rpath | tr \":\" \" \"`"
322fi,
323  RPATH_EXTRA=
324)
325AC_SUBST([RPATH_EXTRA])
326
327dnl Disable rules that do automatic regeneration of configure output by default.
328AC_ARG_ENABLE([autogen],
329  [AS_HELP_STRING([--enable-autogen], [Automatically regenerate configure output])],
330if test "x$enable_autogen" = "xno" ; then
331  enable_autogen="0"
332else
333  enable_autogen="1"
334fi
335,
336enable_autogen="0"
337)
338AC_SUBST([enable_autogen])
339
340AC_PROG_INSTALL
341AC_PROG_RANLIB
342AC_PATH_PROG([AR], [ar], , [$PATH])
343AC_PATH_PROG([LD], [ld], , [$PATH])
344AC_PATH_PROG([AUTOCONF], [autoconf], , [$PATH])
345
346public_syms="malloc_conf malloc_message malloc calloc posix_memalign aligned_alloc realloc free malloc_usable_size malloc_stats_print mallctl mallctlnametomib mallctlbymib"
347
348dnl Check for allocator-related functions that should be wrapped.
349AC_CHECK_FUNC([memalign],
350	      [AC_DEFINE([JEMALLOC_OVERRIDE_MEMALIGN], [ ])
351	       public_syms="${public_syms} memalign"])
352AC_CHECK_FUNC([valloc],
353	      [AC_DEFINE([JEMALLOC_OVERRIDE_VALLOC], [ ])
354	       public_syms="${public_syms} valloc"])
355
356dnl Support the experimental API by default.
357AC_ARG_ENABLE([experimental],
358  [AS_HELP_STRING([--disable-experimental],
359   [Disable support for the experimental API])],
360[if test "x$enable_experimental" = "xno" ; then
361  enable_experimental="0"
362else
363  enable_experimental="1"
364fi
365],
366[enable_experimental="1"]
367)
368if test "x$enable_experimental" = "x1" ; then
369  AC_DEFINE([JEMALLOC_EXPERIMENTAL], [ ])
370  public_syms="${public_syms} allocm dallocm nallocm rallocm sallocm"
371fi
372AC_SUBST([enable_experimental])
373
374dnl Perform no name mangling by default.
375AC_ARG_WITH([mangling],
376  [AS_HELP_STRING([--with-mangling=<map>], [Mangle symbols in <map>])],
377  [mangling_map="$with_mangling"], [mangling_map=""])
378for nm in `echo ${mangling_map} |tr ',' ' '` ; do
379  k="`echo ${nm} |tr ':' ' ' |awk '{print $1}'`"
380  n="je_${k}"
381  m=`echo ${nm} |tr ':' ' ' |awk '{print $2}'`
382  AC_DEFINE_UNQUOTED([${n}], [${m}])
383  dnl Remove key from public_syms so that it isn't redefined later.
384  public_syms=`for sym in ${public_syms}; do echo "${sym}"; done |grep -v "^${k}\$" |tr '\n' ' '`
385done
386
387dnl Do not prefix public APIs by default.
388AC_ARG_WITH([jemalloc_prefix],
389  [AS_HELP_STRING([--with-jemalloc-prefix=<prefix>], [Prefix to prepend to all public APIs])],
390  [JEMALLOC_PREFIX="$with_jemalloc_prefix"],
391  [if test "x$abi" != "xmacho" ; then
392  JEMALLOC_PREFIX=""
393else
394  JEMALLOC_PREFIX="je_"
395fi]
396)
397if test "x$JEMALLOC_PREFIX" != "x" ; then
398  JEMALLOC_CPREFIX=`echo ${JEMALLOC_PREFIX} | tr "a-z" "A-Z"`
399  AC_DEFINE_UNQUOTED([JEMALLOC_PREFIX], ["$JEMALLOC_PREFIX"])
400  AC_DEFINE_UNQUOTED([JEMALLOC_CPREFIX], ["$JEMALLOC_CPREFIX"])
401fi
402dnl Generate macros to rename public symbols.  All public symbols are prefixed
403dnl with je_ in the source code, so these macro definitions are needed even if
404dnl --with-jemalloc-prefix wasn't specified.
405for stem in ${public_syms}; do
406  n="je_${stem}"
407  m="${JEMALLOC_PREFIX}${stem}"
408  AC_DEFINE_UNQUOTED([${n}], [${m}])
409done
410
411dnl Do not mangle library-private APIs by default.
412AC_ARG_WITH([private_namespace],
413  [AS_HELP_STRING([--with-private-namespace=<prefix>], [Prefix to prepend to all library-private APIs])],
414  [JEMALLOC_PRIVATE_NAMESPACE="$with_private_namespace"],
415  [JEMALLOC_PRIVATE_NAMESPACE=""]
416)
417AC_DEFINE_UNQUOTED([JEMALLOC_PRIVATE_NAMESPACE], ["$JEMALLOC_PRIVATE_NAMESPACE"])
418if test "x$JEMALLOC_PRIVATE_NAMESPACE" != "x" ; then
419  AC_DEFINE_UNQUOTED([JEMALLOC_N(string_that_no_one_should_want_to_use_as_a_jemalloc_private_namespace_prefix)], [${JEMALLOC_PRIVATE_NAMESPACE}##string_that_no_one_should_want_to_use_as_a_jemalloc_private_namespace_prefix])
420else
421  AC_DEFINE_UNQUOTED([JEMALLOC_N(string_that_no_one_should_want_to_use_as_a_jemalloc_private_namespace_prefix)], [string_that_no_one_should_want_to_use_as_a_jemalloc_private_namespace_prefix])
422fi
423
424dnl Do not add suffix to installed files by default.
425AC_ARG_WITH([install_suffix],
426  [AS_HELP_STRING([--with-install-suffix=<suffix>], [Suffix to append to all installed files])],
427  [INSTALL_SUFFIX="$with_install_suffix"],
428  [INSTALL_SUFFIX=]
429)
430install_suffix="$INSTALL_SUFFIX"
431AC_SUBST([install_suffix])
432
433cfgoutputs_in="${srcroot}Makefile.in"
434cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/html.xsl.in"
435cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/manpages.xsl.in"
436cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/jemalloc.xml.in"
437cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/jemalloc.h.in"
438cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/internal/jemalloc_internal.h.in"
439cfgoutputs_in="${cfgoutputs_in} ${srcroot}test/jemalloc_test.h.in"
440
441cfgoutputs_out="Makefile"
442cfgoutputs_out="${cfgoutputs_out} doc/html.xsl"
443cfgoutputs_out="${cfgoutputs_out} doc/manpages.xsl"
444cfgoutputs_out="${cfgoutputs_out} doc/jemalloc${install_suffix}.xml"
445cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc${install_suffix}.h"
446cfgoutputs_out="${cfgoutputs_out} include/jemalloc/internal/jemalloc_internal.h"
447cfgoutputs_out="${cfgoutputs_out} test/jemalloc_test.h"
448
449cfgoutputs_tup="Makefile"
450cfgoutputs_tup="${cfgoutputs_tup} doc/html.xsl:doc/html.xsl.in"
451cfgoutputs_tup="${cfgoutputs_tup} doc/manpages.xsl:doc/manpages.xsl.in"
452cfgoutputs_tup="${cfgoutputs_tup} doc/jemalloc${install_suffix}.xml:doc/jemalloc.xml.in"
453cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc${install_suffix}.h:include/jemalloc/jemalloc.h.in"
454cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/internal/jemalloc_internal.h"
455cfgoutputs_tup="${cfgoutputs_tup} test/jemalloc_test.h:test/jemalloc_test.h.in"
456
457cfghdrs_in="${srcroot}include/jemalloc/jemalloc_defs.h.in"
458cfghdrs_in="${cfghdrs_in} ${srcroot}include/jemalloc/internal/size_classes.sh"
459
460cfghdrs_out="include/jemalloc/jemalloc_defs${install_suffix}.h"
461cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/size_classes.h"
462
463cfghdrs_tup="include/jemalloc/jemalloc_defs${install_suffix}.h:include/jemalloc/jemalloc_defs.h.in"
464
465dnl Do not silence irrelevant compiler warnings by default, since enabling this
466dnl option incurs a performance penalty.
467AC_ARG_ENABLE([cc-silence],
468  [AS_HELP_STRING([--enable-cc-silence],
469                  [Silence irrelevant compiler warnings])],
470[if test "x$enable_cc_silence" = "xno" ; then
471  enable_cc_silence="0"
472else
473  enable_cc_silence="1"
474fi
475],
476[enable_cc_silence="0"]
477)
478if test "x$enable_cc_silence" = "x1" ; then
479  AC_DEFINE([JEMALLOC_CC_SILENCE], [ ])
480fi
481
482dnl Do not compile with debugging by default.
483AC_ARG_ENABLE([debug],
484  [AS_HELP_STRING([--enable-debug], [Build debugging code])],
485[if test "x$enable_debug" = "xno" ; then
486  enable_debug="0"
487else
488  enable_debug="1"
489fi
490],
491[enable_debug="0"]
492)
493if test "x$enable_debug" = "x1" ; then
494  AC_DEFINE([JEMALLOC_DEBUG], [ ])
495  AC_DEFINE([JEMALLOC_IVSALLOC], [ ])
496fi
497AC_SUBST([enable_debug])
498
499dnl Only optimize if not debugging.
500if test "x$enable_debug" = "x0" -a "x$no_CFLAGS" = "xyes" ; then
501  dnl Make sure that an optimization flag was not specified in EXTRA_CFLAGS.
502  optimize="no"
503  echo "$EXTRA_CFLAGS" | grep "\-O" >/dev/null || optimize="yes"
504  if test "x${optimize}" = "xyes" ; then
505    if test "x$GCC" = "xyes" ; then
506      JE_CFLAGS_APPEND([-O3])
507      JE_CFLAGS_APPEND([-funroll-loops])
508    else
509      JE_CFLAGS_APPEND([-O])
510    fi
511  fi
512fi
513
514dnl Enable statistics calculation by default.
515AC_ARG_ENABLE([stats],
516  [AS_HELP_STRING([--disable-stats],
517                  [Disable statistics calculation/reporting])],
518[if test "x$enable_stats" = "xno" ; then
519  enable_stats="0"
520else
521  enable_stats="1"
522fi
523],
524[enable_stats="1"]
525)
526if test "x$enable_stats" = "x1" ; then
527  AC_DEFINE([JEMALLOC_STATS], [ ])
528fi
529AC_SUBST([enable_stats])
530
531dnl Do not enable profiling by default.
532AC_ARG_ENABLE([prof],
533  [AS_HELP_STRING([--enable-prof], [Enable allocation profiling])],
534[if test "x$enable_prof" = "xno" ; then
535  enable_prof="0"
536else
537  enable_prof="1"
538fi
539],
540[enable_prof="0"]
541)
542if test "x$enable_prof" = "x1" ; then
543  backtrace_method=""
544else
545  backtrace_method="N/A"
546fi
547
548AC_ARG_ENABLE([prof-libunwind],
549  [AS_HELP_STRING([--enable-prof-libunwind], [Use libunwind for backtracing])],
550[if test "x$enable_prof_libunwind" = "xno" ; then
551  enable_prof_libunwind="0"
552else
553  enable_prof_libunwind="1"
554fi
555],
556[enable_prof_libunwind="0"]
557)
558AC_ARG_WITH([static_libunwind],
559  [AS_HELP_STRING([--with-static-libunwind=<libunwind.a>],
560  [Path to static libunwind library; use rather than dynamically linking])],
561if test "x$with_static_libunwind" = "xno" ; then
562  LUNWIND="-lunwind"
563else
564  if test ! -f "$with_static_libunwind" ; then
565    AC_MSG_ERROR([Static libunwind not found: $with_static_libunwind])
566  fi
567  LUNWIND="$with_static_libunwind"
568fi,
569  LUNWIND="-lunwind"
570)
571if test "x$backtrace_method" = "x" -a "x$enable_prof_libunwind" = "x1" ; then
572  AC_CHECK_HEADERS([libunwind.h], , [enable_prof_libunwind="0"])
573  if test "x$LUNWIND" = "x-lunwind" ; then
574    AC_CHECK_LIB([unwind], [backtrace], [LIBS="$LIBS $LUNWIND"],
575                 [enable_prof_libunwind="0"])
576  else
577    LIBS="$LIBS $LUNWIND"
578  fi
579  if test "x${enable_prof_libunwind}" = "x1" ; then
580    backtrace_method="libunwind"
581    AC_DEFINE([JEMALLOC_PROF_LIBUNWIND], [ ])
582  fi
583fi
584
585AC_ARG_ENABLE([prof-libgcc],
586  [AS_HELP_STRING([--disable-prof-libgcc],
587  [Do not use libgcc for backtracing])],
588[if test "x$enable_prof_libgcc" = "xno" ; then
589  enable_prof_libgcc="0"
590else
591  enable_prof_libgcc="1"
592fi
593],
594[enable_prof_libgcc="1"]
595)
596if test "x$backtrace_method" = "x" -a "x$enable_prof_libgcc" = "x1" \
597     -a "x$GCC" = "xyes" ; then
598  AC_CHECK_HEADERS([unwind.h], , [enable_prof_libgcc="0"])
599  AC_CHECK_LIB([gcc], [_Unwind_Backtrace], [LIBS="$LIBS -lgcc"], [enable_prof_libgcc="0"])
600  dnl The following is conservative, in that it only has entries for CPUs on
601  dnl which jemalloc has been tested.
602  AC_MSG_CHECKING([libgcc-based backtracing reliability on ${host_cpu}])
603  case "${host_cpu}" in
604    i[[3456]]86)
605      AC_MSG_RESULT([unreliable])
606      enable_prof_libgcc="0";
607      ;;
608    x86_64)
609      AC_MSG_RESULT([reliable])
610      ;;
611    *)
612      AC_MSG_RESULT([unreliable])
613      enable_prof_libgcc="0";
614      ;;
615  esac
616  if test "x${enable_prof_libgcc}" = "x1" ; then
617    backtrace_method="libgcc"
618    AC_DEFINE([JEMALLOC_PROF_LIBGCC], [ ])
619  fi
620else
621  enable_prof_libgcc="0"
622fi
623
624AC_ARG_ENABLE([prof-gcc],
625  [AS_HELP_STRING([--disable-prof-gcc],
626  [Do not use gcc intrinsics for backtracing])],
627[if test "x$enable_prof_gcc" = "xno" ; then
628  enable_prof_gcc="0"
629else
630  enable_prof_gcc="1"
631fi
632],
633[enable_prof_gcc="1"]
634)
635if test "x$backtrace_method" = "x" -a "x$enable_prof_gcc" = "x1" \
636     -a "x$GCC" = "xyes" ; then
637  backtrace_method="gcc intrinsics"
638  AC_DEFINE([JEMALLOC_PROF_GCC], [ ])
639else
640  enable_prof_gcc="0"
641fi
642
643if test "x$backtrace_method" = "x" ; then
644  backtrace_method="none (disabling profiling)"
645  enable_prof="0"
646fi
647AC_MSG_CHECKING([configured backtracing method])
648AC_MSG_RESULT([$backtrace_method])
649if test "x$enable_prof" = "x1" ; then
650  AC_DEFINE([JEMALLOC_PROF], [ ])
651fi
652AC_SUBST([enable_prof])
653
654dnl Enable thread-specific caching by default.
655AC_ARG_ENABLE([tcache],
656  [AS_HELP_STRING([--disable-tcache], [Disable per thread caches])],
657[if test "x$enable_tcache" = "xno" ; then
658  enable_tcache="0"
659else
660  enable_tcache="1"
661fi
662],
663[enable_tcache="1"]
664)
665if test "x$enable_tcache" = "x1" ; then
666  AC_DEFINE([JEMALLOC_TCACHE], [ ])
667fi
668AC_SUBST([enable_tcache])
669
670dnl Do not enable allocation from DSS by default.
671AC_ARG_ENABLE([dss],
672  [AS_HELP_STRING([--enable-dss], [Enable allocation from DSS])],
673[if test "x$enable_dss" = "xno" ; then
674  enable_dss="0"
675else
676  enable_dss="1"
677fi
678],
679[enable_dss="0"]
680)
681dnl Check whether the BSD/SUSv1 sbrk() exists.  If not, disable DSS support.
682AC_CHECK_FUNC([sbrk], [have_sbrk="1"], [have_sbrk="0"])
683if test "x$have_sbrk" = "x1" ; then
684  AC_DEFINE([JEMALLOC_HAVE_SBRK], [ ])
685else
686  enable_dss="0"
687fi
688
689if test "x$enable_dss" = "x1" ; then
690  AC_DEFINE([JEMALLOC_DSS], [ ])
691fi
692AC_SUBST([enable_dss])
693
694dnl Support the junk/zero filling option by default.
695AC_ARG_ENABLE([fill],
696  [AS_HELP_STRING([--disable-fill],
697                  [Disable support for junk/zero filling, quarantine, and redzones])],
698[if test "x$enable_fill" = "xno" ; then
699  enable_fill="0"
700else
701  enable_fill="1"
702fi
703],
704[enable_fill="1"]
705)
706if test "x$enable_fill" = "x1" ; then
707  AC_DEFINE([JEMALLOC_FILL], [ ])
708fi
709AC_SUBST([enable_fill])
710
711dnl Disable utrace(2)-based tracing by default.
712AC_ARG_ENABLE([utrace],
713  [AS_HELP_STRING([--enable-utrace], [Enable utrace(2)-based tracing])],
714[if test "x$enable_utrace" = "xno" ; then
715  enable_utrace="0"
716else
717  enable_utrace="1"
718fi
719],
720[enable_utrace="0"]
721)
722JE_COMPILABLE([utrace(2)], [
723#include <sys/types.h>
724#include <sys/param.h>
725#include <sys/time.h>
726#include <sys/uio.h>
727#include <sys/ktrace.h>
728], [
729	utrace((void *)0, 0);
730], [je_cv_utrace])
731if test "x${je_cv_utrace}" = "xno" ; then
732  enable_utrace="0"
733fi
734if test "x$enable_utrace" = "x1" ; then
735  AC_DEFINE([JEMALLOC_UTRACE], [ ])
736fi
737AC_SUBST([enable_utrace])
738
739dnl Support Valgrind by default.
740AC_ARG_ENABLE([valgrind],
741  [AS_HELP_STRING([--disable-valgrind], [Disable support for Valgrind])],
742[if test "x$enable_valgrind" = "xno" ; then
743  enable_valgrind="0"
744else
745  enable_valgrind="1"
746fi
747],
748[enable_valgrind="1"]
749)
750if test "x$enable_valgrind" = "x1" ; then
751  JE_COMPILABLE([valgrind], [
752#include <valgrind/valgrind.h>
753#include <valgrind/memcheck.h>
754
755#if defined(__VALGRIND_MAJOR__) && defined(__VALGRIND_MINOR__)		\
756    && (__VALGRIND_MAJOR__ > 3 || (__VALGRIND_MAJOR__ == 3 &&		\
757    __VALGRIND_MINOR__ >= 6))
758#else
759#  error "Incompatible Valgrind version"
760#endif
761], [], [je_cv_valgrind])
762  if test "x${je_cv_valgrind}" = "xno" ; then
763    enable_valgrind="0"
764  fi
765  if test "x$enable_valgrind" = "x1" ; then
766    AC_DEFINE([JEMALLOC_VALGRIND], [ ])
767  fi
768fi
769AC_SUBST([enable_valgrind])
770
771dnl Do not support the xmalloc option by default.
772AC_ARG_ENABLE([xmalloc],
773  [AS_HELP_STRING([--enable-xmalloc], [Support xmalloc option])],
774[if test "x$enable_xmalloc" = "xno" ; then
775  enable_xmalloc="0"
776else
777  enable_xmalloc="1"
778fi
779],
780[enable_xmalloc="0"]
781)
782if test "x$enable_xmalloc" = "x1" ; then
783  AC_DEFINE([JEMALLOC_XMALLOC], [ ])
784fi
785AC_SUBST([enable_xmalloc])
786
787AC_CACHE_CHECK([STATIC_PAGE_SHIFT],
788               [je_cv_static_page_shift],
789               AC_RUN_IFELSE([AC_LANG_PROGRAM(
790[[#include <stdio.h>
791#include <unistd.h>
792#include <strings.h>
793]],
794[[
795    long result;
796    FILE *f;
797
798    result = sysconf(_SC_PAGESIZE);
799    if (result == -1) {
800	return 1;
801    }
802    f = fopen("conftest.out", "w");
803    if (f == NULL) {
804	return 1;
805    }
806    fprintf(f, "%u\n", ffs((int)result) - 1);
807    fclose(f);
808
809    return 0;
810]])],
811                             [je_cv_static_page_shift=`cat conftest.out`],
812                             [je_cv_static_page_shift=undefined]))
813
814if test "x$je_cv_static_page_shift" != "xundefined"; then
815   AC_DEFINE_UNQUOTED([STATIC_PAGE_SHIFT], [$je_cv_static_page_shift])
816else
817   AC_MSG_ERROR([cannot determine value for STATIC_PAGE_SHIFT])
818fi
819
820dnl Determine whether common sequences of mmap()/munmap() calls will leave
821dnl semi-permanent VM map holes.  If so, disable munmap.
822AC_CACHE_CHECK([whether munmap() leaves semi-permanent VM map holes],
823               [je_cv_vmmap_hole],
824               AC_RUN_IFELSE([AC_LANG_PROGRAM(
825[[#include <stdio.h>
826#include <stdlib.h>
827#include <sys/mman.h>
828
829#define	MMAP_SIZE	((size_t)(1U << 22))
830
831static void *
832do_mmap(size_t size)
833{
834	void *ret;
835
836	ret = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1,
837	    0);
838	if (ret == MAP_FAILED) {
839		fprintf(stderr, "mmap() error\n");
840		exit(1);
841	}
842
843	return (ret);
844}
845
846static void
847do_munmap(void *ptr, size_t size)
848{
849	if (munmap(ptr, size) == -1) {
850		fprintf(stderr, "munmap() error\n");
851		exit(1);
852	}
853}
854]],
855[[
856	void *p0, *p1, *p2, *p3, *p4;
857	FILE *f;
858
859	f = fopen("conftest.out", "w");
860	if (f == NULL)
861		exit(1);
862
863	p0 = do_mmap(MMAP_SIZE);
864	p1 = do_mmap(MMAP_SIZE);
865	p2 = do_mmap(MMAP_SIZE);
866	do_munmap(p1, MMAP_SIZE);
867	p3 = do_mmap(MMAP_SIZE * 2);
868	do_munmap(p3, MMAP_SIZE * 2);
869	p4 = do_mmap(MMAP_SIZE);
870	if (p4 != p1) {
871		fprintf(stderr, "Hoped for %p, got %p\n", p1, p4);
872		fprintf(stderr, "%p..%p..%p..%p..%p\n", p0, p1, p2, p3, p4);
873		fprintf(f, "yes\n");
874	} else
875		fprintf(f, "no\n");
876
877	fclose(f);
878	return (0);
879]])],
880                             [je_cv_vmmap_hole=`cat conftest.out`],
881                             [je_cv_vmmap_hole=unknown]))
882if test "x$je_cv_vmmap_hole" = "xno" ; then
883  AC_DEFINE([JEMALLOC_MUNMAP], [ ])
884fi
885
886dnl ============================================================================
887dnl jemalloc configuration.
888dnl 
889
890dnl Set VERSION if source directory has an embedded git repository.
891if test -d "${srcroot}.git" ; then
892  git describe --long --abbrev=40 > ${srcroot}VERSION
893fi
894jemalloc_version=`cat ${srcroot}VERSION`
895jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'`
896jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'`
897jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'`
898jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'`
899jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'`
900AC_SUBST([jemalloc_version])
901AC_SUBST([jemalloc_version_major])
902AC_SUBST([jemalloc_version_minor])
903AC_SUBST([jemalloc_version_bugfix])
904AC_SUBST([jemalloc_version_nrev])
905AC_SUBST([jemalloc_version_gid])
906
907dnl ============================================================================
908dnl Configure pthreads.
909
910AC_CHECK_HEADERS([pthread.h], , [AC_MSG_ERROR([pthread.h is missing])])
911dnl Some systems may embed pthreads functionality in libc; check for libpthread
912dnl first, but try libc too before failing.
913AC_CHECK_LIB([pthread], [pthread_create], [LIBS="$LIBS -lpthread"],
914             [AC_SEARCH_LIBS([pthread_create], , ,
915                             AC_MSG_ERROR([libpthread is missing]))])
916
917CPPFLAGS="$CPPFLAGS -D_REENTRANT"
918
919dnl Check whether the BSD-specific _malloc_thread_cleanup() exists.  If so, use
920dnl it rather than pthreads TSD cleanup functions to support cleanup during
921dnl thread exit, in order to avoid pthreads library recursion during
922dnl bootstrapping.
923AC_CHECK_FUNC([_malloc_thread_cleanup],
924              [have__malloc_thread_cleanup="1"],
925              [have__malloc_thread_cleanup="0"]
926             )
927if test "x$have__malloc_thread_cleanup" = "x1" ; then
928  AC_DEFINE([JEMALLOC_MALLOC_THREAD_CLEANUP], [ ])
929  force_tls="1"
930fi
931
932dnl Check whether the BSD-specific _pthread_mutex_init_calloc_cb() exists.  If
933dnl so, mutex initialization causes allocation, and we need to implement this
934dnl callback function in order to prevent recursive allocation.
935AC_CHECK_FUNC([_pthread_mutex_init_calloc_cb],
936              [have__pthread_mutex_init_calloc_cb="1"],
937              [have__pthread_mutex_init_calloc_cb="0"]
938             )
939if test "x$have__pthread_mutex_init_calloc_cb" = "x1" ; then
940  AC_DEFINE([JEMALLOC_MUTEX_INIT_CB])
941fi
942
943dnl Disable lazy locking by default.
944AC_ARG_ENABLE([lazy_lock],
945  [AS_HELP_STRING([--enable-lazy-lock],
946  [Enable lazy locking (only lock when multi-threaded)])],
947[if test "x$enable_lazy_lock" = "xno" ; then
948  enable_lazy_lock="0"
949else
950  enable_lazy_lock="1"
951fi
952],
953[enable_lazy_lock="0"]
954)
955if test "x$enable_lazy_lock" = "x0" -a "x${force_lazy_lock}" = "x1" ; then
956  AC_MSG_RESULT([Forcing lazy-lock to avoid allocator/threading bootstrap issues])
957  enable_lazy_lock="1"
958fi
959if test "x$enable_lazy_lock" = "x1" ; then
960  AC_CHECK_HEADERS([dlfcn.h], , [AC_MSG_ERROR([dlfcn.h is missing])])
961  AC_CHECK_FUNC([dlsym], [],
962    [AC_CHECK_LIB([dl], [dlsym], [LIBS="$LIBS -ldl"],
963                  [AC_MSG_ERROR([libdl is missing])])
964    ])
965  AC_DEFINE([JEMALLOC_LAZY_LOCK], [ ])
966fi
967AC_SUBST([enable_lazy_lock])
968
969AC_ARG_ENABLE([tls],
970  [AS_HELP_STRING([--disable-tls], [Disable thread-local storage (__thread keyword)])],
971if test "x$enable_tls" = "xno" ; then
972  enable_tls="0"
973else
974  enable_tls="1"
975fi
976,
977enable_tls="1"
978)
979if test "x${enable_tls}" = "x0" -a "x${force_tls}" = "x1" ; then
980  AC_MSG_RESULT([Forcing TLS to avoid allocator/threading bootstrap issues])
981  enable_tls="1"
982fi
983if test "x${enable_tls}" = "x1" -a "x${force_tls}" = "x0" ; then
984  AC_MSG_RESULT([Forcing no TLS to avoid allocator/threading bootstrap issues])
985  enable_tls="0"
986fi
987if test "x${enable_tls}" = "x1" ; then
988AC_MSG_CHECKING([for TLS])
989AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
990[[
991    __thread int x;
992]], [[
993    x = 42;
994
995    return 0;
996]])],
997              AC_MSG_RESULT([yes]),
998              AC_MSG_RESULT([no])
999              enable_tls="0")
1000fi
1001AC_SUBST([enable_tls])
1002if test "x${enable_tls}" = "x1" ; then
1003  AC_DEFINE_UNQUOTED([JEMALLOC_TLS], [ ])
1004elif test "x${force_tls}" = "x1" ; then
1005  AC_MSG_ERROR([Failed to configure TLS, which is mandatory for correct function])
1006fi
1007
1008dnl ============================================================================
1009dnl Check for ffsl(3), and fail if not found.  This function exists on all
1010dnl platforms that jemalloc currently has a chance of functioning on without
1011dnl modification.
1012JE_COMPILABLE([a program using ffsl], [
1013#include <strings.h>
1014#include <string.h>
1015], [
1016	{
1017		int rv = ffsl(0x08);
1018	}
1019], [je_cv_function_ffsl])
1020if test "x${je_cv_function_ffsl}" != "xyes" ; then
1021   AC_MSG_ERROR([Cannot build without ffsl(3)])
1022fi
1023
1024dnl ============================================================================
1025dnl Check for atomic(3) operations as provided on Darwin.
1026
1027JE_COMPILABLE([Darwin OSAtomic*()], [
1028#include <libkern/OSAtomic.h>
1029#include <inttypes.h>
1030], [
1031	{
1032		int32_t x32 = 0;
1033		volatile int32_t *x32p = &x32;
1034		OSAtomicAdd32(1, x32p);
1035	}
1036	{
1037		int64_t x64 = 0;
1038		volatile int64_t *x64p = &x64;
1039		OSAtomicAdd64(1, x64p);
1040	}
1041], [je_cv_osatomic])
1042if test "x${je_cv_osatomic}" = "xyes" ; then
1043  AC_DEFINE([JEMALLOC_OSATOMIC], [ ])
1044fi
1045
1046dnl ============================================================================
1047dnl Check whether __sync_{add,sub}_and_fetch() are available despite
1048dnl __GCC_HAVE_SYNC_COMPARE_AND_SWAP_n macros being undefined.
1049
1050AC_DEFUN([JE_SYNC_COMPARE_AND_SWAP_CHECK],[
1051  AC_CACHE_CHECK([whether to force $1-bit __sync_{add,sub}_and_fetch()],
1052               [je_cv_sync_compare_and_swap_$2],
1053               [AC_LINK_IFELSE([AC_LANG_PROGRAM([
1054                                                 #include <stdint.h>
1055                                                ],
1056                                                [
1057                                                 #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2
1058                                                 {
1059                                                    uint$1_t x$1 = 0;
1060                                                    __sync_add_and_fetch(&x$1, 42);
1061                                                    __sync_sub_and_fetch(&x$1, 1);
1062                                                 }
1063                                                 #else
1064                                                 #error __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2 is defined, no need to force
1065                                                 #endif
1066                                                ])],
1067                               [je_cv_sync_compare_and_swap_$2=yes],
1068                               [je_cv_sync_compare_and_swap_$2=no])])
1069
1070  if test "x${je_cv_sync_compare_and_swap_$2}" = "xyes" ; then
1071    AC_DEFINE([JE_FORCE_SYNC_COMPARE_AND_SWAP_$2], [ ])
1072  fi
1073])
1074
1075if test "x${je_cv_osatomic}" != "xyes" ; then
1076  JE_SYNC_COMPARE_AND_SWAP_CHECK(32, 4)
1077  JE_SYNC_COMPARE_AND_SWAP_CHECK(64, 8)
1078fi
1079
1080dnl ============================================================================
1081dnl Check for spinlock(3) operations as provided on Darwin.
1082
1083JE_COMPILABLE([Darwin OSSpin*()], [
1084#include <libkern/OSAtomic.h>
1085#include <inttypes.h>
1086], [
1087	OSSpinLock lock = 0;
1088	OSSpinLockLock(&lock);
1089	OSSpinLockUnlock(&lock);
1090], [je_cv_osspin])
1091if test "x${je_cv_osspin}" = "xyes" ; then
1092  AC_DEFINE([JEMALLOC_OSSPIN], [ ])
1093fi
1094
1095dnl ============================================================================
1096dnl Darwin-related configuration.
1097
1098if test "x${abi}" = "xmacho" ; then
1099  AC_DEFINE([JEMALLOC_IVSALLOC], [ ])
1100  AC_DEFINE([JEMALLOC_ZONE], [ ])
1101
1102  dnl The szone version jumped from 3 to 6 between the OS X 10.5.x and 10.6
1103  dnl releases.  malloc_zone_t and malloc_introspection_t have new fields in
1104  dnl 10.6, which is the only source-level indication of the change.
1105  AC_MSG_CHECKING([malloc zone version])
1106  AC_DEFUN([JE_ZONE_PROGRAM],
1107    [AC_LANG_PROGRAM(
1108      [#include <malloc/malloc.h>],
1109      [static foo[[sizeof($1) $2 sizeof(void *) * $3 ? 1 : -1]]]
1110    )])
1111
1112  AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,14)],[JEMALLOC_ZONE_VERSION=3],[
1113  AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,15)],[JEMALLOC_ZONE_VERSION=5],[
1114  AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,16)],[
1115    AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,9)],[JEMALLOC_ZONE_VERSION=6],[
1116    AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,13)],[JEMALLOC_ZONE_VERSION=7],[JEMALLOC_ZONE_VERSION=]
1117  )])],[
1118  AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,17)],[JEMALLOC_ZONE_VERSION=8],[
1119  AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,>,17)],[JEMALLOC_ZONE_VERSION=9],[JEMALLOC_ZONE_VERSION=]
1120  )])])])])
1121  if test "x${JEMALLOC_ZONE_VERSION}" = "x"; then
1122    AC_MSG_RESULT([unsupported])
1123    AC_MSG_ERROR([Unsupported malloc zone version])
1124  fi
1125  if test "${JEMALLOC_ZONE_VERSION}" = 9; then
1126    JEMALLOC_ZONE_VERSION=8
1127    AC_MSG_RESULT([> 8])
1128  else
1129    AC_MSG_RESULT([$JEMALLOC_ZONE_VERSION])
1130  fi
1131  AC_DEFINE_UNQUOTED(JEMALLOC_ZONE_VERSION, [$JEMALLOC_ZONE_VERSION])
1132fi
1133
1134dnl ============================================================================
1135dnl Check for typedefs, structures, and compiler characteristics.
1136AC_HEADER_STDBOOL
1137
1138AC_CONFIG_COMMANDS([include/jemalloc/internal/size_classes.h], [
1139  mkdir -p "include/jemalloc/internal"
1140  "${srcdir}/include/jemalloc/internal/size_classes.sh" > "${objroot}include/jemalloc/internal/size_classes.h"
1141])
1142
1143dnl Process .in files.
1144AC_SUBST([cfghdrs_in])
1145AC_SUBST([cfghdrs_out])
1146AC_CONFIG_HEADERS([$cfghdrs_tup])
1147
1148dnl ============================================================================
1149dnl Generate outputs.
1150AC_CONFIG_FILES([$cfgoutputs_tup config.stamp bin/jemalloc.sh])
1151AC_SUBST([cfgoutputs_in])
1152AC_SUBST([cfgoutputs_out])
1153AC_OUTPUT
1154
1155dnl ============================================================================
1156dnl Print out the results of configuration.
1157AC_MSG_RESULT([===============================================================================])
1158AC_MSG_RESULT([jemalloc version   : ${jemalloc_version}])
1159AC_MSG_RESULT([library revision   : ${rev}])
1160AC_MSG_RESULT([])
1161AC_MSG_RESULT([CC                 : ${CC}])
1162AC_MSG_RESULT([CPPFLAGS           : ${CPPFLAGS}])
1163AC_MSG_RESULT([CFLAGS             : ${CFLAGS}])
1164AC_MSG_RESULT([LDFLAGS            : ${LDFLAGS}])
1165AC_MSG_RESULT([LIBS               : ${LIBS}])
1166AC_MSG_RESULT([RPATH_EXTRA        : ${RPATH_EXTRA}])
1167AC_MSG_RESULT([])
1168AC_MSG_RESULT([XSLTPROC           : ${XSLTPROC}])
1169AC_MSG_RESULT([XSLROOT            : ${XSLROOT}])
1170AC_MSG_RESULT([])
1171AC_MSG_RESULT([PREFIX             : ${PREFIX}])
1172AC_MSG_RESULT([BINDIR             : ${BINDIR}])
1173AC_MSG_RESULT([INCLUDEDIR         : ${INCLUDEDIR}])
1174AC_MSG_RESULT([LIBDIR             : ${LIBDIR}])
1175AC_MSG_RESULT([DATADIR            : ${DATADIR}])
1176AC_MSG_RESULT([MANDIR             : ${MANDIR}])
1177AC_MSG_RESULT([])
1178AC_MSG_RESULT([srcroot            : ${srcroot}])
1179AC_MSG_RESULT([abs_srcroot        : ${abs_srcroot}])
1180AC_MSG_RESULT([objroot            : ${objroot}])
1181AC_MSG_RESULT([abs_objroot        : ${abs_objroot}])
1182AC_MSG_RESULT([])
1183AC_MSG_RESULT([JEMALLOC_PREFIX    : ${JEMALLOC_PREFIX}])
1184AC_MSG_RESULT([JEMALLOC_PRIVATE_NAMESPACE])
1185AC_MSG_RESULT([                   : ${JEMALLOC_PRIVATE_NAMESPACE}])
1186AC_MSG_RESULT([install_suffix     : ${install_suffix}])
1187AC_MSG_RESULT([autogen            : ${enable_autogen}])
1188AC_MSG_RESULT([experimental       : ${enable_experimental}])
1189AC_MSG_RESULT([cc-silence         : ${enable_cc_silence}])
1190AC_MSG_RESULT([debug              : ${enable_debug}])
1191AC_MSG_RESULT([stats              : ${enable_stats}])
1192AC_MSG_RESULT([prof               : ${enable_prof}])
1193AC_MSG_RESULT([prof-libunwind     : ${enable_prof_libunwind}])
1194AC_MSG_RESULT([prof-libgcc        : ${enable_prof_libgcc}])
1195AC_MSG_RESULT([prof-gcc           : ${enable_prof_gcc}])
1196AC_MSG_RESULT([tcache             : ${enable_tcache}])
1197AC_MSG_RESULT([fill               : ${enable_fill}])
1198AC_MSG_RESULT([utrace             : ${enable_utrace}])
1199AC_MSG_RESULT([valgrind           : ${enable_valgrind}])
1200AC_MSG_RESULT([xmalloc            : ${enable_xmalloc}])
1201AC_MSG_RESULT([dss                : ${enable_dss}])
1202AC_MSG_RESULT([lazy_lock          : ${enable_lazy_lock}])
1203AC_MSG_RESULT([tls                : ${enable_tls}])
1204AC_MSG_RESULT([===============================================================================])
1205