]> git.saurik.com Git - redis.git/blame - deps/jemalloc/configure.ac
Use safe dictionary iterator from KEYS
[redis.git] / deps / jemalloc / configure.ac
CommitLineData
a78e148b 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_RUN_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)
29AC_DEFUN([JE_COMPILABLE],
30[
31AC_MSG_CHECKING([whether $1 is compilable])
32AC_RUN_IFELSE([AC_LANG_PROGRAM(
33[$2], [$3])],
34 AC_MSG_RESULT([yes])
35 [$4="yes"],
36 AC_MSG_RESULT([no])
37 [$4="no"]
38)
39])
40
41dnl ============================================================================
42
43srcroot=$srcdir
44if test "x${srcroot}" = "x." ; then
45 srcroot=""
46else
47 srcroot="${srcroot}/"
48fi
49AC_SUBST([srcroot])
50abs_srcroot="`cd \"${srcdir}\"; pwd`/"
51AC_SUBST([abs_srcroot])
52
53objroot=""
54AC_SUBST([objroot])
55abs_objroot="`pwd`/"
56AC_SUBST([abs_objroot])
57
58dnl Munge install path variables.
59if test "x$prefix" = "xNONE" ; then
60 prefix="/usr/local"
61fi
62if test "x$exec_prefix" = "xNONE" ; then
63 exec_prefix=$prefix
64fi
65PREFIX=$prefix
66AC_SUBST([PREFIX])
67BINDIR=`eval echo $bindir`
68BINDIR=`eval echo $BINDIR`
69AC_SUBST([BINDIR])
70INCLUDEDIR=`eval echo $includedir`
71INCLUDEDIR=`eval echo $INCLUDEDIR`
72AC_SUBST([INCLUDEDIR])
73LIBDIR=`eval echo $libdir`
74LIBDIR=`eval echo $LIBDIR`
75AC_SUBST([LIBDIR])
76DATADIR=`eval echo $datadir`
77DATADIR=`eval echo $DATADIR`
78AC_SUBST([DATADIR])
79MANDIR=`eval echo $mandir`
80MANDIR=`eval echo $MANDIR`
81AC_SUBST([MANDIR])
82
83dnl Support for building documentation.
84AC_PATH_PROG([XSLTPROC], [xsltproc], , [$PATH])
85AC_ARG_WITH([xslroot],
86 [AS_HELP_STRING([--with-xslroot=<path>], [XSL stylesheet root path])],
87if test "x$with_xslroot" = "xno" ; then
88 XSLROOT="/usr/share/xml/docbook/stylesheet/docbook-xsl"
89else
90 XSLROOT="${with_xslroot}"
91fi,
92 XSLROOT="/usr/share/xml/docbook/stylesheet/docbook-xsl"
93)
94AC_SUBST([XSLROOT])
95
96dnl If CFLAGS isn't defined, set CFLAGS to something reasonable. Otherwise,
97dnl just prevent autoconf from molesting CFLAGS.
98CFLAGS=$CFLAGS
99AC_PROG_CC
100if test "x$CFLAGS" = "x" ; then
101 no_CFLAGS="yes"
102 if test "x$GCC" = "xyes" ; then
103 JE_CFLAGS_APPEND([-std=gnu99])
104 JE_CFLAGS_APPEND([-Wall])
105 JE_CFLAGS_APPEND([-pipe])
106 JE_CFLAGS_APPEND([-g3])
107 fi
108fi
109dnl Append EXTRA_CFLAGS to CFLAGS, if defined.
110if test "x$EXTRA_CFLAGS" != "x" ; then
111 JE_CFLAGS_APPEND([$EXTRA_CFLAGS])
112fi
113AC_PROG_CPP
114
115AC_CHECK_SIZEOF([void *])
116if test "x${ac_cv_sizeof_void_p}" = "x8" ; then
117 LG_SIZEOF_PTR=3
118elif test "x${ac_cv_sizeof_void_p}" = "x4" ; then
119 LG_SIZEOF_PTR=2
120else
121 AC_MSG_ERROR([Unsupported pointer size: ${ac_cv_sizeof_void_p}])
122fi
123AC_DEFINE_UNQUOTED([LG_SIZEOF_PTR], [$LG_SIZEOF_PTR])
124
125AC_CHECK_SIZEOF([int])
126if test "x${ac_cv_sizeof_int}" = "x8" ; then
127 LG_SIZEOF_INT=3
128elif test "x${ac_cv_sizeof_int}" = "x4" ; then
129 LG_SIZEOF_INT=2
130else
131 AC_MSG_ERROR([Unsupported int size: ${ac_cv_sizeof_int}])
132fi
133AC_DEFINE_UNQUOTED([LG_SIZEOF_INT], [$LG_SIZEOF_INT])
134
135AC_CHECK_SIZEOF([long])
136if test "x${ac_cv_sizeof_long}" = "x8" ; then
137 LG_SIZEOF_LONG=3
138elif test "x${ac_cv_sizeof_long}" = "x4" ; then
139 LG_SIZEOF_LONG=2
140else
141 AC_MSG_ERROR([Unsupported long size: ${ac_cv_sizeof_long}])
142fi
143AC_DEFINE_UNQUOTED([LG_SIZEOF_LONG], [$LG_SIZEOF_LONG])
144
145AC_CANONICAL_HOST
146dnl CPU-specific settings.
147CPU_SPINWAIT=""
148case "${host_cpu}" in
149 i[[345]]86)
150 ;;
151 i686)
152 JE_COMPILABLE([__asm__], [], [[__asm__ volatile("pause"); return 0;]],
153 [asm])
154 if test "x${asm}" = "xyes" ; then
155 CPU_SPINWAIT='__asm__ volatile("pause")'
156 fi
157 ;;
158 x86_64)
159 JE_COMPILABLE([__asm__ syntax], [],
160 [[__asm__ volatile("pause"); return 0;]], [asm])
161 if test "x${asm}" = "xyes" ; then
162 CPU_SPINWAIT='__asm__ volatile("pause")'
163 fi
164 ;;
165 *)
166 ;;
167esac
168AC_DEFINE_UNQUOTED([CPU_SPINWAIT], [$CPU_SPINWAIT])
169
170dnl Platform-specific settings. abi and RPATH can probably be determined
171dnl programmatically, but doing so is error-prone, which makes it generally
172dnl not worth the trouble.
173dnl
174dnl Define cpp macros in CPPFLAGS, rather than doing AC_DEFINE(macro), since the
175dnl definitions need to be seen before any headers are included, which is a pain
176dnl to make happen otherwise.
177case "${host}" in
178 *-*-darwin*)
179 CFLAGS="$CFLAGS -fno-common -no-cpp-precomp"
180 abi="macho"
181 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE])
182 RPATH=""
183 ;;
184 *-*-freebsd*)
185 CFLAGS="$CFLAGS"
186 abi="elf"
187 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE])
188 RPATH="-Wl,-rpath,"
189 ;;
190 *-*-linux*)
191 CFLAGS="$CFLAGS"
192 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
193 abi="elf"
194 AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED])
195 RPATH="-Wl,-rpath,"
196 ;;
197 *-*-netbsd*)
198 AC_MSG_CHECKING([ABI])
199 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
200[[#ifdef __ELF__
201/* ELF */
202#else
203#error aout
204#endif
205]])],
206 [CFLAGS="$CFLAGS"; abi="elf"],
207 [abi="aout"])
208 AC_MSG_RESULT([$abi])
209 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE])
210 RPATH="-Wl,-rpath,"
211 ;;
212 *-*-solaris2*)
213 CFLAGS="$CFLAGS"
214 abi="elf"
215 RPATH="-Wl,-R,"
216 dnl Solaris needs this for sigwait().
217 CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
218 LIBS="$LIBS -lposix4 -lsocket -lnsl"
219 ;;
220 *)
221 AC_MSG_RESULT([Unsupported operating system: ${host}])
222 abi="elf"
223 RPATH="-Wl,-rpath,"
224 ;;
225esac
226AC_SUBST([abi])
227AC_SUBST([RPATH])
228
229JE_COMPILABLE([__attribute__ syntax],
230 [static __attribute__((unused)) void foo(void){}],
231 [],
232 [attribute])
233if test "x${attribute}" = "xyes" ; then
234 AC_DEFINE([JEMALLOC_HAVE_ATTR], [ ])
235 if test "x${GCC}" = "xyes" -a "x${abi}" = "xelf"; then
236 JE_CFLAGS_APPEND([-fvisibility=hidden])
237 fi
238fi
239
240JE_COMPILABLE([mremap(...MREMAP_FIXED...)], [
241#define _GNU_SOURCE
242#include <sys/mman.h>
243], [
244void *p = mremap((void *)0, 0, 0, MREMAP_MAYMOVE|MREMAP_FIXED, (void *)0);
245], [mremap_fixed])
246if test "x${mremap_fixed}" = "xyes" ; then
247 AC_DEFINE([JEMALLOC_MREMAP_FIXED])
248fi
249
250dnl Support optional additions to rpath.
251AC_ARG_WITH([rpath],
252 [AS_HELP_STRING([--with-rpath=<rpath>], [Colon-separated rpath (ELF systems only)])],
253if test "x$with_rpath" = "xno" ; then
254 RPATH_EXTRA=
255else
256 RPATH_EXTRA="`echo $with_rpath | tr \":\" \" \"`"
257fi,
258 RPATH_EXTRA=
259)
260AC_SUBST([RPATH_EXTRA])
261
262dnl Disable rules that do automatic regeneration of configure output by default.
263AC_ARG_ENABLE([autogen],
264 [AS_HELP_STRING([--enable-autogen], [Automatically regenerate configure output])],
265if test "x$enable_autogen" = "xno" ; then
266 enable_autogen="0"
267else
268 enable_autogen="1"
269fi
270,
271enable_autogen="0"
272)
273AC_SUBST([enable_autogen])
274
275AC_PROG_INSTALL
276AC_PROG_RANLIB
277AC_PATH_PROG([AR], [ar], , [$PATH])
278AC_PATH_PROG([LD], [ld], , [$PATH])
279AC_PATH_PROG([AUTOCONF], [autoconf], , [$PATH])
280
281dnl Do not prefix public APIs by default.
282AC_ARG_WITH([jemalloc_prefix],
283 [AS_HELP_STRING([--with-jemalloc-prefix=<prefix>], [Prefix to prepend to all public APIs])],
284 [JEMALLOC_PREFIX="$with_jemalloc_prefix"],
285 [if test "x$abi" != "xmacho" ; then
286 JEMALLOC_PREFIX=""
287else
288 JEMALLOC_PREFIX="je_"
289fi]
290)
291if test "x$JEMALLOC_PREFIX" != "x" ; then
292 JEMALLOC_CPREFIX=`echo ${JEMALLOC_PREFIX} | tr "a-z" "A-Z"`
293 AC_DEFINE_UNQUOTED([JEMALLOC_PREFIX], ["$JEMALLOC_PREFIX"])
294 AC_DEFINE_UNQUOTED([JEMALLOC_CPREFIX], ["$JEMALLOC_CPREFIX"])
a78e148b 295 AC_DEFINE_UNQUOTED([JEMALLOC_P(string_that_no_one_should_want_to_use_as_a_jemalloc_API_prefix)], [${JEMALLOC_PREFIX}##string_that_no_one_should_want_to_use_as_a_jemalloc_API_prefix])
296fi
297
1d03c1c9 298dnl Do not mangle library-private APIs by default.
299AC_ARG_WITH([private_namespace],
300 [AS_HELP_STRING([--with-private-namespace=<prefix>], [Prefix to prepend to all library-private APIs])],
301 [JEMALLOC_PRIVATE_NAMESPACE="$with_private_namespace"],
302 [JEMALLOC_PRIVATE_NAMESPACE=""]
303)
304AC_DEFINE_UNQUOTED([JEMALLOC_PRIVATE_NAMESPACE], ["$JEMALLOC_PRIVATE_NAMESPACE"])
305if test "x$JEMALLOC_PRIVATE_NAMESPACE" != "x" ; then
306 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])
307else
308 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])
309fi
310
a78e148b 311dnl Do not add suffix to installed files by default.
312AC_ARG_WITH([install_suffix],
313 [AS_HELP_STRING([--with-install-suffix=<suffix>], [Suffix to append to all installed files])],
314 [INSTALL_SUFFIX="$with_install_suffix"],
315 [INSTALL_SUFFIX=]
316)
317install_suffix="$INSTALL_SUFFIX"
318AC_SUBST([install_suffix])
319
320cfgoutputs_in="${srcroot}Makefile.in"
321cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/html.xsl.in"
322cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/manpages.xsl.in"
323cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/jemalloc.xml.in"
324cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/jemalloc.h.in"
325cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/internal/jemalloc_internal.h.in"
326cfgoutputs_in="${cfgoutputs_in} ${srcroot}test/jemalloc_test.h.in"
327
328cfgoutputs_out="Makefile"
329cfgoutputs_out="${cfgoutputs_out} doc/html.xsl"
330cfgoutputs_out="${cfgoutputs_out} doc/manpages.xsl"
331cfgoutputs_out="${cfgoutputs_out} doc/jemalloc${install_suffix}.xml"
332cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc${install_suffix}.h"
333cfgoutputs_out="${cfgoutputs_out} include/jemalloc/internal/jemalloc_internal.h"
334cfgoutputs_out="${cfgoutputs_out} test/jemalloc_test.h"
335
336cfgoutputs_tup="Makefile"
337cfgoutputs_tup="${cfgoutputs_tup} doc/html.xsl:doc/html.xsl.in"
338cfgoutputs_tup="${cfgoutputs_tup} doc/manpages.xsl:doc/manpages.xsl.in"
339cfgoutputs_tup="${cfgoutputs_tup} doc/jemalloc${install_suffix}.xml:doc/jemalloc.xml.in"
340cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc${install_suffix}.h:include/jemalloc/jemalloc.h.in"
341cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/internal/jemalloc_internal.h"
342cfgoutputs_tup="${cfgoutputs_tup} test/jemalloc_test.h:test/jemalloc_test.h.in"
343
344cfghdrs_in="${srcroot}include/jemalloc/jemalloc_defs.h.in"
345
346cfghdrs_out="include/jemalloc/jemalloc_defs${install_suffix}.h"
347
348cfghdrs_tup="include/jemalloc/jemalloc_defs${install_suffix}.h:include/jemalloc/jemalloc_defs.h.in"
349
350dnl Do not silence irrelevant compiler warnings by default, since enabling this
351dnl option incurs a performance penalty.
352AC_ARG_ENABLE([cc-silence],
353 [AS_HELP_STRING([--enable-cc-silence],
354 [Silence irrelevant compiler warnings])],
355[if test "x$enable_cc_silence" = "xno" ; then
356 enable_cc_silence="0"
357else
358 enable_cc_silence="1"
359fi
360],
361[enable_cc_silence="0"]
362)
363if test "x$enable_cc_silence" = "x1" ; then
364 AC_DEFINE([JEMALLOC_CC_SILENCE])
365fi
366
367dnl Do not compile with debugging by default.
368AC_ARG_ENABLE([debug],
369 [AS_HELP_STRING([--enable-debug], [Build debugging code])],
370[if test "x$enable_debug" = "xno" ; then
371 enable_debug="0"
372else
373 enable_debug="1"
374fi
375],
376[enable_debug="0"]
377)
378if test "x$enable_debug" = "x1" ; then
379 AC_DEFINE([JEMALLOC_DEBUG], [ ])
380 AC_DEFINE([JEMALLOC_IVSALLOC], [ ])
381fi
382AC_SUBST([enable_debug])
383
384dnl Only optimize if not debugging.
385if test "x$enable_debug" = "x0" -a "x$no_CFLAGS" = "xyes" ; then
386 dnl Make sure that an optimization flag was not specified in EXTRA_CFLAGS.
387 optimize="no"
388 echo "$EXTRA_CFLAGS" | grep "\-O" >/dev/null || optimize="yes"
389 if test "x${optimize}" = "xyes" ; then
390 if test "x$GCC" = "xyes" ; then
391 JE_CFLAGS_APPEND([-O3])
392 JE_CFLAGS_APPEND([-funroll-loops])
393 else
394 JE_CFLAGS_APPEND([-O])
395 fi
396 fi
397fi
398
399dnl Do not enable statistics calculation by default.
400AC_ARG_ENABLE([stats],
401 [AS_HELP_STRING([--enable-stats], [Enable statistics calculation/reporting])],
402[if test "x$enable_stats" = "xno" ; then
403 enable_stats="0"
404else
405 enable_stats="1"
406fi
407],
408[enable_stats="0"]
409)
410if test "x$enable_stats" = "x1" ; then
411 AC_DEFINE([JEMALLOC_STATS], [ ])
412fi
413AC_SUBST([enable_stats])
414
415dnl Do not enable profiling by default.
416AC_ARG_ENABLE([prof],
417 [AS_HELP_STRING([--enable-prof], [Enable allocation profiling])],
418[if test "x$enable_prof" = "xno" ; then
419 enable_prof="0"
420else
421 enable_prof="1"
422fi
423],
424[enable_prof="0"]
425)
426if test "x$enable_prof" = "x1" ; then
427 backtrace_method=""
428else
429 backtrace_method="N/A"
430fi
431
432AC_ARG_ENABLE([prof-libunwind],
433 [AS_HELP_STRING([--enable-prof-libunwind], [Use libunwind for backtracing])],
434[if test "x$enable_prof_libunwind" = "xno" ; then
435 enable_prof_libunwind="0"
436else
437 enable_prof_libunwind="1"
438fi
439],
440[enable_prof_libunwind="0"]
441)
442AC_ARG_WITH([static_libunwind],
443 [AS_HELP_STRING([--with-static-libunwind=<libunwind.a>],
444 [Path to static libunwind library; use rather than dynamically linking])],
445if test "x$with_static_libunwind" = "xno" ; then
446 LUNWIND="-lunwind"
447else
448 if test ! -f "$with_static_libunwind" ; then
449 AC_MSG_ERROR([Static libunwind not found: $with_static_libunwind])
450 fi
451 LUNWIND="$with_static_libunwind"
452fi,
453 LUNWIND="-lunwind"
454)
455if test "x$backtrace_method" = "x" -a "x$enable_prof_libunwind" = "x1" ; then
456 AC_CHECK_HEADERS([libunwind.h], , [enable_prof_libunwind="0"])
457 if test "x$LUNWIND" = "x-lunwind" ; then
458 AC_CHECK_LIB([unwind], [backtrace], [LIBS="$LIBS $LUNWIND"],
459 [enable_prof_libunwind="0"])
460 else
461 LIBS="$LIBS $LUNWIND"
462 fi
463 if test "x${enable_prof_libunwind}" = "x1" ; then
464 backtrace_method="libunwind"
465 AC_DEFINE([JEMALLOC_PROF_LIBUNWIND], [ ])
466 fi
467fi
468
469AC_ARG_ENABLE([prof-libgcc],
470 [AS_HELP_STRING([--disable-prof-libgcc],
471 [Do not use libgcc for backtracing])],
472[if test "x$enable_prof_libgcc" = "xno" ; then
473 enable_prof_libgcc="0"
474else
475 enable_prof_libgcc="1"
476fi
477],
478[enable_prof_libgcc="1"]
479)
480if test "x$backtrace_method" = "x" -a "x$enable_prof_libgcc" = "x1" \
481 -a "x$GCC" = "xyes" ; then
482 AC_CHECK_HEADERS([unwind.h], , [enable_prof_libgcc="0"])
483 AC_CHECK_LIB([gcc], [_Unwind_Backtrace], [LIBS="$LIBS -lgcc"], [enable_prof_libgcc="0"])
484 dnl The following is conservative, in that it only has entries for CPUs on
485 dnl which jemalloc has been tested.
486 AC_MSG_CHECKING([libgcc-based backtracing reliability on ${host_cpu}])
487 case "${host_cpu}" in
488 i[[3456]]86)
489 AC_MSG_RESULT([unreliable])
490 enable_prof_libgcc="0";
491 ;;
492 x86_64)
493 AC_MSG_RESULT([reliable])
494 ;;
495 *)
496 AC_MSG_RESULT([unreliable])
497 enable_prof_libgcc="0";
498 ;;
499 esac
500 if test "x${enable_prof_libgcc}" = "x1" ; then
501 backtrace_method="libgcc"
502 AC_DEFINE([JEMALLOC_PROF_LIBGCC], [ ])
503 fi
504else
505 enable_prof_libgcc="0"
506fi
507
508AC_ARG_ENABLE([prof-gcc],
509 [AS_HELP_STRING([--disable-prof-gcc],
510 [Do not use gcc intrinsics for backtracing])],
511[if test "x$enable_prof_gcc" = "xno" ; then
512 enable_prof_gcc="0"
513else
514 enable_prof_gcc="1"
515fi
516],
517[enable_prof_gcc="1"]
518)
519if test "x$backtrace_method" = "x" -a "x$enable_prof_gcc" = "x1" \
520 -a "x$GCC" = "xyes" ; then
521 backtrace_method="gcc intrinsics"
522 AC_DEFINE([JEMALLOC_PROF_GCC], [ ])
523else
524 enable_prof_gcc="0"
525fi
526
527if test "x$backtrace_method" = "x" ; then
528 backtrace_method="none (disabling profiling)"
529 enable_prof="0"
530fi
531AC_MSG_CHECKING([configured backtracing method])
532AC_MSG_RESULT([$backtrace_method])
533if test "x$enable_prof" = "x1" ; then
534 LIBS="$LIBS -lm"
535 AC_DEFINE([JEMALLOC_PROF], [ ])
536fi
537AC_SUBST([enable_prof])
538
539dnl Enable tiny allocations by default.
540AC_ARG_ENABLE([tiny],
541 [AS_HELP_STRING([--disable-tiny], [Disable tiny (sub-quantum) allocations])],
542[if test "x$enable_tiny" = "xno" ; then
543 enable_tiny="0"
544else
545 enable_tiny="1"
546fi
547],
548[enable_tiny="1"]
549)
550if test "x$enable_tiny" = "x1" ; then
551 AC_DEFINE([JEMALLOC_TINY], [ ])
552fi
553AC_SUBST([enable_tiny])
554
555dnl Enable thread-specific caching by default.
556AC_ARG_ENABLE([tcache],
557 [AS_HELP_STRING([--disable-tcache], [Disable per thread caches])],
558[if test "x$enable_tcache" = "xno" ; then
559 enable_tcache="0"
560else
561 enable_tcache="1"
562fi
563],
564[enable_tcache="1"]
565)
566if test "x$enable_tcache" = "x1" ; then
567 AC_DEFINE([JEMALLOC_TCACHE], [ ])
568fi
569AC_SUBST([enable_tcache])
570
571dnl Do not enable mmap()ped swap files by default.
572AC_ARG_ENABLE([swap],
573 [AS_HELP_STRING([--enable-swap], [Enable mmap()ped swap files])],
574[if test "x$enable_swap" = "xno" ; then
575 enable_swap="0"
576else
577 enable_swap="1"
578fi
579],
580[enable_swap="0"]
581)
582if test "x$enable_swap" = "x1" ; then
583 AC_DEFINE([JEMALLOC_SWAP], [ ])
584fi
585AC_SUBST([enable_swap])
586
587dnl Do not enable allocation from DSS by default.
588AC_ARG_ENABLE([dss],
589 [AS_HELP_STRING([--enable-dss], [Enable allocation from DSS])],
590[if test "x$enable_dss" = "xno" ; then
591 enable_dss="0"
592else
593 enable_dss="1"
594fi
595],
596[enable_dss="0"]
597)
598if test "x$enable_dss" = "x1" ; then
599 AC_DEFINE([JEMALLOC_DSS], [ ])
600fi
601AC_SUBST([enable_dss])
602
603dnl Do not support the junk/zero filling option by default.
604AC_ARG_ENABLE([fill],
605 [AS_HELP_STRING([--enable-fill], [Support junk/zero filling option])],
606[if test "x$enable_fill" = "xno" ; then
607 enable_fill="0"
608else
609 enable_fill="1"
610fi
611],
612[enable_fill="0"]
613)
614if test "x$enable_fill" = "x1" ; then
615 AC_DEFINE([JEMALLOC_FILL], [ ])
616fi
617AC_SUBST([enable_fill])
618
619dnl Do not support the xmalloc option by default.
620AC_ARG_ENABLE([xmalloc],
621 [AS_HELP_STRING([--enable-xmalloc], [Support xmalloc option])],
622[if test "x$enable_xmalloc" = "xno" ; then
623 enable_xmalloc="0"
624else
625 enable_xmalloc="1"
626fi
627],
628[enable_xmalloc="0"]
629)
630if test "x$enable_xmalloc" = "x1" ; then
631 AC_DEFINE([JEMALLOC_XMALLOC], [ ])
632fi
633AC_SUBST([enable_xmalloc])
634
635dnl Do not support the SYSV option by default.
636AC_ARG_ENABLE([sysv],
637 [AS_HELP_STRING([--enable-sysv], [Support SYSV semantics option])],
638[if test "x$enable_sysv" = "xno" ; then
639 enable_sysv="0"
640else
641 enable_sysv="1"
642fi
643],
644[enable_sysv="0"]
645)
646if test "x$enable_sysv" = "x1" ; then
647 AC_DEFINE([JEMALLOC_SYSV], [ ])
648fi
649AC_SUBST([enable_sysv])
650
651dnl Do not determine page shift at run time by default.
652AC_ARG_ENABLE([dynamic_page_shift],
653 [AS_HELP_STRING([--enable-dynamic-page-shift],
654 [Determine page size at run time (don't trust configure result)])],
655[if test "x$enable_dynamic_page_shift" = "xno" ; then
656 enable_dynamic_page_shift="0"
657else
658 enable_dynamic_page_shift="1"
659fi
660],
661[enable_dynamic_page_shift="0"]
662)
663if test "x$enable_dynamic_page_shift" = "x1" ; then
664 AC_DEFINE([DYNAMIC_PAGE_SHIFT], [ ])
665fi
666AC_SUBST([enable_dynamic_page_shift])
667
668AC_MSG_CHECKING([STATIC_PAGE_SHIFT])
669AC_RUN_IFELSE([AC_LANG_PROGRAM(
670[[#include <stdio.h>
671#include <unistd.h>
672#include <strings.h>
673]], [[
674 long result;
675 FILE *f;
676
677 result = sysconf(_SC_PAGESIZE);
678 if (result == -1) {
679 return 1;
680 }
681 f = fopen("conftest.out", "w");
682 if (f == NULL) {
683 return 1;
684 }
685 fprintf(f, "%u\n", ffs((int)result) - 1);
686 close(f);
687
688 return 0;
689]])],
690 [STATIC_PAGE_SHIFT=`cat conftest.out`]
691 AC_MSG_RESULT([$STATIC_PAGE_SHIFT])
692 AC_DEFINE_UNQUOTED([STATIC_PAGE_SHIFT], [$STATIC_PAGE_SHIFT]),
693 AC_MSG_RESULT([error]))
694
695dnl ============================================================================
696dnl jemalloc configuration.
697dnl
698
699dnl Set VERSION if source directory has an embedded git repository.
1d03c1c9 700if test -d "${srcroot}.git" ; then
a78e148b 701 git describe --long --abbrev=40 > ${srcroot}VERSION
702fi
703jemalloc_version=`cat ${srcroot}VERSION`
704jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'`
705jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'`
706jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'`
707jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'`
708jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'`
709AC_SUBST([jemalloc_version])
710AC_SUBST([jemalloc_version_major])
711AC_SUBST([jemalloc_version_minor])
712AC_SUBST([jemalloc_version_bugfix])
713AC_SUBST([jemalloc_version_nrev])
714AC_SUBST([jemalloc_version_gid])
715
716dnl ============================================================================
717dnl Configure pthreads.
718
719AC_CHECK_HEADERS([pthread.h], , [AC_MSG_ERROR([pthread.h is missing])])
720AC_CHECK_LIB([pthread], [pthread_create], [LIBS="$LIBS -lpthread"],
721 [AC_MSG_ERROR([libpthread is missing])])
722
723CPPFLAGS="$CPPFLAGS -D_REENTRANT"
724
725dnl Enable lazy locking by default.
726AC_ARG_ENABLE([lazy_lock],
727 [AS_HELP_STRING([--disable-lazy-lock],
728 [Disable lazy locking (always lock, even when single-threaded)])],
729[if test "x$enable_lazy_lock" = "xno" ; then
730 enable_lazy_lock="0"
731else
732 enable_lazy_lock="1"
733fi
734],
735[enable_lazy_lock="1"]
736)
737if test "x$enable_lazy_lock" = "x1" ; then
738 AC_CHECK_HEADERS([dlfcn.h], , [AC_MSG_ERROR([dlfcn.h is missing])])
739 AC_CHECK_LIB([dl], [dlopen], [LIBS="$LIBS -ldl"],
740 [AC_MSG_ERROR([libdl is missing])])
741 AC_DEFINE([JEMALLOC_LAZY_LOCK], [ ])
742fi
743AC_SUBST([enable_lazy_lock])
744
745AC_ARG_ENABLE([tls],
746 [AS_HELP_STRING([--disable-tls], [Disable thread-local storage (__thread keyword)])],
747if test "x$enable_tls" = "xno" ; then
748 enable_tls="0"
749else
750 enable_tls="1"
751fi
752,
753enable_tls="1"
754)
755if test "x${enable_tls}" = "x1" ; then
756AC_MSG_CHECKING([for TLS])
757AC_RUN_IFELSE([AC_LANG_PROGRAM(
758[[
759 __thread int x;
760]], [[
761 x = 42;
762
763 return 0;
764]])],
765 AC_MSG_RESULT([yes]),
766 AC_MSG_RESULT([no])
767 enable_tls="0")
768fi
769AC_SUBST([enable_tls])
770if test "x${enable_tls}" = "x0" ; then
771 AC_DEFINE_UNQUOTED([NO_TLS], [ ])
772fi
773
774dnl ============================================================================
775dnl Check for ffsl(3), and fail if not found. This function exists on all
776dnl platforms that jemalloc currently has a chance of functioning on without
777dnl modification.
778
779AC_CHECK_FUNC([ffsl], [],
780 [AC_MSG_ERROR([Cannot build without ffsl(3)])])
781
782dnl ============================================================================
783dnl Check for atomic(3) operations as provided on Darwin.
784
785JE_COMPILABLE([Darwin OSAtomic*()], [
786#include <libkern/OSAtomic.h>
787#include <inttypes.h>
788], [
789 {
790 int32_t x32 = 0;
791 volatile int32_t *x32p = &x32;
792 OSAtomicAdd32(1, x32p);
793 }
794 {
795 int64_t x64 = 0;
796 volatile int64_t *x64p = &x64;
797 OSAtomicAdd64(1, x64p);
798 }
799], [osatomic])
800if test "x${osatomic}" = "xyes" ; then
801 AC_DEFINE([JEMALLOC_OSATOMIC])
802fi
803
804dnl ============================================================================
805dnl Check for spinlock(3) operations as provided on Darwin.
806
807JE_COMPILABLE([Darwin OSSpin*()], [
808#include <libkern/OSAtomic.h>
809#include <inttypes.h>
810], [
811 OSSpinLock lock = 0;
812 OSSpinLockLock(&lock);
813 OSSpinLockUnlock(&lock);
814], [osspin])
815if test "x${osspin}" = "xyes" ; then
816 AC_DEFINE([JEMALLOC_OSSPIN])
817fi
818
819dnl ============================================================================
820dnl Check for allocator-related functions that should be wrapped.
821
822AC_CHECK_FUNC([memalign],
823 [AC_DEFINE([JEMALLOC_OVERRIDE_MEMALIGN])])
824AC_CHECK_FUNC([valloc],
825 [AC_DEFINE([JEMALLOC_OVERRIDE_VALLOC])])
826
827dnl ============================================================================
828dnl Darwin-related configuration.
829
830if test "x${abi}" = "xmacho" ; then
831 AC_DEFINE([JEMALLOC_IVSALLOC])
832 AC_DEFINE([JEMALLOC_ZONE])
833
834 dnl The szone version jumped from 3 to 6 between the OS X 10.5.x and 10.6
835 dnl releases. malloc_zone_t and malloc_introspection_t have new fields in
836 dnl 10.6, which is the only source-level indication of the change.
837 AC_MSG_CHECKING([malloc zone version])
838 AC_TRY_COMPILE([#include <stdlib.h>
839#include <malloc/malloc.h>], [
840 static malloc_zone_t zone;
841 static struct malloc_introspection_t zone_introspect;
842
843 zone.size = NULL;
844 zone.malloc = NULL;
845 zone.calloc = NULL;
846 zone.valloc = NULL;
847 zone.free = NULL;
848 zone.realloc = NULL;
849 zone.destroy = NULL;
850 zone.zone_name = "jemalloc_zone";
851 zone.batch_malloc = NULL;
852 zone.batch_free = NULL;
853 zone.introspect = &zone_introspect;
854 zone.version = 6;
855 zone.memalign = NULL;
856 zone.free_definite_size = NULL;
857
858 zone_introspect.enumerator = NULL;
859 zone_introspect.good_size = NULL;
860 zone_introspect.check = NULL;
861 zone_introspect.print = NULL;
862 zone_introspect.log = NULL;
863 zone_introspect.force_lock = NULL;
864 zone_introspect.force_unlock = NULL;
865 zone_introspect.statistics = NULL;
866 zone_introspect.zone_locked = NULL;
867], [AC_DEFINE_UNQUOTED([JEMALLOC_ZONE_VERSION], [6])
868 AC_MSG_RESULT([6])],
869 [AC_DEFINE_UNQUOTED([JEMALLOC_ZONE_VERSION], [3])
870 AC_MSG_RESULT([3])])
871fi
872
873dnl ============================================================================
874dnl Check for typedefs, structures, and compiler characteristics.
875AC_HEADER_STDBOOL
876
877dnl Process .in files.
878AC_SUBST([cfghdrs_in])
879AC_SUBST([cfghdrs_out])
880AC_CONFIG_HEADERS([$cfghdrs_tup])
881
882dnl ============================================================================
883dnl Generate outputs.
884AC_CONFIG_FILES([$cfgoutputs_tup config.stamp])
885AC_SUBST([cfgoutputs_in])
886AC_SUBST([cfgoutputs_out])
887AC_OUTPUT
888
889dnl ============================================================================
890dnl Print out the results of configuration.
891AC_MSG_RESULT([===============================================================================])
892AC_MSG_RESULT([jemalloc version : $jemalloc_version])
893AC_MSG_RESULT([])
894AC_MSG_RESULT([CC : ${CC}])
895AC_MSG_RESULT([CPPFLAGS : ${CPPFLAGS}])
896AC_MSG_RESULT([CFLAGS : ${CFLAGS}])
897AC_MSG_RESULT([LDFLAGS : ${LDFLAGS}])
898AC_MSG_RESULT([LIBS : ${LIBS}])
899AC_MSG_RESULT([RPATH_EXTRA : ${RPATH_EXTRA}])
900AC_MSG_RESULT([])
901AC_MSG_RESULT([XSLTPROC : ${XSLTPROC}])
902AC_MSG_RESULT([XSLROOT : ${XSLROOT}])
903AC_MSG_RESULT([])
904AC_MSG_RESULT([PREFIX : ${PREFIX}])
905AC_MSG_RESULT([BINDIR : ${BINDIR}])
906AC_MSG_RESULT([INCLUDEDIR : ${INCLUDEDIR}])
907AC_MSG_RESULT([LIBDIR : ${LIBDIR}])
908AC_MSG_RESULT([DATADIR : ${DATADIR}])
909AC_MSG_RESULT([MANDIR : ${MANDIR}])
910AC_MSG_RESULT([])
911AC_MSG_RESULT([srcroot : ${srcroot}])
912AC_MSG_RESULT([abs_srcroot : ${abs_srcroot}])
913AC_MSG_RESULT([objroot : ${objroot}])
914AC_MSG_RESULT([abs_objroot : ${abs_objroot}])
915AC_MSG_RESULT([])
916AC_MSG_RESULT([JEMALLOC_PREFIX : ${JEMALLOC_PREFIX}])
1d03c1c9 917AC_MSG_RESULT([JEMALLOC_PRIVATE_NAMESPACE])
918AC_MSG_RESULT([ : ${JEMALLOC_PRIVATE_NAMESPACE}])
a78e148b 919AC_MSG_RESULT([install_suffix : ${install_suffix}])
920AC_MSG_RESULT([autogen : ${enable_autogen}])
921AC_MSG_RESULT([cc-silence : ${enable_cc_silence}])
922AC_MSG_RESULT([debug : ${enable_debug}])
923AC_MSG_RESULT([stats : ${enable_stats}])
924AC_MSG_RESULT([prof : ${enable_prof}])
925AC_MSG_RESULT([prof-libunwind : ${enable_prof_libunwind}])
926AC_MSG_RESULT([prof-libgcc : ${enable_prof_libgcc}])
927AC_MSG_RESULT([prof-gcc : ${enable_prof_gcc}])
928AC_MSG_RESULT([tiny : ${enable_tiny}])
929AC_MSG_RESULT([tcache : ${enable_tcache}])
930AC_MSG_RESULT([fill : ${enable_fill}])
931AC_MSG_RESULT([xmalloc : ${enable_xmalloc}])
932AC_MSG_RESULT([sysv : ${enable_sysv}])
933AC_MSG_RESULT([swap : ${enable_swap}])
934AC_MSG_RESULT([dss : ${enable_dss}])
935AC_MSG_RESULT([dynamic_page_shift : ${enable_dynamic_page_shift}])
936AC_MSG_RESULT([lazy_lock : ${enable_lazy_lock}])
937AC_MSG_RESULT([tls : ${enable_tls}])
938AC_MSG_RESULT([===============================================================================])