blob: 0a4f01e8fc019a428e8acc98641fa026ca8e6ed3 [file] [log] [blame]
Jason Evansb7924f52009-06-23 19:01:18 -07001dnl Process this file with autoconf to produce a configure script.
2AC_INIT([Makefile.in])
3
Jason Evansf3340ca2009-06-30 16:17:05 -07004dnl ============================================================================
5dnl Custom macro definitions.
6
7dnl JE_CFLAGS_APPEND(cflag)
8AC_DEFUN([JE_CFLAGS_APPEND],
9[
10AC_MSG_CHECKING([whether compiler supports $1])
11TCFLAGS="${CFLAGS}"
12if test "x${CFLAGS}" = "x" ; then
13 CFLAGS="$1"
14else
15 CFLAGS="${CFLAGS} $1"
16fi
Jason Evans6684cac2012-03-05 12:15:36 -080017AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Jason Evansf3340ca2009-06-30 16:17:05 -070018[[
19]], [[
20 return 0;
21]])],
Jason Evans99b0fbb2014-02-24 16:08:38 -080022 [je_cv_cflags_appended=$1]
Jason Evansf3340ca2009-06-30 16:17:05 -070023 AC_MSG_RESULT([yes]),
Jason Evans99b0fbb2014-02-24 16:08:38 -080024 [je_cv_cflags_appended=]
Jason Evansf3340ca2009-06-30 16:17:05 -070025 AC_MSG_RESULT([no])
26 [CFLAGS="${TCFLAGS}"]
27)
28])
29
30dnl JE_COMPILABLE(label, hcode, mcode, rvar)
Jason Evans4c2faa82012-03-13 11:09:23 -070031dnl
Jason Evansf3e139a2012-03-19 09:54:20 -070032dnl Use AC_LINK_IFELSE() rather than AC_COMPILE_IFELSE() so that linker errors
Jason Evans4c2faa82012-03-13 11:09:23 -070033dnl cause failure.
Jason Evansf3340ca2009-06-30 16:17:05 -070034AC_DEFUN([JE_COMPILABLE],
35[
Jason Evans6684cac2012-03-05 12:15:36 -080036AC_CACHE_CHECK([whether $1 is compilable],
37 [$4],
Jason Evansf3e139a2012-03-19 09:54:20 -070038 [AC_LINK_IFELSE([AC_LANG_PROGRAM([$2],
39 [$3])],
40 [$4=yes],
41 [$4=no])])
Jason Evansf3340ca2009-06-30 16:17:05 -070042])
43
44dnl ============================================================================
45
Jason Evansbec6a8d2015-01-22 17:55:58 -080046CONFIG=`echo ${ac_configure_args} | sed -e "s#\'\([^ ]*\)\'#\1#g"`
47AC_SUBST([CONFIG])
48
Jason Evansf576c632011-11-01 22:27:41 -070049dnl Library revision.
Jason Evans9790b962014-04-14 22:32:31 -070050rev=2
Jason Evansf576c632011-11-01 22:27:41 -070051AC_SUBST([rev])
52
Jason Evansb7924f52009-06-23 19:01:18 -070053srcroot=$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
Jason Evansaee7fd22010-11-24 22:00:02 -080093dnl Support for building documentation.
Jason Evans7329a4f2013-01-22 10:53:29 -080094AC_PATH_PROG([XSLTPROC], [xsltproc], [false], [$PATH])
Jason Evans7091b412012-03-19 09:36:44 -070095if 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
Jason Evansaee7fd22010-11-24 22:00:02 -0800103AC_ARG_WITH([xslroot],
Jason Evans7091b412012-03-19 09:36:44 -0700104 [AS_HELP_STRING([--with-xslroot=<path>], [XSL stylesheet root path])], [
Jason Evansaee7fd22010-11-24 22:00:02 -0800105if test "x$with_xslroot" = "xno" ; then
Jason Evans7091b412012-03-19 09:36:44 -0700106 XSLROOT="${DEFAULT_XSLROOT}"
Jason Evansaee7fd22010-11-24 22:00:02 -0800107else
108 XSLROOT="${with_xslroot}"
Jason Evans7091b412012-03-19 09:36:44 -0700109fi
110],
111 XSLROOT="${DEFAULT_XSLROOT}"
Jason Evansaee7fd22010-11-24 22:00:02 -0800112)
113AC_SUBST([XSLROOT])
114
Jason Evansf3340ca2009-06-30 16:17:05 -0700115dnl If CFLAGS isn't defined, set CFLAGS to something reasonable. Otherwise,
116dnl just prevent autoconf from molesting CFLAGS.
Jason Evansb7924f52009-06-23 19:01:18 -0700117CFLAGS=$CFLAGS
118AC_PROG_CC
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200119if 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
Jason Evansb7924f52009-06-23 19:01:18 -0700132if test "x$CFLAGS" = "x" ; then
133 no_CFLAGS="yes"
Jason Evanscfeccd32010-03-03 15:48:20 -0800134 if test "x$GCC" = "xyes" ; then
135 JE_CFLAGS_APPEND([-std=gnu99])
Jason Evans99b0fbb2014-02-24 16:08:38 -0800136 if test "x$je_cv_cflags_appended" = "x-std=gnu99" ; then
137 AC_DEFINE_UNQUOTED([JEMALLOC_HAS_RESTRICT])
138 fi
Jason Evanscfeccd32010-03-03 15:48:20 -0800139 JE_CFLAGS_APPEND([-Wall])
Mike Hommeyb7b44df2014-12-18 15:12:53 +0900140 JE_CFLAGS_APPEND([-Werror=declaration-after-statement])
Jason Evanscfeccd32010-03-03 15:48:20 -0800141 JE_CFLAGS_APPEND([-pipe])
142 JE_CFLAGS_APPEND([-g3])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200143 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])
Mike Hommey8c615752014-05-29 16:58:21 +0900148 JE_CFLAGS_APPEND([-FS])
Mike Hommey6f6704c2014-05-29 17:01:10 +0900149 CPPFLAGS="$CPPFLAGS -I${srcdir}/include/msvc_compat"
Jason Evanscfeccd32010-03-03 15:48:20 -0800150 fi
Jason Evansb7924f52009-06-23 19:01:18 -0700151fi
152dnl Append EXTRA_CFLAGS to CFLAGS, if defined.
153if test "x$EXTRA_CFLAGS" != "x" ; then
Jason Evansf3340ca2009-06-30 16:17:05 -0700154 JE_CFLAGS_APPEND([$EXTRA_CFLAGS])
Jason Evansb7924f52009-06-23 19:01:18 -0700155fi
156AC_PROG_CPP
157
Jason Evansdf3f2702014-03-30 16:27:08 -0700158AC_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
Mike Hommeyff2e9992014-05-29 16:33:02 +0900163if test "x${je_cv_msvc}" = "xyes" -a "x${ac_cv_header_inttypes_h}" = "xno"; then
Mike Hommey6f6704c2014-05-29 17:01:10 +0900164 CPPFLAGS="$CPPFLAGS -I${srcdir}/include/msvc_compat/C99"
Mike Hommeyff2e9992014-05-29 16:33:02 +0900165fi
166
Jason Evansb7924f52009-06-23 19:01:18 -0700167AC_CHECK_SIZEOF([void *])
168if test "x${ac_cv_sizeof_void_p}" = "x8" ; then
Jason Evans94ad2b52009-12-29 00:09:15 -0800169 LG_SIZEOF_PTR=3
Jason Evansb7924f52009-06-23 19:01:18 -0700170elif test "x${ac_cv_sizeof_void_p}" = "x4" ; then
Jason Evans94ad2b52009-12-29 00:09:15 -0800171 LG_SIZEOF_PTR=2
Jason Evansb7924f52009-06-23 19:01:18 -0700172else
173 AC_MSG_ERROR([Unsupported pointer size: ${ac_cv_sizeof_void_p}])
174fi
Jason Evans94ad2b52009-12-29 00:09:15 -0800175AC_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])
Jason Evansb7924f52009-06-23 19:01:18 -0700186
Jason Evans84c8eef2011-03-16 10:30:13 -0700187AC_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
Jason Evansd81e4bd2012-03-06 14:57:45 -0800197AC_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
Mike Hommey14103d32012-04-20 08:38:39 +0200205 AC_MSG_ERROR([Unsupported intmax_t size: ${ac_cv_sizeof_intmax_t}])
Jason Evansd81e4bd2012-03-06 14:57:45 -0800206fi
207AC_DEFINE_UNQUOTED([LG_SIZEOF_INTMAX_T], [$LG_SIZEOF_INTMAX_T])
208
Jason Evansb7924f52009-06-23 19:01:18 -0700209AC_CANONICAL_HOST
210dnl CPU-specific settings.
211CPU_SPINWAIT=""
212case "${host_cpu}" in
Jason Evanscb657e32014-02-25 11:21:41 -0800213 i686|x86_64)
Jason Evans81e54752014-10-10 22:34:25 -0700214 AC_CACHE_VAL([je_cv_pause],
Jason Evans2eb941a2014-10-10 20:40:43 -0700215 [JE_COMPILABLE([pause instruction], [],
216 [[__asm__ volatile("pause"); return 0;]],
217 [je_cv_pause])])
Jason Evanscb657e32014-02-25 11:21:41 -0800218 if test "x${je_cv_pause}" = "xyes" ; then
Jason Evansf3340ca2009-06-30 16:17:05 -0700219 CPU_SPINWAIT='__asm__ volatile("pause")'
220 fi
Jason Evans80061b62013-12-09 13:21:08 -0800221 ;;
222 powerpc)
223 AC_DEFINE_UNQUOTED([HAVE_ALTIVEC], [ ])
Jason Evansb7924f52009-06-23 19:01:18 -0700224 ;;
225 *)
226 ;;
227esac
228AC_DEFINE_UNQUOTED([CPU_SPINWAIT], [$CPU_SPINWAIT])
229
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +0400230LD_PRELOAD_VAR="LD_PRELOAD"
Jason Evansf576c632011-11-01 22:27:41 -0700231so="so"
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200232importlib="${so}"
Mike Hommey7cdea392012-04-30 12:38:27 +0200233o="$ac_objext"
Mike Hommey5bee66d2012-04-16 16:30:24 +0200234a="a"
Mike Hommey7cdea392012-04-30 12:38:27 +0200235exe="$ac_exeext"
Mike Hommeya19e87f2012-04-21 21:27:46 -0700236libprefix="lib"
Mike Hommeyfa08da72012-04-16 16:30:25 +0200237DSO_LDFLAGS='-shared -Wl,-soname,$(@F)'
238RPATH='-Wl,-rpath,$(1)'
Mike Hommey7cdea392012-04-30 12:38:27 +0200239SOREV="${so}.${rev}"
Mike Hommey188da7c2012-04-18 18:29:41 +0200240PIC_CFLAGS='-fPIC -DPIC'
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200241CTARGET='-o $@'
242LDTARGET='-o $@'
243EXTRA_LDFLAGS=
Jason Evans80ddf492013-08-20 11:48:19 +0100244ARFLAGS='crus'
245AROUT=' $@'
Mike Hommey79c4bca2012-05-02 21:30:51 +0200246CC_MM=1
Jason Evans7372b152012-02-10 20:22:09 -0800247
Jory A. Prattad505e02013-08-11 09:44:59 -0500248AN_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
Jason Evansb7924f52009-06-23 19:01:18 -0700253dnl 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.
Jason Evans59ae2762012-04-16 17:52:27 -0700260default_munmap="1"
Jason Evansb7924f52009-06-23 19:01:18 -0700261case "${host}" in
Valerii Hiora5921ba72014-05-16 16:28:20 +0300262 *-*-darwin* | *-*-ios*)
Mike Hommeya6770a72012-05-03 14:12:49 +0200263 CFLAGS="$CFLAGS"
Jason Evansb7924f52009-06-23 19:01:18 -0700264 abi="macho"
Jason Evanse24c7af2012-03-19 10:21:17 -0700265 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
Jason Evansb7924f52009-06-23 19:01:18 -0700266 RPATH=""
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +0400267 LD_PRELOAD_VAR="DYLD_INSERT_LIBRARIES"
Jason Evansf576c632011-11-01 22:27:41 -0700268 so="dylib"
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200269 importlib="${so}"
Jason Evansb80581d2012-03-23 16:17:43 -0700270 force_tls="0"
Mike Hommeyfa08da72012-04-16 16:30:25 +0200271 DSO_LDFLAGS='-shared -Wl,-dylib_install_name,$(@F)'
Mike Hommey7cdea392012-04-30 12:38:27 +0200272 SOREV="${rev}.${so}"
Jason Evans66688532013-12-03 21:49:36 -0800273 sbrk_deprecated="1"
Jason Evansb7924f52009-06-23 19:01:18 -0700274 ;;
275 *-*-freebsd*)
276 CFLAGS="$CFLAGS"
277 abi="elf"
Jason Evanse24c7af2012-03-19 10:21:17 -0700278 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
Jason Evansfd4fcef2012-03-23 17:40:58 -0700279 force_lazy_lock="1"
Jason Evansb7924f52009-06-23 19:01:18 -0700280 ;;
Michael Neumann1aa25a32014-08-05 03:06:02 +0200281 *-*-dragonfly*)
282 CFLAGS="$CFLAGS"
283 abi="elf"
284 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
285 ;;
Jason Evansb7924f52009-06-23 19:01:18 -0700286 *-*-linux*)
287 CFLAGS="$CFLAGS"
288 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
289 abi="elf"
Garrett Cooper13e4e242012-12-02 17:58:40 -0800290 AC_DEFINE([JEMALLOC_HAS_ALLOCA_H])
Jason Evanse24c7af2012-03-19 10:21:17 -0700291 AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED], [ ])
Jason Evans02b23122012-04-05 11:06:23 -0700292 AC_DEFINE([JEMALLOC_THREADED_INIT], [ ])
Jason Evans59ae2762012-04-16 17:52:27 -0700293 default_munmap="0"
Jason Evansb7924f52009-06-23 19:01:18 -0700294 ;;
295 *-*-netbsd*)
296 AC_MSG_CHECKING([ABI])
297 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
298[[#ifdef __ELF__
299/* ELF */
300#else
301#error aout
302#endif
303]])],
304 [CFLAGS="$CFLAGS"; abi="elf"],
305 [abi="aout"])
306 AC_MSG_RESULT([$abi])
Jason Evanse24c7af2012-03-19 10:21:17 -0700307 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
Jason Evansb7924f52009-06-23 19:01:18 -0700308 ;;
309 *-*-solaris2*)
310 CFLAGS="$CFLAGS"
311 abi="elf"
George Koladdd6bd42014-02-12 23:05:45 +0000312 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
Mike Hommeyfa08da72012-04-16 16:30:25 +0200313 RPATH='-Wl,-R,$(1)'
Jason Evansb7924f52009-06-23 19:01:18 -0700314 dnl Solaris needs this for sigwait().
315 CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
316 LIBS="$LIBS -lposix4 -lsocket -lnsl"
317 ;;
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +0400318 *-ibm-aix*)
319 if "$LG_SIZEOF_PTR" = "8"; then
320 dnl 64bit AIX
321 LD_PRELOAD_VAR="LDR_PRELOAD64"
322 else
323 dnl 32bit AIX
324 LD_PRELOAD_VAR="LDR_PRELOAD"
325 fi
326 abi="xcoff"
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +0400327 ;;
Dave Rigby70bdee02014-09-22 15:53:16 +0100328 *-*-mingw* | *-*-cygwin*)
Mike Hommeya19e87f2012-04-21 21:27:46 -0700329 abi="pecoff"
330 force_tls="0"
331 RPATH=""
332 so="dll"
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200333 if test "x$je_cv_msvc" = "xyes" ; then
334 importlib="lib"
335 DSO_LDFLAGS="-LD"
336 EXTRA_LDFLAGS="-link -DEBUG"
337 CTARGET='-Fo$@'
338 LDTARGET='-Fe$@'
Jory A. Prattad505e02013-08-11 09:44:59 -0500339 AR='lib'
340 ARFLAGS='-nologo -out:'
Jason Evans80ddf492013-08-20 11:48:19 +0100341 AROUT='$@'
Mike Hommey79c4bca2012-05-02 21:30:51 +0200342 CC_MM=
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200343 else
344 importlib="${so}"
345 DSO_LDFLAGS="-shared"
346 fi
Mike Hommeya19e87f2012-04-21 21:27:46 -0700347 a="lib"
348 libprefix=""
Mike Hommey7cdea392012-04-30 12:38:27 +0200349 SOREV="${so}"
Mike Hommeya19e87f2012-04-21 21:27:46 -0700350 PIC_CFLAGS=""
351 ;;
Jason Evansb7924f52009-06-23 19:01:18 -0700352 *)
353 AC_MSG_RESULT([Unsupported operating system: ${host}])
354 abi="elf"
Jason Evansb7924f52009-06-23 19:01:18 -0700355 ;;
356esac
Mike Hommeyaffe0092014-05-28 08:10:12 +0900357
358JEMALLOC_USABLE_SIZE_CONST=const
359AC_CHECK_HEADERS([malloc.h], [
360 AC_MSG_CHECKING([whether malloc_usable_size definition can use const argument])
361 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
362 [#include <malloc.h>
363 #include <stddef.h>
364 size_t malloc_usable_size(const void *ptr);
365 ],
366 [])],[
367 AC_MSG_RESULT([yes])
368 ],[
369 JEMALLOC_USABLE_SIZE_CONST=
370 AC_MSG_RESULT([no])
371 ])
372])
Jason Evans247d1242012-10-09 16:20:10 -0700373AC_DEFINE_UNQUOTED([JEMALLOC_USABLE_SIZE_CONST], [$JEMALLOC_USABLE_SIZE_CONST])
Jason Evansb7924f52009-06-23 19:01:18 -0700374AC_SUBST([abi])
375AC_SUBST([RPATH])
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +0400376AC_SUBST([LD_PRELOAD_VAR])
Jason Evansf576c632011-11-01 22:27:41 -0700377AC_SUBST([so])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200378AC_SUBST([importlib])
Mike Hommey5bee66d2012-04-16 16:30:24 +0200379AC_SUBST([o])
380AC_SUBST([a])
381AC_SUBST([exe])
Mike Hommeya19e87f2012-04-21 21:27:46 -0700382AC_SUBST([libprefix])
Mike Hommeyfa08da72012-04-16 16:30:25 +0200383AC_SUBST([DSO_LDFLAGS])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200384AC_SUBST([EXTRA_LDFLAGS])
Mike Hommey85221d52012-04-18 18:29:40 +0200385AC_SUBST([SOREV])
Mike Hommey188da7c2012-04-18 18:29:41 +0200386AC_SUBST([PIC_CFLAGS])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200387AC_SUBST([CTARGET])
388AC_SUBST([LDTARGET])
389AC_SUBST([MKLIB])
Jason Evans80ddf492013-08-20 11:48:19 +0100390AC_SUBST([ARFLAGS])
391AC_SUBST([AROUT])
Mike Hommey79c4bca2012-05-02 21:30:51 +0200392AC_SUBST([CC_MM])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200393
Jason Evansfa5d2452011-03-15 10:25:59 -0700394JE_COMPILABLE([__attribute__ syntax],
395 [static __attribute__((unused)) void foo(void){}],
396 [],
Jason Evans6684cac2012-03-05 12:15:36 -0800397 [je_cv_attribute])
398if test "x${je_cv_attribute}" = "xyes" ; then
Jason Evansfa5d2452011-03-15 10:25:59 -0700399 AC_DEFINE([JEMALLOC_HAVE_ATTR], [ ])
400 if test "x${GCC}" = "xyes" -a "x${abi}" = "xelf"; then
401 JE_CFLAGS_APPEND([-fvisibility=hidden])
402 fi
403fi
Jason Evans3cc1f1a2012-04-03 22:30:05 -0700404dnl Check for tls_model attribute support (clang 3.0 still lacks support).
405SAVED_CFLAGS="${CFLAGS}"
406JE_CFLAGS_APPEND([-Werror])
407JE_COMPILABLE([tls_model attribute], [],
408 [static __thread int
Daniel Micayf1cf3ea2014-09-16 04:42:33 -0400409 __attribute__((tls_model("initial-exec"), unused)) foo;
Jason Evans3cc1f1a2012-04-03 22:30:05 -0700410 foo = 0;],
411 [je_cv_tls_model])
412CFLAGS="${SAVED_CFLAGS}"
413if test "x${je_cv_tls_model}" = "xyes" ; then
414 AC_DEFINE([JEMALLOC_TLS_MODEL],
415 [__attribute__((tls_model("initial-exec")))])
416else
417 AC_DEFINE([JEMALLOC_TLS_MODEL], [ ])
418fi
Jason Evansfa5d2452011-03-15 10:25:59 -0700419
Jason Evansb7924f52009-06-23 19:01:18 -0700420dnl Support optional additions to rpath.
421AC_ARG_WITH([rpath],
Jason Evans90895cf2009-12-29 00:09:15 -0800422 [AS_HELP_STRING([--with-rpath=<rpath>], [Colon-separated rpath (ELF systems only)])],
Jason Evansb7924f52009-06-23 19:01:18 -0700423if test "x$with_rpath" = "xno" ; then
424 RPATH_EXTRA=
425else
426 RPATH_EXTRA="`echo $with_rpath | tr \":\" \" \"`"
427fi,
428 RPATH_EXTRA=
429)
430AC_SUBST([RPATH_EXTRA])
431
432dnl Disable rules that do automatic regeneration of configure output by default.
433AC_ARG_ENABLE([autogen],
Jason Evans78d815c2010-01-17 14:06:20 -0800434 [AS_HELP_STRING([--enable-autogen], [Automatically regenerate configure output])],
Jason Evansb7924f52009-06-23 19:01:18 -0700435if test "x$enable_autogen" = "xno" ; then
436 enable_autogen="0"
437else
438 enable_autogen="1"
439fi
440,
441enable_autogen="0"
442)
443AC_SUBST([enable_autogen])
444
445AC_PROG_INSTALL
446AC_PROG_RANLIB
Jason Evans7329a4f2013-01-22 10:53:29 -0800447AC_PATH_PROG([LD], [ld], [false], [$PATH])
448AC_PATH_PROG([AUTOCONF], [autoconf], [false], [$PATH])
Jason Evansb7924f52009-06-23 19:01:18 -0700449
Daniel Micay4cfe5512014-08-28 15:41:48 -0400450public_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"
Jason Evans7e77eaf2012-03-02 17:47:37 -0800451
452dnl Check for allocator-related functions that should be wrapped.
453AC_CHECK_FUNC([memalign],
Jason Evanse24c7af2012-03-19 10:21:17 -0700454 [AC_DEFINE([JEMALLOC_OVERRIDE_MEMALIGN], [ ])
Jason Evans7e77eaf2012-03-02 17:47:37 -0800455 public_syms="${public_syms} memalign"])
456AC_CHECK_FUNC([valloc],
Jason Evanse24c7af2012-03-19 10:21:17 -0700457 [AC_DEFINE([JEMALLOC_OVERRIDE_VALLOC], [ ])
Jason Evans7e77eaf2012-03-02 17:47:37 -0800458 public_syms="${public_syms} valloc"])
459
Jason Evans748dfac2013-12-06 18:27:33 -0800460dnl Do not compute test code coverage by default.
461GCOV_FLAGS=
462AC_ARG_ENABLE([code-coverage],
463 [AS_HELP_STRING([--enable-code-coverage],
464 [Enable code coverage])],
465[if test "x$enable_code_coverage" = "xno" ; then
466 enable_code_coverage="0"
467else
468 enable_code_coverage="1"
469fi
470],
471[enable_code_coverage="0"]
472)
473if test "x$enable_code_coverage" = "x1" ; then
474 deoptimize="no"
475 echo "$CFLAGS $EXTRA_CFLAGS" | grep '\-O' >/dev/null || deoptimize="yes"
476 if test "x${deoptimize}" = "xyes" ; then
477 JE_CFLAGS_APPEND([-O0])
478 fi
479 JE_CFLAGS_APPEND([-fprofile-arcs -ftest-coverage])
480 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -fprofile-arcs -ftest-coverage"
481 AC_DEFINE([JEMALLOC_CODE_COVERAGE], [ ])
482fi
483AC_SUBST([enable_code_coverage])
484
Jason Evans0a5489e2012-03-01 17:19:20 -0800485dnl Perform no name mangling by default.
486AC_ARG_WITH([mangling],
487 [AS_HELP_STRING([--with-mangling=<map>], [Mangle symbols in <map>])],
488 [mangling_map="$with_mangling"], [mangling_map=""])
Jason Evans0a5489e2012-03-01 17:19:20 -0800489
Jason Evans90895cf2009-12-29 00:09:15 -0800490dnl Do not prefix public APIs by default.
491AC_ARG_WITH([jemalloc_prefix],
492 [AS_HELP_STRING([--with-jemalloc-prefix=<prefix>], [Prefix to prepend to all public APIs])],
Jason Evansb0fd5012010-01-17 01:49:20 -0800493 [JEMALLOC_PREFIX="$with_jemalloc_prefix"],
Mike Hommey7cdea392012-04-30 12:38:27 +0200494 [if test "x$abi" != "xmacho" -a "x$abi" != "xpecoff"; then
Jason Evans2dbecf12010-09-05 10:35:13 -0700495 JEMALLOC_PREFIX=""
496else
497 JEMALLOC_PREFIX="je_"
498fi]
Jason Evans90895cf2009-12-29 00:09:15 -0800499)
500if test "x$JEMALLOC_PREFIX" != "x" ; then
Jason Evanse7339702010-10-23 18:37:06 -0700501 JEMALLOC_CPREFIX=`echo ${JEMALLOC_PREFIX} | tr "a-z" "A-Z"`
502 AC_DEFINE_UNQUOTED([JEMALLOC_PREFIX], ["$JEMALLOC_PREFIX"])
503 AC_DEFINE_UNQUOTED([JEMALLOC_CPREFIX], ["$JEMALLOC_CPREFIX"])
Jason Evans90895cf2009-12-29 00:09:15 -0800504fi
505
Mike Hommey99066602012-11-19 10:55:26 +0100506AC_ARG_WITH([export],
507 [AS_HELP_STRING([--without-export], [disable exporting jemalloc public APIs])],
508 [if test "x$with_export" = "xno"; then
Jason Evans2625c892013-01-22 16:46:27 -0800509 AC_DEFINE([JEMALLOC_EXPORT],[])
Mike Hommey99066602012-11-19 10:55:26 +0100510fi]
511)
512
Jason Evans86abd0d2013-11-30 15:25:42 -0800513dnl Mangle library-private APIs.
Jason Evans746e77a2011-07-30 16:40:52 -0700514AC_ARG_WITH([private_namespace],
515 [AS_HELP_STRING([--with-private-namespace=<prefix>], [Prefix to prepend to all library-private APIs])],
Jason Evans86abd0d2013-11-30 15:25:42 -0800516 [JEMALLOC_PRIVATE_NAMESPACE="${with_private_namespace}je_"],
517 [JEMALLOC_PRIVATE_NAMESPACE="je_"]
Jason Evans746e77a2011-07-30 16:40:52 -0700518)
Jason Evans86abd0d2013-11-30 15:25:42 -0800519AC_DEFINE_UNQUOTED([JEMALLOC_PRIVATE_NAMESPACE], [$JEMALLOC_PRIVATE_NAMESPACE])
520private_namespace="$JEMALLOC_PRIVATE_NAMESPACE"
521AC_SUBST([private_namespace])
Jason Evans746e77a2011-07-30 16:40:52 -0700522
Jason Evansb0fd5012010-01-17 01:49:20 -0800523dnl Do not add suffix to installed files by default.
524AC_ARG_WITH([install_suffix],
525 [AS_HELP_STRING([--with-install-suffix=<suffix>], [Suffix to append to all installed files])],
526 [INSTALL_SUFFIX="$with_install_suffix"],
527 [INSTALL_SUFFIX=]
528)
529install_suffix="$INSTALL_SUFFIX"
530AC_SUBST([install_suffix])
531
Jason Evans86abd0d2013-11-30 15:25:42 -0800532dnl Substitute @je_@ in jemalloc_protos.h.in, primarily to make generation of
533dnl jemalloc_protos_jet.h easy.
534je_="je_"
535AC_SUBST([je_])
536
Mike Hommeycf6032d2014-07-30 18:16:13 +0900537cfgoutputs_in="Makefile.in"
Nick White913e9a82014-09-19 22:01:23 +0100538cfgoutputs_in="${cfgoutputs_in} jemalloc.pc.in"
Mike Hommeycf6032d2014-07-30 18:16:13 +0900539cfgoutputs_in="${cfgoutputs_in} doc/html.xsl.in"
540cfgoutputs_in="${cfgoutputs_in} doc/manpages.xsl.in"
541cfgoutputs_in="${cfgoutputs_in} doc/jemalloc.xml.in"
542cfgoutputs_in="${cfgoutputs_in} include/jemalloc/jemalloc_macros.h.in"
543cfgoutputs_in="${cfgoutputs_in} include/jemalloc/jemalloc_protos.h.in"
Jason Evans82e88d12014-09-07 19:55:03 -0700544cfgoutputs_in="${cfgoutputs_in} include/jemalloc/jemalloc_typedefs.h.in"
Mike Hommeycf6032d2014-07-30 18:16:13 +0900545cfgoutputs_in="${cfgoutputs_in} include/jemalloc/internal/jemalloc_internal.h.in"
546cfgoutputs_in="${cfgoutputs_in} test/test.sh.in"
547cfgoutputs_in="${cfgoutputs_in} test/include/test/jemalloc_test.h.in"
Jason Evansb0fd5012010-01-17 01:49:20 -0800548
Jason Evansaee7fd22010-11-24 22:00:02 -0800549cfgoutputs_out="Makefile"
Nick White913e9a82014-09-19 22:01:23 +0100550cfgoutputs_out="${cfgoutputs_out} jemalloc.pc"
Jason Evansaee7fd22010-11-24 22:00:02 -0800551cfgoutputs_out="${cfgoutputs_out} doc/html.xsl"
552cfgoutputs_out="${cfgoutputs_out} doc/manpages.xsl"
Jason Evans86abd0d2013-11-30 15:25:42 -0800553cfgoutputs_out="${cfgoutputs_out} doc/jemalloc.xml"
554cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_macros.h"
555cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_protos.h"
Jason Evans82e88d12014-09-07 19:55:03 -0700556cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_typedefs.h"
Jason Evans376b1522010-02-11 14:45:59 -0800557cfgoutputs_out="${cfgoutputs_out} include/jemalloc/internal/jemalloc_internal.h"
Jason Evans86abd0d2013-11-30 15:25:42 -0800558cfgoutputs_out="${cfgoutputs_out} test/test.sh"
559cfgoutputs_out="${cfgoutputs_out} test/include/test/jemalloc_test.h"
Jason Evansb0fd5012010-01-17 01:49:20 -0800560
Jason Evansaee7fd22010-11-24 22:00:02 -0800561cfgoutputs_tup="Makefile"
Nick White913e9a82014-09-19 22:01:23 +0100562cfgoutputs_tup="${cfgoutputs_tup} jemalloc.pc:jemalloc.pc.in"
Jason Evansaee7fd22010-11-24 22:00:02 -0800563cfgoutputs_tup="${cfgoutputs_tup} doc/html.xsl:doc/html.xsl.in"
564cfgoutputs_tup="${cfgoutputs_tup} doc/manpages.xsl:doc/manpages.xsl.in"
Jason Evans86abd0d2013-11-30 15:25:42 -0800565cfgoutputs_tup="${cfgoutputs_tup} doc/jemalloc.xml:doc/jemalloc.xml.in"
566cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_macros.h:include/jemalloc/jemalloc_macros.h.in"
567cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_protos.h:include/jemalloc/jemalloc_protos.h.in"
Jason Evans82e88d12014-09-07 19:55:03 -0700568cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_typedefs.h:include/jemalloc/jemalloc_typedefs.h.in"
Jason Evans376b1522010-02-11 14:45:59 -0800569cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/internal/jemalloc_internal.h"
Jason Evans86abd0d2013-11-30 15:25:42 -0800570cfgoutputs_tup="${cfgoutputs_tup} test/test.sh:test/test.sh.in"
571cfgoutputs_tup="${cfgoutputs_tup} test/include/test/jemalloc_test.h:test/include/test/jemalloc_test.h.in"
Jason Evansb0fd5012010-01-17 01:49:20 -0800572
Mike Hommeycf6032d2014-07-30 18:16:13 +0900573cfghdrs_in="include/jemalloc/jemalloc_defs.h.in"
574cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/jemalloc_internal_defs.h.in"
575cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/private_namespace.sh"
576cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/private_unnamespace.sh"
577cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/private_symbols.txt"
578cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/public_namespace.sh"
579cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/public_unnamespace.sh"
580cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/size_classes.sh"
581cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc_rename.sh"
582cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc_mangle.sh"
583cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc.sh"
584cfghdrs_in="${cfghdrs_in} test/include/test/jemalloc_test_defs.h.in"
Jason Evansb0fd5012010-01-17 01:49:20 -0800585
Jason Evans86abd0d2013-11-30 15:25:42 -0800586cfghdrs_out="include/jemalloc/jemalloc_defs.h"
587cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc${install_suffix}.h"
Jason Evans86abd0d2013-11-30 15:25:42 -0800588cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/private_namespace.h"
589cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/private_unnamespace.h"
Jason Evansf234dc52014-01-16 17:38:01 -0800590cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_symbols.txt"
Jason Evans86abd0d2013-11-30 15:25:42 -0800591cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_namespace.h"
592cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_unnamespace.h"
Jason Evansb1726102012-02-28 16:50:47 -0800593cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/size_classes.h"
Jason Evansf234dc52014-01-16 17:38:01 -0800594cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_protos_jet.h"
595cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_rename.h"
596cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_mangle.h"
597cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_mangle_jet.h"
598cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/jemalloc_internal_defs.h"
Jason Evans80061b62013-12-09 13:21:08 -0800599cfghdrs_out="${cfghdrs_out} test/include/test/jemalloc_test_defs.h"
Jason Evansb0fd5012010-01-17 01:49:20 -0800600
Jason Evans86abd0d2013-11-30 15:25:42 -0800601cfghdrs_tup="include/jemalloc/jemalloc_defs.h:include/jemalloc/jemalloc_defs.h.in"
Mike Hommeycf6032d2014-07-30 18:16:13 +0900602cfghdrs_tup="${cfghdrs_tup} include/jemalloc/internal/jemalloc_internal_defs.h:include/jemalloc/internal/jemalloc_internal_defs.h.in"
603cfghdrs_tup="${cfghdrs_tup} test/include/test/jemalloc_test_defs.h:test/include/test/jemalloc_test_defs.h.in"
Jason Evansb0fd5012010-01-17 01:49:20 -0800604
Jason Evans644d4142014-04-14 22:49:23 -0700605dnl Silence irrelevant compiler warnings by default.
Jason Evans355b4382010-09-20 19:20:48 -0700606AC_ARG_ENABLE([cc-silence],
Jason Evans644d4142014-04-14 22:49:23 -0700607 [AS_HELP_STRING([--disable-cc-silence],
608 [Do not silence irrelevant compiler warnings])],
Jason Evans355b4382010-09-20 19:20:48 -0700609[if test "x$enable_cc_silence" = "xno" ; then
610 enable_cc_silence="0"
611else
612 enable_cc_silence="1"
613fi
614],
Jason Evans644d4142014-04-14 22:49:23 -0700615[enable_cc_silence="1"]
Jason Evans355b4382010-09-20 19:20:48 -0700616)
617if test "x$enable_cc_silence" = "x1" ; then
Jason Evanse24c7af2012-03-19 10:21:17 -0700618 AC_DEFINE([JEMALLOC_CC_SILENCE], [ ])
Jason Evans355b4382010-09-20 19:20:48 -0700619fi
620
Jason Evansb7924f52009-06-23 19:01:18 -0700621dnl Do not compile with debugging by default.
622AC_ARG_ENABLE([debug],
Mike Hommey5135e342012-12-06 22:16:26 +0100623 [AS_HELP_STRING([--enable-debug], [Build debugging code (implies --enable-ivsalloc)])],
Jason Evansb7924f52009-06-23 19:01:18 -0700624[if test "x$enable_debug" = "xno" ; then
625 enable_debug="0"
626else
627 enable_debug="1"
628fi
629],
630[enable_debug="0"]
631)
632if test "x$enable_debug" = "x1" ; then
633 AC_DEFINE([JEMALLOC_DEBUG], [ ])
Mike Hommey5135e342012-12-06 22:16:26 +0100634 enable_ivsalloc="1"
Jason Evansb7924f52009-06-23 19:01:18 -0700635fi
636AC_SUBST([enable_debug])
637
Mike Hommey5135e342012-12-06 22:16:26 +0100638dnl Do not validate pointers by default.
639AC_ARG_ENABLE([ivsalloc],
640 [AS_HELP_STRING([--enable-ivsalloc], [Validate pointers passed through the public API])],
641[if test "x$enable_ivsalloc" = "xno" ; then
642 enable_ivsalloc="0"
643else
644 enable_ivsalloc="1"
645fi
646],
647[enable_ivsalloc="0"]
648)
649if test "x$enable_ivsalloc" = "x1" ; then
650 AC_DEFINE([JEMALLOC_IVSALLOC], [ ])
651fi
652
Jason Evansb7924f52009-06-23 19:01:18 -0700653dnl Only optimize if not debugging.
654if test "x$enable_debug" = "x0" -a "x$no_CFLAGS" = "xyes" ; then
655 dnl Make sure that an optimization flag was not specified in EXTRA_CFLAGS.
Jason Evansf3340ca2009-06-30 16:17:05 -0700656 optimize="no"
Jason Evans748dfac2013-12-06 18:27:33 -0800657 echo "$CFLAGS $EXTRA_CFLAGS" | grep '\-O' >/dev/null || optimize="yes"
Jason Evansf3340ca2009-06-30 16:17:05 -0700658 if test "x${optimize}" = "xyes" ; then
659 if test "x$GCC" = "xyes" ; then
660 JE_CFLAGS_APPEND([-O3])
661 JE_CFLAGS_APPEND([-funroll-loops])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200662 elif test "x$je_cv_msvc" = "xyes" ; then
663 JE_CFLAGS_APPEND([-O2])
Jason Evansf3340ca2009-06-30 16:17:05 -0700664 else
665 JE_CFLAGS_APPEND([-O])
666 fi
Jason Evansb7924f52009-06-23 19:01:18 -0700667 fi
668fi
669
Jason Evansd073a322012-02-28 20:41:16 -0800670dnl Enable statistics calculation by default.
Jason Evansb7924f52009-06-23 19:01:18 -0700671AC_ARG_ENABLE([stats],
Jason Evans777c1912012-02-28 20:49:22 -0800672 [AS_HELP_STRING([--disable-stats],
673 [Disable statistics calculation/reporting])],
Jason Evansb7924f52009-06-23 19:01:18 -0700674[if test "x$enable_stats" = "xno" ; then
675 enable_stats="0"
676else
677 enable_stats="1"
678fi
679],
Jason Evansd073a322012-02-28 20:41:16 -0800680[enable_stats="1"]
Jason Evansb7924f52009-06-23 19:01:18 -0700681)
682if test "x$enable_stats" = "x1" ; then
683 AC_DEFINE([JEMALLOC_STATS], [ ])
684fi
685AC_SUBST([enable_stats])
686
Jason Evans6109fe02010-02-10 10:37:56 -0800687dnl Do not enable profiling by default.
688AC_ARG_ENABLE([prof],
689 [AS_HELP_STRING([--enable-prof], [Enable allocation profiling])],
690[if test "x$enable_prof" = "xno" ; then
691 enable_prof="0"
692else
693 enable_prof="1"
694fi
695],
696[enable_prof="0"]
697)
Jason Evans77f350b2011-03-15 22:23:12 -0700698if test "x$enable_prof" = "x1" ; then
699 backtrace_method=""
Jason Evansb27805b2010-02-10 18:15:53 -0800700else
Jason Evans77f350b2011-03-15 22:23:12 -0700701 backtrace_method="N/A"
Jason Evansb27805b2010-02-10 18:15:53 -0800702fi
Jason Evans77f350b2011-03-15 22:23:12 -0700703
Jason Evans6109fe02010-02-10 10:37:56 -0800704AC_ARG_ENABLE([prof-libunwind],
705 [AS_HELP_STRING([--enable-prof-libunwind], [Use libunwind for backtracing])],
706[if test "x$enable_prof_libunwind" = "xno" ; then
707 enable_prof_libunwind="0"
708else
709 enable_prof_libunwind="1"
710fi
711],
712[enable_prof_libunwind="0"]
713)
Jason Evansca6bd4f2010-03-02 14:12:58 -0800714AC_ARG_WITH([static_libunwind],
715 [AS_HELP_STRING([--with-static-libunwind=<libunwind.a>],
716 [Path to static libunwind library; use rather than dynamically linking])],
717if test "x$with_static_libunwind" = "xno" ; then
718 LUNWIND="-lunwind"
719else
720 if test ! -f "$with_static_libunwind" ; then
721 AC_MSG_ERROR([Static libunwind not found: $with_static_libunwind])
722 fi
723 LUNWIND="$with_static_libunwind"
724fi,
725 LUNWIND="-lunwind"
726)
Jason Evans77f350b2011-03-15 22:23:12 -0700727if test "x$backtrace_method" = "x" -a "x$enable_prof_libunwind" = "x1" ; then
728 AC_CHECK_HEADERS([libunwind.h], , [enable_prof_libunwind="0"])
729 if test "x$LUNWIND" = "x-lunwind" ; then
Jason Evans05125b82014-04-22 20:48:07 -0700730 AC_CHECK_LIB([unwind], [unw_backtrace], [LIBS="$LIBS $LUNWIND"],
Jason Evans77f350b2011-03-15 22:23:12 -0700731 [enable_prof_libunwind="0"])
732 else
733 LIBS="$LIBS $LUNWIND"
734 fi
735 if test "x${enable_prof_libunwind}" = "x1" ; then
736 backtrace_method="libunwind"
737 AC_DEFINE([JEMALLOC_PROF_LIBUNWIND], [ ])
738 fi
739fi
740
741AC_ARG_ENABLE([prof-libgcc],
742 [AS_HELP_STRING([--disable-prof-libgcc],
743 [Do not use libgcc for backtracing])],
744[if test "x$enable_prof_libgcc" = "xno" ; then
745 enable_prof_libgcc="0"
746else
747 enable_prof_libgcc="1"
748fi
749],
750[enable_prof_libgcc="1"]
751)
752if test "x$backtrace_method" = "x" -a "x$enable_prof_libgcc" = "x1" \
753 -a "x$GCC" = "xyes" ; then
754 AC_CHECK_HEADERS([unwind.h], , [enable_prof_libgcc="0"])
755 AC_CHECK_LIB([gcc], [_Unwind_Backtrace], [LIBS="$LIBS -lgcc"], [enable_prof_libgcc="0"])
Jason Evans77f350b2011-03-15 22:23:12 -0700756 if test "x${enable_prof_libgcc}" = "x1" ; then
757 backtrace_method="libgcc"
758 AC_DEFINE([JEMALLOC_PROF_LIBGCC], [ ])
759 fi
760else
761 enable_prof_libgcc="0"
762fi
763
764AC_ARG_ENABLE([prof-gcc],
765 [AS_HELP_STRING([--disable-prof-gcc],
766 [Do not use gcc intrinsics for backtracing])],
767[if test "x$enable_prof_gcc" = "xno" ; then
768 enable_prof_gcc="0"
769else
770 enable_prof_gcc="1"
771fi
772],
773[enable_prof_gcc="1"]
774)
775if test "x$backtrace_method" = "x" -a "x$enable_prof_gcc" = "x1" \
776 -a "x$GCC" = "xyes" ; then
Jason Evanse181f5a2014-03-30 18:58:32 -0700777 JE_CFLAGS_APPEND([-fno-omit-frame-pointer])
Jason Evans77f350b2011-03-15 22:23:12 -0700778 backtrace_method="gcc intrinsics"
779 AC_DEFINE([JEMALLOC_PROF_GCC], [ ])
780else
781 enable_prof_gcc="0"
782fi
783
784if test "x$backtrace_method" = "x" ; then
785 backtrace_method="none (disabling profiling)"
786 enable_prof="0"
787fi
788AC_MSG_CHECKING([configured backtracing method])
789AC_MSG_RESULT([$backtrace_method])
Jason Evans2dbecf12010-09-05 10:35:13 -0700790if test "x$enable_prof" = "x1" ; then
Jason Evansd37d5ad2013-12-05 23:01:50 -0800791 if test "x$abi" != "xpecoff"; then
792 dnl Heap profiling uses the log(3) function.
793 LIBS="$LIBS -lm"
794 fi
795
Jason Evans2dbecf12010-09-05 10:35:13 -0700796 AC_DEFINE([JEMALLOC_PROF], [ ])
Jason Evans2dbecf12010-09-05 10:35:13 -0700797fi
798AC_SUBST([enable_prof])
Jason Evans2dbecf12010-09-05 10:35:13 -0700799
Jason Evans84cbbcb2009-12-29 00:09:15 -0800800dnl Enable thread-specific caching by default.
801AC_ARG_ENABLE([tcache],
802 [AS_HELP_STRING([--disable-tcache], [Disable per thread caches])],
803[if test "x$enable_tcache" = "xno" ; then
804 enable_tcache="0"
Jason Evansb7924f52009-06-23 19:01:18 -0700805else
Jason Evans84cbbcb2009-12-29 00:09:15 -0800806 enable_tcache="1"
Jason Evansb7924f52009-06-23 19:01:18 -0700807fi
808],
Jason Evans84cbbcb2009-12-29 00:09:15 -0800809[enable_tcache="1"]
Jason Evansb7924f52009-06-23 19:01:18 -0700810)
Jason Evans2dbecf12010-09-05 10:35:13 -0700811if test "x$enable_tcache" = "x1" ; then
812 AC_DEFINE([JEMALLOC_TCACHE], [ ])
813fi
814AC_SUBST([enable_tcache])
Jason Evansb7924f52009-06-23 19:01:18 -0700815
Jason Evans59ae2762012-04-16 17:52:27 -0700816dnl Enable VM deallocation via munmap() by default.
817AC_ARG_ENABLE([munmap],
818 [AS_HELP_STRING([--disable-munmap], [Disable VM deallocation via munmap(2)])],
819[if test "x$enable_munmap" = "xno" ; then
820 enable_munmap="0"
821else
822 enable_munmap="1"
823fi
824],
825[enable_munmap="${default_munmap}"]
826)
827if test "x$enable_munmap" = "x1" ; then
828 AC_DEFINE([JEMALLOC_MUNMAP], [ ])
829fi
830AC_SUBST([enable_munmap])
831
Jason Evans4d434ad2014-04-15 12:09:48 -0700832dnl Enable allocation from DSS if supported by the OS.
833have_dss="1"
Mike Hommey83c324a2012-04-12 10:13:03 +0200834dnl Check whether the BSD/SUSv1 sbrk() exists. If not, disable DSS support.
835AC_CHECK_FUNC([sbrk], [have_sbrk="1"], [have_sbrk="0"])
836if test "x$have_sbrk" = "x1" ; then
Steven Stewart-Gallus79230fe2014-06-19 16:11:43 -0700837 if test "x$sbrk_deprecated" = "x1" ; then
Jason Evans66688532013-12-03 21:49:36 -0800838 AC_MSG_RESULT([Disabling dss allocation because sbrk is deprecated])
Jason Evans4d434ad2014-04-15 12:09:48 -0700839 have_dss="0"
Jason Evans66688532013-12-03 21:49:36 -0800840 fi
Mike Hommey83c324a2012-04-12 10:13:03 +0200841else
Jason Evans4d434ad2014-04-15 12:09:48 -0700842 have_dss="0"
Mike Hommey83c324a2012-04-12 10:13:03 +0200843fi
844
Jason Evans4d434ad2014-04-15 12:09:48 -0700845if test "x$have_dss" = "x1" ; then
Jason Evansb7924f52009-06-23 19:01:18 -0700846 AC_DEFINE([JEMALLOC_DSS], [ ])
847fi
Jason Evansb7924f52009-06-23 19:01:18 -0700848
Jason Evans777c1912012-02-28 20:49:22 -0800849dnl Support the junk/zero filling option by default.
Jason Evansb7924f52009-06-23 19:01:18 -0700850AC_ARG_ENABLE([fill],
Jason Evans122449b2012-04-06 00:35:09 -0700851 [AS_HELP_STRING([--disable-fill],
852 [Disable support for junk/zero filling, quarantine, and redzones])],
Jason Evansb7924f52009-06-23 19:01:18 -0700853[if test "x$enable_fill" = "xno" ; then
854 enable_fill="0"
855else
856 enable_fill="1"
857fi
858],
Jason Evans777c1912012-02-28 20:49:22 -0800859[enable_fill="1"]
Jason Evansb7924f52009-06-23 19:01:18 -0700860)
861if test "x$enable_fill" = "x1" ; then
862 AC_DEFINE([JEMALLOC_FILL], [ ])
863fi
864AC_SUBST([enable_fill])
865
Jason Evansb1476112012-04-05 13:36:17 -0700866dnl Disable utrace(2)-based tracing by default.
867AC_ARG_ENABLE([utrace],
868 [AS_HELP_STRING([--enable-utrace], [Enable utrace(2)-based tracing])],
869[if test "x$enable_utrace" = "xno" ; then
870 enable_utrace="0"
871else
872 enable_utrace="1"
873fi
874],
875[enable_utrace="0"]
876)
877JE_COMPILABLE([utrace(2)], [
878#include <sys/types.h>
879#include <sys/param.h>
880#include <sys/time.h>
881#include <sys/uio.h>
882#include <sys/ktrace.h>
883], [
884 utrace((void *)0, 0);
885], [je_cv_utrace])
886if test "x${je_cv_utrace}" = "xno" ; then
887 enable_utrace="0"
888fi
889if test "x$enable_utrace" = "x1" ; then
890 AC_DEFINE([JEMALLOC_UTRACE], [ ])
891fi
892AC_SUBST([enable_utrace])
893
Jason Evans122449b2012-04-06 00:35:09 -0700894dnl Support Valgrind by default.
895AC_ARG_ENABLE([valgrind],
896 [AS_HELP_STRING([--disable-valgrind], [Disable support for Valgrind])],
897[if test "x$enable_valgrind" = "xno" ; then
898 enable_valgrind="0"
899else
900 enable_valgrind="1"
901fi
902],
903[enable_valgrind="1"]
904)
905if test "x$enable_valgrind" = "x1" ; then
906 JE_COMPILABLE([valgrind], [
907#include <valgrind/valgrind.h>
908#include <valgrind/memcheck.h>
909
Mike Hommey7bfecf42012-04-30 15:15:15 +0200910#if !defined(VALGRIND_RESIZEINPLACE_BLOCK)
Jason Evans122449b2012-04-06 00:35:09 -0700911# error "Incompatible Valgrind version"
912#endif
913], [], [je_cv_valgrind])
914 if test "x${je_cv_valgrind}" = "xno" ; then
915 enable_valgrind="0"
916 fi
917 if test "x$enable_valgrind" = "x1" ; then
918 AC_DEFINE([JEMALLOC_VALGRIND], [ ])
919 fi
920fi
921AC_SUBST([enable_valgrind])
922
Jason Evansb7924f52009-06-23 19:01:18 -0700923dnl Do not support the xmalloc option by default.
924AC_ARG_ENABLE([xmalloc],
925 [AS_HELP_STRING([--enable-xmalloc], [Support xmalloc option])],
926[if test "x$enable_xmalloc" = "xno" ; then
927 enable_xmalloc="0"
928else
929 enable_xmalloc="1"
930fi
931],
932[enable_xmalloc="0"]
933)
934if test "x$enable_xmalloc" = "x1" ; then
935 AC_DEFINE([JEMALLOC_XMALLOC], [ ])
936fi
937AC_SUBST([enable_xmalloc])
938
Mike Hommey8f50ec82014-06-04 12:12:55 +0900939dnl ============================================================================
940dnl Check for __builtin_ffsl(), then ffsl(3), and fail if neither are found.
941dnl One of those two functions should (theoretically) exist on all platforms
942dnl that jemalloc currently has a chance of functioning on without modification.
943dnl We additionally assume ffs() or __builtin_ffs() are defined if
944dnl ffsl() or __builtin_ffsl() are defined, respectively.
945JE_COMPILABLE([a program using __builtin_ffsl], [
946#include <stdio.h>
947#include <strings.h>
948#include <string.h>
949], [
950 {
951 int rv = __builtin_ffsl(0x08);
952 printf("%d\n", rv);
953 }
954], [je_cv_gcc_builtin_ffsl])
Steven Stewart-Gallus79230fe2014-06-19 16:11:43 -0700955if test "x${je_cv_gcc_builtin_ffsl}" = "xyes" ; then
Mike Hommey8f50ec82014-06-04 12:12:55 +0900956 AC_DEFINE([JEMALLOC_INTERNAL_FFSL], [__builtin_ffsl])
957 AC_DEFINE([JEMALLOC_INTERNAL_FFS], [__builtin_ffs])
958else
959 JE_COMPILABLE([a program using ffsl], [
960 #include <stdio.h>
961 #include <strings.h>
962 #include <string.h>
963 ], [
964 {
965 int rv = ffsl(0x08);
966 printf("%d\n", rv);
967 }
968 ], [je_cv_function_ffsl])
Steven Stewart-Gallus79230fe2014-06-19 16:11:43 -0700969 if test "x${je_cv_function_ffsl}" = "xyes" ; then
Mike Hommey8f50ec82014-06-04 12:12:55 +0900970 AC_DEFINE([JEMALLOC_INTERNAL_FFSL], [ffsl])
971 AC_DEFINE([JEMALLOC_INTERNAL_FFS], [ffs])
972 else
973 AC_MSG_ERROR([Cannot build without ffsl(3) or __builtin_ffsl()])
974 fi
975fi
976
Jason Evans81e54752014-10-10 22:34:25 -0700977AC_ARG_WITH([lg_tiny_min],
978 [AS_HELP_STRING([--with-lg-tiny-min=<lg-tiny-min>],
979 [Base 2 log of minimum tiny size class to support])],
980 [LG_TINY_MIN="$with_lg_tiny_min"],
981 [LG_TINY_MIN="3"])
982AC_DEFINE_UNQUOTED([LG_TINY_MIN], [$LG_TINY_MIN])
983
Jason Evansfc0b3b72014-10-09 17:54:06 -0700984AC_ARG_WITH([lg_quantum],
985 [AS_HELP_STRING([--with-lg-quantum=<lg-quantum>],
986 [Base 2 log of minimum allocation alignment])],
Jason Evans81e54752014-10-10 22:34:25 -0700987 [LG_QUANTA="$with_lg_quantum"],
988 [LG_QUANTA="3 4"])
989if test "x$with_lg_quantum" != "x" ; then
990 AC_DEFINE_UNQUOTED([LG_QUANTUM], [$with_lg_quantum])
991fi
Jason Evansfc0b3b72014-10-09 17:54:06 -0700992
993AC_ARG_WITH([lg_page],
994 [AS_HELP_STRING([--with-lg-page=<lg-page>], [Base 2 log of system page size])],
995 [LG_PAGE="$with_lg_page"], [LG_PAGE="detect"])
996if test "x$LG_PAGE" == "xdetect"; then
997 AC_CACHE_CHECK([LG_PAGE],
998 [je_cv_lg_page],
Jason Evans6684cac2012-03-05 12:15:36 -0800999 AC_RUN_IFELSE([AC_LANG_PROGRAM(
Mike Hommeya19e87f2012-04-21 21:27:46 -07001000[[
Mike Hommeyfd97b1d2012-04-30 12:38:31 +02001001#include <strings.h>
Mike Hommeya19e87f2012-04-21 21:27:46 -07001002#ifdef _WIN32
1003#include <windows.h>
1004#else
Jason Evansb7924f52009-06-23 19:01:18 -07001005#include <unistd.h>
Mike Hommeya19e87f2012-04-21 21:27:46 -07001006#endif
1007#include <stdio.h>
Jason Evans6684cac2012-03-05 12:15:36 -08001008]],
1009[[
Garrett Cooper72c1e592012-12-02 17:57:28 -08001010 int result;
Jason Evansb7924f52009-06-23 19:01:18 -07001011 FILE *f;
1012
Mike Hommeya19e87f2012-04-21 21:27:46 -07001013#ifdef _WIN32
1014 SYSTEM_INFO si;
1015 GetSystemInfo(&si);
1016 result = si.dwPageSize;
1017#else
Jason Evansb7924f52009-06-23 19:01:18 -07001018 result = sysconf(_SC_PAGESIZE);
Mike Hommeya19e87f2012-04-21 21:27:46 -07001019#endif
Jason Evansb7924f52009-06-23 19:01:18 -07001020 if (result == -1) {
1021 return 1;
1022 }
Mike Hommey8f50ec82014-06-04 12:12:55 +09001023 result = JEMALLOC_INTERNAL_FFSL(result) - 1;
Mike Hommeya19e87f2012-04-21 21:27:46 -07001024
Jason Evansb7924f52009-06-23 19:01:18 -07001025 f = fopen("conftest.out", "w");
1026 if (f == NULL) {
1027 return 1;
1028 }
Garrett Cooper72c1e592012-12-02 17:57:28 -08001029 fprintf(f, "%d\n", result);
Jason Evans3cc1f1a2012-04-03 22:30:05 -07001030 fclose(f);
Jason Evansb7924f52009-06-23 19:01:18 -07001031
1032 return 0;
1033]])],
Jason Evansfc0b3b72014-10-09 17:54:06 -07001034 [je_cv_lg_page=`cat conftest.out`],
1035 [je_cv_lg_page=undefined],
1036 [je_cv_lg_page=12]))
Jason Evans6684cac2012-03-05 12:15:36 -08001037fi
Jason Evansfc0b3b72014-10-09 17:54:06 -07001038if test "x${je_cv_lg_page}" != "x" ; then
1039 LG_PAGE="${je_cv_lg_page}"
1040fi
1041if test "x${LG_PAGE}" != "xundefined" ; then
1042 AC_DEFINE_UNQUOTED([LG_PAGE], [$LG_PAGE])
1043else
1044 AC_MSG_ERROR([cannot determine value for LG_PAGE])
1045fi
1046
1047AC_ARG_WITH([lg_page_sizes],
1048 [AS_HELP_STRING([--with-lg-page-sizes=<lg-page-sizes>],
1049 [Base 2 logs of system page sizes to support])],
1050 [LG_PAGE_SIZES="$with_lg_page_sizes"], [LG_PAGE_SIZES="$LG_PAGE"])
1051
1052AC_ARG_WITH([lg_size_class_group],
1053 [AS_HELP_STRING([--with-lg-size-class-group=<lg-size-class-group>],
1054 [Base 2 log of size classes per doubling])],
1055 [LG_SIZE_CLASS_GROUP="$with_lg_size_class_group"],
1056 [LG_SIZE_CLASS_GROUP="2"])
Jason Evansb7924f52009-06-23 19:01:18 -07001057
1058dnl ============================================================================
1059dnl jemalloc configuration.
1060dnl
Jason Evansa40bc7a2010-03-02 13:01:16 -08001061
Jason Evansa5a658a2014-09-02 15:07:07 -07001062dnl Set VERSION if source directory is inside a git repository.
1063if test "x`git rev-parse --is-inside-work-tree 2>/dev/null`" = "xtrue" ; then
1064 dnl Pattern globs aren't powerful enough to match both single- and
1065 dnl double-digit version numbers, so iterate over patterns to support up to
1066 dnl version 99.99.99 without any accidental matches.
1067 rm -f "${srcroot}VERSION"
1068 for pattern in ['[0-9].[0-9].[0-9]' '[0-9].[0-9].[0-9][0-9]' \
1069 '[0-9].[0-9][0-9].[0-9]' '[0-9].[0-9][0-9].[0-9][0-9]' \
1070 '[0-9][0-9].[0-9].[0-9]' '[0-9][0-9].[0-9].[0-9][0-9]' \
1071 '[0-9][0-9].[0-9][0-9].[0-9]' \
1072 '[0-9][0-9].[0-9][0-9].[0-9][0-9]']; do
1073 if test ! -e "${srcroot}VERSION" ; then
1074 git describe --long --abbrev=40 --match="${pattern}" > "${srcroot}VERSION.tmp" 2>/dev/null
1075 if test $? -eq 0 ; then
1076 mv "${srcroot}VERSION.tmp" "${srcroot}VERSION"
1077 break
1078 fi
1079 fi
1080 done
Jason Evansa40bc7a2010-03-02 13:01:16 -08001081fi
Jason Evansa5a658a2014-09-02 15:07:07 -07001082rm -f "${srcroot}VERSION.tmp"
1083if test ! -e "${srcroot}VERSION" ; then
1084 AC_MSG_RESULT(
1085 [Missing VERSION file, and unable to generate it; creating bogus VERSION])
1086 echo "0.0.0-0-g0000000000000000000000000000000000000000" > "${srcroot}VERSION"
1087fi
1088jemalloc_version=`cat "${srcroot}VERSION"`
Jason Evansa40bc7a2010-03-02 13:01:16 -08001089jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'`
1090jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'`
1091jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'`
1092jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'`
1093jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'`
Jason Evansb7924f52009-06-23 19:01:18 -07001094AC_SUBST([jemalloc_version])
Jason Evansa40bc7a2010-03-02 13:01:16 -08001095AC_SUBST([jemalloc_version_major])
1096AC_SUBST([jemalloc_version_minor])
1097AC_SUBST([jemalloc_version_bugfix])
1098AC_SUBST([jemalloc_version_nrev])
1099AC_SUBST([jemalloc_version_gid])
Jason Evansb7924f52009-06-23 19:01:18 -07001100
1101dnl ============================================================================
1102dnl Configure pthreads.
1103
Mike Hommeya19e87f2012-04-21 21:27:46 -07001104if test "x$abi" != "xpecoff" ; then
1105 AC_CHECK_HEADERS([pthread.h], , [AC_MSG_ERROR([pthread.h is missing])])
1106 dnl Some systems may embed pthreads functionality in libc; check for libpthread
1107 dnl first, but try libc too before failing.
1108 AC_CHECK_LIB([pthread], [pthread_create], [LIBS="$LIBS -lpthread"],
1109 [AC_SEARCH_LIBS([pthread_create], , ,
1110 AC_MSG_ERROR([libpthread is missing]))])
1111fi
Jason Evansb7924f52009-06-23 19:01:18 -07001112
1113CPPFLAGS="$CPPFLAGS -D_REENTRANT"
1114
Daniel Micayb74041f2014-12-09 17:41:34 -05001115dnl Check if the GNU-specific secure_getenv function exists.
1116AC_CHECK_FUNC([secure_getenv],
1117 [have_secure_getenv="1"],
1118 [have_secure_getenv="0"]
1119 )
1120if test "x$have_secure_getenv" = "x1" ; then
1121 AC_DEFINE([JEMALLOC_HAVE_SECURE_GETENV], [ ])
1122fi
1123
1124dnl Check if the Solaris/BSD issetugid function exists.
1125AC_CHECK_FUNC([issetugid],
1126 [have_issetugid="1"],
1127 [have_issetugid="0"]
1128 )
1129if test "x$have_issetugid" = "x1" ; then
1130 AC_DEFINE([JEMALLOC_HAVE_ISSETUGID], [ ])
1131fi
1132
Jason Evanscd9a1342012-03-21 18:33:03 -07001133dnl Check whether the BSD-specific _malloc_thread_cleanup() exists. If so, use
1134dnl it rather than pthreads TSD cleanup functions to support cleanup during
1135dnl thread exit, in order to avoid pthreads library recursion during
1136dnl bootstrapping.
Jason Evanscd9a1342012-03-21 18:33:03 -07001137AC_CHECK_FUNC([_malloc_thread_cleanup],
1138 [have__malloc_thread_cleanup="1"],
1139 [have__malloc_thread_cleanup="0"]
1140 )
1141if test "x$have__malloc_thread_cleanup" = "x1" ; then
1142 AC_DEFINE([JEMALLOC_MALLOC_THREAD_CLEANUP], [ ])
1143 force_tls="1"
1144fi
1145
Jason Evans41b6afb2012-02-02 22:04:57 -08001146dnl Check whether the BSD-specific _pthread_mutex_init_calloc_cb() exists. If
1147dnl so, mutex initialization causes allocation, and we need to implement this
1148dnl callback function in order to prevent recursive allocation.
1149AC_CHECK_FUNC([_pthread_mutex_init_calloc_cb],
1150 [have__pthread_mutex_init_calloc_cb="1"],
1151 [have__pthread_mutex_init_calloc_cb="0"]
1152 )
1153if test "x$have__pthread_mutex_init_calloc_cb" = "x1" ; then
1154 AC_DEFINE([JEMALLOC_MUTEX_INIT_CB])
1155fi
1156
Jason Evans0fee70d2012-02-13 12:36:11 -08001157dnl Disable lazy locking by default.
Jason Evansb7924f52009-06-23 19:01:18 -07001158AC_ARG_ENABLE([lazy_lock],
Jason Evans0fee70d2012-02-13 12:36:11 -08001159 [AS_HELP_STRING([--enable-lazy-lock],
1160 [Enable lazy locking (only lock when multi-threaded)])],
Jason Evansb7924f52009-06-23 19:01:18 -07001161[if test "x$enable_lazy_lock" = "xno" ; then
1162 enable_lazy_lock="0"
1163else
1164 enable_lazy_lock="1"
1165fi
1166],
Jason Evans0fee70d2012-02-13 12:36:11 -08001167[enable_lazy_lock="0"]
Jason Evansb7924f52009-06-23 19:01:18 -07001168)
Jason Evansfd4fcef2012-03-23 17:40:58 -07001169if test "x$enable_lazy_lock" = "x0" -a "x${force_lazy_lock}" = "x1" ; then
1170 AC_MSG_RESULT([Forcing lazy-lock to avoid allocator/threading bootstrap issues])
1171 enable_lazy_lock="1"
1172fi
Jason Evansb7924f52009-06-23 19:01:18 -07001173if test "x$enable_lazy_lock" = "x1" ; then
Mike Hommeya19e87f2012-04-21 21:27:46 -07001174 if test "x$abi" != "xpecoff" ; then
1175 AC_CHECK_HEADERS([dlfcn.h], , [AC_MSG_ERROR([dlfcn.h is missing])])
1176 AC_CHECK_FUNC([dlsym], [],
1177 [AC_CHECK_LIB([dl], [dlsym], [LIBS="$LIBS -ldl"],
1178 [AC_MSG_ERROR([libdl is missing])])
1179 ])
1180 fi
Jason Evansb7924f52009-06-23 19:01:18 -07001181 AC_DEFINE([JEMALLOC_LAZY_LOCK], [ ])
1182fi
1183AC_SUBST([enable_lazy_lock])
1184
Jason Evans78d815c2010-01-17 14:06:20 -08001185AC_ARG_ENABLE([tls],
1186 [AS_HELP_STRING([--disable-tls], [Disable thread-local storage (__thread keyword)])],
1187if test "x$enable_tls" = "xno" ; then
1188 enable_tls="0"
1189else
1190 enable_tls="1"
1191fi
1192,
1193enable_tls="1"
1194)
Jason Evanscd9a1342012-03-21 18:33:03 -07001195if test "x${enable_tls}" = "x0" -a "x${force_tls}" = "x1" ; then
1196 AC_MSG_RESULT([Forcing TLS to avoid allocator/threading bootstrap issues])
1197 enable_tls="1"
1198fi
Jason Evansb80581d2012-03-23 16:17:43 -07001199if test "x${enable_tls}" = "x1" -a "x${force_tls}" = "x0" ; then
1200 AC_MSG_RESULT([Forcing no TLS to avoid allocator/threading bootstrap issues])
1201 enable_tls="0"
1202fi
Jason Evans78d815c2010-01-17 14:06:20 -08001203if test "x${enable_tls}" = "x1" ; then
1204AC_MSG_CHECKING([for TLS])
Jason Evans6684cac2012-03-05 12:15:36 -08001205AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Jason Evans78d815c2010-01-17 14:06:20 -08001206[[
1207 __thread int x;
1208]], [[
1209 x = 42;
1210
1211 return 0;
1212]])],
1213 AC_MSG_RESULT([yes]),
1214 AC_MSG_RESULT([no])
1215 enable_tls="0")
1216fi
Jason Evansb267d0f2010-08-13 15:42:29 -07001217AC_SUBST([enable_tls])
Jason Evanse24c7af2012-03-19 10:21:17 -07001218if test "x${enable_tls}" = "x1" ; then
1219 AC_DEFINE_UNQUOTED([JEMALLOC_TLS], [ ])
Jason Evanscd9a1342012-03-21 18:33:03 -07001220elif test "x${force_tls}" = "x1" ; then
1221 AC_MSG_ERROR([Failed to configure TLS, which is mandatory for correct function])
Jason Evans78d815c2010-01-17 14:06:20 -08001222fi
1223
Jason Evans2dbecf12010-09-05 10:35:13 -07001224dnl ============================================================================
Chih-hung Hsieh59cd80e2014-12-05 17:42:41 -08001225dnl Check for C11 atomics.
1226
1227JE_COMPILABLE([C11 atomics], [
1228#include <stdint.h>
1229#if (__STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_ATOMICS__)
1230#include <stdatomic.h>
1231#else
1232#error Atomics not available
1233#endif
1234], [
1235 uint64_t *p = (uint64_t *)0;
1236 uint64_t x = 1;
1237 volatile atomic_uint_least64_t *a = (volatile atomic_uint_least64_t *)p;
1238 uint64_t r = atomic_fetch_add(a, x) + x;
1239 return (r == 0);
1240], [je_cv_c11atomics])
1241if test "x${je_cv_c11atomics}" = "xyes" ; then
1242 AC_DEFINE([JEMALLOC_C11ATOMICS])
1243fi
1244
1245dnl ============================================================================
Jason Evansb57d3ec2012-04-17 13:17:54 -07001246dnl Check for atomic(9) operations as provided on FreeBSD.
1247
1248JE_COMPILABLE([atomic(9)], [
1249#include <sys/types.h>
1250#include <machine/atomic.h>
1251#include <inttypes.h>
1252], [
1253 {
1254 uint32_t x32 = 0;
1255 volatile uint32_t *x32p = &x32;
1256 atomic_fetchadd_32(x32p, 1);
1257 }
1258 {
1259 unsigned long xlong = 0;
1260 volatile unsigned long *xlongp = &xlong;
1261 atomic_fetchadd_long(xlongp, 1);
1262 }
1263], [je_cv_atomic9])
1264if test "x${je_cv_atomic9}" = "xyes" ; then
1265 AC_DEFINE([JEMALLOC_ATOMIC9])
1266fi
1267
1268dnl ============================================================================
Jason Evans763baa62011-03-18 19:10:31 -07001269dnl Check for atomic(3) operations as provided on Darwin.
1270
1271JE_COMPILABLE([Darwin OSAtomic*()], [
1272#include <libkern/OSAtomic.h>
1273#include <inttypes.h>
1274], [
1275 {
1276 int32_t x32 = 0;
1277 volatile int32_t *x32p = &x32;
1278 OSAtomicAdd32(1, x32p);
1279 }
1280 {
1281 int64_t x64 = 0;
1282 volatile int64_t *x64p = &x64;
1283 OSAtomicAdd64(1, x64p);
1284 }
Jason Evans6684cac2012-03-05 12:15:36 -08001285], [je_cv_osatomic])
1286if test "x${je_cv_osatomic}" = "xyes" ; then
Jason Evanse24c7af2012-03-19 10:21:17 -07001287 AC_DEFINE([JEMALLOC_OSATOMIC], [ ])
Jason Evans763baa62011-03-18 19:10:31 -07001288fi
1289
1290dnl ============================================================================
Richard Diamond994fad92014-06-03 02:39:18 -05001291dnl Check for madvise(2).
1292
1293JE_COMPILABLE([madvise(2)], [
1294#include <sys/mman.h>
1295], [
1296 {
1297 madvise((void *)0, 0, 0);
1298 }
1299], [je_cv_madvise])
1300if test "x${je_cv_madvise}" = "xyes" ; then
1301 AC_DEFINE([JEMALLOC_HAVE_MADVISE], [ ])
1302fi
1303
1304dnl ============================================================================
Mike Hommeyc1e567b2012-03-26 17:03:41 +02001305dnl Check whether __sync_{add,sub}_and_fetch() are available despite
1306dnl __GCC_HAVE_SYNC_COMPARE_AND_SWAP_n macros being undefined.
1307
1308AC_DEFUN([JE_SYNC_COMPARE_AND_SWAP_CHECK],[
1309 AC_CACHE_CHECK([whether to force $1-bit __sync_{add,sub}_and_fetch()],
1310 [je_cv_sync_compare_and_swap_$2],
Mike Hommey2cfe6d62012-03-27 15:03:07 +02001311 [AC_LINK_IFELSE([AC_LANG_PROGRAM([
1312 #include <stdint.h>
1313 ],
1314 [
1315 #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2
1316 {
1317 uint$1_t x$1 = 0;
1318 __sync_add_and_fetch(&x$1, 42);
1319 __sync_sub_and_fetch(&x$1, 1);
1320 }
1321 #else
1322 #error __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2 is defined, no need to force
1323 #endif
1324 ])],
Mike Hommeyc1e567b2012-03-26 17:03:41 +02001325 [je_cv_sync_compare_and_swap_$2=yes],
1326 [je_cv_sync_compare_and_swap_$2=no])])
1327
1328 if test "x${je_cv_sync_compare_and_swap_$2}" = "xyes" ; then
1329 AC_DEFINE([JE_FORCE_SYNC_COMPARE_AND_SWAP_$2], [ ])
1330 fi
1331])
1332
Jason Evansb57d3ec2012-04-17 13:17:54 -07001333if test "x${je_cv_atomic9}" != "xyes" -a "x${je_cv_osatomic}" != "xyes" ; then
Mike Hommeyc1e567b2012-03-26 17:03:41 +02001334 JE_SYNC_COMPARE_AND_SWAP_CHECK(32, 4)
1335 JE_SYNC_COMPARE_AND_SWAP_CHECK(64, 8)
1336fi
1337
1338dnl ============================================================================
Jason Evansd04047c2014-05-28 16:11:55 -07001339dnl Check for __builtin_clz() and __builtin_clzl().
1340
1341AC_CACHE_CHECK([for __builtin_clz],
1342 [je_cv_builtin_clz],
1343 [AC_LINK_IFELSE([AC_LANG_PROGRAM([],
1344 [
1345 {
1346 unsigned x = 0;
1347 int y = __builtin_clz(x);
1348 }
1349 {
1350 unsigned long x = 0;
1351 int y = __builtin_clzl(x);
1352 }
1353 ])],
1354 [je_cv_builtin_clz=yes],
1355 [je_cv_builtin_clz=no])])
1356
1357if test "x${je_cv_builtin_clz}" = "xyes" ; then
1358 AC_DEFINE([JEMALLOC_HAVE_BUILTIN_CLZ], [ ])
1359fi
1360
1361dnl ============================================================================
Jason Evans893a0ed2011-03-18 19:30:18 -07001362dnl Check for spinlock(3) operations as provided on Darwin.
1363
1364JE_COMPILABLE([Darwin OSSpin*()], [
1365#include <libkern/OSAtomic.h>
1366#include <inttypes.h>
1367], [
1368 OSSpinLock lock = 0;
1369 OSSpinLockLock(&lock);
1370 OSSpinLockUnlock(&lock);
Jason Evans6684cac2012-03-05 12:15:36 -08001371], [je_cv_osspin])
1372if test "x${je_cv_osspin}" = "xyes" ; then
Jason Evanse24c7af2012-03-19 10:21:17 -07001373 AC_DEFINE([JEMALLOC_OSSPIN], [ ])
Jason Evans893a0ed2011-03-18 19:30:18 -07001374fi
1375
1376dnl ============================================================================
Jason Evans2dbecf12010-09-05 10:35:13 -07001377dnl Darwin-related configuration.
Jason Evans78d815c2010-01-17 14:06:20 -08001378
Mike Hommeyd0357f72012-11-26 18:52:41 +01001379AC_ARG_ENABLE([zone-allocator],
1380 [AS_HELP_STRING([--disable-zone-allocator],
1381 [Disable zone allocator for Darwin])],
1382[if test "x$enable_zone_allocator" = "xno" ; then
1383 enable_zone_allocator="0"
1384else
1385 enable_zone_allocator="1"
1386fi
1387],
1388[if test "x${abi}" = "xmacho"; then
1389 enable_zone_allocator="1"
1390fi
1391]
1392)
1393AC_SUBST([enable_zone_allocator])
1394
1395if test "x${enable_zone_allocator}" = "x1" ; then
1396 if test "x${abi}" != "xmacho"; then
1397 AC_MSG_ERROR([--enable-zone-allocator is only supported on Darwin])
1398 fi
Jason Evanse24c7af2012-03-19 10:21:17 -07001399 AC_DEFINE([JEMALLOC_IVSALLOC], [ ])
1400 AC_DEFINE([JEMALLOC_ZONE], [ ])
Jason Evans6109fe02010-02-10 10:37:56 -08001401
Jason Evans2dbecf12010-09-05 10:35:13 -07001402 dnl The szone version jumped from 3 to 6 between the OS X 10.5.x and 10.6
1403 dnl releases. malloc_zone_t and malloc_introspection_t have new fields in
1404 dnl 10.6, which is the only source-level indication of the change.
1405 AC_MSG_CHECKING([malloc zone version])
Mike Hommey154829d2012-03-20 18:01:38 +01001406 AC_DEFUN([JE_ZONE_PROGRAM],
1407 [AC_LANG_PROGRAM(
1408 [#include <malloc/malloc.h>],
Guilherme Goncalves79725aa2014-10-20 14:08:37 -02001409 [static int foo[[sizeof($1) $2 sizeof(void *) * $3 ? 1 : -1]]]
Mike Hommey154829d2012-03-20 18:01:38 +01001410 )])
Jason Evans2dbecf12010-09-05 10:35:13 -07001411
Mike Hommey154829d2012-03-20 18:01:38 +01001412 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,14)],[JEMALLOC_ZONE_VERSION=3],[
1413 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,15)],[JEMALLOC_ZONE_VERSION=5],[
1414 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,16)],[
1415 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,9)],[JEMALLOC_ZONE_VERSION=6],[
1416 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,13)],[JEMALLOC_ZONE_VERSION=7],[JEMALLOC_ZONE_VERSION=]
1417 )])],[
1418 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,17)],[JEMALLOC_ZONE_VERSION=8],[
1419 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,>,17)],[JEMALLOC_ZONE_VERSION=9],[JEMALLOC_ZONE_VERSION=]
1420 )])])])])
1421 if test "x${JEMALLOC_ZONE_VERSION}" = "x"; then
1422 AC_MSG_RESULT([unsupported])
1423 AC_MSG_ERROR([Unsupported malloc zone version])
1424 fi
1425 if test "${JEMALLOC_ZONE_VERSION}" = 9; then
1426 JEMALLOC_ZONE_VERSION=8
1427 AC_MSG_RESULT([> 8])
1428 else
1429 AC_MSG_RESULT([$JEMALLOC_ZONE_VERSION])
1430 fi
1431 AC_DEFINE_UNQUOTED(JEMALLOC_ZONE_VERSION, [$JEMALLOC_ZONE_VERSION])
Jason Evansb27805b2010-02-10 18:15:53 -08001432fi
1433
Jason Evansb7924f52009-06-23 19:01:18 -07001434dnl ============================================================================
Sara Golemon3e24afa2014-08-18 13:06:39 -07001435dnl Check for glibc malloc hooks
1436
1437JE_COMPILABLE([glibc malloc hook], [
1438#include <stddef.h>
1439
1440extern void (* __free_hook)(void *ptr);
1441extern void *(* __malloc_hook)(size_t size);
1442extern void *(* __realloc_hook)(void *ptr, size_t size);
1443], [
1444 void *ptr = 0L;
1445 if (__malloc_hook) ptr = __malloc_hook(1);
1446 if (__realloc_hook) ptr = __realloc_hook(ptr, 2);
1447 if (__free_hook && ptr) __free_hook(ptr);
1448], [je_cv_glibc_malloc_hook])
1449if test "x${je_cv_glibc_malloc_hook}" = "xyes" ; then
1450 AC_DEFINE([JEMALLOC_GLIBC_MALLOC_HOOK], [ ])
1451fi
1452
1453JE_COMPILABLE([glibc memalign hook], [
1454#include <stddef.h>
1455
1456extern void *(* __memalign_hook)(size_t alignment, size_t size);
1457], [
1458 void *ptr = 0L;
1459 if (__memalign_hook) ptr = __memalign_hook(16, 7);
1460], [je_cv_glibc_memalign_hook])
1461if test "x${je_cv_glibc_memalign_hook}" = "xyes" ; then
1462 AC_DEFINE([JEMALLOC_GLIBC_MEMALIGN_HOOK], [ ])
1463fi
1464
Eric Wong4dcf04b2014-08-31 03:57:06 +00001465JE_COMPILABLE([pthreads adaptive mutexes], [
1466#include <pthread.h>
1467], [
1468 pthread_mutexattr_t attr;
1469 pthread_mutexattr_init(&attr);
1470 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ADAPTIVE_NP);
1471 pthread_mutexattr_destroy(&attr);
1472], [je_cv_pthread_mutex_adaptive_np])
1473if test "x${je_cv_pthread_mutex_adaptive_np}" = "xyes" ; then
1474 AC_DEFINE([JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], [ ])
1475fi
1476
Sara Golemon3e24afa2014-08-18 13:06:39 -07001477dnl ============================================================================
Jason Evansb7924f52009-06-23 19:01:18 -07001478dnl Check for typedefs, structures, and compiler characteristics.
1479AC_HEADER_STDBOOL
1480
Jason Evans748dfac2013-12-06 18:27:33 -08001481dnl ============================================================================
1482dnl Define commands that generate output files.
1483
Jason Evans86abd0d2013-11-30 15:25:42 -08001484AC_CONFIG_COMMANDS([include/jemalloc/internal/private_namespace.h], [
1485 mkdir -p "${objroot}include/jemalloc/internal"
1486 "${srcdir}/include/jemalloc/internal/private_namespace.sh" "${srcdir}/include/jemalloc/internal/private_symbols.txt" > "${objroot}include/jemalloc/internal/private_namespace.h"
Jason Evansf234dc52014-01-16 17:38:01 -08001487], [
1488 srcdir="${srcdir}"
1489 objroot="${objroot}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001490])
1491AC_CONFIG_COMMANDS([include/jemalloc/internal/private_unnamespace.h], [
1492 mkdir -p "${objroot}include/jemalloc/internal"
1493 "${srcdir}/include/jemalloc/internal/private_unnamespace.sh" "${srcdir}/include/jemalloc/internal/private_symbols.txt" > "${objroot}include/jemalloc/internal/private_unnamespace.h"
Jason Evansf234dc52014-01-16 17:38:01 -08001494], [
1495 srcdir="${srcdir}"
1496 objroot="${objroot}"
1497])
1498AC_CONFIG_COMMANDS([include/jemalloc/internal/public_symbols.txt], [
1499 f="${objroot}include/jemalloc/internal/public_symbols.txt"
1500 mkdir -p "${objroot}include/jemalloc/internal"
1501 cp /dev/null "${f}"
1502 for nm in `echo ${mangling_map} |tr ',' ' '` ; do
1503 n=`echo ${nm} |tr ':' ' ' |awk '{print $[]1}'`
1504 m=`echo ${nm} |tr ':' ' ' |awk '{print $[]2}'`
1505 echo "${n}:${m}" >> "${f}"
1506 dnl Remove name from public_syms so that it isn't redefined later.
1507 public_syms=`for sym in ${public_syms}; do echo "${sym}"; done |grep -v "^${n}\$" |tr '\n' ' '`
1508 done
1509 for sym in ${public_syms} ; do
1510 n="${sym}"
1511 m="${JEMALLOC_PREFIX}${sym}"
1512 echo "${n}:${m}" >> "${f}"
1513 done
1514], [
1515 srcdir="${srcdir}"
1516 objroot="${objroot}"
1517 mangling_map="${mangling_map}"
1518 public_syms="${public_syms}"
1519 JEMALLOC_PREFIX="${JEMALLOC_PREFIX}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001520])
1521AC_CONFIG_COMMANDS([include/jemalloc/internal/public_namespace.h], [
1522 mkdir -p "${objroot}include/jemalloc/internal"
Jason Evansf234dc52014-01-16 17:38:01 -08001523 "${srcdir}/include/jemalloc/internal/public_namespace.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/internal/public_namespace.h"
1524], [
1525 srcdir="${srcdir}"
1526 objroot="${objroot}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001527])
1528AC_CONFIG_COMMANDS([include/jemalloc/internal/public_unnamespace.h], [
1529 mkdir -p "${objroot}include/jemalloc/internal"
Jason Evansf234dc52014-01-16 17:38:01 -08001530 "${srcdir}/include/jemalloc/internal/public_unnamespace.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/internal/public_unnamespace.h"
1531], [
1532 srcdir="${srcdir}"
1533 objroot="${objroot}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001534])
Jason Evansb1726102012-02-28 16:50:47 -08001535AC_CONFIG_COMMANDS([include/jemalloc/internal/size_classes.h], [
Jason Evans86abd0d2013-11-30 15:25:42 -08001536 mkdir -p "${objroot}include/jemalloc/internal"
Jason Evans81e54752014-10-10 22:34:25 -07001537 "${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"
Jason Evansf234dc52014-01-16 17:38:01 -08001538], [
1539 srcdir="${srcdir}"
1540 objroot="${objroot}"
Jason Evans81e54752014-10-10 22:34:25 -07001541 LG_QUANTA="${LG_QUANTA}"
1542 LG_TINY_MIN=${LG_TINY_MIN}
1543 LG_PAGE_SIZES="${LG_PAGE_SIZES}"
Jason Evansfc0b3b72014-10-09 17:54:06 -07001544 LG_SIZE_CLASS_GROUP=${LG_SIZE_CLASS_GROUP}
Jason Evansb1726102012-02-28 16:50:47 -08001545])
Jason Evans86abd0d2013-11-30 15:25:42 -08001546AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_protos_jet.h], [
1547 mkdir -p "${objroot}include/jemalloc"
1548 cat "${srcdir}/include/jemalloc/jemalloc_protos.h.in" | sed -e 's/@je_@/jet_/g' > "${objroot}include/jemalloc/jemalloc_protos_jet.h"
Jason Evansf234dc52014-01-16 17:38:01 -08001549], [
1550 srcdir="${srcdir}"
1551 objroot="${objroot}"
1552])
1553AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_rename.h], [
1554 mkdir -p "${objroot}include/jemalloc"
1555 "${srcdir}/include/jemalloc/jemalloc_rename.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/jemalloc_rename.h"
1556], [
1557 srcdir="${srcdir}"
1558 objroot="${objroot}"
1559])
1560AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_mangle.h], [
1561 mkdir -p "${objroot}include/jemalloc"
1562 "${srcdir}/include/jemalloc/jemalloc_mangle.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" je_ > "${objroot}include/jemalloc/jemalloc_mangle.h"
1563], [
1564 srcdir="${srcdir}"
1565 objroot="${objroot}"
1566])
1567AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_mangle_jet.h], [
1568 mkdir -p "${objroot}include/jemalloc"
1569 "${srcdir}/include/jemalloc/jemalloc_mangle.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" jet_ > "${objroot}include/jemalloc/jemalloc_mangle_jet.h"
1570], [
1571 srcdir="${srcdir}"
1572 objroot="${objroot}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001573])
1574AC_CONFIG_COMMANDS([include/jemalloc/jemalloc.h], [
1575 mkdir -p "${objroot}include/jemalloc"
1576 "${srcdir}/include/jemalloc/jemalloc.sh" "${objroot}" > "${objroot}include/jemalloc/jemalloc${install_suffix}.h"
Jason Evansf234dc52014-01-16 17:38:01 -08001577], [
1578 srcdir="${srcdir}"
1579 objroot="${objroot}"
1580 install_suffix="${install_suffix}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001581])
Jason Evansb1726102012-02-28 16:50:47 -08001582
Jason Evansb7924f52009-06-23 19:01:18 -07001583dnl Process .in files.
Jason Evansb0fd5012010-01-17 01:49:20 -08001584AC_SUBST([cfghdrs_in])
1585AC_SUBST([cfghdrs_out])
Jason Evans0656ec02010-04-07 23:37:35 -07001586AC_CONFIG_HEADERS([$cfghdrs_tup])
Jason Evansb7924f52009-06-23 19:01:18 -07001587
1588dnl ============================================================================
1589dnl Generate outputs.
Jason Evans748dfac2013-12-06 18:27:33 -08001590
Jason Evansbec6a8d2015-01-22 17:55:58 -08001591AC_CONFIG_FILES([$cfgoutputs_tup config.stamp bin/jemalloc-config bin/jemalloc.sh])
Jason Evansb0fd5012010-01-17 01:49:20 -08001592AC_SUBST([cfgoutputs_in])
1593AC_SUBST([cfgoutputs_out])
Jason Evansb7924f52009-06-23 19:01:18 -07001594AC_OUTPUT
1595
1596dnl ============================================================================
1597dnl Print out the results of configuration.
1598AC_MSG_RESULT([===============================================================================])
Jason Evansf576c632011-11-01 22:27:41 -07001599AC_MSG_RESULT([jemalloc version : ${jemalloc_version}])
1600AC_MSG_RESULT([library revision : ${rev}])
Jason Evansb7924f52009-06-23 19:01:18 -07001601AC_MSG_RESULT([])
Jason Evansbec6a8d2015-01-22 17:55:58 -08001602AC_MSG_RESULT([CONFIG : ${CONFIG}])
Jason Evansb7924f52009-06-23 19:01:18 -07001603AC_MSG_RESULT([CC : ${CC}])
Jason Evansb7924f52009-06-23 19:01:18 -07001604AC_MSG_RESULT([CFLAGS : ${CFLAGS}])
Jason Evansbec6a8d2015-01-22 17:55:58 -08001605AC_MSG_RESULT([CPPFLAGS : ${CPPFLAGS}])
Jason Evansb7924f52009-06-23 19:01:18 -07001606AC_MSG_RESULT([LDFLAGS : ${LDFLAGS}])
Jason Evans748dfac2013-12-06 18:27:33 -08001607AC_MSG_RESULT([EXTRA_LDFLAGS : ${EXTRA_LDFLAGS}])
Jason Evansb7924f52009-06-23 19:01:18 -07001608AC_MSG_RESULT([LIBS : ${LIBS}])
1609AC_MSG_RESULT([RPATH_EXTRA : ${RPATH_EXTRA}])
1610AC_MSG_RESULT([])
Jason Evansaee7fd22010-11-24 22:00:02 -08001611AC_MSG_RESULT([XSLTPROC : ${XSLTPROC}])
1612AC_MSG_RESULT([XSLROOT : ${XSLROOT}])
1613AC_MSG_RESULT([])
Jason Evansb7924f52009-06-23 19:01:18 -07001614AC_MSG_RESULT([PREFIX : ${PREFIX}])
1615AC_MSG_RESULT([BINDIR : ${BINDIR}])
Jason Evansbec6a8d2015-01-22 17:55:58 -08001616AC_MSG_RESULT([DATADIR : ${DATADIR}])
Jason Evans662a0172009-07-01 19:24:31 -07001617AC_MSG_RESULT([INCLUDEDIR : ${INCLUDEDIR}])
1618AC_MSG_RESULT([LIBDIR : ${LIBDIR}])
Jason Evansb7924f52009-06-23 19:01:18 -07001619AC_MSG_RESULT([MANDIR : ${MANDIR}])
1620AC_MSG_RESULT([])
1621AC_MSG_RESULT([srcroot : ${srcroot}])
1622AC_MSG_RESULT([abs_srcroot : ${abs_srcroot}])
1623AC_MSG_RESULT([objroot : ${objroot}])
1624AC_MSG_RESULT([abs_objroot : ${abs_objroot}])
1625AC_MSG_RESULT([])
Jason Evans90895cf2009-12-29 00:09:15 -08001626AC_MSG_RESULT([JEMALLOC_PREFIX : ${JEMALLOC_PREFIX}])
Jason Evans746e77a2011-07-30 16:40:52 -07001627AC_MSG_RESULT([JEMALLOC_PRIVATE_NAMESPACE])
1628AC_MSG_RESULT([ : ${JEMALLOC_PRIVATE_NAMESPACE}])
Jason Evansb0fd5012010-01-17 01:49:20 -08001629AC_MSG_RESULT([install_suffix : ${install_suffix}])
Jason Evansb7924f52009-06-23 19:01:18 -07001630AC_MSG_RESULT([autogen : ${enable_autogen}])
Jason Evans355b4382010-09-20 19:20:48 -07001631AC_MSG_RESULT([cc-silence : ${enable_cc_silence}])
Jason Evansb7924f52009-06-23 19:01:18 -07001632AC_MSG_RESULT([debug : ${enable_debug}])
Jason Evans748dfac2013-12-06 18:27:33 -08001633AC_MSG_RESULT([code-coverage : ${enable_code_coverage}])
Jason Evansb7924f52009-06-23 19:01:18 -07001634AC_MSG_RESULT([stats : ${enable_stats}])
Jason Evans6109fe02010-02-10 10:37:56 -08001635AC_MSG_RESULT([prof : ${enable_prof}])
1636AC_MSG_RESULT([prof-libunwind : ${enable_prof_libunwind}])
Jason Evans77f350b2011-03-15 22:23:12 -07001637AC_MSG_RESULT([prof-libgcc : ${enable_prof_libgcc}])
1638AC_MSG_RESULT([prof-gcc : ${enable_prof_gcc}])
Jason Evans84cbbcb2009-12-29 00:09:15 -08001639AC_MSG_RESULT([tcache : ${enable_tcache}])
Jason Evansb7924f52009-06-23 19:01:18 -07001640AC_MSG_RESULT([fill : ${enable_fill}])
Jason Evansb1476112012-04-05 13:36:17 -07001641AC_MSG_RESULT([utrace : ${enable_utrace}])
Jason Evans122449b2012-04-06 00:35:09 -07001642AC_MSG_RESULT([valgrind : ${enable_valgrind}])
1643AC_MSG_RESULT([xmalloc : ${enable_xmalloc}])
Jason Evans59ae2762012-04-16 17:52:27 -07001644AC_MSG_RESULT([munmap : ${enable_munmap}])
Jason Evansb7924f52009-06-23 19:01:18 -07001645AC_MSG_RESULT([lazy_lock : ${enable_lazy_lock}])
Jason Evans2dbecf12010-09-05 10:35:13 -07001646AC_MSG_RESULT([tls : ${enable_tls}])
Jason Evansb7924f52009-06-23 19:01:18 -07001647AC_MSG_RESULT([===============================================================================])