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              [je_cv_cflags_appended=$1]
23              AC_MSG_RESULT([yes]),
24              [je_cv_cflags_appended=]
25              AC_MSG_RESULT([no])
26              [CFLAGS="${TCFLAGS}"]
27)
28])
29
30dnl JE_COMPILABLE(label, hcode, mcode, rvar)
31dnl
32dnl Use AC_LINK_IFELSE() rather than AC_COMPILE_IFELSE() so that linker errors
33dnl cause failure.
34AC_DEFUN([JE_COMPILABLE],
35[
36AC_CACHE_CHECK([whether $1 is compilable],
37               [$4],
38               [AC_LINK_IFELSE([AC_LANG_PROGRAM([$2],
39                                                [$3])],
40                               [$4=yes],
41                               [$4=no])])
42])
43
44dnl ============================================================================
45
46CONFIG=`echo ${ac_configure_args} | sed -e 's#'"'"'\([^ ]*\)'"'"'#\1#g'`
47AC_SUBST([CONFIG])
48
49dnl Library revision.
50rev=2
51AC_SUBST([rev])
52
53srcroot=$srcdir
54if test "x${srcroot}" = "x." ; then
55  srcroot=""
56else
57  srcroot="${srcroot}/"
58fi
59AC_SUBST([srcroot])
60abs_srcroot="`cd \"${srcdir}\"; pwd`/"
61AC_SUBST([abs_srcroot])
62
63objroot=""
64AC_SUBST([objroot])
65abs_objroot="`pwd`/"
66AC_SUBST([abs_objroot])
67
68dnl Munge install path variables.
69if test "x$prefix" = "xNONE" ; then
70  prefix="/usr/local"
71fi
72if test "x$exec_prefix" = "xNONE" ; then
73  exec_prefix=$prefix
74fi
75PREFIX=$prefix
76AC_SUBST([PREFIX])
77BINDIR=`eval echo $bindir`
78BINDIR=`eval echo $BINDIR`
79AC_SUBST([BINDIR])
80INCLUDEDIR=`eval echo $includedir`
81INCLUDEDIR=`eval echo $INCLUDEDIR`
82AC_SUBST([INCLUDEDIR])
83LIBDIR=`eval echo $libdir`
84LIBDIR=`eval echo $LIBDIR`
85AC_SUBST([LIBDIR])
86DATADIR=`eval echo $datadir`
87DATADIR=`eval echo $DATADIR`
88AC_SUBST([DATADIR])
89MANDIR=`eval echo $mandir`
90MANDIR=`eval echo $MANDIR`
91AC_SUBST([MANDIR])
92
93dnl Support for building documentation.
94AC_PATH_PROG([XSLTPROC], [xsltproc], [false], [$PATH])
95if test -d "/usr/share/xml/docbook/stylesheet/docbook-xsl" ; then
96  DEFAULT_XSLROOT="/usr/share/xml/docbook/stylesheet/docbook-xsl"
97elif test -d "/usr/share/sgml/docbook/xsl-stylesheets" ; then
98  DEFAULT_XSLROOT="/usr/share/sgml/docbook/xsl-stylesheets"
99else
100  dnl Documentation building will fail if this default gets used.
101  DEFAULT_XSLROOT=""
102fi
103AC_ARG_WITH([xslroot],
104  [AS_HELP_STRING([--with-xslroot=<path>], [XSL stylesheet root path])], [
105if test "x$with_xslroot" = "xno" ; then
106  XSLROOT="${DEFAULT_XSLROOT}"
107else
108  XSLROOT="${with_xslroot}"
109fi
110],
111  XSLROOT="${DEFAULT_XSLROOT}"
112)
113AC_SUBST([XSLROOT])
114
115dnl If CFLAGS isn't defined, set CFLAGS to something reasonable.  Otherwise,
116dnl just prevent autoconf from molesting CFLAGS.
117CFLAGS=$CFLAGS
118AC_PROG_CC
119if test "x$GCC" != "xyes" ; then
120  AC_CACHE_CHECK([whether compiler is MSVC],
121                 [je_cv_msvc],
122                 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
123                                                     [
124#ifndef _MSC_VER
125  int fail[-1];
126#endif
127])],
128                               [je_cv_msvc=yes],
129                               [je_cv_msvc=no])])
130fi
131
132if test "x$CFLAGS" = "x" ; then
133  no_CFLAGS="yes"
134  if test "x$GCC" = "xyes" ; then
135    JE_CFLAGS_APPEND([-std=gnu99])
136    if test "x$je_cv_cflags_appended" = "x-std=gnu99" ; then
137      AC_DEFINE_UNQUOTED([JEMALLOC_HAS_RESTRICT])
138    fi
139    JE_CFLAGS_APPEND([-Wall])
140    JE_CFLAGS_APPEND([-Werror=declaration-after-statement])
141    JE_CFLAGS_APPEND([-pipe])
142    JE_CFLAGS_APPEND([-g3])
143  elif test "x$je_cv_msvc" = "xyes" ; then
144    CC="$CC -nologo"
145    JE_CFLAGS_APPEND([-Zi])
146    JE_CFLAGS_APPEND([-MT])
147    JE_CFLAGS_APPEND([-W3])
148    JE_CFLAGS_APPEND([-FS])
149    CPPFLAGS="$CPPFLAGS -I${srcdir}/include/msvc_compat"
150  fi
151fi
152dnl Append EXTRA_CFLAGS to CFLAGS, if defined.
153if test "x$EXTRA_CFLAGS" != "x" ; then
154  JE_CFLAGS_APPEND([$EXTRA_CFLAGS])
155fi
156AC_PROG_CPP
157
158AC_C_BIGENDIAN([ac_cv_big_endian=1], [ac_cv_big_endian=0])
159if test "x${ac_cv_big_endian}" = "x1" ; then
160  AC_DEFINE_UNQUOTED([JEMALLOC_BIG_ENDIAN], [ ])
161fi
162
163if test "x${je_cv_msvc}" = "xyes" -a "x${ac_cv_header_inttypes_h}" = "xno"; then
164  CPPFLAGS="$CPPFLAGS -I${srcdir}/include/msvc_compat/C99"
165fi
166
167AC_CHECK_SIZEOF([void *])
168if test "x${ac_cv_sizeof_void_p}" = "x8" ; then
169  LG_SIZEOF_PTR=3
170elif test "x${ac_cv_sizeof_void_p}" = "x4" ; then
171  LG_SIZEOF_PTR=2
172else
173  AC_MSG_ERROR([Unsupported pointer size: ${ac_cv_sizeof_void_p}])
174fi
175AC_DEFINE_UNQUOTED([LG_SIZEOF_PTR], [$LG_SIZEOF_PTR])
176
177AC_CHECK_SIZEOF([int])
178if test "x${ac_cv_sizeof_int}" = "x8" ; then
179  LG_SIZEOF_INT=3
180elif test "x${ac_cv_sizeof_int}" = "x4" ; then
181  LG_SIZEOF_INT=2
182else
183  AC_MSG_ERROR([Unsupported int size: ${ac_cv_sizeof_int}])
184fi
185AC_DEFINE_UNQUOTED([LG_SIZEOF_INT], [$LG_SIZEOF_INT])
186
187AC_CHECK_SIZEOF([long])
188if test "x${ac_cv_sizeof_long}" = "x8" ; then
189  LG_SIZEOF_LONG=3
190elif test "x${ac_cv_sizeof_long}" = "x4" ; then
191  LG_SIZEOF_LONG=2
192else
193  AC_MSG_ERROR([Unsupported long size: ${ac_cv_sizeof_long}])
194fi
195AC_DEFINE_UNQUOTED([LG_SIZEOF_LONG], [$LG_SIZEOF_LONG])
196
197AC_CHECK_SIZEOF([intmax_t])
198if test "x${ac_cv_sizeof_intmax_t}" = "x16" ; then
199  LG_SIZEOF_INTMAX_T=4
200elif test "x${ac_cv_sizeof_intmax_t}" = "x8" ; then
201  LG_SIZEOF_INTMAX_T=3
202elif test "x${ac_cv_sizeof_intmax_t}" = "x4" ; then
203  LG_SIZEOF_INTMAX_T=2
204else
205  AC_MSG_ERROR([Unsupported intmax_t size: ${ac_cv_sizeof_intmax_t}])
206fi
207AC_DEFINE_UNQUOTED([LG_SIZEOF_INTMAX_T], [$LG_SIZEOF_INTMAX_T])
208
209AC_CANONICAL_HOST
210dnl CPU-specific settings.
211CPU_SPINWAIT=""
212case "${host_cpu}" in
213  i686|x86_64)
214	AC_CACHE_VAL([je_cv_pause],
215	  [JE_COMPILABLE([pause instruction], [],
216	                [[__asm__ volatile("pause"); return 0;]],
217	                [je_cv_pause])])
218	if test "x${je_cv_pause}" = "xyes" ; then
219	    CPU_SPINWAIT='__asm__ volatile("pause")'
220	fi
221	;;
222  powerpc)
223	AC_DEFINE_UNQUOTED([HAVE_ALTIVEC], [ ])
224	;;
225  *)
226	;;
227esac
228AC_DEFINE_UNQUOTED([CPU_SPINWAIT], [$CPU_SPINWAIT])
229
230LD_PRELOAD_VAR="LD_PRELOAD"
231so="so"
232importlib="${so}"
233o="$ac_objext"
234a="a"
235exe="$ac_exeext"
236libprefix="lib"
237DSO_LDFLAGS='-shared -Wl,-soname,$(@F)'
238RPATH='-Wl,-rpath,$(1)'
239SOREV="${so}.${rev}"
240PIC_CFLAGS='-fPIC -DPIC'
241CTARGET='-o $@'
242LDTARGET='-o $@'
243EXTRA_LDFLAGS=
244ARFLAGS='crus'
245AROUT=' $@'
246CC_MM=1
247
248AN_MAKEVAR([AR], [AC_PROG_AR])
249AN_PROGRAM([ar], [AC_PROG_AR])
250AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL(AR, ar, :)])
251AC_PROG_AR
252
253dnl Platform-specific settings.  abi and RPATH can probably be determined
254dnl programmatically, but doing so is error-prone, which makes it generally
255dnl not worth the trouble.
256dnl
257dnl Define cpp macros in CPPFLAGS, rather than doing AC_DEFINE(macro), since the
258dnl definitions need to be seen before any headers are included, which is a pain
259dnl to make happen otherwise.
260default_munmap="1"
261case "${host}" in
262  *-*-darwin* | *-*-ios*)
263	CFLAGS="$CFLAGS"
264	abi="macho"
265	AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
266	RPATH=""
267	LD_PRELOAD_VAR="DYLD_INSERT_LIBRARIES"
268	so="dylib"
269	importlib="${so}"
270	force_tls="0"
271	DSO_LDFLAGS='-shared -Wl,-install_name,$(LIBDIR)/$(@F)'
272	SOREV="${rev}.${so}"
273	sbrk_deprecated="1"
274	;;
275  *-*-freebsd*)
276	CFLAGS="$CFLAGS"
277	abi="elf"
278	AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
279	force_lazy_lock="1"
280	;;
281  *-*-dragonfly*)
282	CFLAGS="$CFLAGS"
283	abi="elf"
284	AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
285	;;
286  *-*-openbsd*|*-*-bitrig*)
287	CFLAGS="$CFLAGS"
288	abi="elf"
289	AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
290	;;
291  *-*-linux*)
292	CFLAGS="$CFLAGS"
293	CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
294	abi="elf"
295	AC_DEFINE([JEMALLOC_HAS_ALLOCA_H])
296	AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED], [ ])
297	AC_DEFINE([JEMALLOC_THREADED_INIT], [ ])
298	default_munmap="0"
299	;;
300  *-*-netbsd*)
301	AC_MSG_CHECKING([ABI])
302        AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
303[[#ifdef __ELF__
304/* ELF */
305#else
306#error aout
307#endif
308]])],
309                          [CFLAGS="$CFLAGS"; abi="elf"],
310                          [abi="aout"])
311	AC_MSG_RESULT([$abi])
312	AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
313	;;
314  *-*-solaris2*)
315	CFLAGS="$CFLAGS"
316	abi="elf"
317	AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
318	RPATH='-Wl,-R,$(1)'
319	dnl Solaris needs this for sigwait().
320	CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
321	LIBS="$LIBS -lposix4 -lsocket -lnsl"
322	;;
323  *-ibm-aix*)
324	if "$LG_SIZEOF_PTR" = "8"; then
325	  dnl 64bit AIX
326	  LD_PRELOAD_VAR="LDR_PRELOAD64"
327	else
328	  dnl 32bit AIX
329	  LD_PRELOAD_VAR="LDR_PRELOAD"
330	fi
331	abi="xcoff"
332	;;
333  *-*-mingw* | *-*-cygwin*)
334	abi="pecoff"
335	force_tls="0"
336	RPATH=""
337	so="dll"
338	if test "x$je_cv_msvc" = "xyes" ; then
339	  importlib="lib"
340	  DSO_LDFLAGS="-LD"
341	  EXTRA_LDFLAGS="-link -DEBUG"
342	  CTARGET='-Fo$@'
343	  LDTARGET='-Fe$@'
344	  AR='lib'
345	  ARFLAGS='-nologo -out:'
346	  AROUT='$@'
347	  CC_MM=
348        else
349	  importlib="${so}"
350	  DSO_LDFLAGS="-shared"
351	fi
352	a="lib"
353	libprefix=""
354	SOREV="${so}"
355	PIC_CFLAGS=""
356	;;
357  *)
358	AC_MSG_RESULT([Unsupported operating system: ${host}])
359	abi="elf"
360	;;
361esac
362
363JEMALLOC_USABLE_SIZE_CONST=const
364AC_CHECK_HEADERS([malloc.h], [
365  AC_MSG_CHECKING([whether malloc_usable_size definition can use const argument])
366  AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
367    [#include <malloc.h>
368     #include <stddef.h>
369    size_t malloc_usable_size(const void *ptr);
370    ],
371    [])],[
372                AC_MSG_RESULT([yes])
373         ],[
374                JEMALLOC_USABLE_SIZE_CONST=
375                AC_MSG_RESULT([no])
376         ])
377])
378AC_DEFINE_UNQUOTED([JEMALLOC_USABLE_SIZE_CONST], [$JEMALLOC_USABLE_SIZE_CONST])
379AC_SUBST([abi])
380AC_SUBST([RPATH])
381AC_SUBST([LD_PRELOAD_VAR])
382AC_SUBST([so])
383AC_SUBST([importlib])
384AC_SUBST([o])
385AC_SUBST([a])
386AC_SUBST([exe])
387AC_SUBST([libprefix])
388AC_SUBST([DSO_LDFLAGS])
389AC_SUBST([EXTRA_LDFLAGS])
390AC_SUBST([SOREV])
391AC_SUBST([PIC_CFLAGS])
392AC_SUBST([CTARGET])
393AC_SUBST([LDTARGET])
394AC_SUBST([MKLIB])
395AC_SUBST([ARFLAGS])
396AC_SUBST([AROUT])
397AC_SUBST([CC_MM])
398
399JE_COMPILABLE([__attribute__ syntax],
400              [static __attribute__((unused)) void foo(void){}],
401              [],
402              [je_cv_attribute])
403if test "x${je_cv_attribute}" = "xyes" ; then
404  AC_DEFINE([JEMALLOC_HAVE_ATTR], [ ])
405  if test "x${GCC}" = "xyes" -a "x${abi}" = "xelf"; then
406    JE_CFLAGS_APPEND([-fvisibility=hidden])
407  fi
408fi
409dnl Check for tls_model attribute support (clang 3.0 still lacks support).
410SAVED_CFLAGS="${CFLAGS}"
411JE_CFLAGS_APPEND([-Werror])
412JE_COMPILABLE([tls_model attribute], [],
413              [static __thread int
414               __attribute__((tls_model("initial-exec"), unused)) foo;
415               foo = 0;],
416              [je_cv_tls_model])
417CFLAGS="${SAVED_CFLAGS}"
418if test "x${je_cv_tls_model}" = "xyes" ; then
419  AC_DEFINE([JEMALLOC_TLS_MODEL],
420            [__attribute__((tls_model("initial-exec")))])
421else
422  AC_DEFINE([JEMALLOC_TLS_MODEL], [ ])
423fi
424
425dnl Support optional additions to rpath.
426AC_ARG_WITH([rpath],
427  [AS_HELP_STRING([--with-rpath=<rpath>], [Colon-separated rpath (ELF systems only)])],
428if test "x$with_rpath" = "xno" ; then
429  RPATH_EXTRA=
430else
431  RPATH_EXTRA="`echo $with_rpath | tr \":\" \" \"`"
432fi,
433  RPATH_EXTRA=
434)
435AC_SUBST([RPATH_EXTRA])
436
437dnl Disable rules that do automatic regeneration of configure output by default.
438AC_ARG_ENABLE([autogen],
439  [AS_HELP_STRING([--enable-autogen], [Automatically regenerate configure output])],
440if test "x$enable_autogen" = "xno" ; then
441  enable_autogen="0"
442else
443  enable_autogen="1"
444fi
445,
446enable_autogen="0"
447)
448AC_SUBST([enable_autogen])
449
450AC_PROG_INSTALL
451AC_PROG_RANLIB
452AC_PATH_PROG([LD], [ld], [false], [$PATH])
453AC_PATH_PROG([AUTOCONF], [autoconf], [false], [$PATH])
454
455public_syms="malloc_conf malloc_message malloc calloc posix_memalign aligned_alloc realloc free mallocx rallocx xallocx sallocx dallocx sdallocx nallocx mallctl mallctlnametomib mallctlbymib malloc_stats_print malloc_usable_size"
456
457dnl Check for allocator-related functions that should be wrapped.
458AC_CHECK_FUNC([memalign],
459	      [AC_DEFINE([JEMALLOC_OVERRIDE_MEMALIGN], [ ])
460	       public_syms="${public_syms} memalign"])
461AC_CHECK_FUNC([valloc],
462	      [AC_DEFINE([JEMALLOC_OVERRIDE_VALLOC], [ ])
463	       public_syms="${public_syms} valloc"])
464
465dnl Do not compute test code coverage by default.
466GCOV_FLAGS=
467AC_ARG_ENABLE([code-coverage],
468  [AS_HELP_STRING([--enable-code-coverage],
469   [Enable code coverage])],
470[if test "x$enable_code_coverage" = "xno" ; then
471  enable_code_coverage="0"
472else
473  enable_code_coverage="1"
474fi
475],
476[enable_code_coverage="0"]
477)
478if test "x$enable_code_coverage" = "x1" ; then
479  deoptimize="no"
480  echo "$CFLAGS $EXTRA_CFLAGS" | grep '\-O' >/dev/null || deoptimize="yes"
481  if test "x${deoptimize}" = "xyes" ; then
482    JE_CFLAGS_APPEND([-O0])
483  fi
484  JE_CFLAGS_APPEND([-fprofile-arcs -ftest-coverage])
485  EXTRA_LDFLAGS="$EXTRA_LDFLAGS -fprofile-arcs -ftest-coverage"
486  AC_DEFINE([JEMALLOC_CODE_COVERAGE], [ ])
487fi
488AC_SUBST([enable_code_coverage])
489
490dnl Perform no name mangling by default.
491AC_ARG_WITH([mangling],
492  [AS_HELP_STRING([--with-mangling=<map>], [Mangle symbols in <map>])],
493  [mangling_map="$with_mangling"], [mangling_map=""])
494
495dnl Do not prefix public APIs by default.
496AC_ARG_WITH([jemalloc_prefix],
497  [AS_HELP_STRING([--with-jemalloc-prefix=<prefix>], [Prefix to prepend to all public APIs])],
498  [JEMALLOC_PREFIX="$with_jemalloc_prefix"],
499  [if test "x$abi" != "xmacho" -a "x$abi" != "xpecoff"; then
500  JEMALLOC_PREFIX=""
501else
502  JEMALLOC_PREFIX="je_"
503fi]
504)
505if test "x$JEMALLOC_PREFIX" != "x" ; then
506  JEMALLOC_CPREFIX=`echo ${JEMALLOC_PREFIX} | tr "a-z" "A-Z"`
507  AC_DEFINE_UNQUOTED([JEMALLOC_PREFIX], ["$JEMALLOC_PREFIX"])
508  AC_DEFINE_UNQUOTED([JEMALLOC_CPREFIX], ["$JEMALLOC_CPREFIX"])
509fi
510
511AC_ARG_WITH([export],
512  [AS_HELP_STRING([--without-export], [disable exporting jemalloc public APIs])],
513  [if test "x$with_export" = "xno"; then
514  AC_DEFINE([JEMALLOC_EXPORT],[])
515fi]
516)
517
518dnl Mangle library-private APIs.
519AC_ARG_WITH([private_namespace],
520  [AS_HELP_STRING([--with-private-namespace=<prefix>], [Prefix to prepend to all library-private APIs])],
521  [JEMALLOC_PRIVATE_NAMESPACE="${with_private_namespace}je_"],
522  [JEMALLOC_PRIVATE_NAMESPACE="je_"]
523)
524AC_DEFINE_UNQUOTED([JEMALLOC_PRIVATE_NAMESPACE], [$JEMALLOC_PRIVATE_NAMESPACE])
525private_namespace="$JEMALLOC_PRIVATE_NAMESPACE"
526AC_SUBST([private_namespace])
527
528dnl Do not add suffix to installed files by default.
529AC_ARG_WITH([install_suffix],
530  [AS_HELP_STRING([--with-install-suffix=<suffix>], [Suffix to append to all installed files])],
531  [INSTALL_SUFFIX="$with_install_suffix"],
532  [INSTALL_SUFFIX=]
533)
534install_suffix="$INSTALL_SUFFIX"
535AC_SUBST([install_suffix])
536
537dnl Substitute @je_@ in jemalloc_protos.h.in, primarily to make generation of
538dnl jemalloc_protos_jet.h easy.
539je_="je_"
540AC_SUBST([je_])
541
542cfgoutputs_in="Makefile.in"
543cfgoutputs_in="${cfgoutputs_in} jemalloc.pc.in"
544cfgoutputs_in="${cfgoutputs_in} doc/html.xsl.in"
545cfgoutputs_in="${cfgoutputs_in} doc/manpages.xsl.in"
546cfgoutputs_in="${cfgoutputs_in} doc/jemalloc.xml.in"
547cfgoutputs_in="${cfgoutputs_in} include/jemalloc/jemalloc_macros.h.in"
548cfgoutputs_in="${cfgoutputs_in} include/jemalloc/jemalloc_protos.h.in"
549cfgoutputs_in="${cfgoutputs_in} include/jemalloc/jemalloc_typedefs.h.in"
550cfgoutputs_in="${cfgoutputs_in} include/jemalloc/internal/jemalloc_internal.h.in"
551cfgoutputs_in="${cfgoutputs_in} test/test.sh.in"
552cfgoutputs_in="${cfgoutputs_in} test/include/test/jemalloc_test.h.in"
553
554cfgoutputs_out="Makefile"
555cfgoutputs_out="${cfgoutputs_out} jemalloc.pc"
556cfgoutputs_out="${cfgoutputs_out} doc/html.xsl"
557cfgoutputs_out="${cfgoutputs_out} doc/manpages.xsl"
558cfgoutputs_out="${cfgoutputs_out} doc/jemalloc.xml"
559cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_macros.h"
560cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_protos.h"
561cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_typedefs.h"
562cfgoutputs_out="${cfgoutputs_out} include/jemalloc/internal/jemalloc_internal.h"
563cfgoutputs_out="${cfgoutputs_out} test/test.sh"
564cfgoutputs_out="${cfgoutputs_out} test/include/test/jemalloc_test.h"
565
566cfgoutputs_tup="Makefile"
567cfgoutputs_tup="${cfgoutputs_tup} jemalloc.pc:jemalloc.pc.in"
568cfgoutputs_tup="${cfgoutputs_tup} doc/html.xsl:doc/html.xsl.in"
569cfgoutputs_tup="${cfgoutputs_tup} doc/manpages.xsl:doc/manpages.xsl.in"
570cfgoutputs_tup="${cfgoutputs_tup} doc/jemalloc.xml:doc/jemalloc.xml.in"
571cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_macros.h:include/jemalloc/jemalloc_macros.h.in"
572cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_protos.h:include/jemalloc/jemalloc_protos.h.in"
573cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_typedefs.h:include/jemalloc/jemalloc_typedefs.h.in"
574cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/internal/jemalloc_internal.h"
575cfgoutputs_tup="${cfgoutputs_tup} test/test.sh:test/test.sh.in"
576cfgoutputs_tup="${cfgoutputs_tup} test/include/test/jemalloc_test.h:test/include/test/jemalloc_test.h.in"
577
578cfghdrs_in="include/jemalloc/jemalloc_defs.h.in"
579cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/jemalloc_internal_defs.h.in"
580cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/private_namespace.sh"
581cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/private_unnamespace.sh"
582cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/private_symbols.txt"
583cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/public_namespace.sh"
584cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/public_unnamespace.sh"
585cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/size_classes.sh"
586cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc_rename.sh"
587cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc_mangle.sh"
588cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc.sh"
589cfghdrs_in="${cfghdrs_in} test/include/test/jemalloc_test_defs.h.in"
590
591cfghdrs_out="include/jemalloc/jemalloc_defs.h"
592cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc${install_suffix}.h"
593cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/private_namespace.h"
594cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/private_unnamespace.h"
595cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_symbols.txt"
596cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_namespace.h"
597cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_unnamespace.h"
598cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/size_classes.h"
599cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_protos_jet.h"
600cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_rename.h"
601cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_mangle.h"
602cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_mangle_jet.h"
603cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/jemalloc_internal_defs.h"
604cfghdrs_out="${cfghdrs_out} test/include/test/jemalloc_test_defs.h"
605
606cfghdrs_tup="include/jemalloc/jemalloc_defs.h:include/jemalloc/jemalloc_defs.h.in"
607cfghdrs_tup="${cfghdrs_tup} include/jemalloc/internal/jemalloc_internal_defs.h:include/jemalloc/internal/jemalloc_internal_defs.h.in"
608cfghdrs_tup="${cfghdrs_tup} test/include/test/jemalloc_test_defs.h:test/include/test/jemalloc_test_defs.h.in"
609
610dnl Silence irrelevant compiler warnings by default.
611AC_ARG_ENABLE([cc-silence],
612  [AS_HELP_STRING([--disable-cc-silence],
613                  [Do not silence irrelevant compiler warnings])],
614[if test "x$enable_cc_silence" = "xno" ; then
615  enable_cc_silence="0"
616else
617  enable_cc_silence="1"
618fi
619],
620[enable_cc_silence="1"]
621)
622if test "x$enable_cc_silence" = "x1" ; then
623  AC_DEFINE([JEMALLOC_CC_SILENCE], [ ])
624fi
625
626dnl Do not compile with debugging by default.
627AC_ARG_ENABLE([debug],
628  [AS_HELP_STRING([--enable-debug],
629                  [Build debugging code (implies --enable-ivsalloc)])],
630[if test "x$enable_debug" = "xno" ; then
631  enable_debug="0"
632else
633  enable_debug="1"
634fi
635],
636[enable_debug="0"]
637)
638if test "x$enable_debug" = "x1" ; then
639  AC_DEFINE([JEMALLOC_DEBUG], [ ])
640fi
641if test "x$enable_debug" = "x1" ; then
642  AC_DEFINE([JEMALLOC_DEBUG], [ ])
643  enable_ivsalloc="1"
644fi
645AC_SUBST([enable_debug])
646
647dnl Do not validate pointers by default.
648AC_ARG_ENABLE([ivsalloc],
649  [AS_HELP_STRING([--enable-ivsalloc],
650                  [Validate pointers passed through the public API])],
651[if test "x$enable_ivsalloc" = "xno" ; then
652  enable_ivsalloc="0"
653else
654  enable_ivsalloc="1"
655fi
656],
657[enable_ivsalloc="0"]
658)
659if test "x$enable_ivsalloc" = "x1" ; then
660  AC_DEFINE([JEMALLOC_IVSALLOC], [ ])
661fi
662
663dnl Only optimize if not debugging.
664if test "x$enable_debug" = "x0" -a "x$no_CFLAGS" = "xyes" ; then
665  dnl Make sure that an optimization flag was not specified in EXTRA_CFLAGS.
666  optimize="no"
667  echo "$CFLAGS $EXTRA_CFLAGS" | grep '\-O' >/dev/null || optimize="yes"
668  if test "x${optimize}" = "xyes" ; then
669    if test "x$GCC" = "xyes" ; then
670      JE_CFLAGS_APPEND([-O3])
671      JE_CFLAGS_APPEND([-funroll-loops])
672    elif test "x$je_cv_msvc" = "xyes" ; then
673      JE_CFLAGS_APPEND([-O2])
674    else
675      JE_CFLAGS_APPEND([-O])
676    fi
677  fi
678fi
679
680dnl Enable statistics calculation by default.
681AC_ARG_ENABLE([stats],
682  [AS_HELP_STRING([--disable-stats],
683                  [Disable statistics calculation/reporting])],
684[if test "x$enable_stats" = "xno" ; then
685  enable_stats="0"
686else
687  enable_stats="1"
688fi
689],
690[enable_stats="1"]
691)
692if test "x$enable_stats" = "x1" ; then
693  AC_DEFINE([JEMALLOC_STATS], [ ])
694fi
695AC_SUBST([enable_stats])
696
697dnl Do not enable profiling by default.
698AC_ARG_ENABLE([prof],
699  [AS_HELP_STRING([--enable-prof], [Enable allocation profiling])],
700[if test "x$enable_prof" = "xno" ; then
701  enable_prof="0"
702else
703  enable_prof="1"
704fi
705],
706[enable_prof="0"]
707)
708if test "x$enable_prof" = "x1" ; then
709  backtrace_method=""
710else
711  backtrace_method="N/A"
712fi
713
714AC_ARG_ENABLE([prof-libunwind],
715  [AS_HELP_STRING([--enable-prof-libunwind], [Use libunwind for backtracing])],
716[if test "x$enable_prof_libunwind" = "xno" ; then
717  enable_prof_libunwind="0"
718else
719  enable_prof_libunwind="1"
720fi
721],
722[enable_prof_libunwind="0"]
723)
724AC_ARG_WITH([static_libunwind],
725  [AS_HELP_STRING([--with-static-libunwind=<libunwind.a>],
726  [Path to static libunwind library; use rather than dynamically linking])],
727if test "x$with_static_libunwind" = "xno" ; then
728  LUNWIND="-lunwind"
729else
730  if test ! -f "$with_static_libunwind" ; then
731    AC_MSG_ERROR([Static libunwind not found: $with_static_libunwind])
732  fi
733  LUNWIND="$with_static_libunwind"
734fi,
735  LUNWIND="-lunwind"
736)
737if test "x$backtrace_method" = "x" -a "x$enable_prof_libunwind" = "x1" ; then
738  AC_CHECK_HEADERS([libunwind.h], , [enable_prof_libunwind="0"])
739  if test "x$LUNWIND" = "x-lunwind" ; then
740    AC_CHECK_LIB([unwind], [unw_backtrace], [LIBS="$LIBS $LUNWIND"],
741                 [enable_prof_libunwind="0"])
742  else
743    LIBS="$LIBS $LUNWIND"
744  fi
745  if test "x${enable_prof_libunwind}" = "x1" ; then
746    backtrace_method="libunwind"
747    AC_DEFINE([JEMALLOC_PROF_LIBUNWIND], [ ])
748  fi
749fi
750
751AC_ARG_ENABLE([prof-libgcc],
752  [AS_HELP_STRING([--disable-prof-libgcc],
753  [Do not use libgcc for backtracing])],
754[if test "x$enable_prof_libgcc" = "xno" ; then
755  enable_prof_libgcc="0"
756else
757  enable_prof_libgcc="1"
758fi
759],
760[enable_prof_libgcc="1"]
761)
762if test "x$backtrace_method" = "x" -a "x$enable_prof_libgcc" = "x1" \
763     -a "x$GCC" = "xyes" ; then
764  AC_CHECK_HEADERS([unwind.h], , [enable_prof_libgcc="0"])
765  AC_CHECK_LIB([gcc], [_Unwind_Backtrace], [LIBS="$LIBS -lgcc"], [enable_prof_libgcc="0"])
766  if test "x${enable_prof_libgcc}" = "x1" ; then
767    backtrace_method="libgcc"
768    AC_DEFINE([JEMALLOC_PROF_LIBGCC], [ ])
769  fi
770else
771  enable_prof_libgcc="0"
772fi
773
774AC_ARG_ENABLE([prof-gcc],
775  [AS_HELP_STRING([--disable-prof-gcc],
776  [Do not use gcc intrinsics for backtracing])],
777[if test "x$enable_prof_gcc" = "xno" ; then
778  enable_prof_gcc="0"
779else
780  enable_prof_gcc="1"
781fi
782],
783[enable_prof_gcc="1"]
784)
785if test "x$backtrace_method" = "x" -a "x$enable_prof_gcc" = "x1" \
786     -a "x$GCC" = "xyes" ; then
787  JE_CFLAGS_APPEND([-fno-omit-frame-pointer])
788  backtrace_method="gcc intrinsics"
789  AC_DEFINE([JEMALLOC_PROF_GCC], [ ])
790else
791  enable_prof_gcc="0"
792fi
793
794if test "x$backtrace_method" = "x" ; then
795  backtrace_method="none (disabling profiling)"
796  enable_prof="0"
797fi
798AC_MSG_CHECKING([configured backtracing method])
799AC_MSG_RESULT([$backtrace_method])
800if test "x$enable_prof" = "x1" ; then
801  if test "x$abi" != "xpecoff"; then
802    dnl Heap profiling uses the log(3) function.
803    LIBS="$LIBS -lm"
804  fi
805
806  AC_DEFINE([JEMALLOC_PROF], [ ])
807fi
808AC_SUBST([enable_prof])
809
810dnl Enable thread-specific caching by default.
811AC_ARG_ENABLE([tcache],
812  [AS_HELP_STRING([--disable-tcache], [Disable per thread caches])],
813[if test "x$enable_tcache" = "xno" ; then
814  enable_tcache="0"
815else
816  enable_tcache="1"
817fi
818],
819[enable_tcache="1"]
820)
821if test "x$enable_tcache" = "x1" ; then
822  AC_DEFINE([JEMALLOC_TCACHE], [ ])
823fi
824AC_SUBST([enable_tcache])
825
826dnl Enable VM deallocation via munmap() by default.
827AC_ARG_ENABLE([munmap],
828  [AS_HELP_STRING([--disable-munmap], [Disable VM deallocation via munmap(2)])],
829[if test "x$enable_munmap" = "xno" ; then
830  enable_munmap="0"
831else
832  enable_munmap="1"
833fi
834],
835[enable_munmap="${default_munmap}"]
836)
837if test "x$enable_munmap" = "x1" ; then
838  AC_DEFINE([JEMALLOC_MUNMAP], [ ])
839fi
840AC_SUBST([enable_munmap])
841
842dnl Enable allocation from DSS if supported by the OS.
843have_dss="1"
844dnl Check whether the BSD/SUSv1 sbrk() exists.  If not, disable DSS support.
845AC_CHECK_FUNC([sbrk], [have_sbrk="1"], [have_sbrk="0"])
846if test "x$have_sbrk" = "x1" ; then
847  if test "x$sbrk_deprecated" = "x1" ; then
848    AC_MSG_RESULT([Disabling dss allocation because sbrk is deprecated])
849    have_dss="0"
850  fi
851else
852  have_dss="0"
853fi
854
855if test "x$have_dss" = "x1" ; then
856  AC_DEFINE([JEMALLOC_DSS], [ ])
857fi
858
859dnl Support the junk/zero filling option by default.
860AC_ARG_ENABLE([fill],
861  [AS_HELP_STRING([--disable-fill],
862                  [Disable support for junk/zero filling, quarantine, and redzones])],
863[if test "x$enable_fill" = "xno" ; then
864  enable_fill="0"
865else
866  enable_fill="1"
867fi
868],
869[enable_fill="1"]
870)
871if test "x$enable_fill" = "x1" ; then
872  AC_DEFINE([JEMALLOC_FILL], [ ])
873fi
874AC_SUBST([enable_fill])
875
876dnl Disable utrace(2)-based tracing by default.
877AC_ARG_ENABLE([utrace],
878  [AS_HELP_STRING([--enable-utrace], [Enable utrace(2)-based tracing])],
879[if test "x$enable_utrace" = "xno" ; then
880  enable_utrace="0"
881else
882  enable_utrace="1"
883fi
884],
885[enable_utrace="0"]
886)
887JE_COMPILABLE([utrace(2)], [
888#include <sys/types.h>
889#include <sys/param.h>
890#include <sys/time.h>
891#include <sys/uio.h>
892#include <sys/ktrace.h>
893], [
894	utrace((void *)0, 0);
895], [je_cv_utrace])
896if test "x${je_cv_utrace}" = "xno" ; then
897  enable_utrace="0"
898fi
899if test "x$enable_utrace" = "x1" ; then
900  AC_DEFINE([JEMALLOC_UTRACE], [ ])
901fi
902AC_SUBST([enable_utrace])
903
904dnl Support Valgrind by default.
905AC_ARG_ENABLE([valgrind],
906  [AS_HELP_STRING([--disable-valgrind], [Disable support for Valgrind])],
907[if test "x$enable_valgrind" = "xno" ; then
908  enable_valgrind="0"
909else
910  enable_valgrind="1"
911fi
912],
913[enable_valgrind="1"]
914)
915if test "x$enable_valgrind" = "x1" ; then
916  JE_COMPILABLE([valgrind], [
917#include <valgrind/valgrind.h>
918#include <valgrind/memcheck.h>
919
920#if !defined(VALGRIND_RESIZEINPLACE_BLOCK)
921#  error "Incompatible Valgrind version"
922#endif
923], [], [je_cv_valgrind])
924  if test "x${je_cv_valgrind}" = "xno" ; then
925    enable_valgrind="0"
926  fi
927  if test "x$enable_valgrind" = "x1" ; then
928    AC_DEFINE([JEMALLOC_VALGRIND], [ ])
929  fi
930fi
931AC_SUBST([enable_valgrind])
932
933dnl Do not support the xmalloc option by default.
934AC_ARG_ENABLE([xmalloc],
935  [AS_HELP_STRING([--enable-xmalloc], [Support xmalloc option])],
936[if test "x$enable_xmalloc" = "xno" ; then
937  enable_xmalloc="0"
938else
939  enable_xmalloc="1"
940fi
941],
942[enable_xmalloc="0"]
943)
944if test "x$enable_xmalloc" = "x1" ; then
945  AC_DEFINE([JEMALLOC_XMALLOC], [ ])
946fi
947AC_SUBST([enable_xmalloc])
948
949dnl Support cache-oblivious allocation alignment by default.
950AC_ARG_ENABLE([cache-oblivious],
951  [AS_HELP_STRING([--disable-cache-oblivious],
952                  [Disable support for cache-oblivious allocation alignment])],
953[if test "x$enable_cache_oblivious" = "xno" ; then
954  enable_cache_oblivious="0"
955else
956  enable_cache_oblivious="1"
957fi
958],
959[enable_cache_oblivious="1"]
960)
961if test "x$enable_cache_oblivious" = "x1" ; then
962  AC_DEFINE([JEMALLOC_CACHE_OBLIVIOUS], [ ])
963fi
964AC_SUBST([enable_cache_oblivious])
965
966dnl ============================================================================
967dnl Check for  __builtin_ffsl(), then ffsl(3), and fail if neither are found.
968dnl One of those two functions should (theoretically) exist on all platforms
969dnl that jemalloc currently has a chance of functioning on without modification.
970dnl We additionally assume ffs() or __builtin_ffs() are defined if
971dnl ffsl() or __builtin_ffsl() are defined, respectively.
972JE_COMPILABLE([a program using __builtin_ffsl], [
973#include <stdio.h>
974#include <strings.h>
975#include <string.h>
976], [
977	{
978		int rv = __builtin_ffsl(0x08);
979		printf("%d\n", rv);
980	}
981], [je_cv_gcc_builtin_ffsl])
982if test "x${je_cv_gcc_builtin_ffsl}" = "xyes" ; then
983  AC_DEFINE([JEMALLOC_INTERNAL_FFSL], [__builtin_ffsl])
984  AC_DEFINE([JEMALLOC_INTERNAL_FFS], [__builtin_ffs])
985else
986  JE_COMPILABLE([a program using ffsl], [
987  #include <stdio.h>
988  #include <strings.h>
989  #include <string.h>
990  ], [
991	{
992		int rv = ffsl(0x08);
993		printf("%d\n", rv);
994	}
995  ], [je_cv_function_ffsl])
996  if test "x${je_cv_function_ffsl}" = "xyes" ; then
997    AC_DEFINE([JEMALLOC_INTERNAL_FFSL], [ffsl])
998    AC_DEFINE([JEMALLOC_INTERNAL_FFS], [ffs])
999  else
1000    AC_MSG_ERROR([Cannot build without ffsl(3) or __builtin_ffsl()])
1001  fi
1002fi
1003
1004AC_ARG_WITH([lg_tiny_min],
1005  [AS_HELP_STRING([--with-lg-tiny-min=<lg-tiny-min>],
1006   [Base 2 log of minimum tiny size class to support])],
1007  [LG_TINY_MIN="$with_lg_tiny_min"],
1008  [LG_TINY_MIN="3"])
1009AC_DEFINE_UNQUOTED([LG_TINY_MIN], [$LG_TINY_MIN])
1010
1011AC_ARG_WITH([lg_quantum],
1012  [AS_HELP_STRING([--with-lg-quantum=<lg-quantum>],
1013   [Base 2 log of minimum allocation alignment])],
1014  [LG_QUANTA="$with_lg_quantum"],
1015  [LG_QUANTA="3 4"])
1016if test "x$with_lg_quantum" != "x" ; then
1017  AC_DEFINE_UNQUOTED([LG_QUANTUM], [$with_lg_quantum])
1018fi
1019
1020AC_ARG_WITH([lg_page],
1021  [AS_HELP_STRING([--with-lg-page=<lg-page>], [Base 2 log of system page size])],
1022  [LG_PAGE="$with_lg_page"], [LG_PAGE="detect"])
1023if test "x$LG_PAGE" = "xdetect"; then
1024  AC_CACHE_CHECK([LG_PAGE],
1025               [je_cv_lg_page],
1026               AC_RUN_IFELSE([AC_LANG_PROGRAM(
1027[[
1028#include <strings.h>
1029#ifdef _WIN32
1030#include <windows.h>
1031#else
1032#include <unistd.h>
1033#endif
1034#include <stdio.h>
1035]],
1036[[
1037    int result;
1038    FILE *f;
1039
1040#ifdef _WIN32
1041    SYSTEM_INFO si;
1042    GetSystemInfo(&si);
1043    result = si.dwPageSize;
1044#else
1045    result = sysconf(_SC_PAGESIZE);
1046#endif
1047    if (result == -1) {
1048	return 1;
1049    }
1050    result = JEMALLOC_INTERNAL_FFSL(result) - 1;
1051
1052    f = fopen("conftest.out", "w");
1053    if (f == NULL) {
1054	return 1;
1055    }
1056    fprintf(f, "%d\n", result);
1057    fclose(f);
1058
1059    return 0;
1060]])],
1061                             [je_cv_lg_page=`cat conftest.out`],
1062                             [je_cv_lg_page=undefined],
1063                             [je_cv_lg_page=12]))
1064fi
1065if test "x${je_cv_lg_page}" != "x" ; then
1066  LG_PAGE="${je_cv_lg_page}"
1067fi
1068if test "x${LG_PAGE}" != "xundefined" ; then
1069   AC_DEFINE_UNQUOTED([LG_PAGE], [$LG_PAGE])
1070else
1071   AC_MSG_ERROR([cannot determine value for LG_PAGE])
1072fi
1073
1074AC_ARG_WITH([lg_page_sizes],
1075  [AS_HELP_STRING([--with-lg-page-sizes=<lg-page-sizes>],
1076   [Base 2 logs of system page sizes to support])],
1077  [LG_PAGE_SIZES="$with_lg_page_sizes"], [LG_PAGE_SIZES="$LG_PAGE"])
1078
1079AC_ARG_WITH([lg_size_class_group],
1080  [AS_HELP_STRING([--with-lg-size-class-group=<lg-size-class-group>],
1081   [Base 2 log of size classes per doubling])],
1082  [LG_SIZE_CLASS_GROUP="$with_lg_size_class_group"],
1083  [LG_SIZE_CLASS_GROUP="2"])
1084
1085dnl ============================================================================
1086dnl jemalloc configuration.
1087dnl
1088
1089dnl Set VERSION if source directory is inside a git repository.
1090if test "x`test ! \"${srcroot}\" && cd \"${srcroot}\"; git rev-parse --is-inside-work-tree 2>/dev/null`" = "xtrue" ; then
1091  dnl Pattern globs aren't powerful enough to match both single- and
1092  dnl double-digit version numbers, so iterate over patterns to support up to
1093  dnl version 99.99.99 without any accidental matches.
1094  rm -f "${objroot}VERSION"
1095  for pattern in ['[0-9].[0-9].[0-9]' '[0-9].[0-9].[0-9][0-9]' \
1096                 '[0-9].[0-9][0-9].[0-9]' '[0-9].[0-9][0-9].[0-9][0-9]' \
1097                 '[0-9][0-9].[0-9].[0-9]' '[0-9][0-9].[0-9].[0-9][0-9]' \
1098                 '[0-9][0-9].[0-9][0-9].[0-9]' \
1099                 '[0-9][0-9].[0-9][0-9].[0-9][0-9]']; do
1100    if test ! -e "${objroot}VERSION" ; then
1101      (test ! "${srcroot}" && cd "${srcroot}"; git describe --long --abbrev=40 --match="${pattern}") > "${objroot}VERSION.tmp" 2>/dev/null
1102      if test $? -eq 0 ; then
1103        mv "${objroot}VERSION.tmp" "${objroot}VERSION"
1104        break
1105      fi
1106    fi
1107  done
1108fi
1109rm -f "${objroot}VERSION.tmp"
1110if test ! -e "${objroot}VERSION" ; then
1111  if test ! -e "${srcroot}VERSION" ; then
1112    AC_MSG_RESULT(
1113      [Missing VERSION file, and unable to generate it; creating bogus VERSION])
1114    echo "0.0.0-0-g0000000000000000000000000000000000000000" > "${objroot}VERSION"
1115  else
1116    cp ${srcroot}VERSION ${objroot}VERSION
1117  fi
1118fi
1119jemalloc_version=`cat "${objroot}VERSION"`
1120jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'`
1121jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'`
1122jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'`
1123jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'`
1124jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'`
1125AC_SUBST([jemalloc_version])
1126AC_SUBST([jemalloc_version_major])
1127AC_SUBST([jemalloc_version_minor])
1128AC_SUBST([jemalloc_version_bugfix])
1129AC_SUBST([jemalloc_version_nrev])
1130AC_SUBST([jemalloc_version_gid])
1131
1132dnl ============================================================================
1133dnl Configure pthreads.
1134
1135if test "x$abi" != "xpecoff" ; then
1136  AC_CHECK_HEADERS([pthread.h], , [AC_MSG_ERROR([pthread.h is missing])])
1137  dnl Some systems may embed pthreads functionality in libc; check for libpthread
1138  dnl first, but try libc too before failing.
1139  AC_CHECK_LIB([pthread], [pthread_create], [LIBS="$LIBS -lpthread"],
1140               [AC_SEARCH_LIBS([pthread_create], , ,
1141                               AC_MSG_ERROR([libpthread is missing]))])
1142fi
1143
1144CPPFLAGS="$CPPFLAGS -D_REENTRANT"
1145
1146dnl Check if the GNU-specific secure_getenv function exists.
1147AC_CHECK_FUNC([secure_getenv],
1148              [have_secure_getenv="1"],
1149              [have_secure_getenv="0"]
1150             )
1151if test "x$have_secure_getenv" = "x1" ; then
1152  AC_DEFINE([JEMALLOC_HAVE_SECURE_GETENV], [ ])
1153fi
1154
1155dnl Check if the Solaris/BSD issetugid function exists.
1156AC_CHECK_FUNC([issetugid],
1157              [have_issetugid="1"],
1158              [have_issetugid="0"]
1159             )
1160if test "x$have_issetugid" = "x1" ; then
1161  AC_DEFINE([JEMALLOC_HAVE_ISSETUGID], [ ])
1162fi
1163
1164dnl Check whether the BSD-specific _malloc_thread_cleanup() exists.  If so, use
1165dnl it rather than pthreads TSD cleanup functions to support cleanup during
1166dnl thread exit, in order to avoid pthreads library recursion during
1167dnl bootstrapping.
1168AC_CHECK_FUNC([_malloc_thread_cleanup],
1169              [have__malloc_thread_cleanup="1"],
1170              [have__malloc_thread_cleanup="0"]
1171             )
1172if test "x$have__malloc_thread_cleanup" = "x1" ; then
1173  AC_DEFINE([JEMALLOC_MALLOC_THREAD_CLEANUP], [ ])
1174  force_tls="1"
1175fi
1176
1177dnl Check whether the BSD-specific _pthread_mutex_init_calloc_cb() exists.  If
1178dnl so, mutex initialization causes allocation, and we need to implement this
1179dnl callback function in order to prevent recursive allocation.
1180AC_CHECK_FUNC([_pthread_mutex_init_calloc_cb],
1181              [have__pthread_mutex_init_calloc_cb="1"],
1182              [have__pthread_mutex_init_calloc_cb="0"]
1183             )
1184if test "x$have__pthread_mutex_init_calloc_cb" = "x1" ; then
1185  AC_DEFINE([JEMALLOC_MUTEX_INIT_CB])
1186fi
1187
1188dnl Disable lazy locking by default.
1189AC_ARG_ENABLE([lazy_lock],
1190  [AS_HELP_STRING([--enable-lazy-lock],
1191  [Enable lazy locking (only lock when multi-threaded)])],
1192[if test "x$enable_lazy_lock" = "xno" ; then
1193  enable_lazy_lock="0"
1194else
1195  enable_lazy_lock="1"
1196fi
1197],
1198[enable_lazy_lock="0"]
1199)
1200if test "x$enable_lazy_lock" = "x0" -a "x${force_lazy_lock}" = "x1" ; then
1201  AC_MSG_RESULT([Forcing lazy-lock to avoid allocator/threading bootstrap issues])
1202  enable_lazy_lock="1"
1203fi
1204if test "x$enable_lazy_lock" = "x1" ; then
1205  if test "x$abi" != "xpecoff" ; then
1206    AC_CHECK_HEADERS([dlfcn.h], , [AC_MSG_ERROR([dlfcn.h is missing])])
1207    AC_CHECK_FUNC([dlsym], [],
1208      [AC_CHECK_LIB([dl], [dlsym], [LIBS="$LIBS -ldl"],
1209                    [AC_MSG_ERROR([libdl is missing])])
1210      ])
1211  fi
1212  AC_DEFINE([JEMALLOC_LAZY_LOCK], [ ])
1213fi
1214AC_SUBST([enable_lazy_lock])
1215
1216AC_ARG_ENABLE([tls],
1217  [AS_HELP_STRING([--disable-tls], [Disable thread-local storage (__thread keyword)])],
1218if test "x$enable_tls" = "xno" ; then
1219  enable_tls="0"
1220else
1221  enable_tls="1"
1222fi
1223,
1224enable_tls="1"
1225)
1226if test "x${enable_tls}" = "x0" -a "x${force_tls}" = "x1" ; then
1227  AC_MSG_RESULT([Forcing TLS to avoid allocator/threading bootstrap issues])
1228  enable_tls="1"
1229fi
1230if test "x${enable_tls}" = "x1" -a "x${force_tls}" = "x0" ; then
1231  AC_MSG_RESULT([Forcing no TLS to avoid allocator/threading bootstrap issues])
1232  enable_tls="0"
1233fi
1234if test "x${enable_tls}" = "x1" ; then
1235AC_MSG_CHECKING([for TLS])
1236AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
1237[[
1238    __thread int x;
1239]], [[
1240    x = 42;
1241
1242    return 0;
1243]])],
1244              AC_MSG_RESULT([yes]),
1245              AC_MSG_RESULT([no])
1246              enable_tls="0")
1247fi
1248AC_SUBST([enable_tls])
1249if test "x${enable_tls}" = "x1" ; then
1250  AC_DEFINE_UNQUOTED([JEMALLOC_TLS], [ ])
1251elif test "x${force_tls}" = "x1" ; then
1252  AC_MSG_ERROR([Failed to configure TLS, which is mandatory for correct function])
1253fi
1254
1255dnl ============================================================================
1256dnl Check for C11 atomics.
1257
1258JE_COMPILABLE([C11 atomics], [
1259#include <stdint.h>
1260#if (__STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_ATOMICS__)
1261#include <stdatomic.h>
1262#else
1263#error Atomics not available
1264#endif
1265], [
1266    uint64_t *p = (uint64_t *)0;
1267    uint64_t x = 1;
1268    volatile atomic_uint_least64_t *a = (volatile atomic_uint_least64_t *)p;
1269    uint64_t r = atomic_fetch_add(a, x) + x;
1270    return (r == 0);
1271], [je_cv_c11atomics])
1272if test "x${je_cv_c11atomics}" = "xyes" ; then
1273  AC_DEFINE([JEMALLOC_C11ATOMICS])
1274fi
1275
1276dnl ============================================================================
1277dnl Check for atomic(9) operations as provided on FreeBSD.
1278
1279JE_COMPILABLE([atomic(9)], [
1280#include <sys/types.h>
1281#include <machine/atomic.h>
1282#include <inttypes.h>
1283], [
1284	{
1285		uint32_t x32 = 0;
1286		volatile uint32_t *x32p = &x32;
1287		atomic_fetchadd_32(x32p, 1);
1288	}
1289	{
1290		unsigned long xlong = 0;
1291		volatile unsigned long *xlongp = &xlong;
1292		atomic_fetchadd_long(xlongp, 1);
1293	}
1294], [je_cv_atomic9])
1295if test "x${je_cv_atomic9}" = "xyes" ; then
1296  AC_DEFINE([JEMALLOC_ATOMIC9])
1297fi
1298
1299dnl ============================================================================
1300dnl Check for atomic(3) operations as provided on Darwin.
1301
1302JE_COMPILABLE([Darwin OSAtomic*()], [
1303#include <libkern/OSAtomic.h>
1304#include <inttypes.h>
1305], [
1306	{
1307		int32_t x32 = 0;
1308		volatile int32_t *x32p = &x32;
1309		OSAtomicAdd32(1, x32p);
1310	}
1311	{
1312		int64_t x64 = 0;
1313		volatile int64_t *x64p = &x64;
1314		OSAtomicAdd64(1, x64p);
1315	}
1316], [je_cv_osatomic])
1317if test "x${je_cv_osatomic}" = "xyes" ; then
1318  AC_DEFINE([JEMALLOC_OSATOMIC], [ ])
1319fi
1320
1321dnl ============================================================================
1322dnl Check for madvise(2).
1323
1324JE_COMPILABLE([madvise(2)], [
1325#include <sys/mman.h>
1326], [
1327	{
1328		madvise((void *)0, 0, 0);
1329	}
1330], [je_cv_madvise])
1331if test "x${je_cv_madvise}" = "xyes" ; then
1332  AC_DEFINE([JEMALLOC_HAVE_MADVISE], [ ])
1333fi
1334
1335dnl ============================================================================
1336dnl Check whether __sync_{add,sub}_and_fetch() are available despite
1337dnl __GCC_HAVE_SYNC_COMPARE_AND_SWAP_n macros being undefined.
1338
1339AC_DEFUN([JE_SYNC_COMPARE_AND_SWAP_CHECK],[
1340  AC_CACHE_CHECK([whether to force $1-bit __sync_{add,sub}_and_fetch()],
1341               [je_cv_sync_compare_and_swap_$2],
1342               [AC_LINK_IFELSE([AC_LANG_PROGRAM([
1343                                                 #include <stdint.h>
1344                                                ],
1345                                                [
1346                                                 #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2
1347                                                 {
1348                                                    uint$1_t x$1 = 0;
1349                                                    __sync_add_and_fetch(&x$1, 42);
1350                                                    __sync_sub_and_fetch(&x$1, 1);
1351                                                 }
1352                                                 #else
1353                                                 #error __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2 is defined, no need to force
1354                                                 #endif
1355                                                ])],
1356                               [je_cv_sync_compare_and_swap_$2=yes],
1357                               [je_cv_sync_compare_and_swap_$2=no])])
1358
1359  if test "x${je_cv_sync_compare_and_swap_$2}" = "xyes" ; then
1360    AC_DEFINE([JE_FORCE_SYNC_COMPARE_AND_SWAP_$2], [ ])
1361  fi
1362])
1363
1364if test "x${je_cv_atomic9}" != "xyes" -a "x${je_cv_osatomic}" != "xyes" ; then
1365  JE_SYNC_COMPARE_AND_SWAP_CHECK(32, 4)
1366  JE_SYNC_COMPARE_AND_SWAP_CHECK(64, 8)
1367fi
1368
1369dnl ============================================================================
1370dnl Check for __builtin_clz() and __builtin_clzl().
1371
1372AC_CACHE_CHECK([for __builtin_clz],
1373               [je_cv_builtin_clz],
1374               [AC_LINK_IFELSE([AC_LANG_PROGRAM([],
1375                                                [
1376                                                {
1377                                                        unsigned x = 0;
1378                                                        int y = __builtin_clz(x);
1379                                                }
1380                                                {
1381                                                        unsigned long x = 0;
1382                                                        int y = __builtin_clzl(x);
1383                                                }
1384                                                ])],
1385                               [je_cv_builtin_clz=yes],
1386                               [je_cv_builtin_clz=no])])
1387
1388if test "x${je_cv_builtin_clz}" = "xyes" ; then
1389  AC_DEFINE([JEMALLOC_HAVE_BUILTIN_CLZ], [ ])
1390fi
1391
1392dnl ============================================================================
1393dnl Check for spinlock(3) operations as provided on Darwin.
1394
1395JE_COMPILABLE([Darwin OSSpin*()], [
1396#include <libkern/OSAtomic.h>
1397#include <inttypes.h>
1398], [
1399	OSSpinLock lock = 0;
1400	OSSpinLockLock(&lock);
1401	OSSpinLockUnlock(&lock);
1402], [je_cv_osspin])
1403if test "x${je_cv_osspin}" = "xyes" ; then
1404  AC_DEFINE([JEMALLOC_OSSPIN], [ ])
1405fi
1406
1407dnl ============================================================================
1408dnl Darwin-related configuration.
1409
1410AC_ARG_ENABLE([zone-allocator],
1411  [AS_HELP_STRING([--disable-zone-allocator],
1412                  [Disable zone allocator for Darwin])],
1413[if test "x$enable_zone_allocator" = "xno" ; then
1414  enable_zone_allocator="0"
1415else
1416  enable_zone_allocator="1"
1417fi
1418],
1419[if test "x${abi}" = "xmacho"; then
1420  enable_zone_allocator="1"
1421fi
1422]
1423)
1424AC_SUBST([enable_zone_allocator])
1425
1426if test "x${enable_zone_allocator}" = "x1" ; then
1427  if test "x${abi}" != "xmacho"; then
1428    AC_MSG_ERROR([--enable-zone-allocator is only supported on Darwin])
1429  fi
1430  AC_DEFINE([JEMALLOC_ZONE], [ ])
1431
1432  dnl The szone version jumped from 3 to 6 between the OS X 10.5.x and 10.6
1433  dnl releases.  malloc_zone_t and malloc_introspection_t have new fields in
1434  dnl 10.6, which is the only source-level indication of the change.
1435  AC_MSG_CHECKING([malloc zone version])
1436  AC_DEFUN([JE_ZONE_PROGRAM],
1437    [AC_LANG_PROGRAM(
1438      [#include <malloc/malloc.h>],
1439      [static int foo[[sizeof($1) $2 sizeof(void *) * $3 ? 1 : -1]]]
1440    )])
1441
1442  AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,14)],[JEMALLOC_ZONE_VERSION=3],[
1443  AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,15)],[JEMALLOC_ZONE_VERSION=5],[
1444  AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,16)],[
1445    AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,9)],[JEMALLOC_ZONE_VERSION=6],[
1446    AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,13)],[JEMALLOC_ZONE_VERSION=7],[JEMALLOC_ZONE_VERSION=]
1447  )])],[
1448  AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,17)],[JEMALLOC_ZONE_VERSION=8],[
1449  AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,>,17)],[JEMALLOC_ZONE_VERSION=9],[JEMALLOC_ZONE_VERSION=]
1450  )])])])])
1451  if test "x${JEMALLOC_ZONE_VERSION}" = "x"; then
1452    AC_MSG_RESULT([unsupported])
1453    AC_MSG_ERROR([Unsupported malloc zone version])
1454  fi
1455  if test "${JEMALLOC_ZONE_VERSION}" = 9; then
1456    JEMALLOC_ZONE_VERSION=8
1457    AC_MSG_RESULT([> 8])
1458  else
1459    AC_MSG_RESULT([$JEMALLOC_ZONE_VERSION])
1460  fi
1461  AC_DEFINE_UNQUOTED(JEMALLOC_ZONE_VERSION, [$JEMALLOC_ZONE_VERSION])
1462fi
1463
1464dnl ============================================================================
1465dnl Check for glibc malloc hooks
1466
1467JE_COMPILABLE([glibc malloc hook], [
1468#include <stddef.h>
1469
1470extern void (* __free_hook)(void *ptr);
1471extern void *(* __malloc_hook)(size_t size);
1472extern void *(* __realloc_hook)(void *ptr, size_t size);
1473], [
1474  void *ptr = 0L;
1475  if (__malloc_hook) ptr = __malloc_hook(1);
1476  if (__realloc_hook) ptr = __realloc_hook(ptr, 2);
1477  if (__free_hook && ptr) __free_hook(ptr);
1478], [je_cv_glibc_malloc_hook])
1479if test "x${je_cv_glibc_malloc_hook}" = "xyes" ; then
1480  AC_DEFINE([JEMALLOC_GLIBC_MALLOC_HOOK], [ ])
1481fi
1482
1483JE_COMPILABLE([glibc memalign hook], [
1484#include <stddef.h>
1485
1486extern void *(* __memalign_hook)(size_t alignment, size_t size);
1487], [
1488  void *ptr = 0L;
1489  if (__memalign_hook) ptr = __memalign_hook(16, 7);
1490], [je_cv_glibc_memalign_hook])
1491if test "x${je_cv_glibc_memalign_hook}" = "xyes" ; then
1492  AC_DEFINE([JEMALLOC_GLIBC_MEMALIGN_HOOK], [ ])
1493fi
1494
1495JE_COMPILABLE([pthreads adaptive mutexes], [
1496#include <pthread.h>
1497], [
1498  pthread_mutexattr_t attr;
1499  pthread_mutexattr_init(&attr);
1500  pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ADAPTIVE_NP);
1501  pthread_mutexattr_destroy(&attr);
1502], [je_cv_pthread_mutex_adaptive_np])
1503if test "x${je_cv_pthread_mutex_adaptive_np}" = "xyes" ; then
1504  AC_DEFINE([JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], [ ])
1505fi
1506
1507dnl ============================================================================
1508dnl Check for typedefs, structures, and compiler characteristics.
1509AC_HEADER_STDBOOL
1510
1511dnl ============================================================================
1512dnl Define commands that generate output files.
1513
1514AC_CONFIG_COMMANDS([include/jemalloc/internal/private_namespace.h], [
1515  mkdir -p "${objroot}include/jemalloc/internal"
1516  "${srcdir}/include/jemalloc/internal/private_namespace.sh" "${srcdir}/include/jemalloc/internal/private_symbols.txt" > "${objroot}include/jemalloc/internal/private_namespace.h"
1517], [
1518  srcdir="${srcdir}"
1519  objroot="${objroot}"
1520])
1521AC_CONFIG_COMMANDS([include/jemalloc/internal/private_unnamespace.h], [
1522  mkdir -p "${objroot}include/jemalloc/internal"
1523  "${srcdir}/include/jemalloc/internal/private_unnamespace.sh" "${srcdir}/include/jemalloc/internal/private_symbols.txt" > "${objroot}include/jemalloc/internal/private_unnamespace.h"
1524], [
1525  srcdir="${srcdir}"
1526  objroot="${objroot}"
1527])
1528AC_CONFIG_COMMANDS([include/jemalloc/internal/public_symbols.txt], [
1529  f="${objroot}include/jemalloc/internal/public_symbols.txt"
1530  mkdir -p "${objroot}include/jemalloc/internal"
1531  cp /dev/null "${f}"
1532  for nm in `echo ${mangling_map} |tr ',' ' '` ; do
1533    n=`echo ${nm} |tr ':' ' ' |awk '{print $[]1}'`
1534    m=`echo ${nm} |tr ':' ' ' |awk '{print $[]2}'`
1535    echo "${n}:${m}" >> "${f}"
1536    dnl Remove name from public_syms so that it isn't redefined later.
1537    public_syms=`for sym in ${public_syms}; do echo "${sym}"; done |grep -v "^${n}\$" |tr '\n' ' '`
1538  done
1539  for sym in ${public_syms} ; do
1540    n="${sym}"
1541    m="${JEMALLOC_PREFIX}${sym}"
1542    echo "${n}:${m}" >> "${f}"
1543  done
1544], [
1545  srcdir="${srcdir}"
1546  objroot="${objroot}"
1547  mangling_map="${mangling_map}"
1548  public_syms="${public_syms}"
1549  JEMALLOC_PREFIX="${JEMALLOC_PREFIX}"
1550])
1551AC_CONFIG_COMMANDS([include/jemalloc/internal/public_namespace.h], [
1552  mkdir -p "${objroot}include/jemalloc/internal"
1553  "${srcdir}/include/jemalloc/internal/public_namespace.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/internal/public_namespace.h"
1554], [
1555  srcdir="${srcdir}"
1556  objroot="${objroot}"
1557])
1558AC_CONFIG_COMMANDS([include/jemalloc/internal/public_unnamespace.h], [
1559  mkdir -p "${objroot}include/jemalloc/internal"
1560  "${srcdir}/include/jemalloc/internal/public_unnamespace.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/internal/public_unnamespace.h"
1561], [
1562  srcdir="${srcdir}"
1563  objroot="${objroot}"
1564])
1565AC_CONFIG_COMMANDS([include/jemalloc/internal/size_classes.h], [
1566  mkdir -p "${objroot}include/jemalloc/internal"
1567  "${srcdir}/include/jemalloc/internal/size_classes.sh" "${LG_QUANTA}" ${LG_TINY_MIN} "${LG_PAGE_SIZES}" ${LG_SIZE_CLASS_GROUP} > "${objroot}include/jemalloc/internal/size_classes.h"
1568], [
1569  srcdir="${srcdir}"
1570  objroot="${objroot}"
1571  LG_QUANTA="${LG_QUANTA}"
1572  LG_TINY_MIN=${LG_TINY_MIN}
1573  LG_PAGE_SIZES="${LG_PAGE_SIZES}"
1574  LG_SIZE_CLASS_GROUP=${LG_SIZE_CLASS_GROUP}
1575])
1576AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_protos_jet.h], [
1577  mkdir -p "${objroot}include/jemalloc"
1578  cat "${srcdir}/include/jemalloc/jemalloc_protos.h.in" | sed -e 's/@je_@/jet_/g' > "${objroot}include/jemalloc/jemalloc_protos_jet.h"
1579], [
1580  srcdir="${srcdir}"
1581  objroot="${objroot}"
1582])
1583AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_rename.h], [
1584  mkdir -p "${objroot}include/jemalloc"
1585  "${srcdir}/include/jemalloc/jemalloc_rename.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/jemalloc_rename.h"
1586], [
1587  srcdir="${srcdir}"
1588  objroot="${objroot}"
1589])
1590AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_mangle.h], [
1591  mkdir -p "${objroot}include/jemalloc"
1592  "${srcdir}/include/jemalloc/jemalloc_mangle.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" je_ > "${objroot}include/jemalloc/jemalloc_mangle.h"
1593], [
1594  srcdir="${srcdir}"
1595  objroot="${objroot}"
1596])
1597AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_mangle_jet.h], [
1598  mkdir -p "${objroot}include/jemalloc"
1599  "${srcdir}/include/jemalloc/jemalloc_mangle.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" jet_ > "${objroot}include/jemalloc/jemalloc_mangle_jet.h"
1600], [
1601  srcdir="${srcdir}"
1602  objroot="${objroot}"
1603])
1604AC_CONFIG_COMMANDS([include/jemalloc/jemalloc.h], [
1605  mkdir -p "${objroot}include/jemalloc"
1606  "${srcdir}/include/jemalloc/jemalloc.sh" "${objroot}" > "${objroot}include/jemalloc/jemalloc${install_suffix}.h"
1607], [
1608  srcdir="${srcdir}"
1609  objroot="${objroot}"
1610  install_suffix="${install_suffix}"
1611])
1612
1613dnl Process .in files.
1614AC_SUBST([cfghdrs_in])
1615AC_SUBST([cfghdrs_out])
1616AC_CONFIG_HEADERS([$cfghdrs_tup])
1617
1618dnl ============================================================================
1619dnl Generate outputs.
1620
1621AC_CONFIG_FILES([$cfgoutputs_tup config.stamp bin/jemalloc-config bin/jemalloc.sh bin/jeprof])
1622AC_SUBST([cfgoutputs_in])
1623AC_SUBST([cfgoutputs_out])
1624AC_OUTPUT
1625
1626dnl ============================================================================
1627dnl Print out the results of configuration.
1628AC_MSG_RESULT([===============================================================================])
1629AC_MSG_RESULT([jemalloc version   : ${jemalloc_version}])
1630AC_MSG_RESULT([library revision   : ${rev}])
1631AC_MSG_RESULT([])
1632AC_MSG_RESULT([CONFIG             : ${CONFIG}])
1633AC_MSG_RESULT([CC                 : ${CC}])
1634AC_MSG_RESULT([CFLAGS             : ${CFLAGS}])
1635AC_MSG_RESULT([CPPFLAGS           : ${CPPFLAGS}])
1636AC_MSG_RESULT([LDFLAGS            : ${LDFLAGS}])
1637AC_MSG_RESULT([EXTRA_LDFLAGS      : ${EXTRA_LDFLAGS}])
1638AC_MSG_RESULT([LIBS               : ${LIBS}])
1639AC_MSG_RESULT([RPATH_EXTRA        : ${RPATH_EXTRA}])
1640AC_MSG_RESULT([])
1641AC_MSG_RESULT([XSLTPROC           : ${XSLTPROC}])
1642AC_MSG_RESULT([XSLROOT            : ${XSLROOT}])
1643AC_MSG_RESULT([])
1644AC_MSG_RESULT([PREFIX             : ${PREFIX}])
1645AC_MSG_RESULT([BINDIR             : ${BINDIR}])
1646AC_MSG_RESULT([DATADIR            : ${DATADIR}])
1647AC_MSG_RESULT([INCLUDEDIR         : ${INCLUDEDIR}])
1648AC_MSG_RESULT([LIBDIR             : ${LIBDIR}])
1649AC_MSG_RESULT([MANDIR             : ${MANDIR}])
1650AC_MSG_RESULT([])
1651AC_MSG_RESULT([srcroot            : ${srcroot}])
1652AC_MSG_RESULT([abs_srcroot        : ${abs_srcroot}])
1653AC_MSG_RESULT([objroot            : ${objroot}])
1654AC_MSG_RESULT([abs_objroot        : ${abs_objroot}])
1655AC_MSG_RESULT([])
1656AC_MSG_RESULT([JEMALLOC_PREFIX    : ${JEMALLOC_PREFIX}])
1657AC_MSG_RESULT([JEMALLOC_PRIVATE_NAMESPACE])
1658AC_MSG_RESULT([                   : ${JEMALLOC_PRIVATE_NAMESPACE}])
1659AC_MSG_RESULT([install_suffix     : ${install_suffix}])
1660AC_MSG_RESULT([autogen            : ${enable_autogen}])
1661AC_MSG_RESULT([cc-silence         : ${enable_cc_silence}])
1662AC_MSG_RESULT([debug              : ${enable_debug}])
1663AC_MSG_RESULT([code-coverage      : ${enable_code_coverage}])
1664AC_MSG_RESULT([stats              : ${enable_stats}])
1665AC_MSG_RESULT([prof               : ${enable_prof}])
1666AC_MSG_RESULT([prof-libunwind     : ${enable_prof_libunwind}])
1667AC_MSG_RESULT([prof-libgcc        : ${enable_prof_libgcc}])
1668AC_MSG_RESULT([prof-gcc           : ${enable_prof_gcc}])
1669AC_MSG_RESULT([tcache             : ${enable_tcache}])
1670AC_MSG_RESULT([fill               : ${enable_fill}])
1671AC_MSG_RESULT([utrace             : ${enable_utrace}])
1672AC_MSG_RESULT([valgrind           : ${enable_valgrind}])
1673AC_MSG_RESULT([xmalloc            : ${enable_xmalloc}])
1674AC_MSG_RESULT([munmap             : ${enable_munmap}])
1675AC_MSG_RESULT([lazy_lock          : ${enable_lazy_lock}])
1676AC_MSG_RESULT([tls                : ${enable_tls}])
1677AC_MSG_RESULT([cache-oblivious    : ${enable_cache_oblivious}])
1678AC_MSG_RESULT([===============================================================================])
1679