blob: 0497eafedcca840e2138c79e05757591e3ac7aa8 [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 Evans41f2e692015-01-25 20:15:13 -080046CONFIG=`echo ${ac_configure_args} | sed -e 's#'"'"'\([^ ]*\)'"'"'#\1#g'`
Jason Evansbec6a8d2015-01-22 17:55:58 -080047AC_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"
Jason Evansf1f2b452015-05-01 08:57:41 -0700271 DSO_LDFLAGS='-shared -Wl,-install_name,$(LIBDIR)/$(@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 ;;
Sébastien Marieb80fbcb2015-04-07 12:21:19 +0200286 *-*-openbsd*)
287 CFLAGS="$CFLAGS"
288 abi="elf"
289 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
290 force_tls="0"
291 ;;
292 *-*-bitrig*)
Sébastien Marie77d597e2015-01-25 10:18:32 +0100293 CFLAGS="$CFLAGS"
294 abi="elf"
295 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
296 ;;
Jason Evansb7924f52009-06-23 19:01:18 -0700297 *-*-linux*)
298 CFLAGS="$CFLAGS"
299 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
300 abi="elf"
Garrett Cooper13e4e242012-12-02 17:58:40 -0800301 AC_DEFINE([JEMALLOC_HAS_ALLOCA_H])
Jason Evanse24c7af2012-03-19 10:21:17 -0700302 AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED], [ ])
Jason Evans02b23122012-04-05 11:06:23 -0700303 AC_DEFINE([JEMALLOC_THREADED_INIT], [ ])
Jason Evansae93d6b2015-07-10 14:33:00 -0700304 AC_DEFINE([JEMALLOC_USE_CXX_THROW], [ ])
Jason Evans59ae2762012-04-16 17:52:27 -0700305 default_munmap="0"
Jason Evansb7924f52009-06-23 19:01:18 -0700306 ;;
307 *-*-netbsd*)
308 AC_MSG_CHECKING([ABI])
309 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
310[[#ifdef __ELF__
311/* ELF */
312#else
313#error aout
314#endif
315]])],
316 [CFLAGS="$CFLAGS"; abi="elf"],
317 [abi="aout"])
318 AC_MSG_RESULT([$abi])
Jason Evanse24c7af2012-03-19 10:21:17 -0700319 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
Jason Evansb7924f52009-06-23 19:01:18 -0700320 ;;
321 *-*-solaris2*)
322 CFLAGS="$CFLAGS"
323 abi="elf"
George Koladdd6bd42014-02-12 23:05:45 +0000324 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
Mike Hommeyfa08da72012-04-16 16:30:25 +0200325 RPATH='-Wl,-R,$(1)'
Jason Evansb7924f52009-06-23 19:01:18 -0700326 dnl Solaris needs this for sigwait().
327 CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
328 LIBS="$LIBS -lposix4 -lsocket -lnsl"
329 ;;
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +0400330 *-ibm-aix*)
331 if "$LG_SIZEOF_PTR" = "8"; then
332 dnl 64bit AIX
333 LD_PRELOAD_VAR="LDR_PRELOAD64"
334 else
335 dnl 32bit AIX
336 LD_PRELOAD_VAR="LDR_PRELOAD"
337 fi
338 abi="xcoff"
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +0400339 ;;
Dave Rigby70bdee02014-09-22 15:53:16 +0100340 *-*-mingw* | *-*-cygwin*)
Mike Hommeya19e87f2012-04-21 21:27:46 -0700341 abi="pecoff"
342 force_tls="0"
Jason Evans13473c72015-07-23 14:08:49 -0700343 force_lazy_lock="1"
Mike Hommeya19e87f2012-04-21 21:27:46 -0700344 RPATH=""
345 so="dll"
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200346 if test "x$je_cv_msvc" = "xyes" ; then
347 importlib="lib"
348 DSO_LDFLAGS="-LD"
349 EXTRA_LDFLAGS="-link -DEBUG"
350 CTARGET='-Fo$@'
351 LDTARGET='-Fe$@'
Jory A. Prattad505e02013-08-11 09:44:59 -0500352 AR='lib'
353 ARFLAGS='-nologo -out:'
Jason Evans80ddf492013-08-20 11:48:19 +0100354 AROUT='$@'
Mike Hommey79c4bca2012-05-02 21:30:51 +0200355 CC_MM=
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200356 else
357 importlib="${so}"
358 DSO_LDFLAGS="-shared"
359 fi
Mike Hommeya19e87f2012-04-21 21:27:46 -0700360 a="lib"
361 libprefix=""
Mike Hommey7cdea392012-04-30 12:38:27 +0200362 SOREV="${so}"
Mike Hommeya19e87f2012-04-21 21:27:46 -0700363 PIC_CFLAGS=""
364 ;;
Jason Evansb7924f52009-06-23 19:01:18 -0700365 *)
366 AC_MSG_RESULT([Unsupported operating system: ${host}])
367 abi="elf"
Jason Evansb7924f52009-06-23 19:01:18 -0700368 ;;
369esac
Mike Hommeyaffe0092014-05-28 08:10:12 +0900370
371JEMALLOC_USABLE_SIZE_CONST=const
372AC_CHECK_HEADERS([malloc.h], [
373 AC_MSG_CHECKING([whether malloc_usable_size definition can use const argument])
374 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
375 [#include <malloc.h>
376 #include <stddef.h>
377 size_t malloc_usable_size(const void *ptr);
378 ],
379 [])],[
380 AC_MSG_RESULT([yes])
381 ],[
382 JEMALLOC_USABLE_SIZE_CONST=
383 AC_MSG_RESULT([no])
384 ])
385])
Jason Evans247d1242012-10-09 16:20:10 -0700386AC_DEFINE_UNQUOTED([JEMALLOC_USABLE_SIZE_CONST], [$JEMALLOC_USABLE_SIZE_CONST])
Jason Evansb7924f52009-06-23 19:01:18 -0700387AC_SUBST([abi])
388AC_SUBST([RPATH])
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +0400389AC_SUBST([LD_PRELOAD_VAR])
Jason Evansf576c632011-11-01 22:27:41 -0700390AC_SUBST([so])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200391AC_SUBST([importlib])
Mike Hommey5bee66d2012-04-16 16:30:24 +0200392AC_SUBST([o])
393AC_SUBST([a])
394AC_SUBST([exe])
Mike Hommeya19e87f2012-04-21 21:27:46 -0700395AC_SUBST([libprefix])
Mike Hommeyfa08da72012-04-16 16:30:25 +0200396AC_SUBST([DSO_LDFLAGS])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200397AC_SUBST([EXTRA_LDFLAGS])
Mike Hommey85221d52012-04-18 18:29:40 +0200398AC_SUBST([SOREV])
Mike Hommey188da7c2012-04-18 18:29:41 +0200399AC_SUBST([PIC_CFLAGS])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200400AC_SUBST([CTARGET])
401AC_SUBST([LDTARGET])
402AC_SUBST([MKLIB])
Jason Evans80ddf492013-08-20 11:48:19 +0100403AC_SUBST([ARFLAGS])
404AC_SUBST([AROUT])
Mike Hommey79c4bca2012-05-02 21:30:51 +0200405AC_SUBST([CC_MM])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200406
Jason Evansfa5d2452011-03-15 10:25:59 -0700407JE_COMPILABLE([__attribute__ syntax],
408 [static __attribute__((unused)) void foo(void){}],
409 [],
Jason Evans6684cac2012-03-05 12:15:36 -0800410 [je_cv_attribute])
411if test "x${je_cv_attribute}" = "xyes" ; then
Jason Evansfa5d2452011-03-15 10:25:59 -0700412 AC_DEFINE([JEMALLOC_HAVE_ATTR], [ ])
413 if test "x${GCC}" = "xyes" -a "x${abi}" = "xelf"; then
414 JE_CFLAGS_APPEND([-fvisibility=hidden])
415 fi
416fi
Jason Evans3cc1f1a2012-04-03 22:30:05 -0700417dnl Check for tls_model attribute support (clang 3.0 still lacks support).
418SAVED_CFLAGS="${CFLAGS}"
419JE_CFLAGS_APPEND([-Werror])
420JE_COMPILABLE([tls_model attribute], [],
421 [static __thread int
Daniel Micayf1cf3ea2014-09-16 04:42:33 -0400422 __attribute__((tls_model("initial-exec"), unused)) foo;
Jason Evans3cc1f1a2012-04-03 22:30:05 -0700423 foo = 0;],
424 [je_cv_tls_model])
425CFLAGS="${SAVED_CFLAGS}"
426if test "x${je_cv_tls_model}" = "xyes" ; then
427 AC_DEFINE([JEMALLOC_TLS_MODEL],
428 [__attribute__((tls_model("initial-exec")))])
429else
430 AC_DEFINE([JEMALLOC_TLS_MODEL], [ ])
431fi
Jason Evans0b8f0bc2015-07-10 16:41:12 -0700432dnl Check for alloc_size attribute support.
433SAVED_CFLAGS="${CFLAGS}"
434JE_CFLAGS_APPEND([-Werror])
Jason Evans92d72ee2015-07-10 16:45:32 -0700435JE_COMPILABLE([alloc_size attribute], [#include <stdlib.h>],
436 [void *foo(size_t size) __attribute__((alloc_size(1)));],
Jason Evans0b8f0bc2015-07-10 16:41:12 -0700437 [je_cv_alloc_size])
438CFLAGS="${SAVED_CFLAGS}"
439if test "x${je_cv_alloc_size}" = "xyes" ; then
440 AC_DEFINE([JEMALLOC_HAVE_ATTR_ALLOC_SIZE], [ ])
441fi
Jason Evanse42c3092015-07-22 15:44:47 -0700442dnl Check for format(gnu_printf, ...) attribute support.
443SAVED_CFLAGS="${CFLAGS}"
444JE_CFLAGS_APPEND([-Werror])
445JE_COMPILABLE([format(gnu_printf, ...) attribute], [#include <stdlib.h>],
446 [void *foo(const char *format, ...) __attribute__((format(gnu_printf, 1, 2)));],
447 [je_cv_format_gnu_printf])
448CFLAGS="${SAVED_CFLAGS}"
449if test "x${je_cv_format_gnu_printf}" = "xyes" ; then
450 AC_DEFINE([JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF], [ ])
451fi
452dnl Check for format(printf, ...) attribute support.
453SAVED_CFLAGS="${CFLAGS}"
454JE_CFLAGS_APPEND([-Werror])
455JE_COMPILABLE([format(printf, ...) attribute], [#include <stdlib.h>],
456 [void *foo(const char *format, ...) __attribute__((format(printf, 1, 2)));],
457 [je_cv_format_printf])
458CFLAGS="${SAVED_CFLAGS}"
459if test "x${je_cv_format_printf}" = "xyes" ; then
460 AC_DEFINE([JEMALLOC_HAVE_ATTR_FORMAT_PRINTF], [ ])
461fi
Jason Evansfa5d2452011-03-15 10:25:59 -0700462
Jason Evansb7924f52009-06-23 19:01:18 -0700463dnl Support optional additions to rpath.
464AC_ARG_WITH([rpath],
Jason Evans90895cf2009-12-29 00:09:15 -0800465 [AS_HELP_STRING([--with-rpath=<rpath>], [Colon-separated rpath (ELF systems only)])],
Jason Evansb7924f52009-06-23 19:01:18 -0700466if test "x$with_rpath" = "xno" ; then
467 RPATH_EXTRA=
468else
469 RPATH_EXTRA="`echo $with_rpath | tr \":\" \" \"`"
470fi,
471 RPATH_EXTRA=
472)
473AC_SUBST([RPATH_EXTRA])
474
475dnl Disable rules that do automatic regeneration of configure output by default.
476AC_ARG_ENABLE([autogen],
Jason Evans78d815c2010-01-17 14:06:20 -0800477 [AS_HELP_STRING([--enable-autogen], [Automatically regenerate configure output])],
Jason Evansb7924f52009-06-23 19:01:18 -0700478if test "x$enable_autogen" = "xno" ; then
479 enable_autogen="0"
480else
481 enable_autogen="1"
482fi
483,
484enable_autogen="0"
485)
486AC_SUBST([enable_autogen])
487
488AC_PROG_INSTALL
489AC_PROG_RANLIB
Jason Evans7329a4f2013-01-22 10:53:29 -0800490AC_PATH_PROG([LD], [ld], [false], [$PATH])
491AC_PATH_PROG([AUTOCONF], [autoconf], [false], [$PATH])
Jason Evansb7924f52009-06-23 19:01:18 -0700492
Daniel Micay4cfe5512014-08-28 15:41:48 -0400493public_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 -0800494
495dnl Check for allocator-related functions that should be wrapped.
496AC_CHECK_FUNC([memalign],
Jason Evanse24c7af2012-03-19 10:21:17 -0700497 [AC_DEFINE([JEMALLOC_OVERRIDE_MEMALIGN], [ ])
Jason Evans7e77eaf2012-03-02 17:47:37 -0800498 public_syms="${public_syms} memalign"])
499AC_CHECK_FUNC([valloc],
Jason Evanse24c7af2012-03-19 10:21:17 -0700500 [AC_DEFINE([JEMALLOC_OVERRIDE_VALLOC], [ ])
Jason Evans7e77eaf2012-03-02 17:47:37 -0800501 public_syms="${public_syms} valloc"])
502
Jason Evans748dfac2013-12-06 18:27:33 -0800503dnl Do not compute test code coverage by default.
504GCOV_FLAGS=
505AC_ARG_ENABLE([code-coverage],
506 [AS_HELP_STRING([--enable-code-coverage],
507 [Enable code coverage])],
508[if test "x$enable_code_coverage" = "xno" ; then
509 enable_code_coverage="0"
510else
511 enable_code_coverage="1"
512fi
513],
514[enable_code_coverage="0"]
515)
516if test "x$enable_code_coverage" = "x1" ; then
517 deoptimize="no"
518 echo "$CFLAGS $EXTRA_CFLAGS" | grep '\-O' >/dev/null || deoptimize="yes"
519 if test "x${deoptimize}" = "xyes" ; then
520 JE_CFLAGS_APPEND([-O0])
521 fi
522 JE_CFLAGS_APPEND([-fprofile-arcs -ftest-coverage])
523 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -fprofile-arcs -ftest-coverage"
524 AC_DEFINE([JEMALLOC_CODE_COVERAGE], [ ])
525fi
526AC_SUBST([enable_code_coverage])
527
Jason Evans0a5489e2012-03-01 17:19:20 -0800528dnl Perform no name mangling by default.
529AC_ARG_WITH([mangling],
530 [AS_HELP_STRING([--with-mangling=<map>], [Mangle symbols in <map>])],
531 [mangling_map="$with_mangling"], [mangling_map=""])
Jason Evans0a5489e2012-03-01 17:19:20 -0800532
Jason Evans90895cf2009-12-29 00:09:15 -0800533dnl Do not prefix public APIs by default.
534AC_ARG_WITH([jemalloc_prefix],
535 [AS_HELP_STRING([--with-jemalloc-prefix=<prefix>], [Prefix to prepend to all public APIs])],
Jason Evansb0fd5012010-01-17 01:49:20 -0800536 [JEMALLOC_PREFIX="$with_jemalloc_prefix"],
Mike Hommey7cdea392012-04-30 12:38:27 +0200537 [if test "x$abi" != "xmacho" -a "x$abi" != "xpecoff"; then
Jason Evans2dbecf12010-09-05 10:35:13 -0700538 JEMALLOC_PREFIX=""
539else
540 JEMALLOC_PREFIX="je_"
541fi]
Jason Evans90895cf2009-12-29 00:09:15 -0800542)
543if test "x$JEMALLOC_PREFIX" != "x" ; then
Jason Evanse7339702010-10-23 18:37:06 -0700544 JEMALLOC_CPREFIX=`echo ${JEMALLOC_PREFIX} | tr "a-z" "A-Z"`
545 AC_DEFINE_UNQUOTED([JEMALLOC_PREFIX], ["$JEMALLOC_PREFIX"])
546 AC_DEFINE_UNQUOTED([JEMALLOC_CPREFIX], ["$JEMALLOC_CPREFIX"])
Jason Evans90895cf2009-12-29 00:09:15 -0800547fi
Jason Evans241abc62015-06-23 18:47:07 -0700548AC_SUBST([JEMALLOC_CPREFIX])
Jason Evans90895cf2009-12-29 00:09:15 -0800549
Mike Hommey99066602012-11-19 10:55:26 +0100550AC_ARG_WITH([export],
551 [AS_HELP_STRING([--without-export], [disable exporting jemalloc public APIs])],
552 [if test "x$with_export" = "xno"; then
Jason Evans2625c892013-01-22 16:46:27 -0800553 AC_DEFINE([JEMALLOC_EXPORT],[])
Mike Hommey99066602012-11-19 10:55:26 +0100554fi]
555)
556
Jason Evans86abd0d2013-11-30 15:25:42 -0800557dnl Mangle library-private APIs.
Jason Evans746e77a2011-07-30 16:40:52 -0700558AC_ARG_WITH([private_namespace],
559 [AS_HELP_STRING([--with-private-namespace=<prefix>], [Prefix to prepend to all library-private APIs])],
Jason Evans86abd0d2013-11-30 15:25:42 -0800560 [JEMALLOC_PRIVATE_NAMESPACE="${with_private_namespace}je_"],
561 [JEMALLOC_PRIVATE_NAMESPACE="je_"]
Jason Evans746e77a2011-07-30 16:40:52 -0700562)
Jason Evans86abd0d2013-11-30 15:25:42 -0800563AC_DEFINE_UNQUOTED([JEMALLOC_PRIVATE_NAMESPACE], [$JEMALLOC_PRIVATE_NAMESPACE])
564private_namespace="$JEMALLOC_PRIVATE_NAMESPACE"
565AC_SUBST([private_namespace])
Jason Evans746e77a2011-07-30 16:40:52 -0700566
Jason Evansb0fd5012010-01-17 01:49:20 -0800567dnl Do not add suffix to installed files by default.
568AC_ARG_WITH([install_suffix],
569 [AS_HELP_STRING([--with-install-suffix=<suffix>], [Suffix to append to all installed files])],
570 [INSTALL_SUFFIX="$with_install_suffix"],
571 [INSTALL_SUFFIX=]
572)
573install_suffix="$INSTALL_SUFFIX"
574AC_SUBST([install_suffix])
575
Jason Evans86abd0d2013-11-30 15:25:42 -0800576dnl Substitute @je_@ in jemalloc_protos.h.in, primarily to make generation of
577dnl jemalloc_protos_jet.h easy.
578je_="je_"
579AC_SUBST([je_])
580
Mike Hommeycf6032d2014-07-30 18:16:13 +0900581cfgoutputs_in="Makefile.in"
Nick White913e9a82014-09-19 22:01:23 +0100582cfgoutputs_in="${cfgoutputs_in} jemalloc.pc.in"
Mike Hommeycf6032d2014-07-30 18:16:13 +0900583cfgoutputs_in="${cfgoutputs_in} doc/html.xsl.in"
584cfgoutputs_in="${cfgoutputs_in} doc/manpages.xsl.in"
585cfgoutputs_in="${cfgoutputs_in} doc/jemalloc.xml.in"
586cfgoutputs_in="${cfgoutputs_in} include/jemalloc/jemalloc_macros.h.in"
587cfgoutputs_in="${cfgoutputs_in} include/jemalloc/jemalloc_protos.h.in"
Jason Evans82e88d12014-09-07 19:55:03 -0700588cfgoutputs_in="${cfgoutputs_in} include/jemalloc/jemalloc_typedefs.h.in"
Mike Hommeycf6032d2014-07-30 18:16:13 +0900589cfgoutputs_in="${cfgoutputs_in} include/jemalloc/internal/jemalloc_internal.h.in"
590cfgoutputs_in="${cfgoutputs_in} test/test.sh.in"
591cfgoutputs_in="${cfgoutputs_in} test/include/test/jemalloc_test.h.in"
Jason Evansb0fd5012010-01-17 01:49:20 -0800592
Jason Evansaee7fd22010-11-24 22:00:02 -0800593cfgoutputs_out="Makefile"
Nick White913e9a82014-09-19 22:01:23 +0100594cfgoutputs_out="${cfgoutputs_out} jemalloc.pc"
Jason Evansaee7fd22010-11-24 22:00:02 -0800595cfgoutputs_out="${cfgoutputs_out} doc/html.xsl"
596cfgoutputs_out="${cfgoutputs_out} doc/manpages.xsl"
Jason Evans86abd0d2013-11-30 15:25:42 -0800597cfgoutputs_out="${cfgoutputs_out} doc/jemalloc.xml"
598cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_macros.h"
599cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_protos.h"
Jason Evans82e88d12014-09-07 19:55:03 -0700600cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_typedefs.h"
Jason Evans376b1522010-02-11 14:45:59 -0800601cfgoutputs_out="${cfgoutputs_out} include/jemalloc/internal/jemalloc_internal.h"
Jason Evans86abd0d2013-11-30 15:25:42 -0800602cfgoutputs_out="${cfgoutputs_out} test/test.sh"
603cfgoutputs_out="${cfgoutputs_out} test/include/test/jemalloc_test.h"
Jason Evansb0fd5012010-01-17 01:49:20 -0800604
Jason Evansaee7fd22010-11-24 22:00:02 -0800605cfgoutputs_tup="Makefile"
Nick White913e9a82014-09-19 22:01:23 +0100606cfgoutputs_tup="${cfgoutputs_tup} jemalloc.pc:jemalloc.pc.in"
Jason Evansaee7fd22010-11-24 22:00:02 -0800607cfgoutputs_tup="${cfgoutputs_tup} doc/html.xsl:doc/html.xsl.in"
608cfgoutputs_tup="${cfgoutputs_tup} doc/manpages.xsl:doc/manpages.xsl.in"
Jason Evans86abd0d2013-11-30 15:25:42 -0800609cfgoutputs_tup="${cfgoutputs_tup} doc/jemalloc.xml:doc/jemalloc.xml.in"
610cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_macros.h:include/jemalloc/jemalloc_macros.h.in"
611cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_protos.h:include/jemalloc/jemalloc_protos.h.in"
Jason Evans82e88d12014-09-07 19:55:03 -0700612cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_typedefs.h:include/jemalloc/jemalloc_typedefs.h.in"
Jason Evans376b1522010-02-11 14:45:59 -0800613cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/internal/jemalloc_internal.h"
Jason Evans86abd0d2013-11-30 15:25:42 -0800614cfgoutputs_tup="${cfgoutputs_tup} test/test.sh:test/test.sh.in"
615cfgoutputs_tup="${cfgoutputs_tup} test/include/test/jemalloc_test.h:test/include/test/jemalloc_test.h.in"
Jason Evansb0fd5012010-01-17 01:49:20 -0800616
Mike Hommeycf6032d2014-07-30 18:16:13 +0900617cfghdrs_in="include/jemalloc/jemalloc_defs.h.in"
618cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/jemalloc_internal_defs.h.in"
619cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/private_namespace.sh"
620cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/private_unnamespace.sh"
621cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/private_symbols.txt"
622cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/public_namespace.sh"
623cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/public_unnamespace.sh"
624cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/size_classes.sh"
625cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc_rename.sh"
626cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc_mangle.sh"
627cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc.sh"
628cfghdrs_in="${cfghdrs_in} test/include/test/jemalloc_test_defs.h.in"
Jason Evansb0fd5012010-01-17 01:49:20 -0800629
Jason Evans86abd0d2013-11-30 15:25:42 -0800630cfghdrs_out="include/jemalloc/jemalloc_defs.h"
631cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc${install_suffix}.h"
Jason Evans86abd0d2013-11-30 15:25:42 -0800632cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/private_namespace.h"
633cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/private_unnamespace.h"
Jason Evansf234dc52014-01-16 17:38:01 -0800634cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_symbols.txt"
Jason Evans86abd0d2013-11-30 15:25:42 -0800635cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_namespace.h"
636cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_unnamespace.h"
Jason Evansb1726102012-02-28 16:50:47 -0800637cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/size_classes.h"
Jason Evansf234dc52014-01-16 17:38:01 -0800638cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_protos_jet.h"
639cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_rename.h"
640cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_mangle.h"
641cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_mangle_jet.h"
642cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/jemalloc_internal_defs.h"
Jason Evans80061b62013-12-09 13:21:08 -0800643cfghdrs_out="${cfghdrs_out} test/include/test/jemalloc_test_defs.h"
Jason Evansb0fd5012010-01-17 01:49:20 -0800644
Jason Evans86abd0d2013-11-30 15:25:42 -0800645cfghdrs_tup="include/jemalloc/jemalloc_defs.h:include/jemalloc/jemalloc_defs.h.in"
Mike Hommeycf6032d2014-07-30 18:16:13 +0900646cfghdrs_tup="${cfghdrs_tup} include/jemalloc/internal/jemalloc_internal_defs.h:include/jemalloc/internal/jemalloc_internal_defs.h.in"
647cfghdrs_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 -0800648
Jason Evans644d4142014-04-14 22:49:23 -0700649dnl Silence irrelevant compiler warnings by default.
Jason Evans355b4382010-09-20 19:20:48 -0700650AC_ARG_ENABLE([cc-silence],
Jason Evans644d4142014-04-14 22:49:23 -0700651 [AS_HELP_STRING([--disable-cc-silence],
652 [Do not silence irrelevant compiler warnings])],
Jason Evans355b4382010-09-20 19:20:48 -0700653[if test "x$enable_cc_silence" = "xno" ; then
654 enable_cc_silence="0"
655else
656 enable_cc_silence="1"
657fi
658],
Jason Evans644d4142014-04-14 22:49:23 -0700659[enable_cc_silence="1"]
Jason Evans355b4382010-09-20 19:20:48 -0700660)
661if test "x$enable_cc_silence" = "x1" ; then
Jason Evanse24c7af2012-03-19 10:21:17 -0700662 AC_DEFINE([JEMALLOC_CC_SILENCE], [ ])
Jason Evans355b4382010-09-20 19:20:48 -0700663fi
664
Jason Evansb7924f52009-06-23 19:01:18 -0700665dnl Do not compile with debugging by default.
666AC_ARG_ENABLE([debug],
Jason Evanse0a08a12015-03-18 21:06:58 -0700667 [AS_HELP_STRING([--enable-debug],
668 [Build debugging code (implies --enable-ivsalloc)])],
Jason Evansb7924f52009-06-23 19:01:18 -0700669[if test "x$enable_debug" = "xno" ; then
670 enable_debug="0"
671else
672 enable_debug="1"
673fi
674],
675[enable_debug="0"]
676)
Jason Evans02e5dcf2015-02-15 20:12:06 -0800677if test "x$enable_debug" = "x1" ; then
678 AC_DEFINE([JEMALLOC_DEBUG], [ ])
679fi
Jason Evanse0a08a12015-03-18 21:06:58 -0700680if test "x$enable_debug" = "x1" ; then
681 AC_DEFINE([JEMALLOC_DEBUG], [ ])
682 enable_ivsalloc="1"
683fi
Jason Evansb7924f52009-06-23 19:01:18 -0700684AC_SUBST([enable_debug])
685
Jason Evanse0a08a12015-03-18 21:06:58 -0700686dnl Do not validate pointers by default.
687AC_ARG_ENABLE([ivsalloc],
688 [AS_HELP_STRING([--enable-ivsalloc],
689 [Validate pointers passed through the public API])],
690[if test "x$enable_ivsalloc" = "xno" ; then
691 enable_ivsalloc="0"
692else
693 enable_ivsalloc="1"
694fi
695],
696[enable_ivsalloc="0"]
697)
698if test "x$enable_ivsalloc" = "x1" ; then
699 AC_DEFINE([JEMALLOC_IVSALLOC], [ ])
700fi
701
Jason Evansb7924f52009-06-23 19:01:18 -0700702dnl Only optimize if not debugging.
703if test "x$enable_debug" = "x0" -a "x$no_CFLAGS" = "xyes" ; then
704 dnl Make sure that an optimization flag was not specified in EXTRA_CFLAGS.
Jason Evansf3340ca2009-06-30 16:17:05 -0700705 optimize="no"
Jason Evans748dfac2013-12-06 18:27:33 -0800706 echo "$CFLAGS $EXTRA_CFLAGS" | grep '\-O' >/dev/null || optimize="yes"
Jason Evansf3340ca2009-06-30 16:17:05 -0700707 if test "x${optimize}" = "xyes" ; then
708 if test "x$GCC" = "xyes" ; then
709 JE_CFLAGS_APPEND([-O3])
710 JE_CFLAGS_APPEND([-funroll-loops])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200711 elif test "x$je_cv_msvc" = "xyes" ; then
712 JE_CFLAGS_APPEND([-O2])
Jason Evansf3340ca2009-06-30 16:17:05 -0700713 else
714 JE_CFLAGS_APPEND([-O])
715 fi
Jason Evansb7924f52009-06-23 19:01:18 -0700716 fi
717fi
718
Jason Evansd073a322012-02-28 20:41:16 -0800719dnl Enable statistics calculation by default.
Jason Evansb7924f52009-06-23 19:01:18 -0700720AC_ARG_ENABLE([stats],
Jason Evans777c1912012-02-28 20:49:22 -0800721 [AS_HELP_STRING([--disable-stats],
722 [Disable statistics calculation/reporting])],
Jason Evansb7924f52009-06-23 19:01:18 -0700723[if test "x$enable_stats" = "xno" ; then
724 enable_stats="0"
725else
726 enable_stats="1"
727fi
728],
Jason Evansd073a322012-02-28 20:41:16 -0800729[enable_stats="1"]
Jason Evansb7924f52009-06-23 19:01:18 -0700730)
731if test "x$enable_stats" = "x1" ; then
732 AC_DEFINE([JEMALLOC_STATS], [ ])
733fi
734AC_SUBST([enable_stats])
735
Jason Evans6109fe02010-02-10 10:37:56 -0800736dnl Do not enable profiling by default.
737AC_ARG_ENABLE([prof],
738 [AS_HELP_STRING([--enable-prof], [Enable allocation profiling])],
739[if test "x$enable_prof" = "xno" ; then
740 enable_prof="0"
741else
742 enable_prof="1"
743fi
744],
745[enable_prof="0"]
746)
Jason Evans77f350b2011-03-15 22:23:12 -0700747if test "x$enable_prof" = "x1" ; then
748 backtrace_method=""
Jason Evansb27805b2010-02-10 18:15:53 -0800749else
Jason Evans77f350b2011-03-15 22:23:12 -0700750 backtrace_method="N/A"
Jason Evansb27805b2010-02-10 18:15:53 -0800751fi
Jason Evans77f350b2011-03-15 22:23:12 -0700752
Jason Evans6109fe02010-02-10 10:37:56 -0800753AC_ARG_ENABLE([prof-libunwind],
754 [AS_HELP_STRING([--enable-prof-libunwind], [Use libunwind for backtracing])],
755[if test "x$enable_prof_libunwind" = "xno" ; then
756 enable_prof_libunwind="0"
757else
758 enable_prof_libunwind="1"
759fi
760],
761[enable_prof_libunwind="0"]
762)
Jason Evansca6bd4f2010-03-02 14:12:58 -0800763AC_ARG_WITH([static_libunwind],
764 [AS_HELP_STRING([--with-static-libunwind=<libunwind.a>],
765 [Path to static libunwind library; use rather than dynamically linking])],
766if test "x$with_static_libunwind" = "xno" ; then
767 LUNWIND="-lunwind"
768else
769 if test ! -f "$with_static_libunwind" ; then
770 AC_MSG_ERROR([Static libunwind not found: $with_static_libunwind])
771 fi
772 LUNWIND="$with_static_libunwind"
773fi,
774 LUNWIND="-lunwind"
775)
Jason Evans77f350b2011-03-15 22:23:12 -0700776if test "x$backtrace_method" = "x" -a "x$enable_prof_libunwind" = "x1" ; then
777 AC_CHECK_HEADERS([libunwind.h], , [enable_prof_libunwind="0"])
778 if test "x$LUNWIND" = "x-lunwind" ; then
Jason Evans05125b82014-04-22 20:48:07 -0700779 AC_CHECK_LIB([unwind], [unw_backtrace], [LIBS="$LIBS $LUNWIND"],
Jason Evans77f350b2011-03-15 22:23:12 -0700780 [enable_prof_libunwind="0"])
781 else
782 LIBS="$LIBS $LUNWIND"
783 fi
784 if test "x${enable_prof_libunwind}" = "x1" ; then
785 backtrace_method="libunwind"
786 AC_DEFINE([JEMALLOC_PROF_LIBUNWIND], [ ])
787 fi
788fi
789
790AC_ARG_ENABLE([prof-libgcc],
791 [AS_HELP_STRING([--disable-prof-libgcc],
792 [Do not use libgcc for backtracing])],
793[if test "x$enable_prof_libgcc" = "xno" ; then
794 enable_prof_libgcc="0"
795else
796 enable_prof_libgcc="1"
797fi
798],
799[enable_prof_libgcc="1"]
800)
801if test "x$backtrace_method" = "x" -a "x$enable_prof_libgcc" = "x1" \
802 -a "x$GCC" = "xyes" ; then
803 AC_CHECK_HEADERS([unwind.h], , [enable_prof_libgcc="0"])
804 AC_CHECK_LIB([gcc], [_Unwind_Backtrace], [LIBS="$LIBS -lgcc"], [enable_prof_libgcc="0"])
Jason Evans77f350b2011-03-15 22:23:12 -0700805 if test "x${enable_prof_libgcc}" = "x1" ; then
806 backtrace_method="libgcc"
807 AC_DEFINE([JEMALLOC_PROF_LIBGCC], [ ])
808 fi
809else
810 enable_prof_libgcc="0"
811fi
812
813AC_ARG_ENABLE([prof-gcc],
814 [AS_HELP_STRING([--disable-prof-gcc],
815 [Do not use gcc intrinsics for backtracing])],
816[if test "x$enable_prof_gcc" = "xno" ; then
817 enable_prof_gcc="0"
818else
819 enable_prof_gcc="1"
820fi
821],
822[enable_prof_gcc="1"]
823)
824if test "x$backtrace_method" = "x" -a "x$enable_prof_gcc" = "x1" \
825 -a "x$GCC" = "xyes" ; then
Jason Evanse181f5a2014-03-30 18:58:32 -0700826 JE_CFLAGS_APPEND([-fno-omit-frame-pointer])
Jason Evans77f350b2011-03-15 22:23:12 -0700827 backtrace_method="gcc intrinsics"
828 AC_DEFINE([JEMALLOC_PROF_GCC], [ ])
829else
830 enable_prof_gcc="0"
831fi
832
833if test "x$backtrace_method" = "x" ; then
834 backtrace_method="none (disabling profiling)"
835 enable_prof="0"
836fi
837AC_MSG_CHECKING([configured backtracing method])
838AC_MSG_RESULT([$backtrace_method])
Jason Evans2dbecf12010-09-05 10:35:13 -0700839if test "x$enable_prof" = "x1" ; then
Jason Evansd37d5ad2013-12-05 23:01:50 -0800840 if test "x$abi" != "xpecoff"; then
841 dnl Heap profiling uses the log(3) function.
842 LIBS="$LIBS -lm"
843 fi
844
Jason Evans2dbecf12010-09-05 10:35:13 -0700845 AC_DEFINE([JEMALLOC_PROF], [ ])
Jason Evans2dbecf12010-09-05 10:35:13 -0700846fi
847AC_SUBST([enable_prof])
Jason Evans2dbecf12010-09-05 10:35:13 -0700848
Jason Evans84cbbcb2009-12-29 00:09:15 -0800849dnl Enable thread-specific caching by default.
850AC_ARG_ENABLE([tcache],
851 [AS_HELP_STRING([--disable-tcache], [Disable per thread caches])],
852[if test "x$enable_tcache" = "xno" ; then
853 enable_tcache="0"
Jason Evansb7924f52009-06-23 19:01:18 -0700854else
Jason Evans84cbbcb2009-12-29 00:09:15 -0800855 enable_tcache="1"
Jason Evansb7924f52009-06-23 19:01:18 -0700856fi
857],
Jason Evans84cbbcb2009-12-29 00:09:15 -0800858[enable_tcache="1"]
Jason Evansb7924f52009-06-23 19:01:18 -0700859)
Jason Evans2dbecf12010-09-05 10:35:13 -0700860if test "x$enable_tcache" = "x1" ; then
861 AC_DEFINE([JEMALLOC_TCACHE], [ ])
862fi
863AC_SUBST([enable_tcache])
Jason Evansb7924f52009-06-23 19:01:18 -0700864
Jason Evans59ae2762012-04-16 17:52:27 -0700865dnl Enable VM deallocation via munmap() by default.
866AC_ARG_ENABLE([munmap],
867 [AS_HELP_STRING([--disable-munmap], [Disable VM deallocation via munmap(2)])],
868[if test "x$enable_munmap" = "xno" ; then
869 enable_munmap="0"
870else
871 enable_munmap="1"
872fi
873],
874[enable_munmap="${default_munmap}"]
875)
876if test "x$enable_munmap" = "x1" ; then
877 AC_DEFINE([JEMALLOC_MUNMAP], [ ])
878fi
879AC_SUBST([enable_munmap])
880
Jason Evans4d434ad2014-04-15 12:09:48 -0700881dnl Enable allocation from DSS if supported by the OS.
882have_dss="1"
Mike Hommey83c324a2012-04-12 10:13:03 +0200883dnl Check whether the BSD/SUSv1 sbrk() exists. If not, disable DSS support.
884AC_CHECK_FUNC([sbrk], [have_sbrk="1"], [have_sbrk="0"])
885if test "x$have_sbrk" = "x1" ; then
Steven Stewart-Gallus79230fe2014-06-19 16:11:43 -0700886 if test "x$sbrk_deprecated" = "x1" ; then
Jason Evans66688532013-12-03 21:49:36 -0800887 AC_MSG_RESULT([Disabling dss allocation because sbrk is deprecated])
Jason Evans4d434ad2014-04-15 12:09:48 -0700888 have_dss="0"
Jason Evans66688532013-12-03 21:49:36 -0800889 fi
Mike Hommey83c324a2012-04-12 10:13:03 +0200890else
Jason Evans4d434ad2014-04-15 12:09:48 -0700891 have_dss="0"
Mike Hommey83c324a2012-04-12 10:13:03 +0200892fi
893
Jason Evans4d434ad2014-04-15 12:09:48 -0700894if test "x$have_dss" = "x1" ; then
Jason Evansb7924f52009-06-23 19:01:18 -0700895 AC_DEFINE([JEMALLOC_DSS], [ ])
896fi
Jason Evansb7924f52009-06-23 19:01:18 -0700897
Jason Evans777c1912012-02-28 20:49:22 -0800898dnl Support the junk/zero filling option by default.
Jason Evansb7924f52009-06-23 19:01:18 -0700899AC_ARG_ENABLE([fill],
Jason Evans122449b2012-04-06 00:35:09 -0700900 [AS_HELP_STRING([--disable-fill],
901 [Disable support for junk/zero filling, quarantine, and redzones])],
Jason Evansb7924f52009-06-23 19:01:18 -0700902[if test "x$enable_fill" = "xno" ; then
903 enable_fill="0"
904else
905 enable_fill="1"
906fi
907],
Jason Evans777c1912012-02-28 20:49:22 -0800908[enable_fill="1"]
Jason Evansb7924f52009-06-23 19:01:18 -0700909)
910if test "x$enable_fill" = "x1" ; then
911 AC_DEFINE([JEMALLOC_FILL], [ ])
912fi
913AC_SUBST([enable_fill])
914
Jason Evansb1476112012-04-05 13:36:17 -0700915dnl Disable utrace(2)-based tracing by default.
916AC_ARG_ENABLE([utrace],
917 [AS_HELP_STRING([--enable-utrace], [Enable utrace(2)-based tracing])],
918[if test "x$enable_utrace" = "xno" ; then
919 enable_utrace="0"
920else
921 enable_utrace="1"
922fi
923],
924[enable_utrace="0"]
925)
926JE_COMPILABLE([utrace(2)], [
927#include <sys/types.h>
928#include <sys/param.h>
929#include <sys/time.h>
930#include <sys/uio.h>
931#include <sys/ktrace.h>
932], [
933 utrace((void *)0, 0);
934], [je_cv_utrace])
935if test "x${je_cv_utrace}" = "xno" ; then
936 enable_utrace="0"
937fi
938if test "x$enable_utrace" = "x1" ; then
939 AC_DEFINE([JEMALLOC_UTRACE], [ ])
940fi
941AC_SUBST([enable_utrace])
942
Jason Evans122449b2012-04-06 00:35:09 -0700943dnl Support Valgrind by default.
944AC_ARG_ENABLE([valgrind],
945 [AS_HELP_STRING([--disable-valgrind], [Disable support for Valgrind])],
946[if test "x$enable_valgrind" = "xno" ; then
947 enable_valgrind="0"
948else
949 enable_valgrind="1"
950fi
951],
952[enable_valgrind="1"]
953)
954if test "x$enable_valgrind" = "x1" ; then
955 JE_COMPILABLE([valgrind], [
956#include <valgrind/valgrind.h>
957#include <valgrind/memcheck.h>
958
Mike Hommey7bfecf42012-04-30 15:15:15 +0200959#if !defined(VALGRIND_RESIZEINPLACE_BLOCK)
Jason Evans122449b2012-04-06 00:35:09 -0700960# error "Incompatible Valgrind version"
961#endif
962], [], [je_cv_valgrind])
963 if test "x${je_cv_valgrind}" = "xno" ; then
964 enable_valgrind="0"
965 fi
966 if test "x$enable_valgrind" = "x1" ; then
967 AC_DEFINE([JEMALLOC_VALGRIND], [ ])
968 fi
969fi
970AC_SUBST([enable_valgrind])
971
Jason Evansb7924f52009-06-23 19:01:18 -0700972dnl Do not support the xmalloc option by default.
973AC_ARG_ENABLE([xmalloc],
974 [AS_HELP_STRING([--enable-xmalloc], [Support xmalloc option])],
975[if test "x$enable_xmalloc" = "xno" ; then
976 enable_xmalloc="0"
977else
978 enable_xmalloc="1"
979fi
980],
981[enable_xmalloc="0"]
982)
983if test "x$enable_xmalloc" = "x1" ; then
984 AC_DEFINE([JEMALLOC_XMALLOC], [ ])
985fi
986AC_SUBST([enable_xmalloc])
987
Jason Evans8a03cf02015-05-04 09:58:36 -0700988dnl Support cache-oblivious allocation alignment by default.
989AC_ARG_ENABLE([cache-oblivious],
990 [AS_HELP_STRING([--disable-cache-oblivious],
991 [Disable support for cache-oblivious allocation alignment])],
992[if test "x$enable_cache_oblivious" = "xno" ; then
993 enable_cache_oblivious="0"
994else
995 enable_cache_oblivious="1"
996fi
997],
998[enable_cache_oblivious="1"]
999)
1000if test "x$enable_cache_oblivious" = "x1" ; then
1001 AC_DEFINE([JEMALLOC_CACHE_OBLIVIOUS], [ ])
1002fi
1003AC_SUBST([enable_cache_oblivious])
1004
Mike Hommey8f50ec82014-06-04 12:12:55 +09001005dnl ============================================================================
1006dnl Check for __builtin_ffsl(), then ffsl(3), and fail if neither are found.
1007dnl One of those two functions should (theoretically) exist on all platforms
1008dnl that jemalloc currently has a chance of functioning on without modification.
1009dnl We additionally assume ffs() or __builtin_ffs() are defined if
1010dnl ffsl() or __builtin_ffsl() are defined, respectively.
1011JE_COMPILABLE([a program using __builtin_ffsl], [
1012#include <stdio.h>
1013#include <strings.h>
1014#include <string.h>
1015], [
1016 {
1017 int rv = __builtin_ffsl(0x08);
1018 printf("%d\n", rv);
1019 }
1020], [je_cv_gcc_builtin_ffsl])
Steven Stewart-Gallus79230fe2014-06-19 16:11:43 -07001021if test "x${je_cv_gcc_builtin_ffsl}" = "xyes" ; then
Mike Hommey8f50ec82014-06-04 12:12:55 +09001022 AC_DEFINE([JEMALLOC_INTERNAL_FFSL], [__builtin_ffsl])
1023 AC_DEFINE([JEMALLOC_INTERNAL_FFS], [__builtin_ffs])
1024else
1025 JE_COMPILABLE([a program using ffsl], [
1026 #include <stdio.h>
1027 #include <strings.h>
1028 #include <string.h>
1029 ], [
1030 {
1031 int rv = ffsl(0x08);
1032 printf("%d\n", rv);
1033 }
1034 ], [je_cv_function_ffsl])
Steven Stewart-Gallus79230fe2014-06-19 16:11:43 -07001035 if test "x${je_cv_function_ffsl}" = "xyes" ; then
Mike Hommey8f50ec82014-06-04 12:12:55 +09001036 AC_DEFINE([JEMALLOC_INTERNAL_FFSL], [ffsl])
1037 AC_DEFINE([JEMALLOC_INTERNAL_FFS], [ffs])
1038 else
1039 AC_MSG_ERROR([Cannot build without ffsl(3) or __builtin_ffsl()])
1040 fi
1041fi
1042
Jason Evans81e54752014-10-10 22:34:25 -07001043AC_ARG_WITH([lg_tiny_min],
1044 [AS_HELP_STRING([--with-lg-tiny-min=<lg-tiny-min>],
1045 [Base 2 log of minimum tiny size class to support])],
1046 [LG_TINY_MIN="$with_lg_tiny_min"],
1047 [LG_TINY_MIN="3"])
1048AC_DEFINE_UNQUOTED([LG_TINY_MIN], [$LG_TINY_MIN])
1049
Jason Evansfc0b3b72014-10-09 17:54:06 -07001050AC_ARG_WITH([lg_quantum],
1051 [AS_HELP_STRING([--with-lg-quantum=<lg-quantum>],
1052 [Base 2 log of minimum allocation alignment])],
Jason Evans81e54752014-10-10 22:34:25 -07001053 [LG_QUANTA="$with_lg_quantum"],
1054 [LG_QUANTA="3 4"])
1055if test "x$with_lg_quantum" != "x" ; then
1056 AC_DEFINE_UNQUOTED([LG_QUANTUM], [$with_lg_quantum])
1057fi
Jason Evansfc0b3b72014-10-09 17:54:06 -07001058
1059AC_ARG_WITH([lg_page],
1060 [AS_HELP_STRING([--with-lg-page=<lg-page>], [Base 2 log of system page size])],
1061 [LG_PAGE="$with_lg_page"], [LG_PAGE="detect"])
Jason Evansb0808d52015-02-03 12:39:31 -08001062if test "x$LG_PAGE" = "xdetect"; then
Jason Evansfc0b3b72014-10-09 17:54:06 -07001063 AC_CACHE_CHECK([LG_PAGE],
1064 [je_cv_lg_page],
Jason Evans6684cac2012-03-05 12:15:36 -08001065 AC_RUN_IFELSE([AC_LANG_PROGRAM(
Mike Hommeya19e87f2012-04-21 21:27:46 -07001066[[
Mike Hommeyfd97b1d2012-04-30 12:38:31 +02001067#include <strings.h>
Mike Hommeya19e87f2012-04-21 21:27:46 -07001068#ifdef _WIN32
1069#include <windows.h>
1070#else
Jason Evansb7924f52009-06-23 19:01:18 -07001071#include <unistd.h>
Mike Hommeya19e87f2012-04-21 21:27:46 -07001072#endif
1073#include <stdio.h>
Jason Evans6684cac2012-03-05 12:15:36 -08001074]],
1075[[
Garrett Cooper72c1e592012-12-02 17:57:28 -08001076 int result;
Jason Evansb7924f52009-06-23 19:01:18 -07001077 FILE *f;
1078
Mike Hommeya19e87f2012-04-21 21:27:46 -07001079#ifdef _WIN32
1080 SYSTEM_INFO si;
1081 GetSystemInfo(&si);
1082 result = si.dwPageSize;
1083#else
Jason Evansb7924f52009-06-23 19:01:18 -07001084 result = sysconf(_SC_PAGESIZE);
Mike Hommeya19e87f2012-04-21 21:27:46 -07001085#endif
Jason Evansb7924f52009-06-23 19:01:18 -07001086 if (result == -1) {
1087 return 1;
1088 }
Mike Hommey8f50ec82014-06-04 12:12:55 +09001089 result = JEMALLOC_INTERNAL_FFSL(result) - 1;
Mike Hommeya19e87f2012-04-21 21:27:46 -07001090
Jason Evansb7924f52009-06-23 19:01:18 -07001091 f = fopen("conftest.out", "w");
1092 if (f == NULL) {
1093 return 1;
1094 }
Garrett Cooper72c1e592012-12-02 17:57:28 -08001095 fprintf(f, "%d\n", result);
Jason Evans3cc1f1a2012-04-03 22:30:05 -07001096 fclose(f);
Jason Evansb7924f52009-06-23 19:01:18 -07001097
1098 return 0;
1099]])],
Jason Evansfc0b3b72014-10-09 17:54:06 -07001100 [je_cv_lg_page=`cat conftest.out`],
1101 [je_cv_lg_page=undefined],
1102 [je_cv_lg_page=12]))
Jason Evans6684cac2012-03-05 12:15:36 -08001103fi
Jason Evansfc0b3b72014-10-09 17:54:06 -07001104if test "x${je_cv_lg_page}" != "x" ; then
1105 LG_PAGE="${je_cv_lg_page}"
1106fi
1107if test "x${LG_PAGE}" != "xundefined" ; then
1108 AC_DEFINE_UNQUOTED([LG_PAGE], [$LG_PAGE])
1109else
1110 AC_MSG_ERROR([cannot determine value for LG_PAGE])
1111fi
1112
1113AC_ARG_WITH([lg_page_sizes],
1114 [AS_HELP_STRING([--with-lg-page-sizes=<lg-page-sizes>],
1115 [Base 2 logs of system page sizes to support])],
1116 [LG_PAGE_SIZES="$with_lg_page_sizes"], [LG_PAGE_SIZES="$LG_PAGE"])
1117
1118AC_ARG_WITH([lg_size_class_group],
1119 [AS_HELP_STRING([--with-lg-size-class-group=<lg-size-class-group>],
1120 [Base 2 log of size classes per doubling])],
1121 [LG_SIZE_CLASS_GROUP="$with_lg_size_class_group"],
1122 [LG_SIZE_CLASS_GROUP="2"])
Jason Evansb7924f52009-06-23 19:01:18 -07001123
1124dnl ============================================================================
1125dnl jemalloc configuration.
1126dnl
Jason Evansa40bc7a2010-03-02 13:01:16 -08001127
Jason Evansa5a658a2014-09-02 15:07:07 -07001128dnl Set VERSION if source directory is inside a git repository.
Dan McGregorf8880312014-12-23 16:10:08 -06001129if test "x`test ! \"${srcroot}\" && cd \"${srcroot}\"; git rev-parse --is-inside-work-tree 2>/dev/null`" = "xtrue" ; then
Jason Evansa5a658a2014-09-02 15:07:07 -07001130 dnl Pattern globs aren't powerful enough to match both single- and
1131 dnl double-digit version numbers, so iterate over patterns to support up to
1132 dnl version 99.99.99 without any accidental matches.
Dan McGregorf8880312014-12-23 16:10:08 -06001133 rm -f "${objroot}VERSION"
Jason Evansa5a658a2014-09-02 15:07:07 -07001134 for pattern in ['[0-9].[0-9].[0-9]' '[0-9].[0-9].[0-9][0-9]' \
1135 '[0-9].[0-9][0-9].[0-9]' '[0-9].[0-9][0-9].[0-9][0-9]' \
1136 '[0-9][0-9].[0-9].[0-9]' '[0-9][0-9].[0-9].[0-9][0-9]' \
1137 '[0-9][0-9].[0-9][0-9].[0-9]' \
1138 '[0-9][0-9].[0-9][0-9].[0-9][0-9]']; do
Dan McGregorf8880312014-12-23 16:10:08 -06001139 if test ! -e "${objroot}VERSION" ; then
1140 (test ! "${srcroot}" && cd "${srcroot}"; git describe --long --abbrev=40 --match="${pattern}") > "${objroot}VERSION.tmp" 2>/dev/null
Jason Evansa5a658a2014-09-02 15:07:07 -07001141 if test $? -eq 0 ; then
Dan McGregorf8880312014-12-23 16:10:08 -06001142 mv "${objroot}VERSION.tmp" "${objroot}VERSION"
Jason Evansa5a658a2014-09-02 15:07:07 -07001143 break
1144 fi
1145 fi
1146 done
Jason Evansa40bc7a2010-03-02 13:01:16 -08001147fi
Dan McGregorf8880312014-12-23 16:10:08 -06001148rm -f "${objroot}VERSION.tmp"
1149if test ! -e "${objroot}VERSION" ; then
1150 if test ! -e "${srcroot}VERSION" ; then
1151 AC_MSG_RESULT(
1152 [Missing VERSION file, and unable to generate it; creating bogus VERSION])
1153 echo "0.0.0-0-g0000000000000000000000000000000000000000" > "${objroot}VERSION"
1154 else
1155 cp ${srcroot}VERSION ${objroot}VERSION
1156 fi
Jason Evansa5a658a2014-09-02 15:07:07 -07001157fi
Dan McGregorf8880312014-12-23 16:10:08 -06001158jemalloc_version=`cat "${objroot}VERSION"`
Jason Evansa40bc7a2010-03-02 13:01:16 -08001159jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'`
1160jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'`
1161jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'`
1162jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'`
1163jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'`
Jason Evansb7924f52009-06-23 19:01:18 -07001164AC_SUBST([jemalloc_version])
Jason Evansa40bc7a2010-03-02 13:01:16 -08001165AC_SUBST([jemalloc_version_major])
1166AC_SUBST([jemalloc_version_minor])
1167AC_SUBST([jemalloc_version_bugfix])
1168AC_SUBST([jemalloc_version_nrev])
1169AC_SUBST([jemalloc_version_gid])
Jason Evansb7924f52009-06-23 19:01:18 -07001170
1171dnl ============================================================================
1172dnl Configure pthreads.
1173
Mike Hommeya19e87f2012-04-21 21:27:46 -07001174if test "x$abi" != "xpecoff" ; then
1175 AC_CHECK_HEADERS([pthread.h], , [AC_MSG_ERROR([pthread.h is missing])])
1176 dnl Some systems may embed pthreads functionality in libc; check for libpthread
1177 dnl first, but try libc too before failing.
1178 AC_CHECK_LIB([pthread], [pthread_create], [LIBS="$LIBS -lpthread"],
1179 [AC_SEARCH_LIBS([pthread_create], , ,
1180 AC_MSG_ERROR([libpthread is missing]))])
1181fi
Jason Evansb7924f52009-06-23 19:01:18 -07001182
1183CPPFLAGS="$CPPFLAGS -D_REENTRANT"
1184
Daniel Micayb74041f2014-12-09 17:41:34 -05001185dnl Check if the GNU-specific secure_getenv function exists.
1186AC_CHECK_FUNC([secure_getenv],
1187 [have_secure_getenv="1"],
1188 [have_secure_getenv="0"]
1189 )
1190if test "x$have_secure_getenv" = "x1" ; then
1191 AC_DEFINE([JEMALLOC_HAVE_SECURE_GETENV], [ ])
1192fi
1193
1194dnl Check if the Solaris/BSD issetugid function exists.
1195AC_CHECK_FUNC([issetugid],
1196 [have_issetugid="1"],
1197 [have_issetugid="0"]
1198 )
1199if test "x$have_issetugid" = "x1" ; then
1200 AC_DEFINE([JEMALLOC_HAVE_ISSETUGID], [ ])
1201fi
1202
Jason Evanscd9a1342012-03-21 18:33:03 -07001203dnl Check whether the BSD-specific _malloc_thread_cleanup() exists. If so, use
1204dnl it rather than pthreads TSD cleanup functions to support cleanup during
1205dnl thread exit, in order to avoid pthreads library recursion during
1206dnl bootstrapping.
Jason Evanscd9a1342012-03-21 18:33:03 -07001207AC_CHECK_FUNC([_malloc_thread_cleanup],
1208 [have__malloc_thread_cleanup="1"],
1209 [have__malloc_thread_cleanup="0"]
1210 )
1211if test "x$have__malloc_thread_cleanup" = "x1" ; then
1212 AC_DEFINE([JEMALLOC_MALLOC_THREAD_CLEANUP], [ ])
1213 force_tls="1"
1214fi
1215
Jason Evans41b6afb2012-02-02 22:04:57 -08001216dnl Check whether the BSD-specific _pthread_mutex_init_calloc_cb() exists. If
1217dnl so, mutex initialization causes allocation, and we need to implement this
1218dnl callback function in order to prevent recursive allocation.
1219AC_CHECK_FUNC([_pthread_mutex_init_calloc_cb],
1220 [have__pthread_mutex_init_calloc_cb="1"],
1221 [have__pthread_mutex_init_calloc_cb="0"]
1222 )
1223if test "x$have__pthread_mutex_init_calloc_cb" = "x1" ; then
1224 AC_DEFINE([JEMALLOC_MUTEX_INIT_CB])
1225fi
1226
Jason Evans0fee70d2012-02-13 12:36:11 -08001227dnl Disable lazy locking by default.
Jason Evansb7924f52009-06-23 19:01:18 -07001228AC_ARG_ENABLE([lazy_lock],
Jason Evans0fee70d2012-02-13 12:36:11 -08001229 [AS_HELP_STRING([--enable-lazy-lock],
1230 [Enable lazy locking (only lock when multi-threaded)])],
Jason Evansb7924f52009-06-23 19:01:18 -07001231[if test "x$enable_lazy_lock" = "xno" ; then
1232 enable_lazy_lock="0"
1233else
1234 enable_lazy_lock="1"
1235fi
1236],
Jason Evans0fee70d2012-02-13 12:36:11 -08001237[enable_lazy_lock="0"]
Jason Evansb7924f52009-06-23 19:01:18 -07001238)
Jason Evansfd4fcef2012-03-23 17:40:58 -07001239if test "x$enable_lazy_lock" = "x0" -a "x${force_lazy_lock}" = "x1" ; then
1240 AC_MSG_RESULT([Forcing lazy-lock to avoid allocator/threading bootstrap issues])
1241 enable_lazy_lock="1"
1242fi
Jason Evansb7924f52009-06-23 19:01:18 -07001243if test "x$enable_lazy_lock" = "x1" ; then
Mike Hommeya19e87f2012-04-21 21:27:46 -07001244 if test "x$abi" != "xpecoff" ; then
1245 AC_CHECK_HEADERS([dlfcn.h], , [AC_MSG_ERROR([dlfcn.h is missing])])
1246 AC_CHECK_FUNC([dlsym], [],
1247 [AC_CHECK_LIB([dl], [dlsym], [LIBS="$LIBS -ldl"],
1248 [AC_MSG_ERROR([libdl is missing])])
1249 ])
1250 fi
Jason Evansb7924f52009-06-23 19:01:18 -07001251 AC_DEFINE([JEMALLOC_LAZY_LOCK], [ ])
1252fi
1253AC_SUBST([enable_lazy_lock])
1254
Jason Evans78d815c2010-01-17 14:06:20 -08001255AC_ARG_ENABLE([tls],
1256 [AS_HELP_STRING([--disable-tls], [Disable thread-local storage (__thread keyword)])],
1257if test "x$enable_tls" = "xno" ; then
1258 enable_tls="0"
1259else
1260 enable_tls="1"
1261fi
1262,
1263enable_tls="1"
1264)
Jason Evanscd9a1342012-03-21 18:33:03 -07001265if test "x${enable_tls}" = "x0" -a "x${force_tls}" = "x1" ; then
1266 AC_MSG_RESULT([Forcing TLS to avoid allocator/threading bootstrap issues])
1267 enable_tls="1"
1268fi
Jason Evansb80581d2012-03-23 16:17:43 -07001269if test "x${enable_tls}" = "x1" -a "x${force_tls}" = "x0" ; then
1270 AC_MSG_RESULT([Forcing no TLS to avoid allocator/threading bootstrap issues])
1271 enable_tls="0"
1272fi
Jason Evans78d815c2010-01-17 14:06:20 -08001273if test "x${enable_tls}" = "x1" ; then
1274AC_MSG_CHECKING([for TLS])
Jason Evans6684cac2012-03-05 12:15:36 -08001275AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Jason Evans78d815c2010-01-17 14:06:20 -08001276[[
1277 __thread int x;
1278]], [[
1279 x = 42;
1280
1281 return 0;
1282]])],
1283 AC_MSG_RESULT([yes]),
1284 AC_MSG_RESULT([no])
1285 enable_tls="0")
1286fi
Jason Evansb267d0f2010-08-13 15:42:29 -07001287AC_SUBST([enable_tls])
Jason Evanse24c7af2012-03-19 10:21:17 -07001288if test "x${enable_tls}" = "x1" ; then
1289 AC_DEFINE_UNQUOTED([JEMALLOC_TLS], [ ])
Jason Evanscd9a1342012-03-21 18:33:03 -07001290elif test "x${force_tls}" = "x1" ; then
1291 AC_MSG_ERROR([Failed to configure TLS, which is mandatory for correct function])
Jason Evans78d815c2010-01-17 14:06:20 -08001292fi
1293
Jason Evans2dbecf12010-09-05 10:35:13 -07001294dnl ============================================================================
Chih-hung Hsieh59cd80e2014-12-05 17:42:41 -08001295dnl Check for C11 atomics.
1296
1297JE_COMPILABLE([C11 atomics], [
1298#include <stdint.h>
1299#if (__STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_ATOMICS__)
1300#include <stdatomic.h>
1301#else
1302#error Atomics not available
1303#endif
1304], [
1305 uint64_t *p = (uint64_t *)0;
1306 uint64_t x = 1;
1307 volatile atomic_uint_least64_t *a = (volatile atomic_uint_least64_t *)p;
1308 uint64_t r = atomic_fetch_add(a, x) + x;
1309 return (r == 0);
1310], [je_cv_c11atomics])
1311if test "x${je_cv_c11atomics}" = "xyes" ; then
1312 AC_DEFINE([JEMALLOC_C11ATOMICS])
1313fi
1314
1315dnl ============================================================================
Jason Evansb57d3ec2012-04-17 13:17:54 -07001316dnl Check for atomic(9) operations as provided on FreeBSD.
1317
1318JE_COMPILABLE([atomic(9)], [
1319#include <sys/types.h>
1320#include <machine/atomic.h>
1321#include <inttypes.h>
1322], [
1323 {
1324 uint32_t x32 = 0;
1325 volatile uint32_t *x32p = &x32;
1326 atomic_fetchadd_32(x32p, 1);
1327 }
1328 {
1329 unsigned long xlong = 0;
1330 volatile unsigned long *xlongp = &xlong;
1331 atomic_fetchadd_long(xlongp, 1);
1332 }
1333], [je_cv_atomic9])
1334if test "x${je_cv_atomic9}" = "xyes" ; then
1335 AC_DEFINE([JEMALLOC_ATOMIC9])
1336fi
1337
1338dnl ============================================================================
Jason Evans763baa62011-03-18 19:10:31 -07001339dnl Check for atomic(3) operations as provided on Darwin.
1340
1341JE_COMPILABLE([Darwin OSAtomic*()], [
1342#include <libkern/OSAtomic.h>
1343#include <inttypes.h>
1344], [
1345 {
1346 int32_t x32 = 0;
1347 volatile int32_t *x32p = &x32;
1348 OSAtomicAdd32(1, x32p);
1349 }
1350 {
1351 int64_t x64 = 0;
1352 volatile int64_t *x64p = &x64;
1353 OSAtomicAdd64(1, x64p);
1354 }
Jason Evans6684cac2012-03-05 12:15:36 -08001355], [je_cv_osatomic])
1356if test "x${je_cv_osatomic}" = "xyes" ; then
Jason Evanse24c7af2012-03-19 10:21:17 -07001357 AC_DEFINE([JEMALLOC_OSATOMIC], [ ])
Jason Evans763baa62011-03-18 19:10:31 -07001358fi
1359
1360dnl ============================================================================
Richard Diamond994fad92014-06-03 02:39:18 -05001361dnl Check for madvise(2).
1362
1363JE_COMPILABLE([madvise(2)], [
1364#include <sys/mman.h>
1365], [
1366 {
1367 madvise((void *)0, 0, 0);
1368 }
1369], [je_cv_madvise])
1370if test "x${je_cv_madvise}" = "xyes" ; then
1371 AC_DEFINE([JEMALLOC_HAVE_MADVISE], [ ])
1372fi
1373
1374dnl ============================================================================
Mike Hommeyc1e567b2012-03-26 17:03:41 +02001375dnl Check whether __sync_{add,sub}_and_fetch() are available despite
1376dnl __GCC_HAVE_SYNC_COMPARE_AND_SWAP_n macros being undefined.
1377
1378AC_DEFUN([JE_SYNC_COMPARE_AND_SWAP_CHECK],[
1379 AC_CACHE_CHECK([whether to force $1-bit __sync_{add,sub}_and_fetch()],
1380 [je_cv_sync_compare_and_swap_$2],
Mike Hommey2cfe6d62012-03-27 15:03:07 +02001381 [AC_LINK_IFELSE([AC_LANG_PROGRAM([
1382 #include <stdint.h>
1383 ],
1384 [
1385 #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2
1386 {
1387 uint$1_t x$1 = 0;
1388 __sync_add_and_fetch(&x$1, 42);
1389 __sync_sub_and_fetch(&x$1, 1);
1390 }
1391 #else
1392 #error __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2 is defined, no need to force
1393 #endif
1394 ])],
Mike Hommeyc1e567b2012-03-26 17:03:41 +02001395 [je_cv_sync_compare_and_swap_$2=yes],
1396 [je_cv_sync_compare_and_swap_$2=no])])
1397
1398 if test "x${je_cv_sync_compare_and_swap_$2}" = "xyes" ; then
1399 AC_DEFINE([JE_FORCE_SYNC_COMPARE_AND_SWAP_$2], [ ])
1400 fi
1401])
1402
Jason Evansb57d3ec2012-04-17 13:17:54 -07001403if test "x${je_cv_atomic9}" != "xyes" -a "x${je_cv_osatomic}" != "xyes" ; then
Mike Hommeyc1e567b2012-03-26 17:03:41 +02001404 JE_SYNC_COMPARE_AND_SWAP_CHECK(32, 4)
1405 JE_SYNC_COMPARE_AND_SWAP_CHECK(64, 8)
1406fi
1407
1408dnl ============================================================================
Jason Evansd04047c2014-05-28 16:11:55 -07001409dnl Check for __builtin_clz() and __builtin_clzl().
1410
1411AC_CACHE_CHECK([for __builtin_clz],
1412 [je_cv_builtin_clz],
1413 [AC_LINK_IFELSE([AC_LANG_PROGRAM([],
1414 [
1415 {
1416 unsigned x = 0;
1417 int y = __builtin_clz(x);
1418 }
1419 {
1420 unsigned long x = 0;
1421 int y = __builtin_clzl(x);
1422 }
1423 ])],
1424 [je_cv_builtin_clz=yes],
1425 [je_cv_builtin_clz=no])])
1426
1427if test "x${je_cv_builtin_clz}" = "xyes" ; then
1428 AC_DEFINE([JEMALLOC_HAVE_BUILTIN_CLZ], [ ])
1429fi
1430
1431dnl ============================================================================
Jason Evans893a0ed2011-03-18 19:30:18 -07001432dnl Check for spinlock(3) operations as provided on Darwin.
1433
1434JE_COMPILABLE([Darwin OSSpin*()], [
1435#include <libkern/OSAtomic.h>
1436#include <inttypes.h>
1437], [
1438 OSSpinLock lock = 0;
1439 OSSpinLockLock(&lock);
1440 OSSpinLockUnlock(&lock);
Jason Evans6684cac2012-03-05 12:15:36 -08001441], [je_cv_osspin])
1442if test "x${je_cv_osspin}" = "xyes" ; then
Jason Evanse24c7af2012-03-19 10:21:17 -07001443 AC_DEFINE([JEMALLOC_OSSPIN], [ ])
Jason Evans893a0ed2011-03-18 19:30:18 -07001444fi
1445
1446dnl ============================================================================
Jason Evans2dbecf12010-09-05 10:35:13 -07001447dnl Darwin-related configuration.
Jason Evans78d815c2010-01-17 14:06:20 -08001448
Mike Hommeyd0357f72012-11-26 18:52:41 +01001449AC_ARG_ENABLE([zone-allocator],
1450 [AS_HELP_STRING([--disable-zone-allocator],
1451 [Disable zone allocator for Darwin])],
1452[if test "x$enable_zone_allocator" = "xno" ; then
1453 enable_zone_allocator="0"
1454else
1455 enable_zone_allocator="1"
1456fi
1457],
1458[if test "x${abi}" = "xmacho"; then
1459 enable_zone_allocator="1"
1460fi
1461]
1462)
1463AC_SUBST([enable_zone_allocator])
1464
1465if test "x${enable_zone_allocator}" = "x1" ; then
1466 if test "x${abi}" != "xmacho"; then
1467 AC_MSG_ERROR([--enable-zone-allocator is only supported on Darwin])
1468 fi
Jason Evanse24c7af2012-03-19 10:21:17 -07001469 AC_DEFINE([JEMALLOC_ZONE], [ ])
Jason Evans6109fe02010-02-10 10:37:56 -08001470
Jason Evans2dbecf12010-09-05 10:35:13 -07001471 dnl The szone version jumped from 3 to 6 between the OS X 10.5.x and 10.6
1472 dnl releases. malloc_zone_t and malloc_introspection_t have new fields in
1473 dnl 10.6, which is the only source-level indication of the change.
1474 AC_MSG_CHECKING([malloc zone version])
Mike Hommey154829d2012-03-20 18:01:38 +01001475 AC_DEFUN([JE_ZONE_PROGRAM],
1476 [AC_LANG_PROGRAM(
1477 [#include <malloc/malloc.h>],
Guilherme Goncalves79725aa2014-10-20 14:08:37 -02001478 [static int foo[[sizeof($1) $2 sizeof(void *) * $3 ? 1 : -1]]]
Mike Hommey154829d2012-03-20 18:01:38 +01001479 )])
Jason Evans2dbecf12010-09-05 10:35:13 -07001480
Mike Hommey154829d2012-03-20 18:01:38 +01001481 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,14)],[JEMALLOC_ZONE_VERSION=3],[
1482 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,15)],[JEMALLOC_ZONE_VERSION=5],[
1483 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,16)],[
1484 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,9)],[JEMALLOC_ZONE_VERSION=6],[
1485 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,13)],[JEMALLOC_ZONE_VERSION=7],[JEMALLOC_ZONE_VERSION=]
1486 )])],[
1487 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,17)],[JEMALLOC_ZONE_VERSION=8],[
1488 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,>,17)],[JEMALLOC_ZONE_VERSION=9],[JEMALLOC_ZONE_VERSION=]
1489 )])])])])
1490 if test "x${JEMALLOC_ZONE_VERSION}" = "x"; then
1491 AC_MSG_RESULT([unsupported])
1492 AC_MSG_ERROR([Unsupported malloc zone version])
1493 fi
1494 if test "${JEMALLOC_ZONE_VERSION}" = 9; then
1495 JEMALLOC_ZONE_VERSION=8
1496 AC_MSG_RESULT([> 8])
1497 else
1498 AC_MSG_RESULT([$JEMALLOC_ZONE_VERSION])
1499 fi
1500 AC_DEFINE_UNQUOTED(JEMALLOC_ZONE_VERSION, [$JEMALLOC_ZONE_VERSION])
Jason Evansb27805b2010-02-10 18:15:53 -08001501fi
1502
Jason Evansb7924f52009-06-23 19:01:18 -07001503dnl ============================================================================
Sara Golemon3e24afa2014-08-18 13:06:39 -07001504dnl Check for glibc malloc hooks
1505
1506JE_COMPILABLE([glibc malloc hook], [
1507#include <stddef.h>
1508
1509extern void (* __free_hook)(void *ptr);
1510extern void *(* __malloc_hook)(size_t size);
1511extern void *(* __realloc_hook)(void *ptr, size_t size);
1512], [
1513 void *ptr = 0L;
1514 if (__malloc_hook) ptr = __malloc_hook(1);
1515 if (__realloc_hook) ptr = __realloc_hook(ptr, 2);
1516 if (__free_hook && ptr) __free_hook(ptr);
1517], [je_cv_glibc_malloc_hook])
1518if test "x${je_cv_glibc_malloc_hook}" = "xyes" ; then
1519 AC_DEFINE([JEMALLOC_GLIBC_MALLOC_HOOK], [ ])
1520fi
1521
1522JE_COMPILABLE([glibc memalign hook], [
1523#include <stddef.h>
1524
1525extern void *(* __memalign_hook)(size_t alignment, size_t size);
1526], [
1527 void *ptr = 0L;
1528 if (__memalign_hook) ptr = __memalign_hook(16, 7);
1529], [je_cv_glibc_memalign_hook])
1530if test "x${je_cv_glibc_memalign_hook}" = "xyes" ; then
1531 AC_DEFINE([JEMALLOC_GLIBC_MEMALIGN_HOOK], [ ])
1532fi
1533
Eric Wong4dcf04b2014-08-31 03:57:06 +00001534JE_COMPILABLE([pthreads adaptive mutexes], [
1535#include <pthread.h>
1536], [
1537 pthread_mutexattr_t attr;
1538 pthread_mutexattr_init(&attr);
1539 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ADAPTIVE_NP);
1540 pthread_mutexattr_destroy(&attr);
1541], [je_cv_pthread_mutex_adaptive_np])
1542if test "x${je_cv_pthread_mutex_adaptive_np}" = "xyes" ; then
1543 AC_DEFINE([JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], [ ])
1544fi
1545
Sara Golemon3e24afa2014-08-18 13:06:39 -07001546dnl ============================================================================
Jason Evansb7924f52009-06-23 19:01:18 -07001547dnl Check for typedefs, structures, and compiler characteristics.
1548AC_HEADER_STDBOOL
1549
Jason Evans748dfac2013-12-06 18:27:33 -08001550dnl ============================================================================
1551dnl Define commands that generate output files.
1552
Jason Evans86abd0d2013-11-30 15:25:42 -08001553AC_CONFIG_COMMANDS([include/jemalloc/internal/private_namespace.h], [
1554 mkdir -p "${objroot}include/jemalloc/internal"
1555 "${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 -08001556], [
1557 srcdir="${srcdir}"
1558 objroot="${objroot}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001559])
1560AC_CONFIG_COMMANDS([include/jemalloc/internal/private_unnamespace.h], [
1561 mkdir -p "${objroot}include/jemalloc/internal"
1562 "${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 -08001563], [
1564 srcdir="${srcdir}"
1565 objroot="${objroot}"
1566])
1567AC_CONFIG_COMMANDS([include/jemalloc/internal/public_symbols.txt], [
1568 f="${objroot}include/jemalloc/internal/public_symbols.txt"
1569 mkdir -p "${objroot}include/jemalloc/internal"
1570 cp /dev/null "${f}"
1571 for nm in `echo ${mangling_map} |tr ',' ' '` ; do
1572 n=`echo ${nm} |tr ':' ' ' |awk '{print $[]1}'`
1573 m=`echo ${nm} |tr ':' ' ' |awk '{print $[]2}'`
1574 echo "${n}:${m}" >> "${f}"
1575 dnl Remove name from public_syms so that it isn't redefined later.
1576 public_syms=`for sym in ${public_syms}; do echo "${sym}"; done |grep -v "^${n}\$" |tr '\n' ' '`
1577 done
1578 for sym in ${public_syms} ; do
1579 n="${sym}"
1580 m="${JEMALLOC_PREFIX}${sym}"
1581 echo "${n}:${m}" >> "${f}"
1582 done
1583], [
1584 srcdir="${srcdir}"
1585 objroot="${objroot}"
1586 mangling_map="${mangling_map}"
1587 public_syms="${public_syms}"
1588 JEMALLOC_PREFIX="${JEMALLOC_PREFIX}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001589])
1590AC_CONFIG_COMMANDS([include/jemalloc/internal/public_namespace.h], [
1591 mkdir -p "${objroot}include/jemalloc/internal"
Jason Evansf234dc52014-01-16 17:38:01 -08001592 "${srcdir}/include/jemalloc/internal/public_namespace.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/internal/public_namespace.h"
1593], [
1594 srcdir="${srcdir}"
1595 objroot="${objroot}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001596])
1597AC_CONFIG_COMMANDS([include/jemalloc/internal/public_unnamespace.h], [
1598 mkdir -p "${objroot}include/jemalloc/internal"
Jason Evansf234dc52014-01-16 17:38:01 -08001599 "${srcdir}/include/jemalloc/internal/public_unnamespace.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/internal/public_unnamespace.h"
1600], [
1601 srcdir="${srcdir}"
1602 objroot="${objroot}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001603])
Jason Evansb1726102012-02-28 16:50:47 -08001604AC_CONFIG_COMMANDS([include/jemalloc/internal/size_classes.h], [
Jason Evans86abd0d2013-11-30 15:25:42 -08001605 mkdir -p "${objroot}include/jemalloc/internal"
Jason Evans81e54752014-10-10 22:34:25 -07001606 "${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 -08001607], [
1608 srcdir="${srcdir}"
1609 objroot="${objroot}"
Jason Evans81e54752014-10-10 22:34:25 -07001610 LG_QUANTA="${LG_QUANTA}"
1611 LG_TINY_MIN=${LG_TINY_MIN}
1612 LG_PAGE_SIZES="${LG_PAGE_SIZES}"
Jason Evansfc0b3b72014-10-09 17:54:06 -07001613 LG_SIZE_CLASS_GROUP=${LG_SIZE_CLASS_GROUP}
Jason Evansb1726102012-02-28 16:50:47 -08001614])
Jason Evans86abd0d2013-11-30 15:25:42 -08001615AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_protos_jet.h], [
1616 mkdir -p "${objroot}include/jemalloc"
1617 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 -08001618], [
1619 srcdir="${srcdir}"
1620 objroot="${objroot}"
1621])
1622AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_rename.h], [
1623 mkdir -p "${objroot}include/jemalloc"
1624 "${srcdir}/include/jemalloc/jemalloc_rename.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/jemalloc_rename.h"
1625], [
1626 srcdir="${srcdir}"
1627 objroot="${objroot}"
1628])
1629AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_mangle.h], [
1630 mkdir -p "${objroot}include/jemalloc"
1631 "${srcdir}/include/jemalloc/jemalloc_mangle.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" je_ > "${objroot}include/jemalloc/jemalloc_mangle.h"
1632], [
1633 srcdir="${srcdir}"
1634 objroot="${objroot}"
1635])
1636AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_mangle_jet.h], [
1637 mkdir -p "${objroot}include/jemalloc"
1638 "${srcdir}/include/jemalloc/jemalloc_mangle.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" jet_ > "${objroot}include/jemalloc/jemalloc_mangle_jet.h"
1639], [
1640 srcdir="${srcdir}"
1641 objroot="${objroot}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001642])
1643AC_CONFIG_COMMANDS([include/jemalloc/jemalloc.h], [
1644 mkdir -p "${objroot}include/jemalloc"
1645 "${srcdir}/include/jemalloc/jemalloc.sh" "${objroot}" > "${objroot}include/jemalloc/jemalloc${install_suffix}.h"
Jason Evansf234dc52014-01-16 17:38:01 -08001646], [
1647 srcdir="${srcdir}"
1648 objroot="${objroot}"
1649 install_suffix="${install_suffix}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001650])
Jason Evansb1726102012-02-28 16:50:47 -08001651
Jason Evansb7924f52009-06-23 19:01:18 -07001652dnl Process .in files.
Jason Evansb0fd5012010-01-17 01:49:20 -08001653AC_SUBST([cfghdrs_in])
1654AC_SUBST([cfghdrs_out])
Jason Evans0656ec02010-04-07 23:37:35 -07001655AC_CONFIG_HEADERS([$cfghdrs_tup])
Jason Evansb7924f52009-06-23 19:01:18 -07001656
1657dnl ============================================================================
1658dnl Generate outputs.
Jason Evans748dfac2013-12-06 18:27:33 -08001659
Jason Evans70417202015-05-01 12:31:12 -07001660AC_CONFIG_FILES([$cfgoutputs_tup config.stamp bin/jemalloc-config bin/jemalloc.sh bin/jeprof])
Jason Evansb0fd5012010-01-17 01:49:20 -08001661AC_SUBST([cfgoutputs_in])
1662AC_SUBST([cfgoutputs_out])
Jason Evansb7924f52009-06-23 19:01:18 -07001663AC_OUTPUT
1664
1665dnl ============================================================================
1666dnl Print out the results of configuration.
1667AC_MSG_RESULT([===============================================================================])
Jason Evansf576c632011-11-01 22:27:41 -07001668AC_MSG_RESULT([jemalloc version : ${jemalloc_version}])
1669AC_MSG_RESULT([library revision : ${rev}])
Jason Evansb7924f52009-06-23 19:01:18 -07001670AC_MSG_RESULT([])
Jason Evansbec6a8d2015-01-22 17:55:58 -08001671AC_MSG_RESULT([CONFIG : ${CONFIG}])
Jason Evansb7924f52009-06-23 19:01:18 -07001672AC_MSG_RESULT([CC : ${CC}])
Jason Evansb7924f52009-06-23 19:01:18 -07001673AC_MSG_RESULT([CFLAGS : ${CFLAGS}])
Jason Evansbec6a8d2015-01-22 17:55:58 -08001674AC_MSG_RESULT([CPPFLAGS : ${CPPFLAGS}])
Jason Evansb7924f52009-06-23 19:01:18 -07001675AC_MSG_RESULT([LDFLAGS : ${LDFLAGS}])
Jason Evans748dfac2013-12-06 18:27:33 -08001676AC_MSG_RESULT([EXTRA_LDFLAGS : ${EXTRA_LDFLAGS}])
Jason Evansb7924f52009-06-23 19:01:18 -07001677AC_MSG_RESULT([LIBS : ${LIBS}])
1678AC_MSG_RESULT([RPATH_EXTRA : ${RPATH_EXTRA}])
1679AC_MSG_RESULT([])
Jason Evansaee7fd22010-11-24 22:00:02 -08001680AC_MSG_RESULT([XSLTPROC : ${XSLTPROC}])
1681AC_MSG_RESULT([XSLROOT : ${XSLROOT}])
1682AC_MSG_RESULT([])
Jason Evansb7924f52009-06-23 19:01:18 -07001683AC_MSG_RESULT([PREFIX : ${PREFIX}])
1684AC_MSG_RESULT([BINDIR : ${BINDIR}])
Jason Evansbec6a8d2015-01-22 17:55:58 -08001685AC_MSG_RESULT([DATADIR : ${DATADIR}])
Jason Evans662a0172009-07-01 19:24:31 -07001686AC_MSG_RESULT([INCLUDEDIR : ${INCLUDEDIR}])
1687AC_MSG_RESULT([LIBDIR : ${LIBDIR}])
Jason Evansb7924f52009-06-23 19:01:18 -07001688AC_MSG_RESULT([MANDIR : ${MANDIR}])
1689AC_MSG_RESULT([])
1690AC_MSG_RESULT([srcroot : ${srcroot}])
1691AC_MSG_RESULT([abs_srcroot : ${abs_srcroot}])
1692AC_MSG_RESULT([objroot : ${objroot}])
1693AC_MSG_RESULT([abs_objroot : ${abs_objroot}])
1694AC_MSG_RESULT([])
Jason Evans90895cf2009-12-29 00:09:15 -08001695AC_MSG_RESULT([JEMALLOC_PREFIX : ${JEMALLOC_PREFIX}])
Jason Evans746e77a2011-07-30 16:40:52 -07001696AC_MSG_RESULT([JEMALLOC_PRIVATE_NAMESPACE])
1697AC_MSG_RESULT([ : ${JEMALLOC_PRIVATE_NAMESPACE}])
Jason Evansb0fd5012010-01-17 01:49:20 -08001698AC_MSG_RESULT([install_suffix : ${install_suffix}])
Jason Evansb7924f52009-06-23 19:01:18 -07001699AC_MSG_RESULT([autogen : ${enable_autogen}])
Jason Evans355b4382010-09-20 19:20:48 -07001700AC_MSG_RESULT([cc-silence : ${enable_cc_silence}])
Jason Evansb7924f52009-06-23 19:01:18 -07001701AC_MSG_RESULT([debug : ${enable_debug}])
Jason Evans748dfac2013-12-06 18:27:33 -08001702AC_MSG_RESULT([code-coverage : ${enable_code_coverage}])
Jason Evansb7924f52009-06-23 19:01:18 -07001703AC_MSG_RESULT([stats : ${enable_stats}])
Jason Evans6109fe02010-02-10 10:37:56 -08001704AC_MSG_RESULT([prof : ${enable_prof}])
1705AC_MSG_RESULT([prof-libunwind : ${enable_prof_libunwind}])
Jason Evans77f350b2011-03-15 22:23:12 -07001706AC_MSG_RESULT([prof-libgcc : ${enable_prof_libgcc}])
1707AC_MSG_RESULT([prof-gcc : ${enable_prof_gcc}])
Jason Evans84cbbcb2009-12-29 00:09:15 -08001708AC_MSG_RESULT([tcache : ${enable_tcache}])
Jason Evansb7924f52009-06-23 19:01:18 -07001709AC_MSG_RESULT([fill : ${enable_fill}])
Jason Evansb1476112012-04-05 13:36:17 -07001710AC_MSG_RESULT([utrace : ${enable_utrace}])
Jason Evans122449b2012-04-06 00:35:09 -07001711AC_MSG_RESULT([valgrind : ${enable_valgrind}])
1712AC_MSG_RESULT([xmalloc : ${enable_xmalloc}])
Jason Evans59ae2762012-04-16 17:52:27 -07001713AC_MSG_RESULT([munmap : ${enable_munmap}])
Jason Evansb7924f52009-06-23 19:01:18 -07001714AC_MSG_RESULT([lazy_lock : ${enable_lazy_lock}])
Jason Evans2dbecf12010-09-05 10:35:13 -07001715AC_MSG_RESULT([tls : ${enable_tls}])
Jason Evans8a03cf02015-05-04 09:58:36 -07001716AC_MSG_RESULT([cache-oblivious : ${enable_cache_oblivious}])
Jason Evansb7924f52009-06-23 19:01:18 -07001717AC_MSG_RESULT([===============================================================================])