blob: b0d470a04f8f22f834f6590e6f1c545d5f8e0448 [file] [log] [blame]
Jason Evansb7924f52009-06-23 19:01:18 -07001dnl Process this file with autoconf to produce a configure script.
2AC_INIT([Makefile.in])
3
Jason Evansf3340ca2009-06-30 16:17:05 -07004dnl ============================================================================
5dnl Custom macro definitions.
6
7dnl JE_CFLAGS_APPEND(cflag)
8AC_DEFUN([JE_CFLAGS_APPEND],
9[
10AC_MSG_CHECKING([whether compiler supports $1])
11TCFLAGS="${CFLAGS}"
12if test "x${CFLAGS}" = "x" ; then
13 CFLAGS="$1"
14else
15 CFLAGS="${CFLAGS} $1"
16fi
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
Jason Evansb7924f52009-06-23 19:01:18 -070043srcroot=$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
Jason Evansf3340ca2009-06-30 16:17:05 -070083dnl If CFLAGS isn't defined, set CFLAGS to something reasonable. Otherwise,
84dnl just prevent autoconf from molesting CFLAGS.
Jason Evansb7924f52009-06-23 19:01:18 -070085CFLAGS=$CFLAGS
86AC_PROG_CC
87if test "x$CFLAGS" = "x" ; then
88 no_CFLAGS="yes"
Jason Evanscfeccd32010-03-03 15:48:20 -080089 if test "x$GCC" = "xyes" ; then
90 JE_CFLAGS_APPEND([-std=gnu99])
91 JE_CFLAGS_APPEND([-Wall])
92 JE_CFLAGS_APPEND([-pipe])
93 JE_CFLAGS_APPEND([-g3])
94 fi
Jason Evansb7924f52009-06-23 19:01:18 -070095fi
96dnl Append EXTRA_CFLAGS to CFLAGS, if defined.
97if test "x$EXTRA_CFLAGS" != "x" ; then
Jason Evansf3340ca2009-06-30 16:17:05 -070098 JE_CFLAGS_APPEND([$EXTRA_CFLAGS])
Jason Evansb7924f52009-06-23 19:01:18 -070099fi
100AC_PROG_CPP
101
Jason Evansb7924f52009-06-23 19:01:18 -0700102AC_CHECK_SIZEOF([void *])
103if test "x${ac_cv_sizeof_void_p}" = "x8" ; then
Jason Evans94ad2b52009-12-29 00:09:15 -0800104 LG_SIZEOF_PTR=3
Jason Evansb7924f52009-06-23 19:01:18 -0700105elif test "x${ac_cv_sizeof_void_p}" = "x4" ; then
Jason Evans94ad2b52009-12-29 00:09:15 -0800106 LG_SIZEOF_PTR=2
Jason Evansb7924f52009-06-23 19:01:18 -0700107else
108 AC_MSG_ERROR([Unsupported pointer size: ${ac_cv_sizeof_void_p}])
109fi
Jason Evans94ad2b52009-12-29 00:09:15 -0800110AC_DEFINE_UNQUOTED([LG_SIZEOF_PTR], [$LG_SIZEOF_PTR])
111
112AC_CHECK_SIZEOF([int])
113if test "x${ac_cv_sizeof_int}" = "x8" ; then
114 LG_SIZEOF_INT=3
115elif test "x${ac_cv_sizeof_int}" = "x4" ; then
116 LG_SIZEOF_INT=2
117else
118 AC_MSG_ERROR([Unsupported int size: ${ac_cv_sizeof_int}])
119fi
120AC_DEFINE_UNQUOTED([LG_SIZEOF_INT], [$LG_SIZEOF_INT])
Jason Evansb7924f52009-06-23 19:01:18 -0700121
122AC_CANONICAL_HOST
123dnl CPU-specific settings.
124CPU_SPINWAIT=""
125case "${host_cpu}" in
126 i[[345]]86)
127 ;;
128 i686)
Jason Evansf3340ca2009-06-30 16:17:05 -0700129 JE_COMPILABLE([__asm__], [], [[__asm__ volatile("pause"); return 0;]],
130 [asm])
131 if test "x${asm}" = "xyes" ; then
132 CPU_SPINWAIT='__asm__ volatile("pause")'
133 fi
Jason Evansb7924f52009-06-23 19:01:18 -0700134 ;;
135 x86_64)
Jason Evansf3340ca2009-06-30 16:17:05 -0700136 JE_COMPILABLE([__asm__ syntax], [],
137 [[__asm__ volatile("pause"); return 0;]], [asm])
138 if test "x${asm}" = "xyes" ; then
139 CPU_SPINWAIT='__asm__ volatile("pause")'
140 fi
Jason Evansb7924f52009-06-23 19:01:18 -0700141 ;;
142 *)
143 ;;
144esac
145AC_DEFINE_UNQUOTED([CPU_SPINWAIT], [$CPU_SPINWAIT])
146
Jason Evansf3340ca2009-06-30 16:17:05 -0700147JE_COMPILABLE([__attribute__ syntax],
148 [static __attribute__((unused)) void foo(void){}],
149 [],
150 [attribute])
151if test "x${attribute}" = "xyes" ; then
Jason Evans9ad48232010-01-03 11:59:20 -0800152 AC_DEFINE([JEMALLOC_HAVE_ATTR], [ ])
Jason Evans2dbecf12010-09-05 10:35:13 -0700153 if test "x$GCC" = "xyes" -a "${abi}" = "xelf"; then
Jason Evanse476f8a2010-01-16 09:53:50 -0800154 JE_CFLAGS_APPEND([-fvisibility=internal])
155 fi
Jason Evansf3340ca2009-06-30 16:17:05 -0700156fi
157
Jason Evansb7924f52009-06-23 19:01:18 -0700158dnl Platform-specific settings. abi and RPATH can probably be determined
159dnl programmatically, but doing so is error-prone, which makes it generally
160dnl not worth the trouble.
161dnl
162dnl Define cpp macros in CPPFLAGS, rather than doing AC_DEFINE(macro), since the
163dnl definitions need to be seen before any headers are included, which is a pain
164dnl to make happen otherwise.
165case "${host}" in
166 *-*-darwin*)
167 CFLAGS="$CFLAGS -fno-common -no-cpp-precomp"
168 abi="macho"
Jason Evans2dbecf12010-09-05 10:35:13 -0700169 AC_DEFINE([JEMALLOC_PURGE_MSYNC_KILLPAGES])
Jason Evansb7924f52009-06-23 19:01:18 -0700170 RPATH=""
171 ;;
172 *-*-freebsd*)
173 CFLAGS="$CFLAGS"
174 abi="elf"
Jason Evans2dbecf12010-09-05 10:35:13 -0700175 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE])
Jason Evansb7924f52009-06-23 19:01:18 -0700176 RPATH="-Wl,-rpath,"
177 ;;
178 *-*-linux*)
179 CFLAGS="$CFLAGS"
180 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
181 abi="elf"
Jason Evans2dbecf12010-09-05 10:35:13 -0700182 AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED])
Jason Evansb7924f52009-06-23 19:01:18 -0700183 RPATH="-Wl,-rpath,"
184 ;;
185 *-*-netbsd*)
186 AC_MSG_CHECKING([ABI])
187 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
188[[#ifdef __ELF__
189/* ELF */
190#else
191#error aout
192#endif
193]])],
194 [CFLAGS="$CFLAGS"; abi="elf"],
195 [abi="aout"])
196 AC_MSG_RESULT([$abi])
Jason Evans2dbecf12010-09-05 10:35:13 -0700197 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE])
Jason Evansb7924f52009-06-23 19:01:18 -0700198 RPATH="-Wl,-rpath,"
199 ;;
200 *-*-solaris2*)
201 CFLAGS="$CFLAGS"
202 abi="elf"
203 RPATH="-Wl,-R,"
204 dnl Solaris needs this for sigwait().
205 CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
206 LIBS="$LIBS -lposix4 -lsocket -lnsl"
207 ;;
208 *)
209 AC_MSG_RESULT([Unsupported operating system: ${host}])
210 abi="elf"
211 RPATH="-Wl,-rpath,"
212 ;;
213esac
214AC_SUBST([abi])
215AC_SUBST([RPATH])
216
217dnl Support optional additions to rpath.
218AC_ARG_WITH([rpath],
Jason Evans90895cf2009-12-29 00:09:15 -0800219 [AS_HELP_STRING([--with-rpath=<rpath>], [Colon-separated rpath (ELF systems only)])],
Jason Evansb7924f52009-06-23 19:01:18 -0700220if test "x$with_rpath" = "xno" ; then
221 RPATH_EXTRA=
222else
223 RPATH_EXTRA="`echo $with_rpath | tr \":\" \" \"`"
224fi,
225 RPATH_EXTRA=
226)
227AC_SUBST([RPATH_EXTRA])
228
229dnl Disable rules that do automatic regeneration of configure output by default.
230AC_ARG_ENABLE([autogen],
Jason Evans78d815c2010-01-17 14:06:20 -0800231 [AS_HELP_STRING([--enable-autogen], [Automatically regenerate configure output])],
Jason Evansb7924f52009-06-23 19:01:18 -0700232if test "x$enable_autogen" = "xno" ; then
233 enable_autogen="0"
234else
235 enable_autogen="1"
236fi
237,
238enable_autogen="0"
239)
240AC_SUBST([enable_autogen])
241
242AC_PROG_INSTALL
243AC_PROG_RANLIB
244AC_PATH_PROG([AR], [ar], , [$PATH])
245AC_PATH_PROG([LD], [ld], , [$PATH])
246AC_PATH_PROG([AUTOCONF], [autoconf], , [$PATH])
247
Jason Evans90895cf2009-12-29 00:09:15 -0800248dnl Do not prefix public APIs by default.
249AC_ARG_WITH([jemalloc_prefix],
250 [AS_HELP_STRING([--with-jemalloc-prefix=<prefix>], [Prefix to prepend to all public APIs])],
Jason Evansb0fd5012010-01-17 01:49:20 -0800251 [JEMALLOC_PREFIX="$with_jemalloc_prefix"],
Jason Evans2dbecf12010-09-05 10:35:13 -0700252 [if test "x$abi" != "xmacho" ; then
253 JEMALLOC_PREFIX=""
254else
255 JEMALLOC_PREFIX="je_"
256fi]
Jason Evans90895cf2009-12-29 00:09:15 -0800257)
258if test "x$JEMALLOC_PREFIX" != "x" ; then
259 AC_DEFINE([JEMALLOC_PREFIX], [ ])
Jason Evansb0fd5012010-01-17 01:49:20 -0800260 jemalloc_prefix="$JEMALLOC_PREFIX"
Jason Evans90895cf2009-12-29 00:09:15 -0800261 AC_SUBST([jemalloc_prefix])
Jason Evanse476f8a2010-01-16 09:53:50 -0800262 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])
Jason Evans90895cf2009-12-29 00:09:15 -0800263fi
264
Jason Evansb0fd5012010-01-17 01:49:20 -0800265dnl Do not add suffix to installed files by default.
266AC_ARG_WITH([install_suffix],
267 [AS_HELP_STRING([--with-install-suffix=<suffix>], [Suffix to append to all installed files])],
268 [INSTALL_SUFFIX="$with_install_suffix"],
269 [INSTALL_SUFFIX=]
270)
271install_suffix="$INSTALL_SUFFIX"
272AC_SUBST([install_suffix])
273
Jason Evans0656ec02010-04-07 23:37:35 -0700274cfgoutputs_in="${srcroot}Makefile.in ${srcroot}doc/jemalloc.3.in"
275cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/jemalloc.h.in"
276cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/internal/jemalloc_internal.h.in"
Jason Evansb0fd5012010-01-17 01:49:20 -0800277
278cfgoutputs_out="Makefile doc/jemalloc${install_suffix}.3"
Jason Evans376b1522010-02-11 14:45:59 -0800279cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc${install_suffix}.h"
280cfgoutputs_out="${cfgoutputs_out} include/jemalloc/internal/jemalloc_internal.h"
Jason Evansb0fd5012010-01-17 01:49:20 -0800281
282cfgoutputs_tup="Makefile doc/jemalloc${install_suffix}.3:doc/jemalloc.3.in"
Jason Evans376b1522010-02-11 14:45:59 -0800283cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc${install_suffix}.h:include/jemalloc/jemalloc.h.in"
284cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/internal/jemalloc_internal.h"
Jason Evansb0fd5012010-01-17 01:49:20 -0800285
Jason Evans0656ec02010-04-07 23:37:35 -0700286cfghdrs_in="${srcroot}include/jemalloc/jemalloc_defs.h.in"
Jason Evansb0fd5012010-01-17 01:49:20 -0800287
Jason Evans376b1522010-02-11 14:45:59 -0800288cfghdrs_out="include/jemalloc/jemalloc_defs${install_suffix}.h"
Jason Evansb0fd5012010-01-17 01:49:20 -0800289
Jason Evans376b1522010-02-11 14:45:59 -0800290cfghdrs_tup="include/jemalloc/jemalloc_defs${install_suffix}.h:include/jemalloc/jemalloc_defs.h.in"
Jason Evansb0fd5012010-01-17 01:49:20 -0800291
Jason Evansb7924f52009-06-23 19:01:18 -0700292dnl Do not compile with debugging by default.
293AC_ARG_ENABLE([debug],
294 [AS_HELP_STRING([--enable-debug], [Build debugging code])],
295[if test "x$enable_debug" = "xno" ; then
296 enable_debug="0"
297else
298 enable_debug="1"
299fi
300],
301[enable_debug="0"]
302)
303if test "x$enable_debug" = "x1" ; then
304 AC_DEFINE([JEMALLOC_DEBUG], [ ])
Jason Evans2dbecf12010-09-05 10:35:13 -0700305 AC_DEFINE([JEMALLOC_IVSALLOC], [ ])
Jason Evansb7924f52009-06-23 19:01:18 -0700306fi
307AC_SUBST([enable_debug])
308
309dnl Only optimize if not debugging.
310if test "x$enable_debug" = "x0" -a "x$no_CFLAGS" = "xyes" ; then
311 dnl Make sure that an optimization flag was not specified in EXTRA_CFLAGS.
Jason Evansf3340ca2009-06-30 16:17:05 -0700312 optimize="no"
313 echo "$EXTRA_CFLAGS" | grep "\-O" >/dev/null || optimize="yes"
314 if test "x${optimize}" = "xyes" ; then
315 if test "x$GCC" = "xyes" ; then
316 JE_CFLAGS_APPEND([-O3])
317 JE_CFLAGS_APPEND([-funroll-loops])
Jason Evansf3340ca2009-06-30 16:17:05 -0700318 else
319 JE_CFLAGS_APPEND([-O])
320 fi
Jason Evansb7924f52009-06-23 19:01:18 -0700321 fi
322fi
323
324dnl Do not enable statistics calculation by default.
325AC_ARG_ENABLE([stats],
326 [AS_HELP_STRING([--enable-stats], [Enable statistics calculation/reporting])],
327[if test "x$enable_stats" = "xno" ; then
328 enable_stats="0"
329else
330 enable_stats="1"
331fi
332],
333[enable_stats="0"]
334)
335if test "x$enable_stats" = "x1" ; then
336 AC_DEFINE([JEMALLOC_STATS], [ ])
337fi
338AC_SUBST([enable_stats])
Jason Evanscc00a152009-06-25 18:06:48 -0700339if test "x$enable_stats" = "x0" ; then
340 roff_stats=".\\\" "
341else
342 roff_stats=""
343fi
344AC_SUBST([roff_stats])
Jason Evansb7924f52009-06-23 19:01:18 -0700345
Jason Evans6109fe02010-02-10 10:37:56 -0800346dnl Do not enable profiling by default.
347AC_ARG_ENABLE([prof],
348 [AS_HELP_STRING([--enable-prof], [Enable allocation profiling])],
349[if test "x$enable_prof" = "xno" ; then
350 enable_prof="0"
351else
352 enable_prof="1"
353fi
354],
355[enable_prof="0"]
356)
Jason Evansb27805b2010-02-10 18:15:53 -0800357AC_ARG_ENABLE([prof-libgcc],
358 [AS_HELP_STRING([--disable-prof-libgcc],
359 [Do not use libgcc for backtracing])],
360[if test "x$enable_prof_libgcc" = "xno" ; then
361 enable_prof_libgcc="0"
362else
363 enable_prof_libgcc="1"
364fi
365],
366[enable_prof_libgcc="1"]
367)
Jason Evans6109fe02010-02-10 10:37:56 -0800368AC_ARG_ENABLE([prof-libunwind],
369 [AS_HELP_STRING([--enable-prof-libunwind], [Use libunwind for backtracing])],
370[if test "x$enable_prof_libunwind" = "xno" ; then
371 enable_prof_libunwind="0"
372else
373 enable_prof_libunwind="1"
374fi
375],
376[enable_prof_libunwind="0"]
377)
Jason Evansca6bd4f2010-03-02 14:12:58 -0800378AC_ARG_WITH([static_libunwind],
379 [AS_HELP_STRING([--with-static-libunwind=<libunwind.a>],
380 [Path to static libunwind library; use rather than dynamically linking])],
381if test "x$with_static_libunwind" = "xno" ; then
382 LUNWIND="-lunwind"
383else
384 if test ! -f "$with_static_libunwind" ; then
385 AC_MSG_ERROR([Static libunwind not found: $with_static_libunwind])
386 fi
387 LUNWIND="$with_static_libunwind"
388fi,
389 LUNWIND="-lunwind"
390)
Jason Evans2dbecf12010-09-05 10:35:13 -0700391if test "x$enable_prof" = "x1" ; then
392 LIBS="$LIBS -lm"
393 AC_DEFINE([JEMALLOC_PROF], [ ])
394 if test "x$enable_prof_libunwind" = "x1" ; then
395 AC_CHECK_HEADERS([libunwind.h], , [enable_prof_libunwind="0"])
396 if test "x$LUNWIND" = "x-lunwind" ; then
397 AC_CHECK_LIB([unwind], [backtrace], [LIBS="$LIBS $LUNWIND"],
398 [enable_prof_libunwind="0"])
399 else
400 LIBS="$LIBS $LUNWIND"
401 fi
402 if test "x${enable_prof_libunwind}" = "x1" ; then
403 AC_DEFINE([JEMALLOC_PROF_LIBUNWIND], [ ])
404 fi
405 fi
406fi
407AC_SUBST([enable_prof])
408if test "x$enable_prof" = "x0" ; then
409 roff_prof=".\\\" "
410 roff_no_prof=""
411else
412 roff_prof=""
413 roff_no_prof=".\\\" "
414fi
415AC_SUBST([roff_prof])
416AC_SUBST([roff_no_prof])
417
418dnl If libunwind isn't enabled, try to use libgcc rather than gcc intrinsics
419dnl for backtracing.
420if test "x$enable_prof" = "x1" -a "x$enable_prof_libunwind" = "x0" \
421 -a "x$GCC" = "xyes" -a "x$enable_prof_libgcc" = "x1" ; then
422 enable_prof_libgcc="1"
423 AC_CHECK_HEADERS([unwind.h], , [enable_prof_libgcc="0"])
424 AC_CHECK_LIB([gcc], [_Unwind_Backtrace], [LIBS="$LIBS -lgcc"], [enable_prof_libgcc="0"])
425 if test "x${enable_prof_libgcc}" = "x1" ; then
426 AC_DEFINE([JEMALLOC_PROF_LIBGCC], [ ])
427 fi
428fi
Jason Evans6109fe02010-02-10 10:37:56 -0800429
Jason Evansb7924f52009-06-23 19:01:18 -0700430dnl Enable tiny allocations by default.
431AC_ARG_ENABLE([tiny],
432 [AS_HELP_STRING([--disable-tiny], [Disable tiny (sub-quantum) allocations])],
433[if test "x$enable_tiny" = "xno" ; then
434 enable_tiny="0"
435else
436 enable_tiny="1"
437fi
438],
439[enable_tiny="1"]
440)
441if test "x$enable_tiny" = "x1" ; then
442 AC_DEFINE([JEMALLOC_TINY], [ ])
443fi
444AC_SUBST([enable_tiny])
Jason Evanscc00a152009-06-25 18:06:48 -0700445if test "x$enable_tiny" = "x0" ; then
446 roff_tiny=".\\\" "
447 roff_no_tiny=""
448else
449 roff_tiny=""
450 roff_no_tiny=".\\\" "
451fi
452AC_SUBST([roff_tiny])
453AC_SUBST([roff_no_tiny])
Jason Evansb7924f52009-06-23 19:01:18 -0700454
Jason Evans84cbbcb2009-12-29 00:09:15 -0800455dnl Enable thread-specific caching by default.
456AC_ARG_ENABLE([tcache],
457 [AS_HELP_STRING([--disable-tcache], [Disable per thread caches])],
458[if test "x$enable_tcache" = "xno" ; then
459 enable_tcache="0"
Jason Evansb7924f52009-06-23 19:01:18 -0700460else
Jason Evans84cbbcb2009-12-29 00:09:15 -0800461 enable_tcache="1"
Jason Evansb7924f52009-06-23 19:01:18 -0700462fi
463],
Jason Evans84cbbcb2009-12-29 00:09:15 -0800464[enable_tcache="1"]
Jason Evansb7924f52009-06-23 19:01:18 -0700465)
Jason Evans2dbecf12010-09-05 10:35:13 -0700466if test "x$enable_tcache" = "x1" ; then
467 AC_DEFINE([JEMALLOC_TCACHE], [ ])
468fi
469AC_SUBST([enable_tcache])
470if test "x$enable_tcache" = "x0" ; then
471 roff_tcache=".\\\" "
472 roff_no_tcache=""
473else
474 roff_tcache=""
475 roff_no_tcache=".\\\" "
476fi
477AC_SUBST([roff_tcache])
478AC_SUBST([roff_no_tcache])
Jason Evansb7924f52009-06-23 19:01:18 -0700479
Jason Evans4201af02010-01-24 02:53:40 -0800480dnl Do not enable mmap()ped swap files by default.
481AC_ARG_ENABLE([swap],
482 [AS_HELP_STRING([--enable-swap], [Enable mmap()ped swap files])],
483[if test "x$enable_swap" = "xno" ; then
484 enable_swap="0"
485else
486 enable_swap="1"
487fi
488],
489[enable_swap="0"]
490)
491if test "x$enable_swap" = "x1" ; then
492 AC_DEFINE([JEMALLOC_SWAP], [ ])
493fi
494AC_SUBST([enable_swap])
495if test "x$enable_swap" = "x0" ; then
496 roff_swap=".\\\" "
497else
498 roff_swap=""
499fi
500AC_SUBST([roff_swap])
501
Jason Evansb7924f52009-06-23 19:01:18 -0700502dnl Do not enable allocation from DSS by default.
503AC_ARG_ENABLE([dss],
504 [AS_HELP_STRING([--enable-dss], [Enable allocation from DSS])],
505[if test "x$enable_dss" = "xno" ; then
506 enable_dss="0"
507else
508 enable_dss="1"
509fi
510],
511[enable_dss="0"]
512)
513if test "x$enable_dss" = "x1" ; then
514 AC_DEFINE([JEMALLOC_DSS], [ ])
515fi
516AC_SUBST([enable_dss])
Jason Evanscc00a152009-06-25 18:06:48 -0700517if test "x$enable_dss" = "x0" ; then
518 roff_dss=".\\\" "
519else
520 roff_dss=""
521fi
522AC_SUBST([roff_dss])
Jason Evansb7924f52009-06-23 19:01:18 -0700523
524dnl Do not support the junk/zero filling option by default.
525AC_ARG_ENABLE([fill],
526 [AS_HELP_STRING([--enable-fill], [Support junk/zero filling option])],
527[if test "x$enable_fill" = "xno" ; then
528 enable_fill="0"
529else
530 enable_fill="1"
531fi
532],
533[enable_fill="0"]
534)
535if test "x$enable_fill" = "x1" ; then
536 AC_DEFINE([JEMALLOC_FILL], [ ])
537fi
538AC_SUBST([enable_fill])
Jason Evanscc00a152009-06-25 18:06:48 -0700539if test "x$enable_fill" = "x0" ; then
540 roff_fill=".\\\" "
541else
542 roff_fill=""
543fi
544AC_SUBST([roff_fill])
Jason Evansb7924f52009-06-23 19:01:18 -0700545
546dnl Do not support the xmalloc option by default.
547AC_ARG_ENABLE([xmalloc],
548 [AS_HELP_STRING([--enable-xmalloc], [Support xmalloc option])],
549[if test "x$enable_xmalloc" = "xno" ; then
550 enable_xmalloc="0"
551else
552 enable_xmalloc="1"
553fi
554],
555[enable_xmalloc="0"]
556)
557if test "x$enable_xmalloc" = "x1" ; then
558 AC_DEFINE([JEMALLOC_XMALLOC], [ ])
559fi
560AC_SUBST([enable_xmalloc])
Jason Evanscc00a152009-06-25 18:06:48 -0700561if test "x$enable_xmalloc" = "x0" ; then
562 roff_xmalloc=".\\\" "
563else
564 roff_xmalloc=""
565fi
566AC_SUBST([roff_xmalloc])
Jason Evansb7924f52009-06-23 19:01:18 -0700567
568dnl Do not support the SYSV option by default.
569AC_ARG_ENABLE([sysv],
570 [AS_HELP_STRING([--enable-sysv], [Support SYSV semantics option])],
571[if test "x$enable_sysv" = "xno" ; then
572 enable_sysv="0"
573else
574 enable_sysv="1"
575fi
576],
577[enable_sysv="0"]
578)
579if test "x$enable_sysv" = "x1" ; then
580 AC_DEFINE([JEMALLOC_SYSV], [ ])
581fi
582AC_SUBST([enable_sysv])
Jason Evanscc00a152009-06-25 18:06:48 -0700583if test "x$enable_sysv" = "x0" ; then
584 roff_sysv=".\\\" "
585else
586 roff_sysv=""
587fi
588AC_SUBST([roff_sysv])
Jason Evansb7924f52009-06-23 19:01:18 -0700589
590dnl Do not determine page shift at run time by default.
591AC_ARG_ENABLE([dynamic_page_shift],
592 [AS_HELP_STRING([--enable-dynamic-page-shift],
593 [Determine page size at run time (don't trust configure result)])],
594[if test "x$enable_dynamic_page_shift" = "xno" ; then
595 enable_dynamic_page_shift="0"
596else
597 enable_dynamic_page_shift="1"
598fi
599],
600[enable_dynamic_page_shift="0"]
601)
602if test "x$enable_dynamic_page_shift" = "x1" ; then
603 AC_DEFINE([DYNAMIC_PAGE_SHIFT], [ ])
604fi
605AC_SUBST([enable_dynamic_page_shift])
606
607AC_MSG_CHECKING([STATIC_PAGE_SHIFT])
608AC_RUN_IFELSE([AC_LANG_PROGRAM(
609[[#include <stdio.h>
610#include <unistd.h>
611#include <strings.h>
612]], [[
613 long result;
614 FILE *f;
615
616 result = sysconf(_SC_PAGESIZE);
617 if (result == -1) {
618 return 1;
619 }
620 f = fopen("conftest.out", "w");
621 if (f == NULL) {
622 return 1;
623 }
624 fprintf(f, "%u\n", ffs((int)result) - 1);
625 close(f);
626
627 return 0;
628]])],
629 [STATIC_PAGE_SHIFT=`cat conftest.out`]
630 AC_MSG_RESULT([$STATIC_PAGE_SHIFT])
631 AC_DEFINE_UNQUOTED([STATIC_PAGE_SHIFT], [$STATIC_PAGE_SHIFT]),
632 AC_MSG_RESULT([error]))
633
634dnl ============================================================================
635dnl jemalloc configuration.
636dnl
Jason Evansa40bc7a2010-03-02 13:01:16 -0800637
638dnl Set VERSION if source directory has an embedded git repository.
639if test -d "${srcroot}../.git" ; then
Jason Evans79d660d2010-09-17 17:38:24 -0700640 git describe --long --abbrev=40 > ${srcroot}VERSION
Jason Evansa40bc7a2010-03-02 13:01:16 -0800641fi
Jason Evansb7924f52009-06-23 19:01:18 -0700642jemalloc_version=`cat ${srcroot}VERSION`
Jason Evansa40bc7a2010-03-02 13:01:16 -0800643jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'`
644jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'`
645jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'`
646jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'`
647jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'`
Jason Evansb7924f52009-06-23 19:01:18 -0700648AC_SUBST([jemalloc_version])
Jason Evansa40bc7a2010-03-02 13:01:16 -0800649AC_SUBST([jemalloc_version_major])
650AC_SUBST([jemalloc_version_minor])
651AC_SUBST([jemalloc_version_bugfix])
652AC_SUBST([jemalloc_version_nrev])
653AC_SUBST([jemalloc_version_gid])
Jason Evansb7924f52009-06-23 19:01:18 -0700654
655dnl ============================================================================
656dnl Configure pthreads.
657
658AC_CHECK_HEADERS([pthread.h], , [AC_MSG_ERROR([pthread.h is missing])])
659AC_CHECK_LIB([pthread], [pthread_create], [LIBS="$LIBS -lpthread"],
660 [AC_MSG_ERROR([libpthread is missing])])
661
662CPPFLAGS="$CPPFLAGS -D_REENTRANT"
663
Jason Evanscc00a152009-06-25 18:06:48 -0700664dnl Enable lazy locking by default.
Jason Evansb7924f52009-06-23 19:01:18 -0700665AC_ARG_ENABLE([lazy_lock],
Jason Evansa1624022009-11-09 14:58:12 -0800666 [AS_HELP_STRING([--disable-lazy-lock],
Jason Evanscc00a152009-06-25 18:06:48 -0700667 [Disable lazy locking (always lock, even when single-threaded)])],
Jason Evansb7924f52009-06-23 19:01:18 -0700668[if test "x$enable_lazy_lock" = "xno" ; then
669 enable_lazy_lock="0"
670else
671 enable_lazy_lock="1"
672fi
673],
Jason Evanscc00a152009-06-25 18:06:48 -0700674[enable_lazy_lock="1"]
Jason Evansb7924f52009-06-23 19:01:18 -0700675)
676if test "x$enable_lazy_lock" = "x1" ; then
677 AC_CHECK_HEADERS([dlfcn.h], , [AC_MSG_ERROR([dlfcn.h is missing])])
678 AC_CHECK_LIB([dl], [dlopen], [LIBS="$LIBS -ldl"],
679 [AC_MSG_ERROR([libdl is missing])])
680 AC_DEFINE([JEMALLOC_LAZY_LOCK], [ ])
681fi
682AC_SUBST([enable_lazy_lock])
683
Jason Evans78d815c2010-01-17 14:06:20 -0800684AC_ARG_ENABLE([tls],
685 [AS_HELP_STRING([--disable-tls], [Disable thread-local storage (__thread keyword)])],
686if test "x$enable_tls" = "xno" ; then
687 enable_tls="0"
688else
689 enable_tls="1"
690fi
691,
692enable_tls="1"
693)
694if test "x${enable_tls}" = "x1" ; then
695AC_MSG_CHECKING([for TLS])
696AC_RUN_IFELSE([AC_LANG_PROGRAM(
697[[
698 __thread int x;
699]], [[
700 x = 42;
701
702 return 0;
703]])],
704 AC_MSG_RESULT([yes]),
705 AC_MSG_RESULT([no])
706 enable_tls="0")
707fi
Jason Evansb267d0f2010-08-13 15:42:29 -0700708AC_SUBST([enable_tls])
Jason Evans78d815c2010-01-17 14:06:20 -0800709if test "x${enable_tls}" = "x0" ; then
710 AC_DEFINE_UNQUOTED([NO_TLS], [ ])
711fi
712
Jason Evans2dbecf12010-09-05 10:35:13 -0700713dnl ============================================================================
714dnl Darwin-related configuration.
Jason Evans78d815c2010-01-17 14:06:20 -0800715
Jason Evans2dbecf12010-09-05 10:35:13 -0700716if test "x${abi}" = "xmacho" ; then
717 AC_DEFINE([JEMALLOC_IVSALLOC])
718 AC_DEFINE([JEMALLOC_ZONE])
Jason Evans6109fe02010-02-10 10:37:56 -0800719
Jason Evans2dbecf12010-09-05 10:35:13 -0700720 dnl The szone version jumped from 3 to 6 between the OS X 10.5.x and 10.6
721 dnl releases. malloc_zone_t and malloc_introspection_t have new fields in
722 dnl 10.6, which is the only source-level indication of the change.
723 AC_MSG_CHECKING([malloc zone version])
724 AC_TRY_COMPILE([#include <stdlib.h>
725#include <malloc/malloc.h>], [
726 static malloc_zone_t zone;
727 static struct malloc_introspection_t zone_introspect;
728
729 zone.size = NULL;
730 zone.malloc = NULL;
731 zone.calloc = NULL;
732 zone.valloc = NULL;
733 zone.free = NULL;
734 zone.realloc = NULL;
735 zone.destroy = NULL;
736 zone.zone_name = "jemalloc_zone";
737 zone.batch_malloc = NULL;
738 zone.batch_free = NULL;
739 zone.introspect = &zone_introspect;
740 zone.version = 6;
741 zone.memalign = NULL;
742 zone.free_definite_size = NULL;
743
744 zone_introspect.enumerator = NULL;
745 zone_introspect.good_size = NULL;
746 zone_introspect.check = NULL;
747 zone_introspect.print = NULL;
748 zone_introspect.log = NULL;
749 zone_introspect.force_lock = NULL;
750 zone_introspect.force_unlock = NULL;
751 zone_introspect.statistics = NULL;
752 zone_introspect.zone_locked = NULL;
753], [AC_DEFINE_UNQUOTED([JEMALLOC_ZONE_VERSION], [6])
754 AC_MSG_RESULT([6])],
755 [AC_DEFINE_UNQUOTED([JEMALLOC_ZONE_VERSION], [3])
756 AC_MSG_RESULT([3])])
Jason Evansb27805b2010-02-10 18:15:53 -0800757fi
758
Jason Evansb7924f52009-06-23 19:01:18 -0700759dnl ============================================================================
760dnl Check for typedefs, structures, and compiler characteristics.
761AC_HEADER_STDBOOL
762
763dnl Process .in files.
Jason Evansb0fd5012010-01-17 01:49:20 -0800764AC_SUBST([cfghdrs_in])
765AC_SUBST([cfghdrs_out])
Jason Evans0656ec02010-04-07 23:37:35 -0700766AC_CONFIG_HEADERS([$cfghdrs_tup])
Jason Evansb7924f52009-06-23 19:01:18 -0700767
768dnl ============================================================================
769dnl Generate outputs.
Jason Evans0656ec02010-04-07 23:37:35 -0700770AC_CONFIG_FILES([$cfgoutputs_tup config.stamp])
Jason Evansb0fd5012010-01-17 01:49:20 -0800771AC_SUBST([cfgoutputs_in])
772AC_SUBST([cfgoutputs_out])
Jason Evansb7924f52009-06-23 19:01:18 -0700773AC_OUTPUT
774
775dnl ============================================================================
776dnl Print out the results of configuration.
777AC_MSG_RESULT([===============================================================================])
778AC_MSG_RESULT([jemalloc version : $jemalloc_version])
779AC_MSG_RESULT([])
780AC_MSG_RESULT([CC : ${CC}])
781AC_MSG_RESULT([CPPFLAGS : ${CPPFLAGS}])
782AC_MSG_RESULT([CFLAGS : ${CFLAGS}])
783AC_MSG_RESULT([LDFLAGS : ${LDFLAGS}])
784AC_MSG_RESULT([LIBS : ${LIBS}])
785AC_MSG_RESULT([RPATH_EXTRA : ${RPATH_EXTRA}])
786AC_MSG_RESULT([])
787AC_MSG_RESULT([PREFIX : ${PREFIX}])
788AC_MSG_RESULT([BINDIR : ${BINDIR}])
Jason Evans662a0172009-07-01 19:24:31 -0700789AC_MSG_RESULT([INCLUDEDIR : ${INCLUDEDIR}])
790AC_MSG_RESULT([LIBDIR : ${LIBDIR}])
Jason Evansb7924f52009-06-23 19:01:18 -0700791AC_MSG_RESULT([DATADIR : ${DATADIR}])
792AC_MSG_RESULT([MANDIR : ${MANDIR}])
793AC_MSG_RESULT([])
794AC_MSG_RESULT([srcroot : ${srcroot}])
795AC_MSG_RESULT([abs_srcroot : ${abs_srcroot}])
796AC_MSG_RESULT([objroot : ${objroot}])
797AC_MSG_RESULT([abs_objroot : ${abs_objroot}])
798AC_MSG_RESULT([])
Jason Evans90895cf2009-12-29 00:09:15 -0800799AC_MSG_RESULT([JEMALLOC_PREFIX : ${JEMALLOC_PREFIX}])
Jason Evansb0fd5012010-01-17 01:49:20 -0800800AC_MSG_RESULT([install_suffix : ${install_suffix}])
Jason Evansb7924f52009-06-23 19:01:18 -0700801AC_MSG_RESULT([autogen : ${enable_autogen}])
802AC_MSG_RESULT([debug : ${enable_debug}])
803AC_MSG_RESULT([stats : ${enable_stats}])
Jason Evans6109fe02010-02-10 10:37:56 -0800804AC_MSG_RESULT([prof : ${enable_prof}])
805AC_MSG_RESULT([prof-libunwind : ${enable_prof_libunwind}])
Jason Evansb7924f52009-06-23 19:01:18 -0700806AC_MSG_RESULT([tiny : ${enable_tiny}])
Jason Evans84cbbcb2009-12-29 00:09:15 -0800807AC_MSG_RESULT([tcache : ${enable_tcache}])
Jason Evansb7924f52009-06-23 19:01:18 -0700808AC_MSG_RESULT([fill : ${enable_fill}])
809AC_MSG_RESULT([xmalloc : ${enable_xmalloc}])
810AC_MSG_RESULT([sysv : ${enable_sysv}])
Jason Evans4201af02010-01-24 02:53:40 -0800811AC_MSG_RESULT([swap : ${enable_swap}])
Jason Evansb7924f52009-06-23 19:01:18 -0700812AC_MSG_RESULT([dss : ${enable_dss}])
813AC_MSG_RESULT([dynamic_page_shift : ${enable_dynamic_page_shift}])
814AC_MSG_RESULT([lazy_lock : ${enable_lazy_lock}])
Jason Evans2dbecf12010-09-05 10:35:13 -0700815AC_MSG_RESULT([tls : ${enable_tls}])
Jason Evansb7924f52009-06-23 19:01:18 -0700816AC_MSG_RESULT([===============================================================================])