blob: 5a3eba27101a5813c8416156e31dd7bffe09a403 [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 Evans3a923192015-11-12 11:23:39 -08004AC_CONFIG_AUX_DIR([build-aux])
5
Jason Evansf3340ca2009-06-30 16:17:05 -07006dnl ============================================================================
7dnl Custom macro definitions.
8
9dnl JE_CFLAGS_APPEND(cflag)
10AC_DEFUN([JE_CFLAGS_APPEND],
11[
12AC_MSG_CHECKING([whether compiler supports $1])
13TCFLAGS="${CFLAGS}"
14if test "x${CFLAGS}" = "x" ; then
15 CFLAGS="$1"
16else
17 CFLAGS="${CFLAGS} $1"
18fi
Jason Evans6684cac2012-03-05 12:15:36 -080019AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Jason Evansf3340ca2009-06-30 16:17:05 -070020[[
21]], [[
22 return 0;
23]])],
Jason Evans99b0fbb2014-02-24 16:08:38 -080024 [je_cv_cflags_appended=$1]
Jason Evansf3340ca2009-06-30 16:17:05 -070025 AC_MSG_RESULT([yes]),
Jason Evans99b0fbb2014-02-24 16:08:38 -080026 [je_cv_cflags_appended=]
Jason Evansf3340ca2009-06-30 16:17:05 -070027 AC_MSG_RESULT([no])
28 [CFLAGS="${TCFLAGS}"]
29)
30])
31
32dnl JE_COMPILABLE(label, hcode, mcode, rvar)
Jason Evans4c2faa82012-03-13 11:09:23 -070033dnl
Jason Evansf3e139a2012-03-19 09:54:20 -070034dnl Use AC_LINK_IFELSE() rather than AC_COMPILE_IFELSE() so that linker errors
Jason Evans4c2faa82012-03-13 11:09:23 -070035dnl cause failure.
Jason Evansf3340ca2009-06-30 16:17:05 -070036AC_DEFUN([JE_COMPILABLE],
37[
Jason Evans6684cac2012-03-05 12:15:36 -080038AC_CACHE_CHECK([whether $1 is compilable],
39 [$4],
Jason Evansf3e139a2012-03-19 09:54:20 -070040 [AC_LINK_IFELSE([AC_LANG_PROGRAM([$2],
41 [$3])],
42 [$4=yes],
43 [$4=no])])
Jason Evansf3340ca2009-06-30 16:17:05 -070044])
45
46dnl ============================================================================
47
Jason Evans41f2e692015-01-25 20:15:13 -080048CONFIG=`echo ${ac_configure_args} | sed -e 's#'"'"'\([^ ]*\)'"'"'#\1#g'`
Jason Evansbec6a8d2015-01-22 17:55:58 -080049AC_SUBST([CONFIG])
50
Jason Evansf576c632011-11-01 22:27:41 -070051dnl Library revision.
Jason Evans9790b962014-04-14 22:32:31 -070052rev=2
Jason Evansf576c632011-11-01 22:27:41 -070053AC_SUBST([rev])
54
Jason Evansb7924f52009-06-23 19:01:18 -070055srcroot=$srcdir
56if test "x${srcroot}" = "x." ; then
57 srcroot=""
58else
59 srcroot="${srcroot}/"
60fi
61AC_SUBST([srcroot])
62abs_srcroot="`cd \"${srcdir}\"; pwd`/"
63AC_SUBST([abs_srcroot])
64
65objroot=""
66AC_SUBST([objroot])
67abs_objroot="`pwd`/"
68AC_SUBST([abs_objroot])
69
70dnl Munge install path variables.
71if test "x$prefix" = "xNONE" ; then
72 prefix="/usr/local"
73fi
74if test "x$exec_prefix" = "xNONE" ; then
75 exec_prefix=$prefix
76fi
77PREFIX=$prefix
78AC_SUBST([PREFIX])
79BINDIR=`eval echo $bindir`
80BINDIR=`eval echo $BINDIR`
81AC_SUBST([BINDIR])
82INCLUDEDIR=`eval echo $includedir`
83INCLUDEDIR=`eval echo $INCLUDEDIR`
84AC_SUBST([INCLUDEDIR])
85LIBDIR=`eval echo $libdir`
86LIBDIR=`eval echo $LIBDIR`
87AC_SUBST([LIBDIR])
88DATADIR=`eval echo $datadir`
89DATADIR=`eval echo $DATADIR`
90AC_SUBST([DATADIR])
91MANDIR=`eval echo $mandir`
92MANDIR=`eval echo $MANDIR`
93AC_SUBST([MANDIR])
94
Jason Evansaee7fd22010-11-24 22:00:02 -080095dnl Support for building documentation.
Jason Evans7329a4f2013-01-22 10:53:29 -080096AC_PATH_PROG([XSLTPROC], [xsltproc], [false], [$PATH])
Jason Evans7091b412012-03-19 09:36:44 -070097if test -d "/usr/share/xml/docbook/stylesheet/docbook-xsl" ; then
98 DEFAULT_XSLROOT="/usr/share/xml/docbook/stylesheet/docbook-xsl"
99elif test -d "/usr/share/sgml/docbook/xsl-stylesheets" ; then
100 DEFAULT_XSLROOT="/usr/share/sgml/docbook/xsl-stylesheets"
101else
102 dnl Documentation building will fail if this default gets used.
103 DEFAULT_XSLROOT=""
104fi
Jason Evansaee7fd22010-11-24 22:00:02 -0800105AC_ARG_WITH([xslroot],
Jason Evans7091b412012-03-19 09:36:44 -0700106 [AS_HELP_STRING([--with-xslroot=<path>], [XSL stylesheet root path])], [
Jason Evansaee7fd22010-11-24 22:00:02 -0800107if test "x$with_xslroot" = "xno" ; then
Jason Evans7091b412012-03-19 09:36:44 -0700108 XSLROOT="${DEFAULT_XSLROOT}"
Jason Evansaee7fd22010-11-24 22:00:02 -0800109else
110 XSLROOT="${with_xslroot}"
Jason Evans7091b412012-03-19 09:36:44 -0700111fi
112],
113 XSLROOT="${DEFAULT_XSLROOT}"
Jason Evansaee7fd22010-11-24 22:00:02 -0800114)
115AC_SUBST([XSLROOT])
116
Jason Evansf3340ca2009-06-30 16:17:05 -0700117dnl If CFLAGS isn't defined, set CFLAGS to something reasonable. Otherwise,
118dnl just prevent autoconf from molesting CFLAGS.
Jason Evansb7924f52009-06-23 19:01:18 -0700119CFLAGS=$CFLAGS
120AC_PROG_CC
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200121if test "x$GCC" != "xyes" ; then
122 AC_CACHE_CHECK([whether compiler is MSVC],
123 [je_cv_msvc],
124 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([],
125 [
126#ifndef _MSC_VER
127 int fail[-1];
128#endif
129])],
130 [je_cv_msvc=yes],
131 [je_cv_msvc=no])])
132fi
133
Jason Evansb7924f52009-06-23 19:01:18 -0700134if test "x$CFLAGS" = "x" ; then
135 no_CFLAGS="yes"
Jason Evanscfeccd32010-03-03 15:48:20 -0800136 if test "x$GCC" = "xyes" ; then
137 JE_CFLAGS_APPEND([-std=gnu99])
Jason Evans99b0fbb2014-02-24 16:08:38 -0800138 if test "x$je_cv_cflags_appended" = "x-std=gnu99" ; then
139 AC_DEFINE_UNQUOTED([JEMALLOC_HAS_RESTRICT])
140 fi
Jason Evanscfeccd32010-03-03 15:48:20 -0800141 JE_CFLAGS_APPEND([-Wall])
Mike Hommeyb7b44df2014-12-18 15:12:53 +0900142 JE_CFLAGS_APPEND([-Werror=declaration-after-statement])
Jason Evanscfeccd32010-03-03 15:48:20 -0800143 JE_CFLAGS_APPEND([-pipe])
144 JE_CFLAGS_APPEND([-g3])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200145 elif test "x$je_cv_msvc" = "xyes" ; then
146 CC="$CC -nologo"
147 JE_CFLAGS_APPEND([-Zi])
148 JE_CFLAGS_APPEND([-MT])
149 JE_CFLAGS_APPEND([-W3])
Mike Hommey8c615752014-05-29 16:58:21 +0900150 JE_CFLAGS_APPEND([-FS])
Mike Hommey6f6704c2014-05-29 17:01:10 +0900151 CPPFLAGS="$CPPFLAGS -I${srcdir}/include/msvc_compat"
Jason Evanscfeccd32010-03-03 15:48:20 -0800152 fi
Jason Evansb7924f52009-06-23 19:01:18 -0700153fi
154dnl Append EXTRA_CFLAGS to CFLAGS, if defined.
155if test "x$EXTRA_CFLAGS" != "x" ; then
Jason Evansf3340ca2009-06-30 16:17:05 -0700156 JE_CFLAGS_APPEND([$EXTRA_CFLAGS])
Jason Evansb7924f52009-06-23 19:01:18 -0700157fi
158AC_PROG_CPP
159
Jason Evansdf3f2702014-03-30 16:27:08 -0700160AC_C_BIGENDIAN([ac_cv_big_endian=1], [ac_cv_big_endian=0])
161if test "x${ac_cv_big_endian}" = "x1" ; then
162 AC_DEFINE_UNQUOTED([JEMALLOC_BIG_ENDIAN], [ ])
163fi
164
Mike Hommeyff2e9992014-05-29 16:33:02 +0900165if test "x${je_cv_msvc}" = "xyes" -a "x${ac_cv_header_inttypes_h}" = "xno"; then
Mike Hommey6f6704c2014-05-29 17:01:10 +0900166 CPPFLAGS="$CPPFLAGS -I${srcdir}/include/msvc_compat/C99"
Mike Hommeyff2e9992014-05-29 16:33:02 +0900167fi
168
Jason Evansb7924f52009-06-23 19:01:18 -0700169AC_CHECK_SIZEOF([void *])
170if test "x${ac_cv_sizeof_void_p}" = "x8" ; then
Jason Evans94ad2b52009-12-29 00:09:15 -0800171 LG_SIZEOF_PTR=3
Jason Evansb7924f52009-06-23 19:01:18 -0700172elif test "x${ac_cv_sizeof_void_p}" = "x4" ; then
Jason Evans94ad2b52009-12-29 00:09:15 -0800173 LG_SIZEOF_PTR=2
Jason Evansb7924f52009-06-23 19:01:18 -0700174else
175 AC_MSG_ERROR([Unsupported pointer size: ${ac_cv_sizeof_void_p}])
176fi
Jason Evans94ad2b52009-12-29 00:09:15 -0800177AC_DEFINE_UNQUOTED([LG_SIZEOF_PTR], [$LG_SIZEOF_PTR])
178
179AC_CHECK_SIZEOF([int])
180if test "x${ac_cv_sizeof_int}" = "x8" ; then
181 LG_SIZEOF_INT=3
182elif test "x${ac_cv_sizeof_int}" = "x4" ; then
183 LG_SIZEOF_INT=2
184else
185 AC_MSG_ERROR([Unsupported int size: ${ac_cv_sizeof_int}])
186fi
187AC_DEFINE_UNQUOTED([LG_SIZEOF_INT], [$LG_SIZEOF_INT])
Jason Evansb7924f52009-06-23 19:01:18 -0700188
Jason Evans84c8eef2011-03-16 10:30:13 -0700189AC_CHECK_SIZEOF([long])
190if test "x${ac_cv_sizeof_long}" = "x8" ; then
191 LG_SIZEOF_LONG=3
192elif test "x${ac_cv_sizeof_long}" = "x4" ; then
193 LG_SIZEOF_LONG=2
194else
195 AC_MSG_ERROR([Unsupported long size: ${ac_cv_sizeof_long}])
196fi
197AC_DEFINE_UNQUOTED([LG_SIZEOF_LONG], [$LG_SIZEOF_LONG])
198
Jason Evansd81e4bd2012-03-06 14:57:45 -0800199AC_CHECK_SIZEOF([intmax_t])
200if test "x${ac_cv_sizeof_intmax_t}" = "x16" ; then
201 LG_SIZEOF_INTMAX_T=4
202elif test "x${ac_cv_sizeof_intmax_t}" = "x8" ; then
203 LG_SIZEOF_INTMAX_T=3
204elif test "x${ac_cv_sizeof_intmax_t}" = "x4" ; then
205 LG_SIZEOF_INTMAX_T=2
206else
Mike Hommey14103d32012-04-20 08:38:39 +0200207 AC_MSG_ERROR([Unsupported intmax_t size: ${ac_cv_sizeof_intmax_t}])
Jason Evansd81e4bd2012-03-06 14:57:45 -0800208fi
209AC_DEFINE_UNQUOTED([LG_SIZEOF_INTMAX_T], [$LG_SIZEOF_INTMAX_T])
210
Jason Evansb7924f52009-06-23 19:01:18 -0700211AC_CANONICAL_HOST
212dnl CPU-specific settings.
213CPU_SPINWAIT=""
214case "${host_cpu}" in
Jason Evanscb657e32014-02-25 11:21:41 -0800215 i686|x86_64)
Jason Evans81e54752014-10-10 22:34:25 -0700216 AC_CACHE_VAL([je_cv_pause],
Jason Evans2eb941a2014-10-10 20:40:43 -0700217 [JE_COMPILABLE([pause instruction], [],
218 [[__asm__ volatile("pause"); return 0;]],
219 [je_cv_pause])])
Jason Evanscb657e32014-02-25 11:21:41 -0800220 if test "x${je_cv_pause}" = "xyes" ; then
Jason Evansf3340ca2009-06-30 16:17:05 -0700221 CPU_SPINWAIT='__asm__ volatile("pause")'
222 fi
Jason Evans80061b62013-12-09 13:21:08 -0800223 ;;
224 powerpc)
225 AC_DEFINE_UNQUOTED([HAVE_ALTIVEC], [ ])
Jason Evansb7924f52009-06-23 19:01:18 -0700226 ;;
227 *)
228 ;;
229esac
230AC_DEFINE_UNQUOTED([CPU_SPINWAIT], [$CPU_SPINWAIT])
231
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +0400232LD_PRELOAD_VAR="LD_PRELOAD"
Jason Evansf576c632011-11-01 22:27:41 -0700233so="so"
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200234importlib="${so}"
Mike Hommey7cdea392012-04-30 12:38:27 +0200235o="$ac_objext"
Mike Hommey5bee66d2012-04-16 16:30:24 +0200236a="a"
Mike Hommey7cdea392012-04-30 12:38:27 +0200237exe="$ac_exeext"
Mike Hommeya19e87f2012-04-21 21:27:46 -0700238libprefix="lib"
Mike Hommeyfa08da72012-04-16 16:30:25 +0200239DSO_LDFLAGS='-shared -Wl,-soname,$(@F)'
240RPATH='-Wl,-rpath,$(1)'
Mike Hommey7cdea392012-04-30 12:38:27 +0200241SOREV="${so}.${rev}"
Mike Hommey188da7c2012-04-18 18:29:41 +0200242PIC_CFLAGS='-fPIC -DPIC'
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200243CTARGET='-o $@'
244LDTARGET='-o $@'
245EXTRA_LDFLAGS=
Jason Evans80ddf492013-08-20 11:48:19 +0100246ARFLAGS='crus'
247AROUT=' $@'
Mike Hommey79c4bca2012-05-02 21:30:51 +0200248CC_MM=1
Jason Evans7372b152012-02-10 20:22:09 -0800249
Jory A. Prattad505e02013-08-11 09:44:59 -0500250AN_MAKEVAR([AR], [AC_PROG_AR])
251AN_PROGRAM([ar], [AC_PROG_AR])
252AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL(AR, ar, :)])
253AC_PROG_AR
254
Jason Evansb7924f52009-06-23 19:01:18 -0700255dnl Platform-specific settings. abi and RPATH can probably be determined
256dnl programmatically, but doing so is error-prone, which makes it generally
257dnl not worth the trouble.
258dnl
259dnl Define cpp macros in CPPFLAGS, rather than doing AC_DEFINE(macro), since the
260dnl definitions need to be seen before any headers are included, which is a pain
261dnl to make happen otherwise.
Jason Evans59ae2762012-04-16 17:52:27 -0700262default_munmap="1"
Jason Evansd059b9d2015-07-24 18:21:42 -0700263maps_coalesce="1"
Jason Evansb7924f52009-06-23 19:01:18 -0700264case "${host}" in
Valerii Hiora5921ba72014-05-16 16:28:20 +0300265 *-*-darwin* | *-*-ios*)
Mike Hommeya6770a72012-05-03 14:12:49 +0200266 CFLAGS="$CFLAGS"
Jason Evansb7924f52009-06-23 19:01:18 -0700267 abi="macho"
Jason Evanse24c7af2012-03-19 10:21:17 -0700268 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
Jason Evansb7924f52009-06-23 19:01:18 -0700269 RPATH=""
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +0400270 LD_PRELOAD_VAR="DYLD_INSERT_LIBRARIES"
Jason Evansf576c632011-11-01 22:27:41 -0700271 so="dylib"
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200272 importlib="${so}"
Jason Evansb80581d2012-03-23 16:17:43 -0700273 force_tls="0"
Jason Evansf1f2b452015-05-01 08:57:41 -0700274 DSO_LDFLAGS='-shared -Wl,-install_name,$(LIBDIR)/$(@F)'
Mike Hommey7cdea392012-04-30 12:38:27 +0200275 SOREV="${rev}.${so}"
Jason Evans66688532013-12-03 21:49:36 -0800276 sbrk_deprecated="1"
Jason Evansb7924f52009-06-23 19:01:18 -0700277 ;;
278 *-*-freebsd*)
279 CFLAGS="$CFLAGS"
280 abi="elf"
Jason Evanse24c7af2012-03-19 10:21:17 -0700281 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
Jason Evansfd4fcef2012-03-23 17:40:58 -0700282 force_lazy_lock="1"
Jason Evansb7924f52009-06-23 19:01:18 -0700283 ;;
Michael Neumann1aa25a32014-08-05 03:06:02 +0200284 *-*-dragonfly*)
285 CFLAGS="$CFLAGS"
286 abi="elf"
287 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
288 ;;
Sébastien Marieb80fbcb2015-04-07 12:21:19 +0200289 *-*-openbsd*)
290 CFLAGS="$CFLAGS"
291 abi="elf"
292 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
293 force_tls="0"
294 ;;
295 *-*-bitrig*)
Sébastien Marie77d597e2015-01-25 10:18:32 +0100296 CFLAGS="$CFLAGS"
297 abi="elf"
298 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
299 ;;
Jason Evansb7924f52009-06-23 19:01:18 -0700300 *-*-linux*)
301 CFLAGS="$CFLAGS"
302 CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
303 abi="elf"
Garrett Cooper13e4e242012-12-02 17:58:40 -0800304 AC_DEFINE([JEMALLOC_HAS_ALLOCA_H])
Jason Evanse24c7af2012-03-19 10:21:17 -0700305 AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED], [ ])
Jason Evans02b23122012-04-05 11:06:23 -0700306 AC_DEFINE([JEMALLOC_THREADED_INIT], [ ])
Jason Evansae93d6b2015-07-10 14:33:00 -0700307 AC_DEFINE([JEMALLOC_USE_CXX_THROW], [ ])
Jason Evans59ae2762012-04-16 17:52:27 -0700308 default_munmap="0"
Jason Evansb7924f52009-06-23 19:01:18 -0700309 ;;
310 *-*-netbsd*)
311 AC_MSG_CHECKING([ABI])
312 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
313[[#ifdef __ELF__
314/* ELF */
315#else
316#error aout
317#endif
318]])],
319 [CFLAGS="$CFLAGS"; abi="elf"],
320 [abi="aout"])
321 AC_MSG_RESULT([$abi])
Jason Evanse24c7af2012-03-19 10:21:17 -0700322 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
Jason Evansb7924f52009-06-23 19:01:18 -0700323 ;;
324 *-*-solaris2*)
325 CFLAGS="$CFLAGS"
326 abi="elf"
George Koladdd6bd42014-02-12 23:05:45 +0000327 AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ])
Mike Hommeyfa08da72012-04-16 16:30:25 +0200328 RPATH='-Wl,-R,$(1)'
Jason Evansb7924f52009-06-23 19:01:18 -0700329 dnl Solaris needs this for sigwait().
330 CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS"
331 LIBS="$LIBS -lposix4 -lsocket -lnsl"
332 ;;
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +0400333 *-ibm-aix*)
334 if "$LG_SIZEOF_PTR" = "8"; then
335 dnl 64bit AIX
336 LD_PRELOAD_VAR="LDR_PRELOAD64"
337 else
338 dnl 32bit AIX
339 LD_PRELOAD_VAR="LDR_PRELOAD"
340 fi
341 abi="xcoff"
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +0400342 ;;
Dave Rigby70bdee02014-09-22 15:53:16 +0100343 *-*-mingw* | *-*-cygwin*)
Mike Hommeya19e87f2012-04-21 21:27:46 -0700344 abi="pecoff"
345 force_tls="0"
Jason Evans13473c72015-07-23 14:08:49 -0700346 force_lazy_lock="1"
Jason Evansd059b9d2015-07-24 18:21:42 -0700347 maps_coalesce="0"
Mike Hommeya19e87f2012-04-21 21:27:46 -0700348 RPATH=""
349 so="dll"
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200350 if test "x$je_cv_msvc" = "xyes" ; then
351 importlib="lib"
352 DSO_LDFLAGS="-LD"
353 EXTRA_LDFLAGS="-link -DEBUG"
354 CTARGET='-Fo$@'
355 LDTARGET='-Fe$@'
Jory A. Prattad505e02013-08-11 09:44:59 -0500356 AR='lib'
357 ARFLAGS='-nologo -out:'
Jason Evans80ddf492013-08-20 11:48:19 +0100358 AROUT='$@'
Mike Hommey79c4bca2012-05-02 21:30:51 +0200359 CC_MM=
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200360 else
361 importlib="${so}"
362 DSO_LDFLAGS="-shared"
363 fi
Mike Hommeya19e87f2012-04-21 21:27:46 -0700364 a="lib"
365 libprefix=""
Mike Hommey7cdea392012-04-30 12:38:27 +0200366 SOREV="${so}"
Mike Hommeya19e87f2012-04-21 21:27:46 -0700367 PIC_CFLAGS=""
368 ;;
Jason Evansb7924f52009-06-23 19:01:18 -0700369 *)
370 AC_MSG_RESULT([Unsupported operating system: ${host}])
371 abi="elf"
Jason Evansb7924f52009-06-23 19:01:18 -0700372 ;;
373esac
Mike Hommeyaffe0092014-05-28 08:10:12 +0900374
375JEMALLOC_USABLE_SIZE_CONST=const
376AC_CHECK_HEADERS([malloc.h], [
377 AC_MSG_CHECKING([whether malloc_usable_size definition can use const argument])
378 AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
379 [#include <malloc.h>
380 #include <stddef.h>
381 size_t malloc_usable_size(const void *ptr);
382 ],
383 [])],[
384 AC_MSG_RESULT([yes])
385 ],[
386 JEMALLOC_USABLE_SIZE_CONST=
387 AC_MSG_RESULT([no])
388 ])
389])
Jason Evans247d1242012-10-09 16:20:10 -0700390AC_DEFINE_UNQUOTED([JEMALLOC_USABLE_SIZE_CONST], [$JEMALLOC_USABLE_SIZE_CONST])
Jason Evansb7924f52009-06-23 19:01:18 -0700391AC_SUBST([abi])
392AC_SUBST([RPATH])
Antony Dovgal2bd3cbc2011-10-13 09:33:33 +0400393AC_SUBST([LD_PRELOAD_VAR])
Jason Evansf576c632011-11-01 22:27:41 -0700394AC_SUBST([so])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200395AC_SUBST([importlib])
Mike Hommey5bee66d2012-04-16 16:30:24 +0200396AC_SUBST([o])
397AC_SUBST([a])
398AC_SUBST([exe])
Mike Hommeya19e87f2012-04-21 21:27:46 -0700399AC_SUBST([libprefix])
Mike Hommeyfa08da72012-04-16 16:30:25 +0200400AC_SUBST([DSO_LDFLAGS])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200401AC_SUBST([EXTRA_LDFLAGS])
Mike Hommey85221d52012-04-18 18:29:40 +0200402AC_SUBST([SOREV])
Mike Hommey188da7c2012-04-18 18:29:41 +0200403AC_SUBST([PIC_CFLAGS])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200404AC_SUBST([CTARGET])
405AC_SUBST([LDTARGET])
406AC_SUBST([MKLIB])
Jason Evans80ddf492013-08-20 11:48:19 +0100407AC_SUBST([ARFLAGS])
408AC_SUBST([AROUT])
Mike Hommey79c4bca2012-05-02 21:30:51 +0200409AC_SUBST([CC_MM])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200410
Jason Evansfa5d2452011-03-15 10:25:59 -0700411JE_COMPILABLE([__attribute__ syntax],
412 [static __attribute__((unused)) void foo(void){}],
413 [],
Jason Evans6684cac2012-03-05 12:15:36 -0800414 [je_cv_attribute])
415if test "x${je_cv_attribute}" = "xyes" ; then
Jason Evansfa5d2452011-03-15 10:25:59 -0700416 AC_DEFINE([JEMALLOC_HAVE_ATTR], [ ])
417 if test "x${GCC}" = "xyes" -a "x${abi}" = "xelf"; then
418 JE_CFLAGS_APPEND([-fvisibility=hidden])
419 fi
420fi
Jason Evans3cc1f1a2012-04-03 22:30:05 -0700421dnl Check for tls_model attribute support (clang 3.0 still lacks support).
422SAVED_CFLAGS="${CFLAGS}"
423JE_CFLAGS_APPEND([-Werror])
424JE_COMPILABLE([tls_model attribute], [],
425 [static __thread int
Daniel Micayf1cf3ea2014-09-16 04:42:33 -0400426 __attribute__((tls_model("initial-exec"), unused)) foo;
Jason Evans3cc1f1a2012-04-03 22:30:05 -0700427 foo = 0;],
428 [je_cv_tls_model])
429CFLAGS="${SAVED_CFLAGS}"
430if test "x${je_cv_tls_model}" = "xyes" ; then
431 AC_DEFINE([JEMALLOC_TLS_MODEL],
432 [__attribute__((tls_model("initial-exec")))])
433else
434 AC_DEFINE([JEMALLOC_TLS_MODEL], [ ])
435fi
Jason Evans0b8f0bc2015-07-10 16:41:12 -0700436dnl Check for alloc_size attribute support.
437SAVED_CFLAGS="${CFLAGS}"
438JE_CFLAGS_APPEND([-Werror])
Jason Evans92d72ee2015-07-10 16:45:32 -0700439JE_COMPILABLE([alloc_size attribute], [#include <stdlib.h>],
440 [void *foo(size_t size) __attribute__((alloc_size(1)));],
Jason Evans0b8f0bc2015-07-10 16:41:12 -0700441 [je_cv_alloc_size])
442CFLAGS="${SAVED_CFLAGS}"
443if test "x${je_cv_alloc_size}" = "xyes" ; then
444 AC_DEFINE([JEMALLOC_HAVE_ATTR_ALLOC_SIZE], [ ])
445fi
Jason Evanse42c3092015-07-22 15:44:47 -0700446dnl Check for format(gnu_printf, ...) attribute support.
447SAVED_CFLAGS="${CFLAGS}"
448JE_CFLAGS_APPEND([-Werror])
449JE_COMPILABLE([format(gnu_printf, ...) attribute], [#include <stdlib.h>],
450 [void *foo(const char *format, ...) __attribute__((format(gnu_printf, 1, 2)));],
451 [je_cv_format_gnu_printf])
452CFLAGS="${SAVED_CFLAGS}"
453if test "x${je_cv_format_gnu_printf}" = "xyes" ; then
454 AC_DEFINE([JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF], [ ])
455fi
456dnl Check for format(printf, ...) attribute support.
457SAVED_CFLAGS="${CFLAGS}"
458JE_CFLAGS_APPEND([-Werror])
459JE_COMPILABLE([format(printf, ...) attribute], [#include <stdlib.h>],
460 [void *foo(const char *format, ...) __attribute__((format(printf, 1, 2)));],
461 [je_cv_format_printf])
462CFLAGS="${SAVED_CFLAGS}"
463if test "x${je_cv_format_printf}" = "xyes" ; then
464 AC_DEFINE([JEMALLOC_HAVE_ATTR_FORMAT_PRINTF], [ ])
465fi
Jason Evansfa5d2452011-03-15 10:25:59 -0700466
Jason Evansb7924f52009-06-23 19:01:18 -0700467dnl Support optional additions to rpath.
468AC_ARG_WITH([rpath],
Jason Evans90895cf2009-12-29 00:09:15 -0800469 [AS_HELP_STRING([--with-rpath=<rpath>], [Colon-separated rpath (ELF systems only)])],
Jason Evansb7924f52009-06-23 19:01:18 -0700470if test "x$with_rpath" = "xno" ; then
471 RPATH_EXTRA=
472else
473 RPATH_EXTRA="`echo $with_rpath | tr \":\" \" \"`"
474fi,
475 RPATH_EXTRA=
476)
477AC_SUBST([RPATH_EXTRA])
478
479dnl Disable rules that do automatic regeneration of configure output by default.
480AC_ARG_ENABLE([autogen],
Jason Evans78d815c2010-01-17 14:06:20 -0800481 [AS_HELP_STRING([--enable-autogen], [Automatically regenerate configure output])],
Jason Evansb7924f52009-06-23 19:01:18 -0700482if test "x$enable_autogen" = "xno" ; then
483 enable_autogen="0"
484else
485 enable_autogen="1"
486fi
487,
488enable_autogen="0"
489)
490AC_SUBST([enable_autogen])
491
492AC_PROG_INSTALL
493AC_PROG_RANLIB
Jason Evans7329a4f2013-01-22 10:53:29 -0800494AC_PATH_PROG([LD], [ld], [false], [$PATH])
495AC_PATH_PROG([AUTOCONF], [autoconf], [false], [$PATH])
Jason Evansb7924f52009-06-23 19:01:18 -0700496
Daniel Micay4cfe5512014-08-28 15:41:48 -0400497public_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 -0800498
499dnl Check for allocator-related functions that should be wrapped.
500AC_CHECK_FUNC([memalign],
Jason Evanse24c7af2012-03-19 10:21:17 -0700501 [AC_DEFINE([JEMALLOC_OVERRIDE_MEMALIGN], [ ])
Jason Evans7e77eaf2012-03-02 17:47:37 -0800502 public_syms="${public_syms} memalign"])
503AC_CHECK_FUNC([valloc],
Jason Evanse24c7af2012-03-19 10:21:17 -0700504 [AC_DEFINE([JEMALLOC_OVERRIDE_VALLOC], [ ])
Jason Evans7e77eaf2012-03-02 17:47:37 -0800505 public_syms="${public_syms} valloc"])
506
Jason Evans748dfac2013-12-06 18:27:33 -0800507dnl Do not compute test code coverage by default.
508GCOV_FLAGS=
509AC_ARG_ENABLE([code-coverage],
510 [AS_HELP_STRING([--enable-code-coverage],
511 [Enable code coverage])],
512[if test "x$enable_code_coverage" = "xno" ; then
513 enable_code_coverage="0"
514else
515 enable_code_coverage="1"
516fi
517],
518[enable_code_coverage="0"]
519)
520if test "x$enable_code_coverage" = "x1" ; then
521 deoptimize="no"
522 echo "$CFLAGS $EXTRA_CFLAGS" | grep '\-O' >/dev/null || deoptimize="yes"
523 if test "x${deoptimize}" = "xyes" ; then
524 JE_CFLAGS_APPEND([-O0])
525 fi
526 JE_CFLAGS_APPEND([-fprofile-arcs -ftest-coverage])
527 EXTRA_LDFLAGS="$EXTRA_LDFLAGS -fprofile-arcs -ftest-coverage"
528 AC_DEFINE([JEMALLOC_CODE_COVERAGE], [ ])
529fi
530AC_SUBST([enable_code_coverage])
531
Jason Evans0a5489e2012-03-01 17:19:20 -0800532dnl Perform no name mangling by default.
533AC_ARG_WITH([mangling],
534 [AS_HELP_STRING([--with-mangling=<map>], [Mangle symbols in <map>])],
535 [mangling_map="$with_mangling"], [mangling_map=""])
Jason Evans0a5489e2012-03-01 17:19:20 -0800536
Jason Evans90895cf2009-12-29 00:09:15 -0800537dnl Do not prefix public APIs by default.
538AC_ARG_WITH([jemalloc_prefix],
539 [AS_HELP_STRING([--with-jemalloc-prefix=<prefix>], [Prefix to prepend to all public APIs])],
Jason Evansb0fd5012010-01-17 01:49:20 -0800540 [JEMALLOC_PREFIX="$with_jemalloc_prefix"],
Mike Hommey7cdea392012-04-30 12:38:27 +0200541 [if test "x$abi" != "xmacho" -a "x$abi" != "xpecoff"; then
Jason Evans2dbecf12010-09-05 10:35:13 -0700542 JEMALLOC_PREFIX=""
543else
544 JEMALLOC_PREFIX="je_"
545fi]
Jason Evans90895cf2009-12-29 00:09:15 -0800546)
547if test "x$JEMALLOC_PREFIX" != "x" ; then
Jason Evanse7339702010-10-23 18:37:06 -0700548 JEMALLOC_CPREFIX=`echo ${JEMALLOC_PREFIX} | tr "a-z" "A-Z"`
549 AC_DEFINE_UNQUOTED([JEMALLOC_PREFIX], ["$JEMALLOC_PREFIX"])
550 AC_DEFINE_UNQUOTED([JEMALLOC_CPREFIX], ["$JEMALLOC_CPREFIX"])
Jason Evans90895cf2009-12-29 00:09:15 -0800551fi
Jason Evans241abc62015-06-23 18:47:07 -0700552AC_SUBST([JEMALLOC_CPREFIX])
Jason Evans90895cf2009-12-29 00:09:15 -0800553
Mike Hommey99066602012-11-19 10:55:26 +0100554AC_ARG_WITH([export],
555 [AS_HELP_STRING([--without-export], [disable exporting jemalloc public APIs])],
556 [if test "x$with_export" = "xno"; then
Jason Evans2625c892013-01-22 16:46:27 -0800557 AC_DEFINE([JEMALLOC_EXPORT],[])
Mike Hommey99066602012-11-19 10:55:26 +0100558fi]
559)
560
Jason Evans86abd0d2013-11-30 15:25:42 -0800561dnl Mangle library-private APIs.
Jason Evans746e77a2011-07-30 16:40:52 -0700562AC_ARG_WITH([private_namespace],
563 [AS_HELP_STRING([--with-private-namespace=<prefix>], [Prefix to prepend to all library-private APIs])],
Jason Evans86abd0d2013-11-30 15:25:42 -0800564 [JEMALLOC_PRIVATE_NAMESPACE="${with_private_namespace}je_"],
565 [JEMALLOC_PRIVATE_NAMESPACE="je_"]
Jason Evans746e77a2011-07-30 16:40:52 -0700566)
Jason Evans86abd0d2013-11-30 15:25:42 -0800567AC_DEFINE_UNQUOTED([JEMALLOC_PRIVATE_NAMESPACE], [$JEMALLOC_PRIVATE_NAMESPACE])
568private_namespace="$JEMALLOC_PRIVATE_NAMESPACE"
569AC_SUBST([private_namespace])
Jason Evans746e77a2011-07-30 16:40:52 -0700570
Jason Evansb0fd5012010-01-17 01:49:20 -0800571dnl Do not add suffix to installed files by default.
572AC_ARG_WITH([install_suffix],
573 [AS_HELP_STRING([--with-install-suffix=<suffix>], [Suffix to append to all installed files])],
574 [INSTALL_SUFFIX="$with_install_suffix"],
575 [INSTALL_SUFFIX=]
576)
577install_suffix="$INSTALL_SUFFIX"
578AC_SUBST([install_suffix])
579
Jason Evans86abd0d2013-11-30 15:25:42 -0800580dnl Substitute @je_@ in jemalloc_protos.h.in, primarily to make generation of
581dnl jemalloc_protos_jet.h easy.
582je_="je_"
583AC_SUBST([je_])
584
Mike Hommeycf6032d2014-07-30 18:16:13 +0900585cfgoutputs_in="Makefile.in"
Nick White913e9a82014-09-19 22:01:23 +0100586cfgoutputs_in="${cfgoutputs_in} jemalloc.pc.in"
Mike Hommeycf6032d2014-07-30 18:16:13 +0900587cfgoutputs_in="${cfgoutputs_in} doc/html.xsl.in"
588cfgoutputs_in="${cfgoutputs_in} doc/manpages.xsl.in"
589cfgoutputs_in="${cfgoutputs_in} doc/jemalloc.xml.in"
590cfgoutputs_in="${cfgoutputs_in} include/jemalloc/jemalloc_macros.h.in"
591cfgoutputs_in="${cfgoutputs_in} include/jemalloc/jemalloc_protos.h.in"
Jason Evans82e88d12014-09-07 19:55:03 -0700592cfgoutputs_in="${cfgoutputs_in} include/jemalloc/jemalloc_typedefs.h.in"
Mike Hommeycf6032d2014-07-30 18:16:13 +0900593cfgoutputs_in="${cfgoutputs_in} include/jemalloc/internal/jemalloc_internal.h.in"
594cfgoutputs_in="${cfgoutputs_in} test/test.sh.in"
595cfgoutputs_in="${cfgoutputs_in} test/include/test/jemalloc_test.h.in"
Jason Evansb0fd5012010-01-17 01:49:20 -0800596
Jason Evansaee7fd22010-11-24 22:00:02 -0800597cfgoutputs_out="Makefile"
Nick White913e9a82014-09-19 22:01:23 +0100598cfgoutputs_out="${cfgoutputs_out} jemalloc.pc"
Jason Evansaee7fd22010-11-24 22:00:02 -0800599cfgoutputs_out="${cfgoutputs_out} doc/html.xsl"
600cfgoutputs_out="${cfgoutputs_out} doc/manpages.xsl"
Jason Evans86abd0d2013-11-30 15:25:42 -0800601cfgoutputs_out="${cfgoutputs_out} doc/jemalloc.xml"
602cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_macros.h"
603cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_protos.h"
Jason Evans82e88d12014-09-07 19:55:03 -0700604cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_typedefs.h"
Jason Evans376b1522010-02-11 14:45:59 -0800605cfgoutputs_out="${cfgoutputs_out} include/jemalloc/internal/jemalloc_internal.h"
Jason Evans86abd0d2013-11-30 15:25:42 -0800606cfgoutputs_out="${cfgoutputs_out} test/test.sh"
607cfgoutputs_out="${cfgoutputs_out} test/include/test/jemalloc_test.h"
Jason Evansb0fd5012010-01-17 01:49:20 -0800608
Jason Evansaee7fd22010-11-24 22:00:02 -0800609cfgoutputs_tup="Makefile"
Nick White913e9a82014-09-19 22:01:23 +0100610cfgoutputs_tup="${cfgoutputs_tup} jemalloc.pc:jemalloc.pc.in"
Jason Evansaee7fd22010-11-24 22:00:02 -0800611cfgoutputs_tup="${cfgoutputs_tup} doc/html.xsl:doc/html.xsl.in"
612cfgoutputs_tup="${cfgoutputs_tup} doc/manpages.xsl:doc/manpages.xsl.in"
Jason Evans86abd0d2013-11-30 15:25:42 -0800613cfgoutputs_tup="${cfgoutputs_tup} doc/jemalloc.xml:doc/jemalloc.xml.in"
614cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_macros.h:include/jemalloc/jemalloc_macros.h.in"
615cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_protos.h:include/jemalloc/jemalloc_protos.h.in"
Jason Evans82e88d12014-09-07 19:55:03 -0700616cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_typedefs.h:include/jemalloc/jemalloc_typedefs.h.in"
Jason Evans376b1522010-02-11 14:45:59 -0800617cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/internal/jemalloc_internal.h"
Jason Evans86abd0d2013-11-30 15:25:42 -0800618cfgoutputs_tup="${cfgoutputs_tup} test/test.sh:test/test.sh.in"
619cfgoutputs_tup="${cfgoutputs_tup} test/include/test/jemalloc_test.h:test/include/test/jemalloc_test.h.in"
Jason Evansb0fd5012010-01-17 01:49:20 -0800620
Mike Hommeycf6032d2014-07-30 18:16:13 +0900621cfghdrs_in="include/jemalloc/jemalloc_defs.h.in"
622cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/jemalloc_internal_defs.h.in"
623cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/private_namespace.sh"
624cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/private_unnamespace.sh"
625cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/private_symbols.txt"
626cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/public_namespace.sh"
627cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/public_unnamespace.sh"
628cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/size_classes.sh"
629cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc_rename.sh"
630cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc_mangle.sh"
631cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc.sh"
632cfghdrs_in="${cfghdrs_in} test/include/test/jemalloc_test_defs.h.in"
Jason Evansb0fd5012010-01-17 01:49:20 -0800633
Jason Evans86abd0d2013-11-30 15:25:42 -0800634cfghdrs_out="include/jemalloc/jemalloc_defs.h"
635cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc${install_suffix}.h"
Jason Evans86abd0d2013-11-30 15:25:42 -0800636cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/private_namespace.h"
637cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/private_unnamespace.h"
Jason Evansf234dc52014-01-16 17:38:01 -0800638cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_symbols.txt"
Jason Evans86abd0d2013-11-30 15:25:42 -0800639cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_namespace.h"
640cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_unnamespace.h"
Jason Evansb1726102012-02-28 16:50:47 -0800641cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/size_classes.h"
Jason Evansf234dc52014-01-16 17:38:01 -0800642cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_protos_jet.h"
643cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_rename.h"
644cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_mangle.h"
645cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_mangle_jet.h"
646cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/jemalloc_internal_defs.h"
Jason Evans80061b62013-12-09 13:21:08 -0800647cfghdrs_out="${cfghdrs_out} test/include/test/jemalloc_test_defs.h"
Jason Evansb0fd5012010-01-17 01:49:20 -0800648
Jason Evans86abd0d2013-11-30 15:25:42 -0800649cfghdrs_tup="include/jemalloc/jemalloc_defs.h:include/jemalloc/jemalloc_defs.h.in"
Mike Hommeycf6032d2014-07-30 18:16:13 +0900650cfghdrs_tup="${cfghdrs_tup} include/jemalloc/internal/jemalloc_internal_defs.h:include/jemalloc/internal/jemalloc_internal_defs.h.in"
651cfghdrs_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 -0800652
Jason Evans644d4142014-04-14 22:49:23 -0700653dnl Silence irrelevant compiler warnings by default.
Jason Evans355b4382010-09-20 19:20:48 -0700654AC_ARG_ENABLE([cc-silence],
Jason Evans644d4142014-04-14 22:49:23 -0700655 [AS_HELP_STRING([--disable-cc-silence],
656 [Do not silence irrelevant compiler warnings])],
Jason Evans355b4382010-09-20 19:20:48 -0700657[if test "x$enable_cc_silence" = "xno" ; then
658 enable_cc_silence="0"
659else
660 enable_cc_silence="1"
661fi
662],
Jason Evans644d4142014-04-14 22:49:23 -0700663[enable_cc_silence="1"]
Jason Evans355b4382010-09-20 19:20:48 -0700664)
665if test "x$enable_cc_silence" = "x1" ; then
Jason Evanse24c7af2012-03-19 10:21:17 -0700666 AC_DEFINE([JEMALLOC_CC_SILENCE], [ ])
Jason Evans355b4382010-09-20 19:20:48 -0700667fi
668
Jason Evansb7924f52009-06-23 19:01:18 -0700669dnl Do not compile with debugging by default.
670AC_ARG_ENABLE([debug],
Jason Evanse0a08a12015-03-18 21:06:58 -0700671 [AS_HELP_STRING([--enable-debug],
672 [Build debugging code (implies --enable-ivsalloc)])],
Jason Evansb7924f52009-06-23 19:01:18 -0700673[if test "x$enable_debug" = "xno" ; then
674 enable_debug="0"
675else
676 enable_debug="1"
677fi
678],
679[enable_debug="0"]
680)
Jason Evans02e5dcf2015-02-15 20:12:06 -0800681if test "x$enable_debug" = "x1" ; then
682 AC_DEFINE([JEMALLOC_DEBUG], [ ])
683fi
Jason Evanse0a08a12015-03-18 21:06:58 -0700684if test "x$enable_debug" = "x1" ; then
685 AC_DEFINE([JEMALLOC_DEBUG], [ ])
686 enable_ivsalloc="1"
687fi
Jason Evansb7924f52009-06-23 19:01:18 -0700688AC_SUBST([enable_debug])
689
Jason Evanse0a08a12015-03-18 21:06:58 -0700690dnl Do not validate pointers by default.
691AC_ARG_ENABLE([ivsalloc],
692 [AS_HELP_STRING([--enable-ivsalloc],
693 [Validate pointers passed through the public API])],
694[if test "x$enable_ivsalloc" = "xno" ; then
695 enable_ivsalloc="0"
696else
697 enable_ivsalloc="1"
698fi
699],
700[enable_ivsalloc="0"]
701)
702if test "x$enable_ivsalloc" = "x1" ; then
703 AC_DEFINE([JEMALLOC_IVSALLOC], [ ])
704fi
705
Jason Evansb7924f52009-06-23 19:01:18 -0700706dnl Only optimize if not debugging.
707if test "x$enable_debug" = "x0" -a "x$no_CFLAGS" = "xyes" ; then
708 dnl Make sure that an optimization flag was not specified in EXTRA_CFLAGS.
Jason Evansf3340ca2009-06-30 16:17:05 -0700709 optimize="no"
Jason Evans748dfac2013-12-06 18:27:33 -0800710 echo "$CFLAGS $EXTRA_CFLAGS" | grep '\-O' >/dev/null || optimize="yes"
Jason Evansf3340ca2009-06-30 16:17:05 -0700711 if test "x${optimize}" = "xyes" ; then
712 if test "x$GCC" = "xyes" ; then
713 JE_CFLAGS_APPEND([-O3])
714 JE_CFLAGS_APPEND([-funroll-loops])
Mike Hommeyfd97b1d2012-04-30 12:38:31 +0200715 elif test "x$je_cv_msvc" = "xyes" ; then
716 JE_CFLAGS_APPEND([-O2])
Jason Evansf3340ca2009-06-30 16:17:05 -0700717 else
718 JE_CFLAGS_APPEND([-O])
719 fi
Jason Evansb7924f52009-06-23 19:01:18 -0700720 fi
721fi
722
Jason Evansd073a322012-02-28 20:41:16 -0800723dnl Enable statistics calculation by default.
Jason Evansb7924f52009-06-23 19:01:18 -0700724AC_ARG_ENABLE([stats],
Jason Evans777c1912012-02-28 20:49:22 -0800725 [AS_HELP_STRING([--disable-stats],
726 [Disable statistics calculation/reporting])],
Jason Evansb7924f52009-06-23 19:01:18 -0700727[if test "x$enable_stats" = "xno" ; then
728 enable_stats="0"
729else
730 enable_stats="1"
731fi
732],
Jason Evansd073a322012-02-28 20:41:16 -0800733[enable_stats="1"]
Jason Evansb7924f52009-06-23 19:01:18 -0700734)
735if test "x$enable_stats" = "x1" ; then
736 AC_DEFINE([JEMALLOC_STATS], [ ])
737fi
738AC_SUBST([enable_stats])
739
Jason Evans6109fe02010-02-10 10:37:56 -0800740dnl Do not enable profiling by default.
741AC_ARG_ENABLE([prof],
742 [AS_HELP_STRING([--enable-prof], [Enable allocation profiling])],
743[if test "x$enable_prof" = "xno" ; then
744 enable_prof="0"
745else
746 enable_prof="1"
747fi
748],
749[enable_prof="0"]
750)
Jason Evans77f350b2011-03-15 22:23:12 -0700751if test "x$enable_prof" = "x1" ; then
752 backtrace_method=""
Jason Evansb27805b2010-02-10 18:15:53 -0800753else
Jason Evans77f350b2011-03-15 22:23:12 -0700754 backtrace_method="N/A"
Jason Evansb27805b2010-02-10 18:15:53 -0800755fi
Jason Evans77f350b2011-03-15 22:23:12 -0700756
Jason Evans6109fe02010-02-10 10:37:56 -0800757AC_ARG_ENABLE([prof-libunwind],
758 [AS_HELP_STRING([--enable-prof-libunwind], [Use libunwind for backtracing])],
759[if test "x$enable_prof_libunwind" = "xno" ; then
760 enable_prof_libunwind="0"
761else
762 enable_prof_libunwind="1"
763fi
764],
765[enable_prof_libunwind="0"]
766)
Jason Evansca6bd4f2010-03-02 14:12:58 -0800767AC_ARG_WITH([static_libunwind],
768 [AS_HELP_STRING([--with-static-libunwind=<libunwind.a>],
769 [Path to static libunwind library; use rather than dynamically linking])],
770if test "x$with_static_libunwind" = "xno" ; then
771 LUNWIND="-lunwind"
772else
773 if test ! -f "$with_static_libunwind" ; then
774 AC_MSG_ERROR([Static libunwind not found: $with_static_libunwind])
775 fi
776 LUNWIND="$with_static_libunwind"
777fi,
778 LUNWIND="-lunwind"
779)
Jason Evans77f350b2011-03-15 22:23:12 -0700780if test "x$backtrace_method" = "x" -a "x$enable_prof_libunwind" = "x1" ; then
781 AC_CHECK_HEADERS([libunwind.h], , [enable_prof_libunwind="0"])
782 if test "x$LUNWIND" = "x-lunwind" ; then
Jason Evans05125b82014-04-22 20:48:07 -0700783 AC_CHECK_LIB([unwind], [unw_backtrace], [LIBS="$LIBS $LUNWIND"],
Jason Evans77f350b2011-03-15 22:23:12 -0700784 [enable_prof_libunwind="0"])
785 else
786 LIBS="$LIBS $LUNWIND"
787 fi
788 if test "x${enable_prof_libunwind}" = "x1" ; then
789 backtrace_method="libunwind"
790 AC_DEFINE([JEMALLOC_PROF_LIBUNWIND], [ ])
791 fi
792fi
793
794AC_ARG_ENABLE([prof-libgcc],
795 [AS_HELP_STRING([--disable-prof-libgcc],
796 [Do not use libgcc for backtracing])],
797[if test "x$enable_prof_libgcc" = "xno" ; then
798 enable_prof_libgcc="0"
799else
800 enable_prof_libgcc="1"
801fi
802],
803[enable_prof_libgcc="1"]
804)
805if test "x$backtrace_method" = "x" -a "x$enable_prof_libgcc" = "x1" \
806 -a "x$GCC" = "xyes" ; then
807 AC_CHECK_HEADERS([unwind.h], , [enable_prof_libgcc="0"])
808 AC_CHECK_LIB([gcc], [_Unwind_Backtrace], [LIBS="$LIBS -lgcc"], [enable_prof_libgcc="0"])
Jason Evans77f350b2011-03-15 22:23:12 -0700809 if test "x${enable_prof_libgcc}" = "x1" ; then
810 backtrace_method="libgcc"
811 AC_DEFINE([JEMALLOC_PROF_LIBGCC], [ ])
812 fi
813else
814 enable_prof_libgcc="0"
815fi
816
817AC_ARG_ENABLE([prof-gcc],
818 [AS_HELP_STRING([--disable-prof-gcc],
819 [Do not use gcc intrinsics for backtracing])],
820[if test "x$enable_prof_gcc" = "xno" ; then
821 enable_prof_gcc="0"
822else
823 enable_prof_gcc="1"
824fi
825],
826[enable_prof_gcc="1"]
827)
828if test "x$backtrace_method" = "x" -a "x$enable_prof_gcc" = "x1" \
829 -a "x$GCC" = "xyes" ; then
Jason Evanse181f5a2014-03-30 18:58:32 -0700830 JE_CFLAGS_APPEND([-fno-omit-frame-pointer])
Jason Evans77f350b2011-03-15 22:23:12 -0700831 backtrace_method="gcc intrinsics"
832 AC_DEFINE([JEMALLOC_PROF_GCC], [ ])
833else
834 enable_prof_gcc="0"
835fi
836
837if test "x$backtrace_method" = "x" ; then
838 backtrace_method="none (disabling profiling)"
839 enable_prof="0"
840fi
841AC_MSG_CHECKING([configured backtracing method])
842AC_MSG_RESULT([$backtrace_method])
Jason Evans2dbecf12010-09-05 10:35:13 -0700843if test "x$enable_prof" = "x1" ; then
Jason Evansd37d5ad2013-12-05 23:01:50 -0800844 if test "x$abi" != "xpecoff"; then
845 dnl Heap profiling uses the log(3) function.
846 LIBS="$LIBS -lm"
847 fi
848
Jason Evans2dbecf12010-09-05 10:35:13 -0700849 AC_DEFINE([JEMALLOC_PROF], [ ])
Jason Evans2dbecf12010-09-05 10:35:13 -0700850fi
851AC_SUBST([enable_prof])
Jason Evans2dbecf12010-09-05 10:35:13 -0700852
Jason Evans84cbbcb2009-12-29 00:09:15 -0800853dnl Enable thread-specific caching by default.
854AC_ARG_ENABLE([tcache],
855 [AS_HELP_STRING([--disable-tcache], [Disable per thread caches])],
856[if test "x$enable_tcache" = "xno" ; then
857 enable_tcache="0"
Jason Evansb7924f52009-06-23 19:01:18 -0700858else
Jason Evans84cbbcb2009-12-29 00:09:15 -0800859 enable_tcache="1"
Jason Evansb7924f52009-06-23 19:01:18 -0700860fi
861],
Jason Evans84cbbcb2009-12-29 00:09:15 -0800862[enable_tcache="1"]
Jason Evansb7924f52009-06-23 19:01:18 -0700863)
Jason Evans2dbecf12010-09-05 10:35:13 -0700864if test "x$enable_tcache" = "x1" ; then
865 AC_DEFINE([JEMALLOC_TCACHE], [ ])
866fi
867AC_SUBST([enable_tcache])
Jason Evansb7924f52009-06-23 19:01:18 -0700868
Jason Evansd059b9d2015-07-24 18:21:42 -0700869dnl Indicate whether adjacent virtual memory mappings automatically coalesce
870dnl (and fragment on demand).
871if test "x${maps_coalesce}" = "x1" ; then
872 AC_DEFINE([JEMALLOC_MAPS_COALESCE], [ ])
873fi
874
Jason Evans59ae2762012-04-16 17:52:27 -0700875dnl Enable VM deallocation via munmap() by default.
876AC_ARG_ENABLE([munmap],
877 [AS_HELP_STRING([--disable-munmap], [Disable VM deallocation via munmap(2)])],
878[if test "x$enable_munmap" = "xno" ; then
879 enable_munmap="0"
880else
881 enable_munmap="1"
882fi
883],
884[enable_munmap="${default_munmap}"]
885)
886if test "x$enable_munmap" = "x1" ; then
887 AC_DEFINE([JEMALLOC_MUNMAP], [ ])
888fi
889AC_SUBST([enable_munmap])
890
Jason Evans4d434ad2014-04-15 12:09:48 -0700891dnl Enable allocation from DSS if supported by the OS.
892have_dss="1"
Mike Hommey83c324a2012-04-12 10:13:03 +0200893dnl Check whether the BSD/SUSv1 sbrk() exists. If not, disable DSS support.
894AC_CHECK_FUNC([sbrk], [have_sbrk="1"], [have_sbrk="0"])
895if test "x$have_sbrk" = "x1" ; then
Steven Stewart-Gallus79230fe2014-06-19 16:11:43 -0700896 if test "x$sbrk_deprecated" = "x1" ; then
Jason Evans66688532013-12-03 21:49:36 -0800897 AC_MSG_RESULT([Disabling dss allocation because sbrk is deprecated])
Jason Evans4d434ad2014-04-15 12:09:48 -0700898 have_dss="0"
Jason Evans66688532013-12-03 21:49:36 -0800899 fi
Mike Hommey83c324a2012-04-12 10:13:03 +0200900else
Jason Evans4d434ad2014-04-15 12:09:48 -0700901 have_dss="0"
Mike Hommey83c324a2012-04-12 10:13:03 +0200902fi
903
Jason Evans4d434ad2014-04-15 12:09:48 -0700904if test "x$have_dss" = "x1" ; then
Jason Evansb7924f52009-06-23 19:01:18 -0700905 AC_DEFINE([JEMALLOC_DSS], [ ])
906fi
Jason Evansb7924f52009-06-23 19:01:18 -0700907
Jason Evans777c1912012-02-28 20:49:22 -0800908dnl Support the junk/zero filling option by default.
Jason Evansb7924f52009-06-23 19:01:18 -0700909AC_ARG_ENABLE([fill],
Jason Evans122449b2012-04-06 00:35:09 -0700910 [AS_HELP_STRING([--disable-fill],
911 [Disable support for junk/zero filling, quarantine, and redzones])],
Jason Evansb7924f52009-06-23 19:01:18 -0700912[if test "x$enable_fill" = "xno" ; then
913 enable_fill="0"
914else
915 enable_fill="1"
916fi
917],
Jason Evans777c1912012-02-28 20:49:22 -0800918[enable_fill="1"]
Jason Evansb7924f52009-06-23 19:01:18 -0700919)
920if test "x$enable_fill" = "x1" ; then
921 AC_DEFINE([JEMALLOC_FILL], [ ])
922fi
923AC_SUBST([enable_fill])
924
Jason Evansb1476112012-04-05 13:36:17 -0700925dnl Disable utrace(2)-based tracing by default.
926AC_ARG_ENABLE([utrace],
927 [AS_HELP_STRING([--enable-utrace], [Enable utrace(2)-based tracing])],
928[if test "x$enable_utrace" = "xno" ; then
929 enable_utrace="0"
930else
931 enable_utrace="1"
932fi
933],
934[enable_utrace="0"]
935)
936JE_COMPILABLE([utrace(2)], [
937#include <sys/types.h>
938#include <sys/param.h>
939#include <sys/time.h>
940#include <sys/uio.h>
941#include <sys/ktrace.h>
942], [
943 utrace((void *)0, 0);
944], [je_cv_utrace])
945if test "x${je_cv_utrace}" = "xno" ; then
946 enable_utrace="0"
947fi
948if test "x$enable_utrace" = "x1" ; then
949 AC_DEFINE([JEMALLOC_UTRACE], [ ])
950fi
951AC_SUBST([enable_utrace])
952
Jason Evans122449b2012-04-06 00:35:09 -0700953dnl Support Valgrind by default.
954AC_ARG_ENABLE([valgrind],
955 [AS_HELP_STRING([--disable-valgrind], [Disable support for Valgrind])],
956[if test "x$enable_valgrind" = "xno" ; then
957 enable_valgrind="0"
958else
959 enable_valgrind="1"
960fi
961],
962[enable_valgrind="1"]
963)
964if test "x$enable_valgrind" = "x1" ; then
965 JE_COMPILABLE([valgrind], [
966#include <valgrind/valgrind.h>
967#include <valgrind/memcheck.h>
968
Mike Hommey7bfecf42012-04-30 15:15:15 +0200969#if !defined(VALGRIND_RESIZEINPLACE_BLOCK)
Jason Evans122449b2012-04-06 00:35:09 -0700970# error "Incompatible Valgrind version"
971#endif
972], [], [je_cv_valgrind])
973 if test "x${je_cv_valgrind}" = "xno" ; then
974 enable_valgrind="0"
975 fi
976 if test "x$enable_valgrind" = "x1" ; then
977 AC_DEFINE([JEMALLOC_VALGRIND], [ ])
978 fi
979fi
980AC_SUBST([enable_valgrind])
981
Jason Evansb7924f52009-06-23 19:01:18 -0700982dnl Do not support the xmalloc option by default.
983AC_ARG_ENABLE([xmalloc],
984 [AS_HELP_STRING([--enable-xmalloc], [Support xmalloc option])],
985[if test "x$enable_xmalloc" = "xno" ; then
986 enable_xmalloc="0"
987else
988 enable_xmalloc="1"
989fi
990],
991[enable_xmalloc="0"]
992)
993if test "x$enable_xmalloc" = "x1" ; then
994 AC_DEFINE([JEMALLOC_XMALLOC], [ ])
995fi
996AC_SUBST([enable_xmalloc])
997
Jason Evans8a03cf02015-05-04 09:58:36 -0700998dnl Support cache-oblivious allocation alignment by default.
999AC_ARG_ENABLE([cache-oblivious],
1000 [AS_HELP_STRING([--disable-cache-oblivious],
1001 [Disable support for cache-oblivious allocation alignment])],
1002[if test "x$enable_cache_oblivious" = "xno" ; then
1003 enable_cache_oblivious="0"
1004else
1005 enable_cache_oblivious="1"
1006fi
1007],
1008[enable_cache_oblivious="1"]
1009)
1010if test "x$enable_cache_oblivious" = "x1" ; then
1011 AC_DEFINE([JEMALLOC_CACHE_OBLIVIOUS], [ ])
1012fi
1013AC_SUBST([enable_cache_oblivious])
1014
Mike Hommey8f50ec82014-06-04 12:12:55 +09001015dnl ============================================================================
1016dnl Check for __builtin_ffsl(), then ffsl(3), and fail if neither are found.
1017dnl One of those two functions should (theoretically) exist on all platforms
1018dnl that jemalloc currently has a chance of functioning on without modification.
1019dnl We additionally assume ffs() or __builtin_ffs() are defined if
1020dnl ffsl() or __builtin_ffsl() are defined, respectively.
1021JE_COMPILABLE([a program using __builtin_ffsl], [
1022#include <stdio.h>
1023#include <strings.h>
1024#include <string.h>
1025], [
1026 {
1027 int rv = __builtin_ffsl(0x08);
1028 printf("%d\n", rv);
1029 }
1030], [je_cv_gcc_builtin_ffsl])
Steven Stewart-Gallus79230fe2014-06-19 16:11:43 -07001031if test "x${je_cv_gcc_builtin_ffsl}" = "xyes" ; then
Mike Hommey8f50ec82014-06-04 12:12:55 +09001032 AC_DEFINE([JEMALLOC_INTERNAL_FFSL], [__builtin_ffsl])
1033 AC_DEFINE([JEMALLOC_INTERNAL_FFS], [__builtin_ffs])
1034else
1035 JE_COMPILABLE([a program using ffsl], [
1036 #include <stdio.h>
1037 #include <strings.h>
1038 #include <string.h>
1039 ], [
1040 {
1041 int rv = ffsl(0x08);
1042 printf("%d\n", rv);
1043 }
1044 ], [je_cv_function_ffsl])
Steven Stewart-Gallus79230fe2014-06-19 16:11:43 -07001045 if test "x${je_cv_function_ffsl}" = "xyes" ; then
Mike Hommey8f50ec82014-06-04 12:12:55 +09001046 AC_DEFINE([JEMALLOC_INTERNAL_FFSL], [ffsl])
1047 AC_DEFINE([JEMALLOC_INTERNAL_FFS], [ffs])
1048 else
1049 AC_MSG_ERROR([Cannot build without ffsl(3) or __builtin_ffsl()])
1050 fi
1051fi
1052
Jason Evans81e54752014-10-10 22:34:25 -07001053AC_ARG_WITH([lg_tiny_min],
1054 [AS_HELP_STRING([--with-lg-tiny-min=<lg-tiny-min>],
1055 [Base 2 log of minimum tiny size class to support])],
1056 [LG_TINY_MIN="$with_lg_tiny_min"],
1057 [LG_TINY_MIN="3"])
1058AC_DEFINE_UNQUOTED([LG_TINY_MIN], [$LG_TINY_MIN])
1059
Jason Evansfc0b3b72014-10-09 17:54:06 -07001060AC_ARG_WITH([lg_quantum],
1061 [AS_HELP_STRING([--with-lg-quantum=<lg-quantum>],
1062 [Base 2 log of minimum allocation alignment])],
Jason Evans81e54752014-10-10 22:34:25 -07001063 [LG_QUANTA="$with_lg_quantum"],
1064 [LG_QUANTA="3 4"])
1065if test "x$with_lg_quantum" != "x" ; then
1066 AC_DEFINE_UNQUOTED([LG_QUANTUM], [$with_lg_quantum])
1067fi
Jason Evansfc0b3b72014-10-09 17:54:06 -07001068
1069AC_ARG_WITH([lg_page],
1070 [AS_HELP_STRING([--with-lg-page=<lg-page>], [Base 2 log of system page size])],
1071 [LG_PAGE="$with_lg_page"], [LG_PAGE="detect"])
Jason Evansb0808d52015-02-03 12:39:31 -08001072if test "x$LG_PAGE" = "xdetect"; then
Jason Evansfc0b3b72014-10-09 17:54:06 -07001073 AC_CACHE_CHECK([LG_PAGE],
1074 [je_cv_lg_page],
Jason Evans6684cac2012-03-05 12:15:36 -08001075 AC_RUN_IFELSE([AC_LANG_PROGRAM(
Mike Hommeya19e87f2012-04-21 21:27:46 -07001076[[
Mike Hommeyfd97b1d2012-04-30 12:38:31 +02001077#include <strings.h>
Mike Hommeya19e87f2012-04-21 21:27:46 -07001078#ifdef _WIN32
1079#include <windows.h>
1080#else
Jason Evansb7924f52009-06-23 19:01:18 -07001081#include <unistd.h>
Mike Hommeya19e87f2012-04-21 21:27:46 -07001082#endif
1083#include <stdio.h>
Jason Evans6684cac2012-03-05 12:15:36 -08001084]],
1085[[
Garrett Cooper72c1e592012-12-02 17:57:28 -08001086 int result;
Jason Evansb7924f52009-06-23 19:01:18 -07001087 FILE *f;
1088
Mike Hommeya19e87f2012-04-21 21:27:46 -07001089#ifdef _WIN32
1090 SYSTEM_INFO si;
1091 GetSystemInfo(&si);
1092 result = si.dwPageSize;
1093#else
Jason Evansb7924f52009-06-23 19:01:18 -07001094 result = sysconf(_SC_PAGESIZE);
Mike Hommeya19e87f2012-04-21 21:27:46 -07001095#endif
Jason Evansb7924f52009-06-23 19:01:18 -07001096 if (result == -1) {
1097 return 1;
1098 }
Mike Hommey8f50ec82014-06-04 12:12:55 +09001099 result = JEMALLOC_INTERNAL_FFSL(result) - 1;
Mike Hommeya19e87f2012-04-21 21:27:46 -07001100
Jason Evansb7924f52009-06-23 19:01:18 -07001101 f = fopen("conftest.out", "w");
1102 if (f == NULL) {
1103 return 1;
1104 }
Garrett Cooper72c1e592012-12-02 17:57:28 -08001105 fprintf(f, "%d\n", result);
Jason Evans3cc1f1a2012-04-03 22:30:05 -07001106 fclose(f);
Jason Evansb7924f52009-06-23 19:01:18 -07001107
1108 return 0;
1109]])],
Jason Evansfc0b3b72014-10-09 17:54:06 -07001110 [je_cv_lg_page=`cat conftest.out`],
1111 [je_cv_lg_page=undefined],
1112 [je_cv_lg_page=12]))
Jason Evans6684cac2012-03-05 12:15:36 -08001113fi
Jason Evansfc0b3b72014-10-09 17:54:06 -07001114if test "x${je_cv_lg_page}" != "x" ; then
1115 LG_PAGE="${je_cv_lg_page}"
1116fi
1117if test "x${LG_PAGE}" != "xundefined" ; then
1118 AC_DEFINE_UNQUOTED([LG_PAGE], [$LG_PAGE])
1119else
1120 AC_MSG_ERROR([cannot determine value for LG_PAGE])
1121fi
1122
1123AC_ARG_WITH([lg_page_sizes],
1124 [AS_HELP_STRING([--with-lg-page-sizes=<lg-page-sizes>],
1125 [Base 2 logs of system page sizes to support])],
1126 [LG_PAGE_SIZES="$with_lg_page_sizes"], [LG_PAGE_SIZES="$LG_PAGE"])
1127
1128AC_ARG_WITH([lg_size_class_group],
1129 [AS_HELP_STRING([--with-lg-size-class-group=<lg-size-class-group>],
1130 [Base 2 log of size classes per doubling])],
1131 [LG_SIZE_CLASS_GROUP="$with_lg_size_class_group"],
1132 [LG_SIZE_CLASS_GROUP="2"])
Jason Evansb7924f52009-06-23 19:01:18 -07001133
1134dnl ============================================================================
1135dnl jemalloc configuration.
1136dnl
Jason Evansa40bc7a2010-03-02 13:01:16 -08001137
Jason Evansa5a658a2014-09-02 15:07:07 -07001138dnl Set VERSION if source directory is inside a git repository.
Dan McGregorf8880312014-12-23 16:10:08 -06001139if 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 -07001140 dnl Pattern globs aren't powerful enough to match both single- and
1141 dnl double-digit version numbers, so iterate over patterns to support up to
1142 dnl version 99.99.99 without any accidental matches.
Dan McGregorf8880312014-12-23 16:10:08 -06001143 rm -f "${objroot}VERSION"
Jason Evansa5a658a2014-09-02 15:07:07 -07001144 for pattern in ['[0-9].[0-9].[0-9]' '[0-9].[0-9].[0-9][0-9]' \
1145 '[0-9].[0-9][0-9].[0-9]' '[0-9].[0-9][0-9].[0-9][0-9]' \
1146 '[0-9][0-9].[0-9].[0-9]' '[0-9][0-9].[0-9].[0-9][0-9]' \
1147 '[0-9][0-9].[0-9][0-9].[0-9]' \
1148 '[0-9][0-9].[0-9][0-9].[0-9][0-9]']; do
Dan McGregorf8880312014-12-23 16:10:08 -06001149 if test ! -e "${objroot}VERSION" ; then
1150 (test ! "${srcroot}" && cd "${srcroot}"; git describe --long --abbrev=40 --match="${pattern}") > "${objroot}VERSION.tmp" 2>/dev/null
Jason Evansa5a658a2014-09-02 15:07:07 -07001151 if test $? -eq 0 ; then
Dan McGregorf8880312014-12-23 16:10:08 -06001152 mv "${objroot}VERSION.tmp" "${objroot}VERSION"
Jason Evansa5a658a2014-09-02 15:07:07 -07001153 break
1154 fi
1155 fi
1156 done
Jason Evansa40bc7a2010-03-02 13:01:16 -08001157fi
Dan McGregorf8880312014-12-23 16:10:08 -06001158rm -f "${objroot}VERSION.tmp"
1159if test ! -e "${objroot}VERSION" ; then
1160 if test ! -e "${srcroot}VERSION" ; then
1161 AC_MSG_RESULT(
1162 [Missing VERSION file, and unable to generate it; creating bogus VERSION])
1163 echo "0.0.0-0-g0000000000000000000000000000000000000000" > "${objroot}VERSION"
1164 else
1165 cp ${srcroot}VERSION ${objroot}VERSION
1166 fi
Jason Evansa5a658a2014-09-02 15:07:07 -07001167fi
Dan McGregorf8880312014-12-23 16:10:08 -06001168jemalloc_version=`cat "${objroot}VERSION"`
Jason Evansa40bc7a2010-03-02 13:01:16 -08001169jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'`
1170jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'`
1171jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'`
1172jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'`
1173jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'`
Jason Evansb7924f52009-06-23 19:01:18 -07001174AC_SUBST([jemalloc_version])
Jason Evansa40bc7a2010-03-02 13:01:16 -08001175AC_SUBST([jemalloc_version_major])
1176AC_SUBST([jemalloc_version_minor])
1177AC_SUBST([jemalloc_version_bugfix])
1178AC_SUBST([jemalloc_version_nrev])
1179AC_SUBST([jemalloc_version_gid])
Jason Evansb7924f52009-06-23 19:01:18 -07001180
1181dnl ============================================================================
1182dnl Configure pthreads.
1183
Mike Hommeya19e87f2012-04-21 21:27:46 -07001184if test "x$abi" != "xpecoff" ; then
1185 AC_CHECK_HEADERS([pthread.h], , [AC_MSG_ERROR([pthread.h is missing])])
1186 dnl Some systems may embed pthreads functionality in libc; check for libpthread
1187 dnl first, but try libc too before failing.
1188 AC_CHECK_LIB([pthread], [pthread_create], [LIBS="$LIBS -lpthread"],
1189 [AC_SEARCH_LIBS([pthread_create], , ,
1190 AC_MSG_ERROR([libpthread is missing]))])
1191fi
Jason Evansb7924f52009-06-23 19:01:18 -07001192
1193CPPFLAGS="$CPPFLAGS -D_REENTRANT"
1194
Jason Evans345c1b02015-09-15 14:59:56 -07001195dnl Check whether clock_gettime(2) is in libc or librt. This function is only
1196dnl used in test code, so save the result to TESTLIBS to avoid poluting LIBS.
1197SAVED_LIBS="${LIBS}"
1198LIBS=
1199AC_SEARCH_LIBS([clock_gettime], [rt], [TESTLIBS="${LIBS}"])
1200AC_SUBST([TESTLIBS])
1201LIBS="${SAVED_LIBS}"
1202
Daniel Micayb74041f2014-12-09 17:41:34 -05001203dnl Check if the GNU-specific secure_getenv function exists.
1204AC_CHECK_FUNC([secure_getenv],
1205 [have_secure_getenv="1"],
1206 [have_secure_getenv="0"]
1207 )
1208if test "x$have_secure_getenv" = "x1" ; then
1209 AC_DEFINE([JEMALLOC_HAVE_SECURE_GETENV], [ ])
1210fi
1211
1212dnl Check if the Solaris/BSD issetugid function exists.
1213AC_CHECK_FUNC([issetugid],
1214 [have_issetugid="1"],
1215 [have_issetugid="0"]
1216 )
1217if test "x$have_issetugid" = "x1" ; then
1218 AC_DEFINE([JEMALLOC_HAVE_ISSETUGID], [ ])
1219fi
1220
Jason Evanscd9a1342012-03-21 18:33:03 -07001221dnl Check whether the BSD-specific _malloc_thread_cleanup() exists. If so, use
1222dnl it rather than pthreads TSD cleanup functions to support cleanup during
1223dnl thread exit, in order to avoid pthreads library recursion during
1224dnl bootstrapping.
Jason Evanscd9a1342012-03-21 18:33:03 -07001225AC_CHECK_FUNC([_malloc_thread_cleanup],
1226 [have__malloc_thread_cleanup="1"],
1227 [have__malloc_thread_cleanup="0"]
1228 )
1229if test "x$have__malloc_thread_cleanup" = "x1" ; then
1230 AC_DEFINE([JEMALLOC_MALLOC_THREAD_CLEANUP], [ ])
1231 force_tls="1"
1232fi
1233
Jason Evans41b6afb2012-02-02 22:04:57 -08001234dnl Check whether the BSD-specific _pthread_mutex_init_calloc_cb() exists. If
1235dnl so, mutex initialization causes allocation, and we need to implement this
1236dnl callback function in order to prevent recursive allocation.
1237AC_CHECK_FUNC([_pthread_mutex_init_calloc_cb],
1238 [have__pthread_mutex_init_calloc_cb="1"],
1239 [have__pthread_mutex_init_calloc_cb="0"]
1240 )
1241if test "x$have__pthread_mutex_init_calloc_cb" = "x1" ; then
1242 AC_DEFINE([JEMALLOC_MUTEX_INIT_CB])
1243fi
1244
Jason Evans0fee70d2012-02-13 12:36:11 -08001245dnl Disable lazy locking by default.
Jason Evansb7924f52009-06-23 19:01:18 -07001246AC_ARG_ENABLE([lazy_lock],
Jason Evans0fee70d2012-02-13 12:36:11 -08001247 [AS_HELP_STRING([--enable-lazy-lock],
1248 [Enable lazy locking (only lock when multi-threaded)])],
Jason Evansb7924f52009-06-23 19:01:18 -07001249[if test "x$enable_lazy_lock" = "xno" ; then
1250 enable_lazy_lock="0"
1251else
1252 enable_lazy_lock="1"
1253fi
1254],
Mike Hommeyac5db022015-08-11 14:01:59 +09001255[enable_lazy_lock=""]
Jason Evansb7924f52009-06-23 19:01:18 -07001256)
Mike Hommeyac5db022015-08-11 14:01:59 +09001257if test "x$enable_lazy_lock" = "x" -a "x${force_lazy_lock}" = "x1" ; then
Jason Evansfd4fcef2012-03-23 17:40:58 -07001258 AC_MSG_RESULT([Forcing lazy-lock to avoid allocator/threading bootstrap issues])
1259 enable_lazy_lock="1"
1260fi
Jason Evansb7924f52009-06-23 19:01:18 -07001261if test "x$enable_lazy_lock" = "x1" ; then
Mike Hommeya19e87f2012-04-21 21:27:46 -07001262 if test "x$abi" != "xpecoff" ; then
1263 AC_CHECK_HEADERS([dlfcn.h], , [AC_MSG_ERROR([dlfcn.h is missing])])
1264 AC_CHECK_FUNC([dlsym], [],
1265 [AC_CHECK_LIB([dl], [dlsym], [LIBS="$LIBS -ldl"],
1266 [AC_MSG_ERROR([libdl is missing])])
1267 ])
1268 fi
Jason Evansb7924f52009-06-23 19:01:18 -07001269 AC_DEFINE([JEMALLOC_LAZY_LOCK], [ ])
Mike Hommeyac5db022015-08-11 14:01:59 +09001270else
1271 enable_lazy_lock="0"
Jason Evansb7924f52009-06-23 19:01:18 -07001272fi
1273AC_SUBST([enable_lazy_lock])
1274
Jason Evans78d815c2010-01-17 14:06:20 -08001275AC_ARG_ENABLE([tls],
1276 [AS_HELP_STRING([--disable-tls], [Disable thread-local storage (__thread keyword)])],
1277if test "x$enable_tls" = "xno" ; then
1278 enable_tls="0"
1279else
1280 enable_tls="1"
1281fi
1282,
Mike Hommeyac5db022015-08-11 14:01:59 +09001283enable_tls=""
Jason Evans78d815c2010-01-17 14:06:20 -08001284)
Jason Evansc0f43b62015-09-02 12:46:35 -07001285if test "x${enable_tls}" = "x" ; then
1286 if test "x${force_tls}" = "x1" ; then
1287 AC_MSG_RESULT([Forcing TLS to avoid allocator/threading bootstrap issues])
1288 enable_tls="1"
1289 elif test "x${force_tls}" = "x0" ; then
1290 AC_MSG_RESULT([Forcing no TLS to avoid allocator/threading bootstrap issues])
1291 enable_tls="0"
1292 else
1293 enable_tls="1"
1294 fi
Jason Evansb80581d2012-03-23 16:17:43 -07001295fi
Jason Evans78d815c2010-01-17 14:06:20 -08001296if test "x${enable_tls}" = "x1" ; then
1297AC_MSG_CHECKING([for TLS])
Jason Evans6684cac2012-03-05 12:15:36 -08001298AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
Jason Evans78d815c2010-01-17 14:06:20 -08001299[[
1300 __thread int x;
1301]], [[
1302 x = 42;
1303
1304 return 0;
1305]])],
1306 AC_MSG_RESULT([yes]),
1307 AC_MSG_RESULT([no])
1308 enable_tls="0")
Mike Hommeyac5db022015-08-11 14:01:59 +09001309else
1310 enable_tls="0"
Jason Evans78d815c2010-01-17 14:06:20 -08001311fi
Jason Evansb267d0f2010-08-13 15:42:29 -07001312AC_SUBST([enable_tls])
Jason Evanse24c7af2012-03-19 10:21:17 -07001313if test "x${enable_tls}" = "x1" ; then
Jason Evansc0f43b62015-09-02 12:46:35 -07001314 if test "x${force_tls}" = "x0" ; then
1315 AC_MSG_WARN([TLS enabled despite being marked unusable on this platform])
1316 fi
Jason Evanse24c7af2012-03-19 10:21:17 -07001317 AC_DEFINE_UNQUOTED([JEMALLOC_TLS], [ ])
Jason Evanscd9a1342012-03-21 18:33:03 -07001318elif test "x${force_tls}" = "x1" ; then
Jason Evansc0f43b62015-09-02 12:46:35 -07001319 AC_MSG_WARN([TLS disabled despite being marked critical on this platform])
Jason Evans78d815c2010-01-17 14:06:20 -08001320fi
1321
Jason Evans2dbecf12010-09-05 10:35:13 -07001322dnl ============================================================================
Chih-hung Hsieh59cd80e2014-12-05 17:42:41 -08001323dnl Check for C11 atomics.
1324
1325JE_COMPILABLE([C11 atomics], [
1326#include <stdint.h>
1327#if (__STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_ATOMICS__)
1328#include <stdatomic.h>
1329#else
1330#error Atomics not available
1331#endif
1332], [
1333 uint64_t *p = (uint64_t *)0;
1334 uint64_t x = 1;
1335 volatile atomic_uint_least64_t *a = (volatile atomic_uint_least64_t *)p;
1336 uint64_t r = atomic_fetch_add(a, x) + x;
1337 return (r == 0);
1338], [je_cv_c11atomics])
1339if test "x${je_cv_c11atomics}" = "xyes" ; then
1340 AC_DEFINE([JEMALLOC_C11ATOMICS])
1341fi
1342
1343dnl ============================================================================
Jason Evansb57d3ec2012-04-17 13:17:54 -07001344dnl Check for atomic(9) operations as provided on FreeBSD.
1345
1346JE_COMPILABLE([atomic(9)], [
1347#include <sys/types.h>
1348#include <machine/atomic.h>
1349#include <inttypes.h>
1350], [
1351 {
1352 uint32_t x32 = 0;
1353 volatile uint32_t *x32p = &x32;
1354 atomic_fetchadd_32(x32p, 1);
1355 }
1356 {
1357 unsigned long xlong = 0;
1358 volatile unsigned long *xlongp = &xlong;
1359 atomic_fetchadd_long(xlongp, 1);
1360 }
1361], [je_cv_atomic9])
1362if test "x${je_cv_atomic9}" = "xyes" ; then
1363 AC_DEFINE([JEMALLOC_ATOMIC9])
1364fi
1365
1366dnl ============================================================================
Jason Evans763baa62011-03-18 19:10:31 -07001367dnl Check for atomic(3) operations as provided on Darwin.
1368
1369JE_COMPILABLE([Darwin OSAtomic*()], [
1370#include <libkern/OSAtomic.h>
1371#include <inttypes.h>
1372], [
1373 {
1374 int32_t x32 = 0;
1375 volatile int32_t *x32p = &x32;
1376 OSAtomicAdd32(1, x32p);
1377 }
1378 {
1379 int64_t x64 = 0;
1380 volatile int64_t *x64p = &x64;
1381 OSAtomicAdd64(1, x64p);
1382 }
Jason Evans6684cac2012-03-05 12:15:36 -08001383], [je_cv_osatomic])
1384if test "x${je_cv_osatomic}" = "xyes" ; then
Jason Evanse24c7af2012-03-19 10:21:17 -07001385 AC_DEFINE([JEMALLOC_OSATOMIC], [ ])
Jason Evans763baa62011-03-18 19:10:31 -07001386fi
1387
1388dnl ============================================================================
Richard Diamond994fad92014-06-03 02:39:18 -05001389dnl Check for madvise(2).
1390
1391JE_COMPILABLE([madvise(2)], [
1392#include <sys/mman.h>
1393], [
1394 {
1395 madvise((void *)0, 0, 0);
1396 }
1397], [je_cv_madvise])
1398if test "x${je_cv_madvise}" = "xyes" ; then
1399 AC_DEFINE([JEMALLOC_HAVE_MADVISE], [ ])
1400fi
1401
1402dnl ============================================================================
Mike Hommeyc1e567b2012-03-26 17:03:41 +02001403dnl Check whether __sync_{add,sub}_and_fetch() are available despite
1404dnl __GCC_HAVE_SYNC_COMPARE_AND_SWAP_n macros being undefined.
1405
1406AC_DEFUN([JE_SYNC_COMPARE_AND_SWAP_CHECK],[
1407 AC_CACHE_CHECK([whether to force $1-bit __sync_{add,sub}_and_fetch()],
1408 [je_cv_sync_compare_and_swap_$2],
Mike Hommey2cfe6d62012-03-27 15:03:07 +02001409 [AC_LINK_IFELSE([AC_LANG_PROGRAM([
1410 #include <stdint.h>
1411 ],
1412 [
1413 #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2
1414 {
1415 uint$1_t x$1 = 0;
1416 __sync_add_and_fetch(&x$1, 42);
1417 __sync_sub_and_fetch(&x$1, 1);
1418 }
1419 #else
1420 #error __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2 is defined, no need to force
1421 #endif
1422 ])],
Mike Hommeyc1e567b2012-03-26 17:03:41 +02001423 [je_cv_sync_compare_and_swap_$2=yes],
1424 [je_cv_sync_compare_and_swap_$2=no])])
1425
1426 if test "x${je_cv_sync_compare_and_swap_$2}" = "xyes" ; then
1427 AC_DEFINE([JE_FORCE_SYNC_COMPARE_AND_SWAP_$2], [ ])
1428 fi
1429])
1430
Jason Evansb57d3ec2012-04-17 13:17:54 -07001431if test "x${je_cv_atomic9}" != "xyes" -a "x${je_cv_osatomic}" != "xyes" ; then
Mike Hommeyc1e567b2012-03-26 17:03:41 +02001432 JE_SYNC_COMPARE_AND_SWAP_CHECK(32, 4)
1433 JE_SYNC_COMPARE_AND_SWAP_CHECK(64, 8)
1434fi
1435
1436dnl ============================================================================
Jason Evansd04047c2014-05-28 16:11:55 -07001437dnl Check for __builtin_clz() and __builtin_clzl().
1438
1439AC_CACHE_CHECK([for __builtin_clz],
1440 [je_cv_builtin_clz],
1441 [AC_LINK_IFELSE([AC_LANG_PROGRAM([],
1442 [
1443 {
1444 unsigned x = 0;
1445 int y = __builtin_clz(x);
1446 }
1447 {
1448 unsigned long x = 0;
1449 int y = __builtin_clzl(x);
1450 }
1451 ])],
1452 [je_cv_builtin_clz=yes],
1453 [je_cv_builtin_clz=no])])
1454
1455if test "x${je_cv_builtin_clz}" = "xyes" ; then
1456 AC_DEFINE([JEMALLOC_HAVE_BUILTIN_CLZ], [ ])
1457fi
1458
1459dnl ============================================================================
Jason Evans893a0ed2011-03-18 19:30:18 -07001460dnl Check for spinlock(3) operations as provided on Darwin.
1461
1462JE_COMPILABLE([Darwin OSSpin*()], [
1463#include <libkern/OSAtomic.h>
1464#include <inttypes.h>
1465], [
1466 OSSpinLock lock = 0;
1467 OSSpinLockLock(&lock);
1468 OSSpinLockUnlock(&lock);
Jason Evans6684cac2012-03-05 12:15:36 -08001469], [je_cv_osspin])
1470if test "x${je_cv_osspin}" = "xyes" ; then
Jason Evanse24c7af2012-03-19 10:21:17 -07001471 AC_DEFINE([JEMALLOC_OSSPIN], [ ])
Jason Evans893a0ed2011-03-18 19:30:18 -07001472fi
1473
1474dnl ============================================================================
Jason Evans2dbecf12010-09-05 10:35:13 -07001475dnl Darwin-related configuration.
Jason Evans78d815c2010-01-17 14:06:20 -08001476
Mike Hommeyd0357f72012-11-26 18:52:41 +01001477AC_ARG_ENABLE([zone-allocator],
1478 [AS_HELP_STRING([--disable-zone-allocator],
1479 [Disable zone allocator for Darwin])],
1480[if test "x$enable_zone_allocator" = "xno" ; then
1481 enable_zone_allocator="0"
1482else
1483 enable_zone_allocator="1"
1484fi
1485],
1486[if test "x${abi}" = "xmacho"; then
1487 enable_zone_allocator="1"
1488fi
1489]
1490)
1491AC_SUBST([enable_zone_allocator])
1492
1493if test "x${enable_zone_allocator}" = "x1" ; then
1494 if test "x${abi}" != "xmacho"; then
1495 AC_MSG_ERROR([--enable-zone-allocator is only supported on Darwin])
1496 fi
Jason Evanse24c7af2012-03-19 10:21:17 -07001497 AC_DEFINE([JEMALLOC_ZONE], [ ])
Jason Evans6109fe02010-02-10 10:37:56 -08001498
Jason Evans2dbecf12010-09-05 10:35:13 -07001499 dnl The szone version jumped from 3 to 6 between the OS X 10.5.x and 10.6
1500 dnl releases. malloc_zone_t and malloc_introspection_t have new fields in
1501 dnl 10.6, which is the only source-level indication of the change.
1502 AC_MSG_CHECKING([malloc zone version])
Mike Hommey154829d2012-03-20 18:01:38 +01001503 AC_DEFUN([JE_ZONE_PROGRAM],
1504 [AC_LANG_PROGRAM(
1505 [#include <malloc/malloc.h>],
Guilherme Goncalves79725aa2014-10-20 14:08:37 -02001506 [static int foo[[sizeof($1) $2 sizeof(void *) * $3 ? 1 : -1]]]
Mike Hommey154829d2012-03-20 18:01:38 +01001507 )])
Jason Evans2dbecf12010-09-05 10:35:13 -07001508
Mike Hommey154829d2012-03-20 18:01:38 +01001509 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,14)],[JEMALLOC_ZONE_VERSION=3],[
1510 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,15)],[JEMALLOC_ZONE_VERSION=5],[
1511 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,16)],[
1512 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,9)],[JEMALLOC_ZONE_VERSION=6],[
1513 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,13)],[JEMALLOC_ZONE_VERSION=7],[JEMALLOC_ZONE_VERSION=]
1514 )])],[
1515 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,17)],[JEMALLOC_ZONE_VERSION=8],[
1516 AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,>,17)],[JEMALLOC_ZONE_VERSION=9],[JEMALLOC_ZONE_VERSION=]
1517 )])])])])
1518 if test "x${JEMALLOC_ZONE_VERSION}" = "x"; then
1519 AC_MSG_RESULT([unsupported])
1520 AC_MSG_ERROR([Unsupported malloc zone version])
1521 fi
1522 if test "${JEMALLOC_ZONE_VERSION}" = 9; then
1523 JEMALLOC_ZONE_VERSION=8
1524 AC_MSG_RESULT([> 8])
1525 else
1526 AC_MSG_RESULT([$JEMALLOC_ZONE_VERSION])
1527 fi
1528 AC_DEFINE_UNQUOTED(JEMALLOC_ZONE_VERSION, [$JEMALLOC_ZONE_VERSION])
Jason Evansb27805b2010-02-10 18:15:53 -08001529fi
1530
Jason Evansb7924f52009-06-23 19:01:18 -07001531dnl ============================================================================
Sara Golemon3e24afa2014-08-18 13:06:39 -07001532dnl Check for glibc malloc hooks
1533
1534JE_COMPILABLE([glibc malloc hook], [
1535#include <stddef.h>
1536
1537extern void (* __free_hook)(void *ptr);
1538extern void *(* __malloc_hook)(size_t size);
1539extern void *(* __realloc_hook)(void *ptr, size_t size);
1540], [
1541 void *ptr = 0L;
1542 if (__malloc_hook) ptr = __malloc_hook(1);
1543 if (__realloc_hook) ptr = __realloc_hook(ptr, 2);
1544 if (__free_hook && ptr) __free_hook(ptr);
1545], [je_cv_glibc_malloc_hook])
1546if test "x${je_cv_glibc_malloc_hook}" = "xyes" ; then
1547 AC_DEFINE([JEMALLOC_GLIBC_MALLOC_HOOK], [ ])
1548fi
1549
1550JE_COMPILABLE([glibc memalign hook], [
1551#include <stddef.h>
1552
1553extern void *(* __memalign_hook)(size_t alignment, size_t size);
1554], [
1555 void *ptr = 0L;
1556 if (__memalign_hook) ptr = __memalign_hook(16, 7);
1557], [je_cv_glibc_memalign_hook])
1558if test "x${je_cv_glibc_memalign_hook}" = "xyes" ; then
1559 AC_DEFINE([JEMALLOC_GLIBC_MEMALIGN_HOOK], [ ])
1560fi
1561
Eric Wong4dcf04b2014-08-31 03:57:06 +00001562JE_COMPILABLE([pthreads adaptive mutexes], [
1563#include <pthread.h>
1564], [
1565 pthread_mutexattr_t attr;
1566 pthread_mutexattr_init(&attr);
1567 pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ADAPTIVE_NP);
1568 pthread_mutexattr_destroy(&attr);
1569], [je_cv_pthread_mutex_adaptive_np])
1570if test "x${je_cv_pthread_mutex_adaptive_np}" = "xyes" ; then
1571 AC_DEFINE([JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], [ ])
1572fi
1573
Sara Golemon3e24afa2014-08-18 13:06:39 -07001574dnl ============================================================================
Jason Evansb7924f52009-06-23 19:01:18 -07001575dnl Check for typedefs, structures, and compiler characteristics.
1576AC_HEADER_STDBOOL
1577
Jason Evans748dfac2013-12-06 18:27:33 -08001578dnl ============================================================================
1579dnl Define commands that generate output files.
1580
Jason Evans86abd0d2013-11-30 15:25:42 -08001581AC_CONFIG_COMMANDS([include/jemalloc/internal/private_namespace.h], [
1582 mkdir -p "${objroot}include/jemalloc/internal"
1583 "${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 -08001584], [
1585 srcdir="${srcdir}"
1586 objroot="${objroot}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001587])
1588AC_CONFIG_COMMANDS([include/jemalloc/internal/private_unnamespace.h], [
1589 mkdir -p "${objroot}include/jemalloc/internal"
1590 "${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 -08001591], [
1592 srcdir="${srcdir}"
1593 objroot="${objroot}"
1594])
1595AC_CONFIG_COMMANDS([include/jemalloc/internal/public_symbols.txt], [
1596 f="${objroot}include/jemalloc/internal/public_symbols.txt"
1597 mkdir -p "${objroot}include/jemalloc/internal"
1598 cp /dev/null "${f}"
1599 for nm in `echo ${mangling_map} |tr ',' ' '` ; do
1600 n=`echo ${nm} |tr ':' ' ' |awk '{print $[]1}'`
1601 m=`echo ${nm} |tr ':' ' ' |awk '{print $[]2}'`
1602 echo "${n}:${m}" >> "${f}"
1603 dnl Remove name from public_syms so that it isn't redefined later.
1604 public_syms=`for sym in ${public_syms}; do echo "${sym}"; done |grep -v "^${n}\$" |tr '\n' ' '`
1605 done
1606 for sym in ${public_syms} ; do
1607 n="${sym}"
1608 m="${JEMALLOC_PREFIX}${sym}"
1609 echo "${n}:${m}" >> "${f}"
1610 done
1611], [
1612 srcdir="${srcdir}"
1613 objroot="${objroot}"
1614 mangling_map="${mangling_map}"
1615 public_syms="${public_syms}"
1616 JEMALLOC_PREFIX="${JEMALLOC_PREFIX}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001617])
1618AC_CONFIG_COMMANDS([include/jemalloc/internal/public_namespace.h], [
1619 mkdir -p "${objroot}include/jemalloc/internal"
Jason Evansf234dc52014-01-16 17:38:01 -08001620 "${srcdir}/include/jemalloc/internal/public_namespace.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/internal/public_namespace.h"
1621], [
1622 srcdir="${srcdir}"
1623 objroot="${objroot}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001624])
1625AC_CONFIG_COMMANDS([include/jemalloc/internal/public_unnamespace.h], [
1626 mkdir -p "${objroot}include/jemalloc/internal"
Jason Evansf234dc52014-01-16 17:38:01 -08001627 "${srcdir}/include/jemalloc/internal/public_unnamespace.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/internal/public_unnamespace.h"
1628], [
1629 srcdir="${srcdir}"
1630 objroot="${objroot}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001631])
Jason Evansb1726102012-02-28 16:50:47 -08001632AC_CONFIG_COMMANDS([include/jemalloc/internal/size_classes.h], [
Jason Evans86abd0d2013-11-30 15:25:42 -08001633 mkdir -p "${objroot}include/jemalloc/internal"
Jason Evans6d919292015-09-15 10:42:36 -07001634 "${SHELL}" "${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 -08001635], [
Jason Evans6d919292015-09-15 10:42:36 -07001636 SHELL="${SHELL}"
Jason Evansf234dc52014-01-16 17:38:01 -08001637 srcdir="${srcdir}"
1638 objroot="${objroot}"
Jason Evans81e54752014-10-10 22:34:25 -07001639 LG_QUANTA="${LG_QUANTA}"
1640 LG_TINY_MIN=${LG_TINY_MIN}
1641 LG_PAGE_SIZES="${LG_PAGE_SIZES}"
Jason Evansfc0b3b72014-10-09 17:54:06 -07001642 LG_SIZE_CLASS_GROUP=${LG_SIZE_CLASS_GROUP}
Jason Evansb1726102012-02-28 16:50:47 -08001643])
Jason Evans86abd0d2013-11-30 15:25:42 -08001644AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_protos_jet.h], [
1645 mkdir -p "${objroot}include/jemalloc"
1646 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 -08001647], [
1648 srcdir="${srcdir}"
1649 objroot="${objroot}"
1650])
1651AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_rename.h], [
1652 mkdir -p "${objroot}include/jemalloc"
1653 "${srcdir}/include/jemalloc/jemalloc_rename.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/jemalloc_rename.h"
1654], [
1655 srcdir="${srcdir}"
1656 objroot="${objroot}"
1657])
1658AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_mangle.h], [
1659 mkdir -p "${objroot}include/jemalloc"
1660 "${srcdir}/include/jemalloc/jemalloc_mangle.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" je_ > "${objroot}include/jemalloc/jemalloc_mangle.h"
1661], [
1662 srcdir="${srcdir}"
1663 objroot="${objroot}"
1664])
1665AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_mangle_jet.h], [
1666 mkdir -p "${objroot}include/jemalloc"
1667 "${srcdir}/include/jemalloc/jemalloc_mangle.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" jet_ > "${objroot}include/jemalloc/jemalloc_mangle_jet.h"
1668], [
1669 srcdir="${srcdir}"
1670 objroot="${objroot}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001671])
1672AC_CONFIG_COMMANDS([include/jemalloc/jemalloc.h], [
1673 mkdir -p "${objroot}include/jemalloc"
1674 "${srcdir}/include/jemalloc/jemalloc.sh" "${objroot}" > "${objroot}include/jemalloc/jemalloc${install_suffix}.h"
Jason Evansf234dc52014-01-16 17:38:01 -08001675], [
1676 srcdir="${srcdir}"
1677 objroot="${objroot}"
1678 install_suffix="${install_suffix}"
Jason Evans86abd0d2013-11-30 15:25:42 -08001679])
Jason Evansb1726102012-02-28 16:50:47 -08001680
Jason Evansb7924f52009-06-23 19:01:18 -07001681dnl Process .in files.
Jason Evansb0fd5012010-01-17 01:49:20 -08001682AC_SUBST([cfghdrs_in])
1683AC_SUBST([cfghdrs_out])
Jason Evans0656ec02010-04-07 23:37:35 -07001684AC_CONFIG_HEADERS([$cfghdrs_tup])
Jason Evansb7924f52009-06-23 19:01:18 -07001685
1686dnl ============================================================================
1687dnl Generate outputs.
Jason Evans748dfac2013-12-06 18:27:33 -08001688
Jason Evans70417202015-05-01 12:31:12 -07001689AC_CONFIG_FILES([$cfgoutputs_tup config.stamp bin/jemalloc-config bin/jemalloc.sh bin/jeprof])
Jason Evansb0fd5012010-01-17 01:49:20 -08001690AC_SUBST([cfgoutputs_in])
1691AC_SUBST([cfgoutputs_out])
Jason Evansb7924f52009-06-23 19:01:18 -07001692AC_OUTPUT
1693
1694dnl ============================================================================
1695dnl Print out the results of configuration.
1696AC_MSG_RESULT([===============================================================================])
Jason Evansf576c632011-11-01 22:27:41 -07001697AC_MSG_RESULT([jemalloc version : ${jemalloc_version}])
1698AC_MSG_RESULT([library revision : ${rev}])
Jason Evansb7924f52009-06-23 19:01:18 -07001699AC_MSG_RESULT([])
Jason Evansbec6a8d2015-01-22 17:55:58 -08001700AC_MSG_RESULT([CONFIG : ${CONFIG}])
Jason Evansb7924f52009-06-23 19:01:18 -07001701AC_MSG_RESULT([CC : ${CC}])
Jason Evansb7924f52009-06-23 19:01:18 -07001702AC_MSG_RESULT([CFLAGS : ${CFLAGS}])
Jason Evansbec6a8d2015-01-22 17:55:58 -08001703AC_MSG_RESULT([CPPFLAGS : ${CPPFLAGS}])
Jason Evansb7924f52009-06-23 19:01:18 -07001704AC_MSG_RESULT([LDFLAGS : ${LDFLAGS}])
Jason Evans748dfac2013-12-06 18:27:33 -08001705AC_MSG_RESULT([EXTRA_LDFLAGS : ${EXTRA_LDFLAGS}])
Jason Evansb7924f52009-06-23 19:01:18 -07001706AC_MSG_RESULT([LIBS : ${LIBS}])
Jason Evans345c1b02015-09-15 14:59:56 -07001707AC_MSG_RESULT([TESTLIBS : ${TESTLIBS}])
Jason Evansb7924f52009-06-23 19:01:18 -07001708AC_MSG_RESULT([RPATH_EXTRA : ${RPATH_EXTRA}])
1709AC_MSG_RESULT([])
Jason Evansaee7fd22010-11-24 22:00:02 -08001710AC_MSG_RESULT([XSLTPROC : ${XSLTPROC}])
1711AC_MSG_RESULT([XSLROOT : ${XSLROOT}])
1712AC_MSG_RESULT([])
Jason Evansb7924f52009-06-23 19:01:18 -07001713AC_MSG_RESULT([PREFIX : ${PREFIX}])
1714AC_MSG_RESULT([BINDIR : ${BINDIR}])
Jason Evansbec6a8d2015-01-22 17:55:58 -08001715AC_MSG_RESULT([DATADIR : ${DATADIR}])
Jason Evans662a0172009-07-01 19:24:31 -07001716AC_MSG_RESULT([INCLUDEDIR : ${INCLUDEDIR}])
1717AC_MSG_RESULT([LIBDIR : ${LIBDIR}])
Jason Evansb7924f52009-06-23 19:01:18 -07001718AC_MSG_RESULT([MANDIR : ${MANDIR}])
1719AC_MSG_RESULT([])
1720AC_MSG_RESULT([srcroot : ${srcroot}])
1721AC_MSG_RESULT([abs_srcroot : ${abs_srcroot}])
1722AC_MSG_RESULT([objroot : ${objroot}])
1723AC_MSG_RESULT([abs_objroot : ${abs_objroot}])
1724AC_MSG_RESULT([])
Jason Evans90895cf2009-12-29 00:09:15 -08001725AC_MSG_RESULT([JEMALLOC_PREFIX : ${JEMALLOC_PREFIX}])
Jason Evans746e77a2011-07-30 16:40:52 -07001726AC_MSG_RESULT([JEMALLOC_PRIVATE_NAMESPACE])
1727AC_MSG_RESULT([ : ${JEMALLOC_PRIVATE_NAMESPACE}])
Jason Evansb0fd5012010-01-17 01:49:20 -08001728AC_MSG_RESULT([install_suffix : ${install_suffix}])
Jason Evansb7924f52009-06-23 19:01:18 -07001729AC_MSG_RESULT([autogen : ${enable_autogen}])
Jason Evans355b4382010-09-20 19:20:48 -07001730AC_MSG_RESULT([cc-silence : ${enable_cc_silence}])
Jason Evansb7924f52009-06-23 19:01:18 -07001731AC_MSG_RESULT([debug : ${enable_debug}])
Jason Evans748dfac2013-12-06 18:27:33 -08001732AC_MSG_RESULT([code-coverage : ${enable_code_coverage}])
Jason Evansb7924f52009-06-23 19:01:18 -07001733AC_MSG_RESULT([stats : ${enable_stats}])
Jason Evans6109fe02010-02-10 10:37:56 -08001734AC_MSG_RESULT([prof : ${enable_prof}])
1735AC_MSG_RESULT([prof-libunwind : ${enable_prof_libunwind}])
Jason Evans77f350b2011-03-15 22:23:12 -07001736AC_MSG_RESULT([prof-libgcc : ${enable_prof_libgcc}])
1737AC_MSG_RESULT([prof-gcc : ${enable_prof_gcc}])
Jason Evans84cbbcb2009-12-29 00:09:15 -08001738AC_MSG_RESULT([tcache : ${enable_tcache}])
Jason Evansb7924f52009-06-23 19:01:18 -07001739AC_MSG_RESULT([fill : ${enable_fill}])
Jason Evansb1476112012-04-05 13:36:17 -07001740AC_MSG_RESULT([utrace : ${enable_utrace}])
Jason Evans122449b2012-04-06 00:35:09 -07001741AC_MSG_RESULT([valgrind : ${enable_valgrind}])
1742AC_MSG_RESULT([xmalloc : ${enable_xmalloc}])
Jason Evans59ae2762012-04-16 17:52:27 -07001743AC_MSG_RESULT([munmap : ${enable_munmap}])
Jason Evansb7924f52009-06-23 19:01:18 -07001744AC_MSG_RESULT([lazy_lock : ${enable_lazy_lock}])
Jason Evans2dbecf12010-09-05 10:35:13 -07001745AC_MSG_RESULT([tls : ${enable_tls}])
Jason Evans8a03cf02015-05-04 09:58:36 -07001746AC_MSG_RESULT([cache-oblivious : ${enable_cache_oblivious}])
Jason Evansb7924f52009-06-23 19:01:18 -07001747AC_MSG_RESULT([===============================================================================])