Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1 | dnl Process this file with autoconf to produce a configure script. |
| 2 | AC_INIT([Makefile.in]) |
| 3 | |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 4 | dnl ============================================================================ |
| 5 | dnl Custom macro definitions. |
| 6 | |
| 7 | dnl JE_CFLAGS_APPEND(cflag) |
| 8 | AC_DEFUN([JE_CFLAGS_APPEND], |
| 9 | [ |
| 10 | AC_MSG_CHECKING([whether compiler supports $1]) |
| 11 | TCFLAGS="${CFLAGS}" |
| 12 | if test "x${CFLAGS}" = "x" ; then |
| 13 | CFLAGS="$1" |
| 14 | else |
| 15 | CFLAGS="${CFLAGS} $1" |
| 16 | fi |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 17 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM( |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 18 | [[ |
| 19 | ]], [[ |
| 20 | return 0; |
| 21 | ]])], |
Jason Evans | 99b0fbb | 2014-02-24 16:08:38 -0800 | [diff] [blame] | 22 | [je_cv_cflags_appended=$1] |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 23 | AC_MSG_RESULT([yes]), |
Jason Evans | 99b0fbb | 2014-02-24 16:08:38 -0800 | [diff] [blame] | 24 | [je_cv_cflags_appended=] |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 25 | AC_MSG_RESULT([no]) |
| 26 | [CFLAGS="${TCFLAGS}"] |
| 27 | ) |
| 28 | ]) |
| 29 | |
| 30 | dnl JE_COMPILABLE(label, hcode, mcode, rvar) |
Jason Evans | 4c2faa8 | 2012-03-13 11:09:23 -0700 | [diff] [blame] | 31 | dnl |
Jason Evans | f3e139a | 2012-03-19 09:54:20 -0700 | [diff] [blame] | 32 | dnl Use AC_LINK_IFELSE() rather than AC_COMPILE_IFELSE() so that linker errors |
Jason Evans | 4c2faa8 | 2012-03-13 11:09:23 -0700 | [diff] [blame] | 33 | dnl cause failure. |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 34 | AC_DEFUN([JE_COMPILABLE], |
| 35 | [ |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 36 | AC_CACHE_CHECK([whether $1 is compilable], |
| 37 | [$4], |
Jason Evans | f3e139a | 2012-03-19 09:54:20 -0700 | [diff] [blame] | 38 | [AC_LINK_IFELSE([AC_LANG_PROGRAM([$2], |
| 39 | [$3])], |
| 40 | [$4=yes], |
| 41 | [$4=no])]) |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 42 | ]) |
| 43 | |
| 44 | dnl ============================================================================ |
| 45 | |
Jason Evans | 41f2e69 | 2015-01-25 20:15:13 -0800 | [diff] [blame] | 46 | CONFIG=`echo ${ac_configure_args} | sed -e 's#'"'"'\([^ ]*\)'"'"'#\1#g'` |
Jason Evans | bec6a8d | 2015-01-22 17:55:58 -0800 | [diff] [blame] | 47 | AC_SUBST([CONFIG]) |
| 48 | |
Jason Evans | f576c63 | 2011-11-01 22:27:41 -0700 | [diff] [blame] | 49 | dnl Library revision. |
Jason Evans | 9790b96 | 2014-04-14 22:32:31 -0700 | [diff] [blame] | 50 | rev=2 |
Jason Evans | f576c63 | 2011-11-01 22:27:41 -0700 | [diff] [blame] | 51 | AC_SUBST([rev]) |
| 52 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 53 | srcroot=$srcdir |
| 54 | if test "x${srcroot}" = "x." ; then |
| 55 | srcroot="" |
| 56 | else |
| 57 | srcroot="${srcroot}/" |
| 58 | fi |
| 59 | AC_SUBST([srcroot]) |
| 60 | abs_srcroot="`cd \"${srcdir}\"; pwd`/" |
| 61 | AC_SUBST([abs_srcroot]) |
| 62 | |
| 63 | objroot="" |
| 64 | AC_SUBST([objroot]) |
| 65 | abs_objroot="`pwd`/" |
| 66 | AC_SUBST([abs_objroot]) |
| 67 | |
| 68 | dnl Munge install path variables. |
| 69 | if test "x$prefix" = "xNONE" ; then |
| 70 | prefix="/usr/local" |
| 71 | fi |
| 72 | if test "x$exec_prefix" = "xNONE" ; then |
| 73 | exec_prefix=$prefix |
| 74 | fi |
| 75 | PREFIX=$prefix |
| 76 | AC_SUBST([PREFIX]) |
| 77 | BINDIR=`eval echo $bindir` |
| 78 | BINDIR=`eval echo $BINDIR` |
| 79 | AC_SUBST([BINDIR]) |
| 80 | INCLUDEDIR=`eval echo $includedir` |
| 81 | INCLUDEDIR=`eval echo $INCLUDEDIR` |
| 82 | AC_SUBST([INCLUDEDIR]) |
| 83 | LIBDIR=`eval echo $libdir` |
| 84 | LIBDIR=`eval echo $LIBDIR` |
| 85 | AC_SUBST([LIBDIR]) |
| 86 | DATADIR=`eval echo $datadir` |
| 87 | DATADIR=`eval echo $DATADIR` |
| 88 | AC_SUBST([DATADIR]) |
| 89 | MANDIR=`eval echo $mandir` |
| 90 | MANDIR=`eval echo $MANDIR` |
| 91 | AC_SUBST([MANDIR]) |
| 92 | |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 93 | dnl Support for building documentation. |
Jason Evans | 7329a4f | 2013-01-22 10:53:29 -0800 | [diff] [blame] | 94 | AC_PATH_PROG([XSLTPROC], [xsltproc], [false], [$PATH]) |
Jason Evans | 7091b41 | 2012-03-19 09:36:44 -0700 | [diff] [blame] | 95 | if test -d "/usr/share/xml/docbook/stylesheet/docbook-xsl" ; then |
| 96 | DEFAULT_XSLROOT="/usr/share/xml/docbook/stylesheet/docbook-xsl" |
| 97 | elif test -d "/usr/share/sgml/docbook/xsl-stylesheets" ; then |
| 98 | DEFAULT_XSLROOT="/usr/share/sgml/docbook/xsl-stylesheets" |
| 99 | else |
| 100 | dnl Documentation building will fail if this default gets used. |
| 101 | DEFAULT_XSLROOT="" |
| 102 | fi |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 103 | AC_ARG_WITH([xslroot], |
Jason Evans | 7091b41 | 2012-03-19 09:36:44 -0700 | [diff] [blame] | 104 | [AS_HELP_STRING([--with-xslroot=<path>], [XSL stylesheet root path])], [ |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 105 | if test "x$with_xslroot" = "xno" ; then |
Jason Evans | 7091b41 | 2012-03-19 09:36:44 -0700 | [diff] [blame] | 106 | XSLROOT="${DEFAULT_XSLROOT}" |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 107 | else |
| 108 | XSLROOT="${with_xslroot}" |
Jason Evans | 7091b41 | 2012-03-19 09:36:44 -0700 | [diff] [blame] | 109 | fi |
| 110 | ], |
| 111 | XSLROOT="${DEFAULT_XSLROOT}" |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 112 | ) |
| 113 | AC_SUBST([XSLROOT]) |
| 114 | |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 115 | dnl If CFLAGS isn't defined, set CFLAGS to something reasonable. Otherwise, |
| 116 | dnl just prevent autoconf from molesting CFLAGS. |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 117 | CFLAGS=$CFLAGS |
| 118 | AC_PROG_CC |
Mike Hommey | fd97b1d | 2012-04-30 12:38:31 +0200 | [diff] [blame] | 119 | if 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])]) |
| 130 | fi |
| 131 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 132 | if test "x$CFLAGS" = "x" ; then |
| 133 | no_CFLAGS="yes" |
Jason Evans | cfeccd3 | 2010-03-03 15:48:20 -0800 | [diff] [blame] | 134 | if test "x$GCC" = "xyes" ; then |
| 135 | JE_CFLAGS_APPEND([-std=gnu99]) |
Jason Evans | 99b0fbb | 2014-02-24 16:08:38 -0800 | [diff] [blame] | 136 | if test "x$je_cv_cflags_appended" = "x-std=gnu99" ; then |
| 137 | AC_DEFINE_UNQUOTED([JEMALLOC_HAS_RESTRICT]) |
| 138 | fi |
Jason Evans | cfeccd3 | 2010-03-03 15:48:20 -0800 | [diff] [blame] | 139 | JE_CFLAGS_APPEND([-Wall]) |
Mike Hommey | b7b44df | 2014-12-18 15:12:53 +0900 | [diff] [blame] | 140 | JE_CFLAGS_APPEND([-Werror=declaration-after-statement]) |
Jason Evans | cfeccd3 | 2010-03-03 15:48:20 -0800 | [diff] [blame] | 141 | JE_CFLAGS_APPEND([-pipe]) |
| 142 | JE_CFLAGS_APPEND([-g3]) |
Mike Hommey | fd97b1d | 2012-04-30 12:38:31 +0200 | [diff] [blame] | 143 | 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 Hommey | 8c61575 | 2014-05-29 16:58:21 +0900 | [diff] [blame] | 148 | JE_CFLAGS_APPEND([-FS]) |
Mike Hommey | 6f6704c | 2014-05-29 17:01:10 +0900 | [diff] [blame] | 149 | CPPFLAGS="$CPPFLAGS -I${srcdir}/include/msvc_compat" |
Jason Evans | cfeccd3 | 2010-03-03 15:48:20 -0800 | [diff] [blame] | 150 | fi |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 151 | fi |
| 152 | dnl Append EXTRA_CFLAGS to CFLAGS, if defined. |
| 153 | if test "x$EXTRA_CFLAGS" != "x" ; then |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 154 | JE_CFLAGS_APPEND([$EXTRA_CFLAGS]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 155 | fi |
| 156 | AC_PROG_CPP |
| 157 | |
Jason Evans | df3f270 | 2014-03-30 16:27:08 -0700 | [diff] [blame] | 158 | AC_C_BIGENDIAN([ac_cv_big_endian=1], [ac_cv_big_endian=0]) |
| 159 | if test "x${ac_cv_big_endian}" = "x1" ; then |
| 160 | AC_DEFINE_UNQUOTED([JEMALLOC_BIG_ENDIAN], [ ]) |
| 161 | fi |
| 162 | |
Mike Hommey | ff2e999 | 2014-05-29 16:33:02 +0900 | [diff] [blame] | 163 | if test "x${je_cv_msvc}" = "xyes" -a "x${ac_cv_header_inttypes_h}" = "xno"; then |
Mike Hommey | 6f6704c | 2014-05-29 17:01:10 +0900 | [diff] [blame] | 164 | CPPFLAGS="$CPPFLAGS -I${srcdir}/include/msvc_compat/C99" |
Mike Hommey | ff2e999 | 2014-05-29 16:33:02 +0900 | [diff] [blame] | 165 | fi |
| 166 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 167 | AC_CHECK_SIZEOF([void *]) |
| 168 | if test "x${ac_cv_sizeof_void_p}" = "x8" ; then |
Jason Evans | 94ad2b5 | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 169 | LG_SIZEOF_PTR=3 |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 170 | elif test "x${ac_cv_sizeof_void_p}" = "x4" ; then |
Jason Evans | 94ad2b5 | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 171 | LG_SIZEOF_PTR=2 |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 172 | else |
| 173 | AC_MSG_ERROR([Unsupported pointer size: ${ac_cv_sizeof_void_p}]) |
| 174 | fi |
Jason Evans | 94ad2b5 | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 175 | AC_DEFINE_UNQUOTED([LG_SIZEOF_PTR], [$LG_SIZEOF_PTR]) |
| 176 | |
| 177 | AC_CHECK_SIZEOF([int]) |
| 178 | if test "x${ac_cv_sizeof_int}" = "x8" ; then |
| 179 | LG_SIZEOF_INT=3 |
| 180 | elif test "x${ac_cv_sizeof_int}" = "x4" ; then |
| 181 | LG_SIZEOF_INT=2 |
| 182 | else |
| 183 | AC_MSG_ERROR([Unsupported int size: ${ac_cv_sizeof_int}]) |
| 184 | fi |
| 185 | AC_DEFINE_UNQUOTED([LG_SIZEOF_INT], [$LG_SIZEOF_INT]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 186 | |
Jason Evans | 84c8eef | 2011-03-16 10:30:13 -0700 | [diff] [blame] | 187 | AC_CHECK_SIZEOF([long]) |
| 188 | if test "x${ac_cv_sizeof_long}" = "x8" ; then |
| 189 | LG_SIZEOF_LONG=3 |
| 190 | elif test "x${ac_cv_sizeof_long}" = "x4" ; then |
| 191 | LG_SIZEOF_LONG=2 |
| 192 | else |
| 193 | AC_MSG_ERROR([Unsupported long size: ${ac_cv_sizeof_long}]) |
| 194 | fi |
| 195 | AC_DEFINE_UNQUOTED([LG_SIZEOF_LONG], [$LG_SIZEOF_LONG]) |
| 196 | |
Jason Evans | d81e4bd | 2012-03-06 14:57:45 -0800 | [diff] [blame] | 197 | AC_CHECK_SIZEOF([intmax_t]) |
| 198 | if test "x${ac_cv_sizeof_intmax_t}" = "x16" ; then |
| 199 | LG_SIZEOF_INTMAX_T=4 |
| 200 | elif test "x${ac_cv_sizeof_intmax_t}" = "x8" ; then |
| 201 | LG_SIZEOF_INTMAX_T=3 |
| 202 | elif test "x${ac_cv_sizeof_intmax_t}" = "x4" ; then |
| 203 | LG_SIZEOF_INTMAX_T=2 |
| 204 | else |
Mike Hommey | 14103d3 | 2012-04-20 08:38:39 +0200 | [diff] [blame] | 205 | AC_MSG_ERROR([Unsupported intmax_t size: ${ac_cv_sizeof_intmax_t}]) |
Jason Evans | d81e4bd | 2012-03-06 14:57:45 -0800 | [diff] [blame] | 206 | fi |
| 207 | AC_DEFINE_UNQUOTED([LG_SIZEOF_INTMAX_T], [$LG_SIZEOF_INTMAX_T]) |
| 208 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 209 | AC_CANONICAL_HOST |
| 210 | dnl CPU-specific settings. |
| 211 | CPU_SPINWAIT="" |
| 212 | case "${host_cpu}" in |
Jason Evans | cb657e3 | 2014-02-25 11:21:41 -0800 | [diff] [blame] | 213 | i686|x86_64) |
Jason Evans | 81e5475 | 2014-10-10 22:34:25 -0700 | [diff] [blame] | 214 | AC_CACHE_VAL([je_cv_pause], |
Jason Evans | 2eb941a | 2014-10-10 20:40:43 -0700 | [diff] [blame] | 215 | [JE_COMPILABLE([pause instruction], [], |
| 216 | [[__asm__ volatile("pause"); return 0;]], |
| 217 | [je_cv_pause])]) |
Jason Evans | cb657e3 | 2014-02-25 11:21:41 -0800 | [diff] [blame] | 218 | if test "x${je_cv_pause}" = "xyes" ; then |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 219 | CPU_SPINWAIT='__asm__ volatile("pause")' |
| 220 | fi |
Jason Evans | 80061b6 | 2013-12-09 13:21:08 -0800 | [diff] [blame] | 221 | ;; |
| 222 | powerpc) |
| 223 | AC_DEFINE_UNQUOTED([HAVE_ALTIVEC], [ ]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 224 | ;; |
| 225 | *) |
| 226 | ;; |
| 227 | esac |
| 228 | AC_DEFINE_UNQUOTED([CPU_SPINWAIT], [$CPU_SPINWAIT]) |
| 229 | |
Antony Dovgal | 2bd3cbc | 2011-10-13 09:33:33 +0400 | [diff] [blame] | 230 | LD_PRELOAD_VAR="LD_PRELOAD" |
Jason Evans | f576c63 | 2011-11-01 22:27:41 -0700 | [diff] [blame] | 231 | so="so" |
Mike Hommey | fd97b1d | 2012-04-30 12:38:31 +0200 | [diff] [blame] | 232 | importlib="${so}" |
Mike Hommey | 7cdea39 | 2012-04-30 12:38:27 +0200 | [diff] [blame] | 233 | o="$ac_objext" |
Mike Hommey | 5bee66d | 2012-04-16 16:30:24 +0200 | [diff] [blame] | 234 | a="a" |
Mike Hommey | 7cdea39 | 2012-04-30 12:38:27 +0200 | [diff] [blame] | 235 | exe="$ac_exeext" |
Mike Hommey | a19e87f | 2012-04-21 21:27:46 -0700 | [diff] [blame] | 236 | libprefix="lib" |
Mike Hommey | fa08da7 | 2012-04-16 16:30:25 +0200 | [diff] [blame] | 237 | DSO_LDFLAGS='-shared -Wl,-soname,$(@F)' |
| 238 | RPATH='-Wl,-rpath,$(1)' |
Mike Hommey | 7cdea39 | 2012-04-30 12:38:27 +0200 | [diff] [blame] | 239 | SOREV="${so}.${rev}" |
Mike Hommey | 188da7c | 2012-04-18 18:29:41 +0200 | [diff] [blame] | 240 | PIC_CFLAGS='-fPIC -DPIC' |
Mike Hommey | fd97b1d | 2012-04-30 12:38:31 +0200 | [diff] [blame] | 241 | CTARGET='-o $@' |
| 242 | LDTARGET='-o $@' |
| 243 | EXTRA_LDFLAGS= |
Jason Evans | 80ddf49 | 2013-08-20 11:48:19 +0100 | [diff] [blame] | 244 | ARFLAGS='crus' |
| 245 | AROUT=' $@' |
Mike Hommey | 79c4bca | 2012-05-02 21:30:51 +0200 | [diff] [blame] | 246 | CC_MM=1 |
Jason Evans | 7372b15 | 2012-02-10 20:22:09 -0800 | [diff] [blame] | 247 | |
Jory A. Pratt | ad505e0 | 2013-08-11 09:44:59 -0500 | [diff] [blame] | 248 | AN_MAKEVAR([AR], [AC_PROG_AR]) |
| 249 | AN_PROGRAM([ar], [AC_PROG_AR]) |
| 250 | AC_DEFUN([AC_PROG_AR], [AC_CHECK_TOOL(AR, ar, :)]) |
| 251 | AC_PROG_AR |
| 252 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 253 | dnl Platform-specific settings. abi and RPATH can probably be determined |
| 254 | dnl programmatically, but doing so is error-prone, which makes it generally |
| 255 | dnl not worth the trouble. |
| 256 | dnl |
| 257 | dnl Define cpp macros in CPPFLAGS, rather than doing AC_DEFINE(macro), since the |
| 258 | dnl definitions need to be seen before any headers are included, which is a pain |
| 259 | dnl to make happen otherwise. |
Jason Evans | 59ae276 | 2012-04-16 17:52:27 -0700 | [diff] [blame] | 260 | default_munmap="1" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 261 | case "${host}" in |
Valerii Hiora | 5921ba7 | 2014-05-16 16:28:20 +0300 | [diff] [blame] | 262 | *-*-darwin* | *-*-ios*) |
Mike Hommey | a6770a7 | 2012-05-03 14:12:49 +0200 | [diff] [blame] | 263 | CFLAGS="$CFLAGS" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 264 | abi="macho" |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 265 | AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 266 | RPATH="" |
Antony Dovgal | 2bd3cbc | 2011-10-13 09:33:33 +0400 | [diff] [blame] | 267 | LD_PRELOAD_VAR="DYLD_INSERT_LIBRARIES" |
Jason Evans | f576c63 | 2011-11-01 22:27:41 -0700 | [diff] [blame] | 268 | so="dylib" |
Mike Hommey | fd97b1d | 2012-04-30 12:38:31 +0200 | [diff] [blame] | 269 | importlib="${so}" |
Jason Evans | b80581d | 2012-03-23 16:17:43 -0700 | [diff] [blame] | 270 | force_tls="0" |
Mike Hommey | fa08da7 | 2012-04-16 16:30:25 +0200 | [diff] [blame] | 271 | DSO_LDFLAGS='-shared -Wl,-dylib_install_name,$(@F)' |
Mike Hommey | 7cdea39 | 2012-04-30 12:38:27 +0200 | [diff] [blame] | 272 | SOREV="${rev}.${so}" |
Jason Evans | 6668853 | 2013-12-03 21:49:36 -0800 | [diff] [blame] | 273 | sbrk_deprecated="1" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 274 | ;; |
| 275 | *-*-freebsd*) |
| 276 | CFLAGS="$CFLAGS" |
| 277 | abi="elf" |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 278 | AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ]) |
Jason Evans | fd4fcef | 2012-03-23 17:40:58 -0700 | [diff] [blame] | 279 | force_lazy_lock="1" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 280 | ;; |
Michael Neumann | 1aa25a3 | 2014-08-05 03:06:02 +0200 | [diff] [blame] | 281 | *-*-dragonfly*) |
| 282 | CFLAGS="$CFLAGS" |
| 283 | abi="elf" |
| 284 | AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ]) |
| 285 | ;; |
Sébastien Marie | 77d597e | 2015-01-25 10:18:32 +0100 | [diff] [blame] | 286 | *-*-openbsd*) |
| 287 | CFLAGS="$CFLAGS" |
| 288 | abi="elf" |
| 289 | AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ]) |
| 290 | ;; |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 291 | *-*-linux*) |
| 292 | CFLAGS="$CFLAGS" |
| 293 | CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" |
| 294 | abi="elf" |
Garrett Cooper | 13e4e24 | 2012-12-02 17:58:40 -0800 | [diff] [blame] | 295 | AC_DEFINE([JEMALLOC_HAS_ALLOCA_H]) |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 296 | AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED], [ ]) |
Jason Evans | 02b2312 | 2012-04-05 11:06:23 -0700 | [diff] [blame] | 297 | AC_DEFINE([JEMALLOC_THREADED_INIT], [ ]) |
Jason Evans | 59ae276 | 2012-04-16 17:52:27 -0700 | [diff] [blame] | 298 | default_munmap="0" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 299 | ;; |
| 300 | *-*-netbsd*) |
| 301 | AC_MSG_CHECKING([ABI]) |
| 302 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM( |
| 303 | [[#ifdef __ELF__ |
| 304 | /* ELF */ |
| 305 | #else |
| 306 | #error aout |
| 307 | #endif |
| 308 | ]])], |
| 309 | [CFLAGS="$CFLAGS"; abi="elf"], |
| 310 | [abi="aout"]) |
| 311 | AC_MSG_RESULT([$abi]) |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 312 | AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 313 | ;; |
| 314 | *-*-solaris2*) |
| 315 | CFLAGS="$CFLAGS" |
| 316 | abi="elf" |
George Kola | ddd6bd4 | 2014-02-12 23:05:45 +0000 | [diff] [blame] | 317 | AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ]) |
Mike Hommey | fa08da7 | 2012-04-16 16:30:25 +0200 | [diff] [blame] | 318 | RPATH='-Wl,-R,$(1)' |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 319 | dnl Solaris needs this for sigwait(). |
| 320 | CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS" |
| 321 | LIBS="$LIBS -lposix4 -lsocket -lnsl" |
| 322 | ;; |
Antony Dovgal | 2bd3cbc | 2011-10-13 09:33:33 +0400 | [diff] [blame] | 323 | *-ibm-aix*) |
| 324 | if "$LG_SIZEOF_PTR" = "8"; then |
| 325 | dnl 64bit AIX |
| 326 | LD_PRELOAD_VAR="LDR_PRELOAD64" |
| 327 | else |
| 328 | dnl 32bit AIX |
| 329 | LD_PRELOAD_VAR="LDR_PRELOAD" |
| 330 | fi |
| 331 | abi="xcoff" |
Antony Dovgal | 2bd3cbc | 2011-10-13 09:33:33 +0400 | [diff] [blame] | 332 | ;; |
Dave Rigby | 70bdee0 | 2014-09-22 15:53:16 +0100 | [diff] [blame] | 333 | *-*-mingw* | *-*-cygwin*) |
Mike Hommey | a19e87f | 2012-04-21 21:27:46 -0700 | [diff] [blame] | 334 | abi="pecoff" |
| 335 | force_tls="0" |
| 336 | RPATH="" |
| 337 | so="dll" |
Mike Hommey | fd97b1d | 2012-04-30 12:38:31 +0200 | [diff] [blame] | 338 | if test "x$je_cv_msvc" = "xyes" ; then |
| 339 | importlib="lib" |
| 340 | DSO_LDFLAGS="-LD" |
| 341 | EXTRA_LDFLAGS="-link -DEBUG" |
| 342 | CTARGET='-Fo$@' |
| 343 | LDTARGET='-Fe$@' |
Jory A. Pratt | ad505e0 | 2013-08-11 09:44:59 -0500 | [diff] [blame] | 344 | AR='lib' |
| 345 | ARFLAGS='-nologo -out:' |
Jason Evans | 80ddf49 | 2013-08-20 11:48:19 +0100 | [diff] [blame] | 346 | AROUT='$@' |
Mike Hommey | 79c4bca | 2012-05-02 21:30:51 +0200 | [diff] [blame] | 347 | CC_MM= |
Mike Hommey | fd97b1d | 2012-04-30 12:38:31 +0200 | [diff] [blame] | 348 | else |
| 349 | importlib="${so}" |
| 350 | DSO_LDFLAGS="-shared" |
| 351 | fi |
Mike Hommey | a19e87f | 2012-04-21 21:27:46 -0700 | [diff] [blame] | 352 | a="lib" |
| 353 | libprefix="" |
Mike Hommey | 7cdea39 | 2012-04-30 12:38:27 +0200 | [diff] [blame] | 354 | SOREV="${so}" |
Mike Hommey | a19e87f | 2012-04-21 21:27:46 -0700 | [diff] [blame] | 355 | PIC_CFLAGS="" |
| 356 | ;; |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 357 | *) |
| 358 | AC_MSG_RESULT([Unsupported operating system: ${host}]) |
| 359 | abi="elf" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 360 | ;; |
| 361 | esac |
Mike Hommey | affe009 | 2014-05-28 08:10:12 +0900 | [diff] [blame] | 362 | |
| 363 | JEMALLOC_USABLE_SIZE_CONST=const |
| 364 | AC_CHECK_HEADERS([malloc.h], [ |
| 365 | AC_MSG_CHECKING([whether malloc_usable_size definition can use const argument]) |
| 366 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM( |
| 367 | [#include <malloc.h> |
| 368 | #include <stddef.h> |
| 369 | size_t malloc_usable_size(const void *ptr); |
| 370 | ], |
| 371 | [])],[ |
| 372 | AC_MSG_RESULT([yes]) |
| 373 | ],[ |
| 374 | JEMALLOC_USABLE_SIZE_CONST= |
| 375 | AC_MSG_RESULT([no]) |
| 376 | ]) |
| 377 | ]) |
Jason Evans | 247d124 | 2012-10-09 16:20:10 -0700 | [diff] [blame] | 378 | AC_DEFINE_UNQUOTED([JEMALLOC_USABLE_SIZE_CONST], [$JEMALLOC_USABLE_SIZE_CONST]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 379 | AC_SUBST([abi]) |
| 380 | AC_SUBST([RPATH]) |
Antony Dovgal | 2bd3cbc | 2011-10-13 09:33:33 +0400 | [diff] [blame] | 381 | AC_SUBST([LD_PRELOAD_VAR]) |
Jason Evans | f576c63 | 2011-11-01 22:27:41 -0700 | [diff] [blame] | 382 | AC_SUBST([so]) |
Mike Hommey | fd97b1d | 2012-04-30 12:38:31 +0200 | [diff] [blame] | 383 | AC_SUBST([importlib]) |
Mike Hommey | 5bee66d | 2012-04-16 16:30:24 +0200 | [diff] [blame] | 384 | AC_SUBST([o]) |
| 385 | AC_SUBST([a]) |
| 386 | AC_SUBST([exe]) |
Mike Hommey | a19e87f | 2012-04-21 21:27:46 -0700 | [diff] [blame] | 387 | AC_SUBST([libprefix]) |
Mike Hommey | fa08da7 | 2012-04-16 16:30:25 +0200 | [diff] [blame] | 388 | AC_SUBST([DSO_LDFLAGS]) |
Mike Hommey | fd97b1d | 2012-04-30 12:38:31 +0200 | [diff] [blame] | 389 | AC_SUBST([EXTRA_LDFLAGS]) |
Mike Hommey | 85221d5 | 2012-04-18 18:29:40 +0200 | [diff] [blame] | 390 | AC_SUBST([SOREV]) |
Mike Hommey | 188da7c | 2012-04-18 18:29:41 +0200 | [diff] [blame] | 391 | AC_SUBST([PIC_CFLAGS]) |
Mike Hommey | fd97b1d | 2012-04-30 12:38:31 +0200 | [diff] [blame] | 392 | AC_SUBST([CTARGET]) |
| 393 | AC_SUBST([LDTARGET]) |
| 394 | AC_SUBST([MKLIB]) |
Jason Evans | 80ddf49 | 2013-08-20 11:48:19 +0100 | [diff] [blame] | 395 | AC_SUBST([ARFLAGS]) |
| 396 | AC_SUBST([AROUT]) |
Mike Hommey | 79c4bca | 2012-05-02 21:30:51 +0200 | [diff] [blame] | 397 | AC_SUBST([CC_MM]) |
Mike Hommey | fd97b1d | 2012-04-30 12:38:31 +0200 | [diff] [blame] | 398 | |
Jason Evans | fa5d245 | 2011-03-15 10:25:59 -0700 | [diff] [blame] | 399 | JE_COMPILABLE([__attribute__ syntax], |
| 400 | [static __attribute__((unused)) void foo(void){}], |
| 401 | [], |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 402 | [je_cv_attribute]) |
| 403 | if test "x${je_cv_attribute}" = "xyes" ; then |
Jason Evans | fa5d245 | 2011-03-15 10:25:59 -0700 | [diff] [blame] | 404 | AC_DEFINE([JEMALLOC_HAVE_ATTR], [ ]) |
| 405 | if test "x${GCC}" = "xyes" -a "x${abi}" = "xelf"; then |
| 406 | JE_CFLAGS_APPEND([-fvisibility=hidden]) |
| 407 | fi |
| 408 | fi |
Jason Evans | 3cc1f1a | 2012-04-03 22:30:05 -0700 | [diff] [blame] | 409 | dnl Check for tls_model attribute support (clang 3.0 still lacks support). |
| 410 | SAVED_CFLAGS="${CFLAGS}" |
| 411 | JE_CFLAGS_APPEND([-Werror]) |
| 412 | JE_COMPILABLE([tls_model attribute], [], |
| 413 | [static __thread int |
Daniel Micay | f1cf3ea | 2014-09-16 04:42:33 -0400 | [diff] [blame] | 414 | __attribute__((tls_model("initial-exec"), unused)) foo; |
Jason Evans | 3cc1f1a | 2012-04-03 22:30:05 -0700 | [diff] [blame] | 415 | foo = 0;], |
| 416 | [je_cv_tls_model]) |
| 417 | CFLAGS="${SAVED_CFLAGS}" |
| 418 | if test "x${je_cv_tls_model}" = "xyes" ; then |
| 419 | AC_DEFINE([JEMALLOC_TLS_MODEL], |
| 420 | [__attribute__((tls_model("initial-exec")))]) |
| 421 | else |
| 422 | AC_DEFINE([JEMALLOC_TLS_MODEL], [ ]) |
| 423 | fi |
Jason Evans | fa5d245 | 2011-03-15 10:25:59 -0700 | [diff] [blame] | 424 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 425 | dnl Support optional additions to rpath. |
| 426 | AC_ARG_WITH([rpath], |
Jason Evans | 90895cf | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 427 | [AS_HELP_STRING([--with-rpath=<rpath>], [Colon-separated rpath (ELF systems only)])], |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 428 | if test "x$with_rpath" = "xno" ; then |
| 429 | RPATH_EXTRA= |
| 430 | else |
| 431 | RPATH_EXTRA="`echo $with_rpath | tr \":\" \" \"`" |
| 432 | fi, |
| 433 | RPATH_EXTRA= |
| 434 | ) |
| 435 | AC_SUBST([RPATH_EXTRA]) |
| 436 | |
| 437 | dnl Disable rules that do automatic regeneration of configure output by default. |
| 438 | AC_ARG_ENABLE([autogen], |
Jason Evans | 78d815c | 2010-01-17 14:06:20 -0800 | [diff] [blame] | 439 | [AS_HELP_STRING([--enable-autogen], [Automatically regenerate configure output])], |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 440 | if test "x$enable_autogen" = "xno" ; then |
| 441 | enable_autogen="0" |
| 442 | else |
| 443 | enable_autogen="1" |
| 444 | fi |
| 445 | , |
| 446 | enable_autogen="0" |
| 447 | ) |
| 448 | AC_SUBST([enable_autogen]) |
| 449 | |
| 450 | AC_PROG_INSTALL |
| 451 | AC_PROG_RANLIB |
Jason Evans | 7329a4f | 2013-01-22 10:53:29 -0800 | [diff] [blame] | 452 | AC_PATH_PROG([LD], [ld], [false], [$PATH]) |
| 453 | AC_PATH_PROG([AUTOCONF], [autoconf], [false], [$PATH]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 454 | |
Daniel Micay | 4cfe551 | 2014-08-28 15:41:48 -0400 | [diff] [blame] | 455 | public_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 Evans | 7e77eaf | 2012-03-02 17:47:37 -0800 | [diff] [blame] | 456 | |
| 457 | dnl Check for allocator-related functions that should be wrapped. |
| 458 | AC_CHECK_FUNC([memalign], |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 459 | [AC_DEFINE([JEMALLOC_OVERRIDE_MEMALIGN], [ ]) |
Jason Evans | 7e77eaf | 2012-03-02 17:47:37 -0800 | [diff] [blame] | 460 | public_syms="${public_syms} memalign"]) |
| 461 | AC_CHECK_FUNC([valloc], |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 462 | [AC_DEFINE([JEMALLOC_OVERRIDE_VALLOC], [ ]) |
Jason Evans | 7e77eaf | 2012-03-02 17:47:37 -0800 | [diff] [blame] | 463 | public_syms="${public_syms} valloc"]) |
| 464 | |
Jason Evans | 748dfac | 2013-12-06 18:27:33 -0800 | [diff] [blame] | 465 | dnl Do not compute test code coverage by default. |
| 466 | GCOV_FLAGS= |
| 467 | AC_ARG_ENABLE([code-coverage], |
| 468 | [AS_HELP_STRING([--enable-code-coverage], |
| 469 | [Enable code coverage])], |
| 470 | [if test "x$enable_code_coverage" = "xno" ; then |
| 471 | enable_code_coverage="0" |
| 472 | else |
| 473 | enable_code_coverage="1" |
| 474 | fi |
| 475 | ], |
| 476 | [enable_code_coverage="0"] |
| 477 | ) |
| 478 | if test "x$enable_code_coverage" = "x1" ; then |
| 479 | deoptimize="no" |
| 480 | echo "$CFLAGS $EXTRA_CFLAGS" | grep '\-O' >/dev/null || deoptimize="yes" |
| 481 | if test "x${deoptimize}" = "xyes" ; then |
| 482 | JE_CFLAGS_APPEND([-O0]) |
| 483 | fi |
| 484 | JE_CFLAGS_APPEND([-fprofile-arcs -ftest-coverage]) |
| 485 | EXTRA_LDFLAGS="$EXTRA_LDFLAGS -fprofile-arcs -ftest-coverage" |
| 486 | AC_DEFINE([JEMALLOC_CODE_COVERAGE], [ ]) |
| 487 | fi |
| 488 | AC_SUBST([enable_code_coverage]) |
| 489 | |
Jason Evans | 0a5489e | 2012-03-01 17:19:20 -0800 | [diff] [blame] | 490 | dnl Perform no name mangling by default. |
| 491 | AC_ARG_WITH([mangling], |
| 492 | [AS_HELP_STRING([--with-mangling=<map>], [Mangle symbols in <map>])], |
| 493 | [mangling_map="$with_mangling"], [mangling_map=""]) |
Jason Evans | 0a5489e | 2012-03-01 17:19:20 -0800 | [diff] [blame] | 494 | |
Jason Evans | 90895cf | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 495 | dnl Do not prefix public APIs by default. |
| 496 | AC_ARG_WITH([jemalloc_prefix], |
| 497 | [AS_HELP_STRING([--with-jemalloc-prefix=<prefix>], [Prefix to prepend to all public APIs])], |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 498 | [JEMALLOC_PREFIX="$with_jemalloc_prefix"], |
Mike Hommey | 7cdea39 | 2012-04-30 12:38:27 +0200 | [diff] [blame] | 499 | [if test "x$abi" != "xmacho" -a "x$abi" != "xpecoff"; then |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 500 | JEMALLOC_PREFIX="" |
| 501 | else |
| 502 | JEMALLOC_PREFIX="je_" |
| 503 | fi] |
Jason Evans | 90895cf | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 504 | ) |
| 505 | if test "x$JEMALLOC_PREFIX" != "x" ; then |
Jason Evans | e733970 | 2010-10-23 18:37:06 -0700 | [diff] [blame] | 506 | JEMALLOC_CPREFIX=`echo ${JEMALLOC_PREFIX} | tr "a-z" "A-Z"` |
| 507 | AC_DEFINE_UNQUOTED([JEMALLOC_PREFIX], ["$JEMALLOC_PREFIX"]) |
| 508 | AC_DEFINE_UNQUOTED([JEMALLOC_CPREFIX], ["$JEMALLOC_CPREFIX"]) |
Jason Evans | 90895cf | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 509 | fi |
| 510 | |
Mike Hommey | 9906660 | 2012-11-19 10:55:26 +0100 | [diff] [blame] | 511 | AC_ARG_WITH([export], |
| 512 | [AS_HELP_STRING([--without-export], [disable exporting jemalloc public APIs])], |
| 513 | [if test "x$with_export" = "xno"; then |
Jason Evans | 2625c89 | 2013-01-22 16:46:27 -0800 | [diff] [blame] | 514 | AC_DEFINE([JEMALLOC_EXPORT],[]) |
Mike Hommey | 9906660 | 2012-11-19 10:55:26 +0100 | [diff] [blame] | 515 | fi] |
| 516 | ) |
| 517 | |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 518 | dnl Mangle library-private APIs. |
Jason Evans | 746e77a | 2011-07-30 16:40:52 -0700 | [diff] [blame] | 519 | AC_ARG_WITH([private_namespace], |
| 520 | [AS_HELP_STRING([--with-private-namespace=<prefix>], [Prefix to prepend to all library-private APIs])], |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 521 | [JEMALLOC_PRIVATE_NAMESPACE="${with_private_namespace}je_"], |
| 522 | [JEMALLOC_PRIVATE_NAMESPACE="je_"] |
Jason Evans | 746e77a | 2011-07-30 16:40:52 -0700 | [diff] [blame] | 523 | ) |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 524 | AC_DEFINE_UNQUOTED([JEMALLOC_PRIVATE_NAMESPACE], [$JEMALLOC_PRIVATE_NAMESPACE]) |
| 525 | private_namespace="$JEMALLOC_PRIVATE_NAMESPACE" |
| 526 | AC_SUBST([private_namespace]) |
Jason Evans | 746e77a | 2011-07-30 16:40:52 -0700 | [diff] [blame] | 527 | |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 528 | dnl Do not add suffix to installed files by default. |
| 529 | AC_ARG_WITH([install_suffix], |
| 530 | [AS_HELP_STRING([--with-install-suffix=<suffix>], [Suffix to append to all installed files])], |
| 531 | [INSTALL_SUFFIX="$with_install_suffix"], |
| 532 | [INSTALL_SUFFIX=] |
| 533 | ) |
| 534 | install_suffix="$INSTALL_SUFFIX" |
| 535 | AC_SUBST([install_suffix]) |
| 536 | |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 537 | dnl Substitute @je_@ in jemalloc_protos.h.in, primarily to make generation of |
| 538 | dnl jemalloc_protos_jet.h easy. |
| 539 | je_="je_" |
| 540 | AC_SUBST([je_]) |
| 541 | |
Mike Hommey | cf6032d | 2014-07-30 18:16:13 +0900 | [diff] [blame] | 542 | cfgoutputs_in="Makefile.in" |
Nick White | 913e9a8 | 2014-09-19 22:01:23 +0100 | [diff] [blame] | 543 | cfgoutputs_in="${cfgoutputs_in} jemalloc.pc.in" |
Mike Hommey | cf6032d | 2014-07-30 18:16:13 +0900 | [diff] [blame] | 544 | cfgoutputs_in="${cfgoutputs_in} doc/html.xsl.in" |
| 545 | cfgoutputs_in="${cfgoutputs_in} doc/manpages.xsl.in" |
| 546 | cfgoutputs_in="${cfgoutputs_in} doc/jemalloc.xml.in" |
| 547 | cfgoutputs_in="${cfgoutputs_in} include/jemalloc/jemalloc_macros.h.in" |
| 548 | cfgoutputs_in="${cfgoutputs_in} include/jemalloc/jemalloc_protos.h.in" |
Jason Evans | 82e88d1 | 2014-09-07 19:55:03 -0700 | [diff] [blame] | 549 | cfgoutputs_in="${cfgoutputs_in} include/jemalloc/jemalloc_typedefs.h.in" |
Mike Hommey | cf6032d | 2014-07-30 18:16:13 +0900 | [diff] [blame] | 550 | cfgoutputs_in="${cfgoutputs_in} include/jemalloc/internal/jemalloc_internal.h.in" |
| 551 | cfgoutputs_in="${cfgoutputs_in} test/test.sh.in" |
| 552 | cfgoutputs_in="${cfgoutputs_in} test/include/test/jemalloc_test.h.in" |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 553 | |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 554 | cfgoutputs_out="Makefile" |
Nick White | 913e9a8 | 2014-09-19 22:01:23 +0100 | [diff] [blame] | 555 | cfgoutputs_out="${cfgoutputs_out} jemalloc.pc" |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 556 | cfgoutputs_out="${cfgoutputs_out} doc/html.xsl" |
| 557 | cfgoutputs_out="${cfgoutputs_out} doc/manpages.xsl" |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 558 | cfgoutputs_out="${cfgoutputs_out} doc/jemalloc.xml" |
| 559 | cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_macros.h" |
| 560 | cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_protos.h" |
Jason Evans | 82e88d1 | 2014-09-07 19:55:03 -0700 | [diff] [blame] | 561 | cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc_typedefs.h" |
Jason Evans | 376b152 | 2010-02-11 14:45:59 -0800 | [diff] [blame] | 562 | cfgoutputs_out="${cfgoutputs_out} include/jemalloc/internal/jemalloc_internal.h" |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 563 | cfgoutputs_out="${cfgoutputs_out} test/test.sh" |
| 564 | cfgoutputs_out="${cfgoutputs_out} test/include/test/jemalloc_test.h" |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 565 | |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 566 | cfgoutputs_tup="Makefile" |
Nick White | 913e9a8 | 2014-09-19 22:01:23 +0100 | [diff] [blame] | 567 | cfgoutputs_tup="${cfgoutputs_tup} jemalloc.pc:jemalloc.pc.in" |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 568 | cfgoutputs_tup="${cfgoutputs_tup} doc/html.xsl:doc/html.xsl.in" |
| 569 | cfgoutputs_tup="${cfgoutputs_tup} doc/manpages.xsl:doc/manpages.xsl.in" |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 570 | cfgoutputs_tup="${cfgoutputs_tup} doc/jemalloc.xml:doc/jemalloc.xml.in" |
| 571 | cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_macros.h:include/jemalloc/jemalloc_macros.h.in" |
| 572 | cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_protos.h:include/jemalloc/jemalloc_protos.h.in" |
Jason Evans | 82e88d1 | 2014-09-07 19:55:03 -0700 | [diff] [blame] | 573 | cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc_typedefs.h:include/jemalloc/jemalloc_typedefs.h.in" |
Jason Evans | 376b152 | 2010-02-11 14:45:59 -0800 | [diff] [blame] | 574 | cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/internal/jemalloc_internal.h" |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 575 | cfgoutputs_tup="${cfgoutputs_tup} test/test.sh:test/test.sh.in" |
| 576 | cfgoutputs_tup="${cfgoutputs_tup} test/include/test/jemalloc_test.h:test/include/test/jemalloc_test.h.in" |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 577 | |
Mike Hommey | cf6032d | 2014-07-30 18:16:13 +0900 | [diff] [blame] | 578 | cfghdrs_in="include/jemalloc/jemalloc_defs.h.in" |
| 579 | cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/jemalloc_internal_defs.h.in" |
| 580 | cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/private_namespace.sh" |
| 581 | cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/private_unnamespace.sh" |
| 582 | cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/private_symbols.txt" |
| 583 | cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/public_namespace.sh" |
| 584 | cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/public_unnamespace.sh" |
| 585 | cfghdrs_in="${cfghdrs_in} include/jemalloc/internal/size_classes.sh" |
| 586 | cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc_rename.sh" |
| 587 | cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc_mangle.sh" |
| 588 | cfghdrs_in="${cfghdrs_in} include/jemalloc/jemalloc.sh" |
| 589 | cfghdrs_in="${cfghdrs_in} test/include/test/jemalloc_test_defs.h.in" |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 590 | |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 591 | cfghdrs_out="include/jemalloc/jemalloc_defs.h" |
| 592 | cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc${install_suffix}.h" |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 593 | cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/private_namespace.h" |
| 594 | cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/private_unnamespace.h" |
Jason Evans | f234dc5 | 2014-01-16 17:38:01 -0800 | [diff] [blame] | 595 | cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_symbols.txt" |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 596 | cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_namespace.h" |
| 597 | cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/public_unnamespace.h" |
Jason Evans | b172610 | 2012-02-28 16:50:47 -0800 | [diff] [blame] | 598 | cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/size_classes.h" |
Jason Evans | f234dc5 | 2014-01-16 17:38:01 -0800 | [diff] [blame] | 599 | cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_protos_jet.h" |
| 600 | cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_rename.h" |
| 601 | cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_mangle.h" |
| 602 | cfghdrs_out="${cfghdrs_out} include/jemalloc/jemalloc_mangle_jet.h" |
| 603 | cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/jemalloc_internal_defs.h" |
Jason Evans | 80061b6 | 2013-12-09 13:21:08 -0800 | [diff] [blame] | 604 | cfghdrs_out="${cfghdrs_out} test/include/test/jemalloc_test_defs.h" |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 605 | |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 606 | cfghdrs_tup="include/jemalloc/jemalloc_defs.h:include/jemalloc/jemalloc_defs.h.in" |
Mike Hommey | cf6032d | 2014-07-30 18:16:13 +0900 | [diff] [blame] | 607 | cfghdrs_tup="${cfghdrs_tup} include/jemalloc/internal/jemalloc_internal_defs.h:include/jemalloc/internal/jemalloc_internal_defs.h.in" |
| 608 | cfghdrs_tup="${cfghdrs_tup} test/include/test/jemalloc_test_defs.h:test/include/test/jemalloc_test_defs.h.in" |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 609 | |
Jason Evans | 644d414 | 2014-04-14 22:49:23 -0700 | [diff] [blame] | 610 | dnl Silence irrelevant compiler warnings by default. |
Jason Evans | 355b438 | 2010-09-20 19:20:48 -0700 | [diff] [blame] | 611 | AC_ARG_ENABLE([cc-silence], |
Jason Evans | 644d414 | 2014-04-14 22:49:23 -0700 | [diff] [blame] | 612 | [AS_HELP_STRING([--disable-cc-silence], |
| 613 | [Do not silence irrelevant compiler warnings])], |
Jason Evans | 355b438 | 2010-09-20 19:20:48 -0700 | [diff] [blame] | 614 | [if test "x$enable_cc_silence" = "xno" ; then |
| 615 | enable_cc_silence="0" |
| 616 | else |
| 617 | enable_cc_silence="1" |
| 618 | fi |
| 619 | ], |
Jason Evans | 644d414 | 2014-04-14 22:49:23 -0700 | [diff] [blame] | 620 | [enable_cc_silence="1"] |
Jason Evans | 355b438 | 2010-09-20 19:20:48 -0700 | [diff] [blame] | 621 | ) |
| 622 | if test "x$enable_cc_silence" = "x1" ; then |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 623 | AC_DEFINE([JEMALLOC_CC_SILENCE], [ ]) |
Jason Evans | 355b438 | 2010-09-20 19:20:48 -0700 | [diff] [blame] | 624 | fi |
| 625 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 626 | dnl Do not compile with debugging by default. |
| 627 | AC_ARG_ENABLE([debug], |
Mike Hommey | 5135e34 | 2012-12-06 22:16:26 +0100 | [diff] [blame] | 628 | [AS_HELP_STRING([--enable-debug], [Build debugging code (implies --enable-ivsalloc)])], |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 629 | [if test "x$enable_debug" = "xno" ; then |
| 630 | enable_debug="0" |
| 631 | else |
| 632 | enable_debug="1" |
| 633 | fi |
| 634 | ], |
| 635 | [enable_debug="0"] |
| 636 | ) |
| 637 | if test "x$enable_debug" = "x1" ; then |
| 638 | AC_DEFINE([JEMALLOC_DEBUG], [ ]) |
Mike Hommey | 5135e34 | 2012-12-06 22:16:26 +0100 | [diff] [blame] | 639 | enable_ivsalloc="1" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 640 | fi |
| 641 | AC_SUBST([enable_debug]) |
| 642 | |
Mike Hommey | 5135e34 | 2012-12-06 22:16:26 +0100 | [diff] [blame] | 643 | dnl Do not validate pointers by default. |
| 644 | AC_ARG_ENABLE([ivsalloc], |
| 645 | [AS_HELP_STRING([--enable-ivsalloc], [Validate pointers passed through the public API])], |
| 646 | [if test "x$enable_ivsalloc" = "xno" ; then |
| 647 | enable_ivsalloc="0" |
| 648 | else |
| 649 | enable_ivsalloc="1" |
| 650 | fi |
| 651 | ], |
| 652 | [enable_ivsalloc="0"] |
| 653 | ) |
| 654 | if test "x$enable_ivsalloc" = "x1" ; then |
| 655 | AC_DEFINE([JEMALLOC_IVSALLOC], [ ]) |
| 656 | fi |
| 657 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 658 | dnl Only optimize if not debugging. |
| 659 | if test "x$enable_debug" = "x0" -a "x$no_CFLAGS" = "xyes" ; then |
| 660 | dnl Make sure that an optimization flag was not specified in EXTRA_CFLAGS. |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 661 | optimize="no" |
Jason Evans | 748dfac | 2013-12-06 18:27:33 -0800 | [diff] [blame] | 662 | echo "$CFLAGS $EXTRA_CFLAGS" | grep '\-O' >/dev/null || optimize="yes" |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 663 | if test "x${optimize}" = "xyes" ; then |
| 664 | if test "x$GCC" = "xyes" ; then |
| 665 | JE_CFLAGS_APPEND([-O3]) |
| 666 | JE_CFLAGS_APPEND([-funroll-loops]) |
Mike Hommey | fd97b1d | 2012-04-30 12:38:31 +0200 | [diff] [blame] | 667 | elif test "x$je_cv_msvc" = "xyes" ; then |
| 668 | JE_CFLAGS_APPEND([-O2]) |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 669 | else |
| 670 | JE_CFLAGS_APPEND([-O]) |
| 671 | fi |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 672 | fi |
| 673 | fi |
| 674 | |
Jason Evans | d073a32 | 2012-02-28 20:41:16 -0800 | [diff] [blame] | 675 | dnl Enable statistics calculation by default. |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 676 | AC_ARG_ENABLE([stats], |
Jason Evans | 777c191 | 2012-02-28 20:49:22 -0800 | [diff] [blame] | 677 | [AS_HELP_STRING([--disable-stats], |
| 678 | [Disable statistics calculation/reporting])], |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 679 | [if test "x$enable_stats" = "xno" ; then |
| 680 | enable_stats="0" |
| 681 | else |
| 682 | enable_stats="1" |
| 683 | fi |
| 684 | ], |
Jason Evans | d073a32 | 2012-02-28 20:41:16 -0800 | [diff] [blame] | 685 | [enable_stats="1"] |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 686 | ) |
| 687 | if test "x$enable_stats" = "x1" ; then |
| 688 | AC_DEFINE([JEMALLOC_STATS], [ ]) |
| 689 | fi |
| 690 | AC_SUBST([enable_stats]) |
| 691 | |
Jason Evans | 6109fe0 | 2010-02-10 10:37:56 -0800 | [diff] [blame] | 692 | dnl Do not enable profiling by default. |
| 693 | AC_ARG_ENABLE([prof], |
| 694 | [AS_HELP_STRING([--enable-prof], [Enable allocation profiling])], |
| 695 | [if test "x$enable_prof" = "xno" ; then |
| 696 | enable_prof="0" |
| 697 | else |
| 698 | enable_prof="1" |
| 699 | fi |
| 700 | ], |
| 701 | [enable_prof="0"] |
| 702 | ) |
Jason Evans | 77f350b | 2011-03-15 22:23:12 -0700 | [diff] [blame] | 703 | if test "x$enable_prof" = "x1" ; then |
| 704 | backtrace_method="" |
Jason Evans | b27805b | 2010-02-10 18:15:53 -0800 | [diff] [blame] | 705 | else |
Jason Evans | 77f350b | 2011-03-15 22:23:12 -0700 | [diff] [blame] | 706 | backtrace_method="N/A" |
Jason Evans | b27805b | 2010-02-10 18:15:53 -0800 | [diff] [blame] | 707 | fi |
Jason Evans | 77f350b | 2011-03-15 22:23:12 -0700 | [diff] [blame] | 708 | |
Jason Evans | 6109fe0 | 2010-02-10 10:37:56 -0800 | [diff] [blame] | 709 | AC_ARG_ENABLE([prof-libunwind], |
| 710 | [AS_HELP_STRING([--enable-prof-libunwind], [Use libunwind for backtracing])], |
| 711 | [if test "x$enable_prof_libunwind" = "xno" ; then |
| 712 | enable_prof_libunwind="0" |
| 713 | else |
| 714 | enable_prof_libunwind="1" |
| 715 | fi |
| 716 | ], |
| 717 | [enable_prof_libunwind="0"] |
| 718 | ) |
Jason Evans | ca6bd4f | 2010-03-02 14:12:58 -0800 | [diff] [blame] | 719 | AC_ARG_WITH([static_libunwind], |
| 720 | [AS_HELP_STRING([--with-static-libunwind=<libunwind.a>], |
| 721 | [Path to static libunwind library; use rather than dynamically linking])], |
| 722 | if test "x$with_static_libunwind" = "xno" ; then |
| 723 | LUNWIND="-lunwind" |
| 724 | else |
| 725 | if test ! -f "$with_static_libunwind" ; then |
| 726 | AC_MSG_ERROR([Static libunwind not found: $with_static_libunwind]) |
| 727 | fi |
| 728 | LUNWIND="$with_static_libunwind" |
| 729 | fi, |
| 730 | LUNWIND="-lunwind" |
| 731 | ) |
Jason Evans | 77f350b | 2011-03-15 22:23:12 -0700 | [diff] [blame] | 732 | if test "x$backtrace_method" = "x" -a "x$enable_prof_libunwind" = "x1" ; then |
| 733 | AC_CHECK_HEADERS([libunwind.h], , [enable_prof_libunwind="0"]) |
| 734 | if test "x$LUNWIND" = "x-lunwind" ; then |
Jason Evans | 05125b8 | 2014-04-22 20:48:07 -0700 | [diff] [blame] | 735 | AC_CHECK_LIB([unwind], [unw_backtrace], [LIBS="$LIBS $LUNWIND"], |
Jason Evans | 77f350b | 2011-03-15 22:23:12 -0700 | [diff] [blame] | 736 | [enable_prof_libunwind="0"]) |
| 737 | else |
| 738 | LIBS="$LIBS $LUNWIND" |
| 739 | fi |
| 740 | if test "x${enable_prof_libunwind}" = "x1" ; then |
| 741 | backtrace_method="libunwind" |
| 742 | AC_DEFINE([JEMALLOC_PROF_LIBUNWIND], [ ]) |
| 743 | fi |
| 744 | fi |
| 745 | |
| 746 | AC_ARG_ENABLE([prof-libgcc], |
| 747 | [AS_HELP_STRING([--disable-prof-libgcc], |
| 748 | [Do not use libgcc for backtracing])], |
| 749 | [if test "x$enable_prof_libgcc" = "xno" ; then |
| 750 | enable_prof_libgcc="0" |
| 751 | else |
| 752 | enable_prof_libgcc="1" |
| 753 | fi |
| 754 | ], |
| 755 | [enable_prof_libgcc="1"] |
| 756 | ) |
| 757 | if test "x$backtrace_method" = "x" -a "x$enable_prof_libgcc" = "x1" \ |
| 758 | -a "x$GCC" = "xyes" ; then |
| 759 | AC_CHECK_HEADERS([unwind.h], , [enable_prof_libgcc="0"]) |
| 760 | AC_CHECK_LIB([gcc], [_Unwind_Backtrace], [LIBS="$LIBS -lgcc"], [enable_prof_libgcc="0"]) |
Jason Evans | 77f350b | 2011-03-15 22:23:12 -0700 | [diff] [blame] | 761 | if test "x${enable_prof_libgcc}" = "x1" ; then |
| 762 | backtrace_method="libgcc" |
| 763 | AC_DEFINE([JEMALLOC_PROF_LIBGCC], [ ]) |
| 764 | fi |
| 765 | else |
| 766 | enable_prof_libgcc="0" |
| 767 | fi |
| 768 | |
| 769 | AC_ARG_ENABLE([prof-gcc], |
| 770 | [AS_HELP_STRING([--disable-prof-gcc], |
| 771 | [Do not use gcc intrinsics for backtracing])], |
| 772 | [if test "x$enable_prof_gcc" = "xno" ; then |
| 773 | enable_prof_gcc="0" |
| 774 | else |
| 775 | enable_prof_gcc="1" |
| 776 | fi |
| 777 | ], |
| 778 | [enable_prof_gcc="1"] |
| 779 | ) |
| 780 | if test "x$backtrace_method" = "x" -a "x$enable_prof_gcc" = "x1" \ |
| 781 | -a "x$GCC" = "xyes" ; then |
Jason Evans | e181f5a | 2014-03-30 18:58:32 -0700 | [diff] [blame] | 782 | JE_CFLAGS_APPEND([-fno-omit-frame-pointer]) |
Jason Evans | 77f350b | 2011-03-15 22:23:12 -0700 | [diff] [blame] | 783 | backtrace_method="gcc intrinsics" |
| 784 | AC_DEFINE([JEMALLOC_PROF_GCC], [ ]) |
| 785 | else |
| 786 | enable_prof_gcc="0" |
| 787 | fi |
| 788 | |
| 789 | if test "x$backtrace_method" = "x" ; then |
| 790 | backtrace_method="none (disabling profiling)" |
| 791 | enable_prof="0" |
| 792 | fi |
| 793 | AC_MSG_CHECKING([configured backtracing method]) |
| 794 | AC_MSG_RESULT([$backtrace_method]) |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 795 | if test "x$enable_prof" = "x1" ; then |
Jason Evans | d37d5ad | 2013-12-05 23:01:50 -0800 | [diff] [blame] | 796 | if test "x$abi" != "xpecoff"; then |
| 797 | dnl Heap profiling uses the log(3) function. |
| 798 | LIBS="$LIBS -lm" |
| 799 | fi |
| 800 | |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 801 | AC_DEFINE([JEMALLOC_PROF], [ ]) |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 802 | fi |
| 803 | AC_SUBST([enable_prof]) |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 804 | |
Jason Evans | 84cbbcb | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 805 | dnl Enable thread-specific caching by default. |
| 806 | AC_ARG_ENABLE([tcache], |
| 807 | [AS_HELP_STRING([--disable-tcache], [Disable per thread caches])], |
| 808 | [if test "x$enable_tcache" = "xno" ; then |
| 809 | enable_tcache="0" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 810 | else |
Jason Evans | 84cbbcb | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 811 | enable_tcache="1" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 812 | fi |
| 813 | ], |
Jason Evans | 84cbbcb | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 814 | [enable_tcache="1"] |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 815 | ) |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 816 | if test "x$enable_tcache" = "x1" ; then |
| 817 | AC_DEFINE([JEMALLOC_TCACHE], [ ]) |
| 818 | fi |
| 819 | AC_SUBST([enable_tcache]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 820 | |
Jason Evans | 59ae276 | 2012-04-16 17:52:27 -0700 | [diff] [blame] | 821 | dnl Enable VM deallocation via munmap() by default. |
| 822 | AC_ARG_ENABLE([munmap], |
| 823 | [AS_HELP_STRING([--disable-munmap], [Disable VM deallocation via munmap(2)])], |
| 824 | [if test "x$enable_munmap" = "xno" ; then |
| 825 | enable_munmap="0" |
| 826 | else |
| 827 | enable_munmap="1" |
| 828 | fi |
| 829 | ], |
| 830 | [enable_munmap="${default_munmap}"] |
| 831 | ) |
| 832 | if test "x$enable_munmap" = "x1" ; then |
| 833 | AC_DEFINE([JEMALLOC_MUNMAP], [ ]) |
| 834 | fi |
| 835 | AC_SUBST([enable_munmap]) |
| 836 | |
Jason Evans | 4d434ad | 2014-04-15 12:09:48 -0700 | [diff] [blame] | 837 | dnl Enable allocation from DSS if supported by the OS. |
| 838 | have_dss="1" |
Mike Hommey | 83c324a | 2012-04-12 10:13:03 +0200 | [diff] [blame] | 839 | dnl Check whether the BSD/SUSv1 sbrk() exists. If not, disable DSS support. |
| 840 | AC_CHECK_FUNC([sbrk], [have_sbrk="1"], [have_sbrk="0"]) |
| 841 | if test "x$have_sbrk" = "x1" ; then |
Steven Stewart-Gallus | 79230fe | 2014-06-19 16:11:43 -0700 | [diff] [blame] | 842 | if test "x$sbrk_deprecated" = "x1" ; then |
Jason Evans | 6668853 | 2013-12-03 21:49:36 -0800 | [diff] [blame] | 843 | AC_MSG_RESULT([Disabling dss allocation because sbrk is deprecated]) |
Jason Evans | 4d434ad | 2014-04-15 12:09:48 -0700 | [diff] [blame] | 844 | have_dss="0" |
Jason Evans | 6668853 | 2013-12-03 21:49:36 -0800 | [diff] [blame] | 845 | fi |
Mike Hommey | 83c324a | 2012-04-12 10:13:03 +0200 | [diff] [blame] | 846 | else |
Jason Evans | 4d434ad | 2014-04-15 12:09:48 -0700 | [diff] [blame] | 847 | have_dss="0" |
Mike Hommey | 83c324a | 2012-04-12 10:13:03 +0200 | [diff] [blame] | 848 | fi |
| 849 | |
Jason Evans | 4d434ad | 2014-04-15 12:09:48 -0700 | [diff] [blame] | 850 | if test "x$have_dss" = "x1" ; then |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 851 | AC_DEFINE([JEMALLOC_DSS], [ ]) |
| 852 | fi |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 853 | |
Jason Evans | 777c191 | 2012-02-28 20:49:22 -0800 | [diff] [blame] | 854 | dnl Support the junk/zero filling option by default. |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 855 | AC_ARG_ENABLE([fill], |
Jason Evans | 122449b | 2012-04-06 00:35:09 -0700 | [diff] [blame] | 856 | [AS_HELP_STRING([--disable-fill], |
| 857 | [Disable support for junk/zero filling, quarantine, and redzones])], |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 858 | [if test "x$enable_fill" = "xno" ; then |
| 859 | enable_fill="0" |
| 860 | else |
| 861 | enable_fill="1" |
| 862 | fi |
| 863 | ], |
Jason Evans | 777c191 | 2012-02-28 20:49:22 -0800 | [diff] [blame] | 864 | [enable_fill="1"] |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 865 | ) |
| 866 | if test "x$enable_fill" = "x1" ; then |
| 867 | AC_DEFINE([JEMALLOC_FILL], [ ]) |
| 868 | fi |
| 869 | AC_SUBST([enable_fill]) |
| 870 | |
Jason Evans | b147611 | 2012-04-05 13:36:17 -0700 | [diff] [blame] | 871 | dnl Disable utrace(2)-based tracing by default. |
| 872 | AC_ARG_ENABLE([utrace], |
| 873 | [AS_HELP_STRING([--enable-utrace], [Enable utrace(2)-based tracing])], |
| 874 | [if test "x$enable_utrace" = "xno" ; then |
| 875 | enable_utrace="0" |
| 876 | else |
| 877 | enable_utrace="1" |
| 878 | fi |
| 879 | ], |
| 880 | [enable_utrace="0"] |
| 881 | ) |
| 882 | JE_COMPILABLE([utrace(2)], [ |
| 883 | #include <sys/types.h> |
| 884 | #include <sys/param.h> |
| 885 | #include <sys/time.h> |
| 886 | #include <sys/uio.h> |
| 887 | #include <sys/ktrace.h> |
| 888 | ], [ |
| 889 | utrace((void *)0, 0); |
| 890 | ], [je_cv_utrace]) |
| 891 | if test "x${je_cv_utrace}" = "xno" ; then |
| 892 | enable_utrace="0" |
| 893 | fi |
| 894 | if test "x$enable_utrace" = "x1" ; then |
| 895 | AC_DEFINE([JEMALLOC_UTRACE], [ ]) |
| 896 | fi |
| 897 | AC_SUBST([enable_utrace]) |
| 898 | |
Jason Evans | 122449b | 2012-04-06 00:35:09 -0700 | [diff] [blame] | 899 | dnl Support Valgrind by default. |
| 900 | AC_ARG_ENABLE([valgrind], |
| 901 | [AS_HELP_STRING([--disable-valgrind], [Disable support for Valgrind])], |
| 902 | [if test "x$enable_valgrind" = "xno" ; then |
| 903 | enable_valgrind="0" |
| 904 | else |
| 905 | enable_valgrind="1" |
| 906 | fi |
| 907 | ], |
| 908 | [enable_valgrind="1"] |
| 909 | ) |
| 910 | if test "x$enable_valgrind" = "x1" ; then |
| 911 | JE_COMPILABLE([valgrind], [ |
| 912 | #include <valgrind/valgrind.h> |
| 913 | #include <valgrind/memcheck.h> |
| 914 | |
Mike Hommey | 7bfecf4 | 2012-04-30 15:15:15 +0200 | [diff] [blame] | 915 | #if !defined(VALGRIND_RESIZEINPLACE_BLOCK) |
Jason Evans | 122449b | 2012-04-06 00:35:09 -0700 | [diff] [blame] | 916 | # error "Incompatible Valgrind version" |
| 917 | #endif |
| 918 | ], [], [je_cv_valgrind]) |
| 919 | if test "x${je_cv_valgrind}" = "xno" ; then |
| 920 | enable_valgrind="0" |
| 921 | fi |
| 922 | if test "x$enable_valgrind" = "x1" ; then |
| 923 | AC_DEFINE([JEMALLOC_VALGRIND], [ ]) |
| 924 | fi |
| 925 | fi |
| 926 | AC_SUBST([enable_valgrind]) |
| 927 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 928 | dnl Do not support the xmalloc option by default. |
| 929 | AC_ARG_ENABLE([xmalloc], |
| 930 | [AS_HELP_STRING([--enable-xmalloc], [Support xmalloc option])], |
| 931 | [if test "x$enable_xmalloc" = "xno" ; then |
| 932 | enable_xmalloc="0" |
| 933 | else |
| 934 | enable_xmalloc="1" |
| 935 | fi |
| 936 | ], |
| 937 | [enable_xmalloc="0"] |
| 938 | ) |
| 939 | if test "x$enable_xmalloc" = "x1" ; then |
| 940 | AC_DEFINE([JEMALLOC_XMALLOC], [ ]) |
| 941 | fi |
| 942 | AC_SUBST([enable_xmalloc]) |
| 943 | |
Mike Hommey | 8f50ec8 | 2014-06-04 12:12:55 +0900 | [diff] [blame] | 944 | dnl ============================================================================ |
| 945 | dnl Check for __builtin_ffsl(), then ffsl(3), and fail if neither are found. |
| 946 | dnl One of those two functions should (theoretically) exist on all platforms |
| 947 | dnl that jemalloc currently has a chance of functioning on without modification. |
| 948 | dnl We additionally assume ffs() or __builtin_ffs() are defined if |
| 949 | dnl ffsl() or __builtin_ffsl() are defined, respectively. |
| 950 | JE_COMPILABLE([a program using __builtin_ffsl], [ |
| 951 | #include <stdio.h> |
| 952 | #include <strings.h> |
| 953 | #include <string.h> |
| 954 | ], [ |
| 955 | { |
| 956 | int rv = __builtin_ffsl(0x08); |
| 957 | printf("%d\n", rv); |
| 958 | } |
| 959 | ], [je_cv_gcc_builtin_ffsl]) |
Steven Stewart-Gallus | 79230fe | 2014-06-19 16:11:43 -0700 | [diff] [blame] | 960 | if test "x${je_cv_gcc_builtin_ffsl}" = "xyes" ; then |
Mike Hommey | 8f50ec8 | 2014-06-04 12:12:55 +0900 | [diff] [blame] | 961 | AC_DEFINE([JEMALLOC_INTERNAL_FFSL], [__builtin_ffsl]) |
| 962 | AC_DEFINE([JEMALLOC_INTERNAL_FFS], [__builtin_ffs]) |
| 963 | else |
| 964 | JE_COMPILABLE([a program using ffsl], [ |
| 965 | #include <stdio.h> |
| 966 | #include <strings.h> |
| 967 | #include <string.h> |
| 968 | ], [ |
| 969 | { |
| 970 | int rv = ffsl(0x08); |
| 971 | printf("%d\n", rv); |
| 972 | } |
| 973 | ], [je_cv_function_ffsl]) |
Steven Stewart-Gallus | 79230fe | 2014-06-19 16:11:43 -0700 | [diff] [blame] | 974 | if test "x${je_cv_function_ffsl}" = "xyes" ; then |
Mike Hommey | 8f50ec8 | 2014-06-04 12:12:55 +0900 | [diff] [blame] | 975 | AC_DEFINE([JEMALLOC_INTERNAL_FFSL], [ffsl]) |
| 976 | AC_DEFINE([JEMALLOC_INTERNAL_FFS], [ffs]) |
| 977 | else |
| 978 | AC_MSG_ERROR([Cannot build without ffsl(3) or __builtin_ffsl()]) |
| 979 | fi |
| 980 | fi |
| 981 | |
Jason Evans | 81e5475 | 2014-10-10 22:34:25 -0700 | [diff] [blame] | 982 | AC_ARG_WITH([lg_tiny_min], |
| 983 | [AS_HELP_STRING([--with-lg-tiny-min=<lg-tiny-min>], |
| 984 | [Base 2 log of minimum tiny size class to support])], |
| 985 | [LG_TINY_MIN="$with_lg_tiny_min"], |
| 986 | [LG_TINY_MIN="3"]) |
| 987 | AC_DEFINE_UNQUOTED([LG_TINY_MIN], [$LG_TINY_MIN]) |
| 988 | |
Jason Evans | fc0b3b7 | 2014-10-09 17:54:06 -0700 | [diff] [blame] | 989 | AC_ARG_WITH([lg_quantum], |
| 990 | [AS_HELP_STRING([--with-lg-quantum=<lg-quantum>], |
| 991 | [Base 2 log of minimum allocation alignment])], |
Jason Evans | 81e5475 | 2014-10-10 22:34:25 -0700 | [diff] [blame] | 992 | [LG_QUANTA="$with_lg_quantum"], |
| 993 | [LG_QUANTA="3 4"]) |
| 994 | if test "x$with_lg_quantum" != "x" ; then |
| 995 | AC_DEFINE_UNQUOTED([LG_QUANTUM], [$with_lg_quantum]) |
| 996 | fi |
Jason Evans | fc0b3b7 | 2014-10-09 17:54:06 -0700 | [diff] [blame] | 997 | |
| 998 | AC_ARG_WITH([lg_page], |
| 999 | [AS_HELP_STRING([--with-lg-page=<lg-page>], [Base 2 log of system page size])], |
| 1000 | [LG_PAGE="$with_lg_page"], [LG_PAGE="detect"]) |
| 1001 | if test "x$LG_PAGE" == "xdetect"; then |
| 1002 | AC_CACHE_CHECK([LG_PAGE], |
| 1003 | [je_cv_lg_page], |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 1004 | AC_RUN_IFELSE([AC_LANG_PROGRAM( |
Mike Hommey | a19e87f | 2012-04-21 21:27:46 -0700 | [diff] [blame] | 1005 | [[ |
Mike Hommey | fd97b1d | 2012-04-30 12:38:31 +0200 | [diff] [blame] | 1006 | #include <strings.h> |
Mike Hommey | a19e87f | 2012-04-21 21:27:46 -0700 | [diff] [blame] | 1007 | #ifdef _WIN32 |
| 1008 | #include <windows.h> |
| 1009 | #else |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1010 | #include <unistd.h> |
Mike Hommey | a19e87f | 2012-04-21 21:27:46 -0700 | [diff] [blame] | 1011 | #endif |
| 1012 | #include <stdio.h> |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 1013 | ]], |
| 1014 | [[ |
Garrett Cooper | 72c1e59 | 2012-12-02 17:57:28 -0800 | [diff] [blame] | 1015 | int result; |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1016 | FILE *f; |
| 1017 | |
Mike Hommey | a19e87f | 2012-04-21 21:27:46 -0700 | [diff] [blame] | 1018 | #ifdef _WIN32 |
| 1019 | SYSTEM_INFO si; |
| 1020 | GetSystemInfo(&si); |
| 1021 | result = si.dwPageSize; |
| 1022 | #else |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1023 | result = sysconf(_SC_PAGESIZE); |
Mike Hommey | a19e87f | 2012-04-21 21:27:46 -0700 | [diff] [blame] | 1024 | #endif |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1025 | if (result == -1) { |
| 1026 | return 1; |
| 1027 | } |
Mike Hommey | 8f50ec8 | 2014-06-04 12:12:55 +0900 | [diff] [blame] | 1028 | result = JEMALLOC_INTERNAL_FFSL(result) - 1; |
Mike Hommey | a19e87f | 2012-04-21 21:27:46 -0700 | [diff] [blame] | 1029 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1030 | f = fopen("conftest.out", "w"); |
| 1031 | if (f == NULL) { |
| 1032 | return 1; |
| 1033 | } |
Garrett Cooper | 72c1e59 | 2012-12-02 17:57:28 -0800 | [diff] [blame] | 1034 | fprintf(f, "%d\n", result); |
Jason Evans | 3cc1f1a | 2012-04-03 22:30:05 -0700 | [diff] [blame] | 1035 | fclose(f); |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1036 | |
| 1037 | return 0; |
| 1038 | ]])], |
Jason Evans | fc0b3b7 | 2014-10-09 17:54:06 -0700 | [diff] [blame] | 1039 | [je_cv_lg_page=`cat conftest.out`], |
| 1040 | [je_cv_lg_page=undefined], |
| 1041 | [je_cv_lg_page=12])) |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 1042 | fi |
Jason Evans | fc0b3b7 | 2014-10-09 17:54:06 -0700 | [diff] [blame] | 1043 | if test "x${je_cv_lg_page}" != "x" ; then |
| 1044 | LG_PAGE="${je_cv_lg_page}" |
| 1045 | fi |
| 1046 | if test "x${LG_PAGE}" != "xundefined" ; then |
| 1047 | AC_DEFINE_UNQUOTED([LG_PAGE], [$LG_PAGE]) |
| 1048 | else |
| 1049 | AC_MSG_ERROR([cannot determine value for LG_PAGE]) |
| 1050 | fi |
| 1051 | |
| 1052 | AC_ARG_WITH([lg_page_sizes], |
| 1053 | [AS_HELP_STRING([--with-lg-page-sizes=<lg-page-sizes>], |
| 1054 | [Base 2 logs of system page sizes to support])], |
| 1055 | [LG_PAGE_SIZES="$with_lg_page_sizes"], [LG_PAGE_SIZES="$LG_PAGE"]) |
| 1056 | |
| 1057 | AC_ARG_WITH([lg_size_class_group], |
| 1058 | [AS_HELP_STRING([--with-lg-size-class-group=<lg-size-class-group>], |
| 1059 | [Base 2 log of size classes per doubling])], |
| 1060 | [LG_SIZE_CLASS_GROUP="$with_lg_size_class_group"], |
| 1061 | [LG_SIZE_CLASS_GROUP="2"]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1062 | |
| 1063 | dnl ============================================================================ |
| 1064 | dnl jemalloc configuration. |
| 1065 | dnl |
Jason Evans | a40bc7a | 2010-03-02 13:01:16 -0800 | [diff] [blame] | 1066 | |
Jason Evans | a5a658a | 2014-09-02 15:07:07 -0700 | [diff] [blame] | 1067 | dnl Set VERSION if source directory is inside a git repository. |
| 1068 | if test "x`git rev-parse --is-inside-work-tree 2>/dev/null`" = "xtrue" ; then |
| 1069 | dnl Pattern globs aren't powerful enough to match both single- and |
| 1070 | dnl double-digit version numbers, so iterate over patterns to support up to |
| 1071 | dnl version 99.99.99 without any accidental matches. |
| 1072 | rm -f "${srcroot}VERSION" |
| 1073 | for pattern in ['[0-9].[0-9].[0-9]' '[0-9].[0-9].[0-9][0-9]' \ |
| 1074 | '[0-9].[0-9][0-9].[0-9]' '[0-9].[0-9][0-9].[0-9][0-9]' \ |
| 1075 | '[0-9][0-9].[0-9].[0-9]' '[0-9][0-9].[0-9].[0-9][0-9]' \ |
| 1076 | '[0-9][0-9].[0-9][0-9].[0-9]' \ |
| 1077 | '[0-9][0-9].[0-9][0-9].[0-9][0-9]']; do |
| 1078 | if test ! -e "${srcroot}VERSION" ; then |
| 1079 | git describe --long --abbrev=40 --match="${pattern}" > "${srcroot}VERSION.tmp" 2>/dev/null |
| 1080 | if test $? -eq 0 ; then |
| 1081 | mv "${srcroot}VERSION.tmp" "${srcroot}VERSION" |
| 1082 | break |
| 1083 | fi |
| 1084 | fi |
| 1085 | done |
Jason Evans | a40bc7a | 2010-03-02 13:01:16 -0800 | [diff] [blame] | 1086 | fi |
Jason Evans | a5a658a | 2014-09-02 15:07:07 -0700 | [diff] [blame] | 1087 | rm -f "${srcroot}VERSION.tmp" |
| 1088 | if test ! -e "${srcroot}VERSION" ; then |
| 1089 | AC_MSG_RESULT( |
| 1090 | [Missing VERSION file, and unable to generate it; creating bogus VERSION]) |
| 1091 | echo "0.0.0-0-g0000000000000000000000000000000000000000" > "${srcroot}VERSION" |
| 1092 | fi |
| 1093 | jemalloc_version=`cat "${srcroot}VERSION"` |
Jason Evans | a40bc7a | 2010-03-02 13:01:16 -0800 | [diff] [blame] | 1094 | jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'` |
| 1095 | jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'` |
| 1096 | jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'` |
| 1097 | jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'` |
| 1098 | jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'` |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1099 | AC_SUBST([jemalloc_version]) |
Jason Evans | a40bc7a | 2010-03-02 13:01:16 -0800 | [diff] [blame] | 1100 | AC_SUBST([jemalloc_version_major]) |
| 1101 | AC_SUBST([jemalloc_version_minor]) |
| 1102 | AC_SUBST([jemalloc_version_bugfix]) |
| 1103 | AC_SUBST([jemalloc_version_nrev]) |
| 1104 | AC_SUBST([jemalloc_version_gid]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1105 | |
| 1106 | dnl ============================================================================ |
| 1107 | dnl Configure pthreads. |
| 1108 | |
Mike Hommey | a19e87f | 2012-04-21 21:27:46 -0700 | [diff] [blame] | 1109 | if test "x$abi" != "xpecoff" ; then |
| 1110 | AC_CHECK_HEADERS([pthread.h], , [AC_MSG_ERROR([pthread.h is missing])]) |
| 1111 | dnl Some systems may embed pthreads functionality in libc; check for libpthread |
| 1112 | dnl first, but try libc too before failing. |
| 1113 | AC_CHECK_LIB([pthread], [pthread_create], [LIBS="$LIBS -lpthread"], |
| 1114 | [AC_SEARCH_LIBS([pthread_create], , , |
| 1115 | AC_MSG_ERROR([libpthread is missing]))]) |
| 1116 | fi |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1117 | |
| 1118 | CPPFLAGS="$CPPFLAGS -D_REENTRANT" |
| 1119 | |
Daniel Micay | b74041f | 2014-12-09 17:41:34 -0500 | [diff] [blame] | 1120 | dnl Check if the GNU-specific secure_getenv function exists. |
| 1121 | AC_CHECK_FUNC([secure_getenv], |
| 1122 | [have_secure_getenv="1"], |
| 1123 | [have_secure_getenv="0"] |
| 1124 | ) |
| 1125 | if test "x$have_secure_getenv" = "x1" ; then |
| 1126 | AC_DEFINE([JEMALLOC_HAVE_SECURE_GETENV], [ ]) |
| 1127 | fi |
| 1128 | |
| 1129 | dnl Check if the Solaris/BSD issetugid function exists. |
| 1130 | AC_CHECK_FUNC([issetugid], |
| 1131 | [have_issetugid="1"], |
| 1132 | [have_issetugid="0"] |
| 1133 | ) |
| 1134 | if test "x$have_issetugid" = "x1" ; then |
| 1135 | AC_DEFINE([JEMALLOC_HAVE_ISSETUGID], [ ]) |
| 1136 | fi |
| 1137 | |
Jason Evans | cd9a134 | 2012-03-21 18:33:03 -0700 | [diff] [blame] | 1138 | dnl Check whether the BSD-specific _malloc_thread_cleanup() exists. If so, use |
| 1139 | dnl it rather than pthreads TSD cleanup functions to support cleanup during |
| 1140 | dnl thread exit, in order to avoid pthreads library recursion during |
| 1141 | dnl bootstrapping. |
Jason Evans | cd9a134 | 2012-03-21 18:33:03 -0700 | [diff] [blame] | 1142 | AC_CHECK_FUNC([_malloc_thread_cleanup], |
| 1143 | [have__malloc_thread_cleanup="1"], |
| 1144 | [have__malloc_thread_cleanup="0"] |
| 1145 | ) |
| 1146 | if test "x$have__malloc_thread_cleanup" = "x1" ; then |
| 1147 | AC_DEFINE([JEMALLOC_MALLOC_THREAD_CLEANUP], [ ]) |
| 1148 | force_tls="1" |
| 1149 | fi |
| 1150 | |
Jason Evans | 41b6afb | 2012-02-02 22:04:57 -0800 | [diff] [blame] | 1151 | dnl Check whether the BSD-specific _pthread_mutex_init_calloc_cb() exists. If |
| 1152 | dnl so, mutex initialization causes allocation, and we need to implement this |
| 1153 | dnl callback function in order to prevent recursive allocation. |
| 1154 | AC_CHECK_FUNC([_pthread_mutex_init_calloc_cb], |
| 1155 | [have__pthread_mutex_init_calloc_cb="1"], |
| 1156 | [have__pthread_mutex_init_calloc_cb="0"] |
| 1157 | ) |
| 1158 | if test "x$have__pthread_mutex_init_calloc_cb" = "x1" ; then |
| 1159 | AC_DEFINE([JEMALLOC_MUTEX_INIT_CB]) |
| 1160 | fi |
| 1161 | |
Jason Evans | 0fee70d | 2012-02-13 12:36:11 -0800 | [diff] [blame] | 1162 | dnl Disable lazy locking by default. |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1163 | AC_ARG_ENABLE([lazy_lock], |
Jason Evans | 0fee70d | 2012-02-13 12:36:11 -0800 | [diff] [blame] | 1164 | [AS_HELP_STRING([--enable-lazy-lock], |
| 1165 | [Enable lazy locking (only lock when multi-threaded)])], |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1166 | [if test "x$enable_lazy_lock" = "xno" ; then |
| 1167 | enable_lazy_lock="0" |
| 1168 | else |
| 1169 | enable_lazy_lock="1" |
| 1170 | fi |
| 1171 | ], |
Jason Evans | 0fee70d | 2012-02-13 12:36:11 -0800 | [diff] [blame] | 1172 | [enable_lazy_lock="0"] |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1173 | ) |
Jason Evans | fd4fcef | 2012-03-23 17:40:58 -0700 | [diff] [blame] | 1174 | if test "x$enable_lazy_lock" = "x0" -a "x${force_lazy_lock}" = "x1" ; then |
| 1175 | AC_MSG_RESULT([Forcing lazy-lock to avoid allocator/threading bootstrap issues]) |
| 1176 | enable_lazy_lock="1" |
| 1177 | fi |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1178 | if test "x$enable_lazy_lock" = "x1" ; then |
Mike Hommey | a19e87f | 2012-04-21 21:27:46 -0700 | [diff] [blame] | 1179 | if test "x$abi" != "xpecoff" ; then |
| 1180 | AC_CHECK_HEADERS([dlfcn.h], , [AC_MSG_ERROR([dlfcn.h is missing])]) |
| 1181 | AC_CHECK_FUNC([dlsym], [], |
| 1182 | [AC_CHECK_LIB([dl], [dlsym], [LIBS="$LIBS -ldl"], |
| 1183 | [AC_MSG_ERROR([libdl is missing])]) |
| 1184 | ]) |
| 1185 | fi |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1186 | AC_DEFINE([JEMALLOC_LAZY_LOCK], [ ]) |
| 1187 | fi |
| 1188 | AC_SUBST([enable_lazy_lock]) |
| 1189 | |
Jason Evans | 78d815c | 2010-01-17 14:06:20 -0800 | [diff] [blame] | 1190 | AC_ARG_ENABLE([tls], |
| 1191 | [AS_HELP_STRING([--disable-tls], [Disable thread-local storage (__thread keyword)])], |
| 1192 | if test "x$enable_tls" = "xno" ; then |
| 1193 | enable_tls="0" |
| 1194 | else |
| 1195 | enable_tls="1" |
| 1196 | fi |
| 1197 | , |
| 1198 | enable_tls="1" |
| 1199 | ) |
Jason Evans | cd9a134 | 2012-03-21 18:33:03 -0700 | [diff] [blame] | 1200 | if test "x${enable_tls}" = "x0" -a "x${force_tls}" = "x1" ; then |
| 1201 | AC_MSG_RESULT([Forcing TLS to avoid allocator/threading bootstrap issues]) |
| 1202 | enable_tls="1" |
| 1203 | fi |
Jason Evans | b80581d | 2012-03-23 16:17:43 -0700 | [diff] [blame] | 1204 | if test "x${enable_tls}" = "x1" -a "x${force_tls}" = "x0" ; then |
| 1205 | AC_MSG_RESULT([Forcing no TLS to avoid allocator/threading bootstrap issues]) |
| 1206 | enable_tls="0" |
| 1207 | fi |
Jason Evans | 78d815c | 2010-01-17 14:06:20 -0800 | [diff] [blame] | 1208 | if test "x${enable_tls}" = "x1" ; then |
| 1209 | AC_MSG_CHECKING([for TLS]) |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 1210 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM( |
Jason Evans | 78d815c | 2010-01-17 14:06:20 -0800 | [diff] [blame] | 1211 | [[ |
| 1212 | __thread int x; |
| 1213 | ]], [[ |
| 1214 | x = 42; |
| 1215 | |
| 1216 | return 0; |
| 1217 | ]])], |
| 1218 | AC_MSG_RESULT([yes]), |
| 1219 | AC_MSG_RESULT([no]) |
| 1220 | enable_tls="0") |
| 1221 | fi |
Jason Evans | b267d0f | 2010-08-13 15:42:29 -0700 | [diff] [blame] | 1222 | AC_SUBST([enable_tls]) |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 1223 | if test "x${enable_tls}" = "x1" ; then |
| 1224 | AC_DEFINE_UNQUOTED([JEMALLOC_TLS], [ ]) |
Jason Evans | cd9a134 | 2012-03-21 18:33:03 -0700 | [diff] [blame] | 1225 | elif test "x${force_tls}" = "x1" ; then |
| 1226 | AC_MSG_ERROR([Failed to configure TLS, which is mandatory for correct function]) |
Jason Evans | 78d815c | 2010-01-17 14:06:20 -0800 | [diff] [blame] | 1227 | fi |
| 1228 | |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 1229 | dnl ============================================================================ |
Chih-hung Hsieh | 59cd80e | 2014-12-05 17:42:41 -0800 | [diff] [blame] | 1230 | dnl Check for C11 atomics. |
| 1231 | |
| 1232 | JE_COMPILABLE([C11 atomics], [ |
| 1233 | #include <stdint.h> |
| 1234 | #if (__STDC_VERSION__ >= 201112L) && !defined(__STDC_NO_ATOMICS__) |
| 1235 | #include <stdatomic.h> |
| 1236 | #else |
| 1237 | #error Atomics not available |
| 1238 | #endif |
| 1239 | ], [ |
| 1240 | uint64_t *p = (uint64_t *)0; |
| 1241 | uint64_t x = 1; |
| 1242 | volatile atomic_uint_least64_t *a = (volatile atomic_uint_least64_t *)p; |
| 1243 | uint64_t r = atomic_fetch_add(a, x) + x; |
| 1244 | return (r == 0); |
| 1245 | ], [je_cv_c11atomics]) |
| 1246 | if test "x${je_cv_c11atomics}" = "xyes" ; then |
| 1247 | AC_DEFINE([JEMALLOC_C11ATOMICS]) |
| 1248 | fi |
| 1249 | |
| 1250 | dnl ============================================================================ |
Jason Evans | b57d3ec | 2012-04-17 13:17:54 -0700 | [diff] [blame] | 1251 | dnl Check for atomic(9) operations as provided on FreeBSD. |
| 1252 | |
| 1253 | JE_COMPILABLE([atomic(9)], [ |
| 1254 | #include <sys/types.h> |
| 1255 | #include <machine/atomic.h> |
| 1256 | #include <inttypes.h> |
| 1257 | ], [ |
| 1258 | { |
| 1259 | uint32_t x32 = 0; |
| 1260 | volatile uint32_t *x32p = &x32; |
| 1261 | atomic_fetchadd_32(x32p, 1); |
| 1262 | } |
| 1263 | { |
| 1264 | unsigned long xlong = 0; |
| 1265 | volatile unsigned long *xlongp = &xlong; |
| 1266 | atomic_fetchadd_long(xlongp, 1); |
| 1267 | } |
| 1268 | ], [je_cv_atomic9]) |
| 1269 | if test "x${je_cv_atomic9}" = "xyes" ; then |
| 1270 | AC_DEFINE([JEMALLOC_ATOMIC9]) |
| 1271 | fi |
| 1272 | |
| 1273 | dnl ============================================================================ |
Jason Evans | 763baa6 | 2011-03-18 19:10:31 -0700 | [diff] [blame] | 1274 | dnl Check for atomic(3) operations as provided on Darwin. |
| 1275 | |
| 1276 | JE_COMPILABLE([Darwin OSAtomic*()], [ |
| 1277 | #include <libkern/OSAtomic.h> |
| 1278 | #include <inttypes.h> |
| 1279 | ], [ |
| 1280 | { |
| 1281 | int32_t x32 = 0; |
| 1282 | volatile int32_t *x32p = &x32; |
| 1283 | OSAtomicAdd32(1, x32p); |
| 1284 | } |
| 1285 | { |
| 1286 | int64_t x64 = 0; |
| 1287 | volatile int64_t *x64p = &x64; |
| 1288 | OSAtomicAdd64(1, x64p); |
| 1289 | } |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 1290 | ], [je_cv_osatomic]) |
| 1291 | if test "x${je_cv_osatomic}" = "xyes" ; then |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 1292 | AC_DEFINE([JEMALLOC_OSATOMIC], [ ]) |
Jason Evans | 763baa6 | 2011-03-18 19:10:31 -0700 | [diff] [blame] | 1293 | fi |
| 1294 | |
| 1295 | dnl ============================================================================ |
Richard Diamond | 994fad9 | 2014-06-03 02:39:18 -0500 | [diff] [blame] | 1296 | dnl Check for madvise(2). |
| 1297 | |
| 1298 | JE_COMPILABLE([madvise(2)], [ |
| 1299 | #include <sys/mman.h> |
| 1300 | ], [ |
| 1301 | { |
| 1302 | madvise((void *)0, 0, 0); |
| 1303 | } |
| 1304 | ], [je_cv_madvise]) |
| 1305 | if test "x${je_cv_madvise}" = "xyes" ; then |
| 1306 | AC_DEFINE([JEMALLOC_HAVE_MADVISE], [ ]) |
| 1307 | fi |
| 1308 | |
| 1309 | dnl ============================================================================ |
Mike Hommey | c1e567b | 2012-03-26 17:03:41 +0200 | [diff] [blame] | 1310 | dnl Check whether __sync_{add,sub}_and_fetch() are available despite |
| 1311 | dnl __GCC_HAVE_SYNC_COMPARE_AND_SWAP_n macros being undefined. |
| 1312 | |
| 1313 | AC_DEFUN([JE_SYNC_COMPARE_AND_SWAP_CHECK],[ |
| 1314 | AC_CACHE_CHECK([whether to force $1-bit __sync_{add,sub}_and_fetch()], |
| 1315 | [je_cv_sync_compare_and_swap_$2], |
Mike Hommey | 2cfe6d6 | 2012-03-27 15:03:07 +0200 | [diff] [blame] | 1316 | [AC_LINK_IFELSE([AC_LANG_PROGRAM([ |
| 1317 | #include <stdint.h> |
| 1318 | ], |
| 1319 | [ |
| 1320 | #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2 |
| 1321 | { |
| 1322 | uint$1_t x$1 = 0; |
| 1323 | __sync_add_and_fetch(&x$1, 42); |
| 1324 | __sync_sub_and_fetch(&x$1, 1); |
| 1325 | } |
| 1326 | #else |
| 1327 | #error __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2 is defined, no need to force |
| 1328 | #endif |
| 1329 | ])], |
Mike Hommey | c1e567b | 2012-03-26 17:03:41 +0200 | [diff] [blame] | 1330 | [je_cv_sync_compare_and_swap_$2=yes], |
| 1331 | [je_cv_sync_compare_and_swap_$2=no])]) |
| 1332 | |
| 1333 | if test "x${je_cv_sync_compare_and_swap_$2}" = "xyes" ; then |
| 1334 | AC_DEFINE([JE_FORCE_SYNC_COMPARE_AND_SWAP_$2], [ ]) |
| 1335 | fi |
| 1336 | ]) |
| 1337 | |
Jason Evans | b57d3ec | 2012-04-17 13:17:54 -0700 | [diff] [blame] | 1338 | if test "x${je_cv_atomic9}" != "xyes" -a "x${je_cv_osatomic}" != "xyes" ; then |
Mike Hommey | c1e567b | 2012-03-26 17:03:41 +0200 | [diff] [blame] | 1339 | JE_SYNC_COMPARE_AND_SWAP_CHECK(32, 4) |
| 1340 | JE_SYNC_COMPARE_AND_SWAP_CHECK(64, 8) |
| 1341 | fi |
| 1342 | |
| 1343 | dnl ============================================================================ |
Jason Evans | d04047c | 2014-05-28 16:11:55 -0700 | [diff] [blame] | 1344 | dnl Check for __builtin_clz() and __builtin_clzl(). |
| 1345 | |
| 1346 | AC_CACHE_CHECK([for __builtin_clz], |
| 1347 | [je_cv_builtin_clz], |
| 1348 | [AC_LINK_IFELSE([AC_LANG_PROGRAM([], |
| 1349 | [ |
| 1350 | { |
| 1351 | unsigned x = 0; |
| 1352 | int y = __builtin_clz(x); |
| 1353 | } |
| 1354 | { |
| 1355 | unsigned long x = 0; |
| 1356 | int y = __builtin_clzl(x); |
| 1357 | } |
| 1358 | ])], |
| 1359 | [je_cv_builtin_clz=yes], |
| 1360 | [je_cv_builtin_clz=no])]) |
| 1361 | |
| 1362 | if test "x${je_cv_builtin_clz}" = "xyes" ; then |
| 1363 | AC_DEFINE([JEMALLOC_HAVE_BUILTIN_CLZ], [ ]) |
| 1364 | fi |
| 1365 | |
| 1366 | dnl ============================================================================ |
Jason Evans | 893a0ed | 2011-03-18 19:30:18 -0700 | [diff] [blame] | 1367 | dnl Check for spinlock(3) operations as provided on Darwin. |
| 1368 | |
| 1369 | JE_COMPILABLE([Darwin OSSpin*()], [ |
| 1370 | #include <libkern/OSAtomic.h> |
| 1371 | #include <inttypes.h> |
| 1372 | ], [ |
| 1373 | OSSpinLock lock = 0; |
| 1374 | OSSpinLockLock(&lock); |
| 1375 | OSSpinLockUnlock(&lock); |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 1376 | ], [je_cv_osspin]) |
| 1377 | if test "x${je_cv_osspin}" = "xyes" ; then |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 1378 | AC_DEFINE([JEMALLOC_OSSPIN], [ ]) |
Jason Evans | 893a0ed | 2011-03-18 19:30:18 -0700 | [diff] [blame] | 1379 | fi |
| 1380 | |
| 1381 | dnl ============================================================================ |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 1382 | dnl Darwin-related configuration. |
Jason Evans | 78d815c | 2010-01-17 14:06:20 -0800 | [diff] [blame] | 1383 | |
Mike Hommey | d0357f7 | 2012-11-26 18:52:41 +0100 | [diff] [blame] | 1384 | AC_ARG_ENABLE([zone-allocator], |
| 1385 | [AS_HELP_STRING([--disable-zone-allocator], |
| 1386 | [Disable zone allocator for Darwin])], |
| 1387 | [if test "x$enable_zone_allocator" = "xno" ; then |
| 1388 | enable_zone_allocator="0" |
| 1389 | else |
| 1390 | enable_zone_allocator="1" |
| 1391 | fi |
| 1392 | ], |
| 1393 | [if test "x${abi}" = "xmacho"; then |
| 1394 | enable_zone_allocator="1" |
| 1395 | fi |
| 1396 | ] |
| 1397 | ) |
| 1398 | AC_SUBST([enable_zone_allocator]) |
| 1399 | |
| 1400 | if test "x${enable_zone_allocator}" = "x1" ; then |
| 1401 | if test "x${abi}" != "xmacho"; then |
| 1402 | AC_MSG_ERROR([--enable-zone-allocator is only supported on Darwin]) |
| 1403 | fi |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 1404 | AC_DEFINE([JEMALLOC_IVSALLOC], [ ]) |
| 1405 | AC_DEFINE([JEMALLOC_ZONE], [ ]) |
Jason Evans | 6109fe0 | 2010-02-10 10:37:56 -0800 | [diff] [blame] | 1406 | |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 1407 | dnl The szone version jumped from 3 to 6 between the OS X 10.5.x and 10.6 |
| 1408 | dnl releases. malloc_zone_t and malloc_introspection_t have new fields in |
| 1409 | dnl 10.6, which is the only source-level indication of the change. |
| 1410 | AC_MSG_CHECKING([malloc zone version]) |
Mike Hommey | 154829d | 2012-03-20 18:01:38 +0100 | [diff] [blame] | 1411 | AC_DEFUN([JE_ZONE_PROGRAM], |
| 1412 | [AC_LANG_PROGRAM( |
| 1413 | [#include <malloc/malloc.h>], |
Guilherme Goncalves | 79725aa | 2014-10-20 14:08:37 -0200 | [diff] [blame] | 1414 | [static int foo[[sizeof($1) $2 sizeof(void *) * $3 ? 1 : -1]]] |
Mike Hommey | 154829d | 2012-03-20 18:01:38 +0100 | [diff] [blame] | 1415 | )]) |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 1416 | |
Mike Hommey | 154829d | 2012-03-20 18:01:38 +0100 | [diff] [blame] | 1417 | AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,14)],[JEMALLOC_ZONE_VERSION=3],[ |
| 1418 | AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,15)],[JEMALLOC_ZONE_VERSION=5],[ |
| 1419 | AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,16)],[ |
| 1420 | AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,9)],[JEMALLOC_ZONE_VERSION=6],[ |
| 1421 | AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,13)],[JEMALLOC_ZONE_VERSION=7],[JEMALLOC_ZONE_VERSION=] |
| 1422 | )])],[ |
| 1423 | AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,17)],[JEMALLOC_ZONE_VERSION=8],[ |
| 1424 | AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,>,17)],[JEMALLOC_ZONE_VERSION=9],[JEMALLOC_ZONE_VERSION=] |
| 1425 | )])])])]) |
| 1426 | if test "x${JEMALLOC_ZONE_VERSION}" = "x"; then |
| 1427 | AC_MSG_RESULT([unsupported]) |
| 1428 | AC_MSG_ERROR([Unsupported malloc zone version]) |
| 1429 | fi |
| 1430 | if test "${JEMALLOC_ZONE_VERSION}" = 9; then |
| 1431 | JEMALLOC_ZONE_VERSION=8 |
| 1432 | AC_MSG_RESULT([> 8]) |
| 1433 | else |
| 1434 | AC_MSG_RESULT([$JEMALLOC_ZONE_VERSION]) |
| 1435 | fi |
| 1436 | AC_DEFINE_UNQUOTED(JEMALLOC_ZONE_VERSION, [$JEMALLOC_ZONE_VERSION]) |
Jason Evans | b27805b | 2010-02-10 18:15:53 -0800 | [diff] [blame] | 1437 | fi |
| 1438 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1439 | dnl ============================================================================ |
Sara Golemon | 3e24afa | 2014-08-18 13:06:39 -0700 | [diff] [blame] | 1440 | dnl Check for glibc malloc hooks |
| 1441 | |
| 1442 | JE_COMPILABLE([glibc malloc hook], [ |
| 1443 | #include <stddef.h> |
| 1444 | |
| 1445 | extern void (* __free_hook)(void *ptr); |
| 1446 | extern void *(* __malloc_hook)(size_t size); |
| 1447 | extern void *(* __realloc_hook)(void *ptr, size_t size); |
| 1448 | ], [ |
| 1449 | void *ptr = 0L; |
| 1450 | if (__malloc_hook) ptr = __malloc_hook(1); |
| 1451 | if (__realloc_hook) ptr = __realloc_hook(ptr, 2); |
| 1452 | if (__free_hook && ptr) __free_hook(ptr); |
| 1453 | ], [je_cv_glibc_malloc_hook]) |
| 1454 | if test "x${je_cv_glibc_malloc_hook}" = "xyes" ; then |
| 1455 | AC_DEFINE([JEMALLOC_GLIBC_MALLOC_HOOK], [ ]) |
| 1456 | fi |
| 1457 | |
| 1458 | JE_COMPILABLE([glibc memalign hook], [ |
| 1459 | #include <stddef.h> |
| 1460 | |
| 1461 | extern void *(* __memalign_hook)(size_t alignment, size_t size); |
| 1462 | ], [ |
| 1463 | void *ptr = 0L; |
| 1464 | if (__memalign_hook) ptr = __memalign_hook(16, 7); |
| 1465 | ], [je_cv_glibc_memalign_hook]) |
| 1466 | if test "x${je_cv_glibc_memalign_hook}" = "xyes" ; then |
| 1467 | AC_DEFINE([JEMALLOC_GLIBC_MEMALIGN_HOOK], [ ]) |
| 1468 | fi |
| 1469 | |
Eric Wong | 4dcf04b | 2014-08-31 03:57:06 +0000 | [diff] [blame] | 1470 | JE_COMPILABLE([pthreads adaptive mutexes], [ |
| 1471 | #include <pthread.h> |
| 1472 | ], [ |
| 1473 | pthread_mutexattr_t attr; |
| 1474 | pthread_mutexattr_init(&attr); |
| 1475 | pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_ADAPTIVE_NP); |
| 1476 | pthread_mutexattr_destroy(&attr); |
| 1477 | ], [je_cv_pthread_mutex_adaptive_np]) |
| 1478 | if test "x${je_cv_pthread_mutex_adaptive_np}" = "xyes" ; then |
| 1479 | AC_DEFINE([JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], [ ]) |
| 1480 | fi |
| 1481 | |
Sara Golemon | 3e24afa | 2014-08-18 13:06:39 -0700 | [diff] [blame] | 1482 | dnl ============================================================================ |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1483 | dnl Check for typedefs, structures, and compiler characteristics. |
| 1484 | AC_HEADER_STDBOOL |
| 1485 | |
Jason Evans | 748dfac | 2013-12-06 18:27:33 -0800 | [diff] [blame] | 1486 | dnl ============================================================================ |
| 1487 | dnl Define commands that generate output files. |
| 1488 | |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 1489 | AC_CONFIG_COMMANDS([include/jemalloc/internal/private_namespace.h], [ |
| 1490 | mkdir -p "${objroot}include/jemalloc/internal" |
| 1491 | "${srcdir}/include/jemalloc/internal/private_namespace.sh" "${srcdir}/include/jemalloc/internal/private_symbols.txt" > "${objroot}include/jemalloc/internal/private_namespace.h" |
Jason Evans | f234dc5 | 2014-01-16 17:38:01 -0800 | [diff] [blame] | 1492 | ], [ |
| 1493 | srcdir="${srcdir}" |
| 1494 | objroot="${objroot}" |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 1495 | ]) |
| 1496 | AC_CONFIG_COMMANDS([include/jemalloc/internal/private_unnamespace.h], [ |
| 1497 | mkdir -p "${objroot}include/jemalloc/internal" |
| 1498 | "${srcdir}/include/jemalloc/internal/private_unnamespace.sh" "${srcdir}/include/jemalloc/internal/private_symbols.txt" > "${objroot}include/jemalloc/internal/private_unnamespace.h" |
Jason Evans | f234dc5 | 2014-01-16 17:38:01 -0800 | [diff] [blame] | 1499 | ], [ |
| 1500 | srcdir="${srcdir}" |
| 1501 | objroot="${objroot}" |
| 1502 | ]) |
| 1503 | AC_CONFIG_COMMANDS([include/jemalloc/internal/public_symbols.txt], [ |
| 1504 | f="${objroot}include/jemalloc/internal/public_symbols.txt" |
| 1505 | mkdir -p "${objroot}include/jemalloc/internal" |
| 1506 | cp /dev/null "${f}" |
| 1507 | for nm in `echo ${mangling_map} |tr ',' ' '` ; do |
| 1508 | n=`echo ${nm} |tr ':' ' ' |awk '{print $[]1}'` |
| 1509 | m=`echo ${nm} |tr ':' ' ' |awk '{print $[]2}'` |
| 1510 | echo "${n}:${m}" >> "${f}" |
| 1511 | dnl Remove name from public_syms so that it isn't redefined later. |
| 1512 | public_syms=`for sym in ${public_syms}; do echo "${sym}"; done |grep -v "^${n}\$" |tr '\n' ' '` |
| 1513 | done |
| 1514 | for sym in ${public_syms} ; do |
| 1515 | n="${sym}" |
| 1516 | m="${JEMALLOC_PREFIX}${sym}" |
| 1517 | echo "${n}:${m}" >> "${f}" |
| 1518 | done |
| 1519 | ], [ |
| 1520 | srcdir="${srcdir}" |
| 1521 | objroot="${objroot}" |
| 1522 | mangling_map="${mangling_map}" |
| 1523 | public_syms="${public_syms}" |
| 1524 | JEMALLOC_PREFIX="${JEMALLOC_PREFIX}" |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 1525 | ]) |
| 1526 | AC_CONFIG_COMMANDS([include/jemalloc/internal/public_namespace.h], [ |
| 1527 | mkdir -p "${objroot}include/jemalloc/internal" |
Jason Evans | f234dc5 | 2014-01-16 17:38:01 -0800 | [diff] [blame] | 1528 | "${srcdir}/include/jemalloc/internal/public_namespace.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/internal/public_namespace.h" |
| 1529 | ], [ |
| 1530 | srcdir="${srcdir}" |
| 1531 | objroot="${objroot}" |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 1532 | ]) |
| 1533 | AC_CONFIG_COMMANDS([include/jemalloc/internal/public_unnamespace.h], [ |
| 1534 | mkdir -p "${objroot}include/jemalloc/internal" |
Jason Evans | f234dc5 | 2014-01-16 17:38:01 -0800 | [diff] [blame] | 1535 | "${srcdir}/include/jemalloc/internal/public_unnamespace.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/internal/public_unnamespace.h" |
| 1536 | ], [ |
| 1537 | srcdir="${srcdir}" |
| 1538 | objroot="${objroot}" |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 1539 | ]) |
Jason Evans | b172610 | 2012-02-28 16:50:47 -0800 | [diff] [blame] | 1540 | AC_CONFIG_COMMANDS([include/jemalloc/internal/size_classes.h], [ |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 1541 | mkdir -p "${objroot}include/jemalloc/internal" |
Jason Evans | 81e5475 | 2014-10-10 22:34:25 -0700 | [diff] [blame] | 1542 | "${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 Evans | f234dc5 | 2014-01-16 17:38:01 -0800 | [diff] [blame] | 1543 | ], [ |
| 1544 | srcdir="${srcdir}" |
| 1545 | objroot="${objroot}" |
Jason Evans | 81e5475 | 2014-10-10 22:34:25 -0700 | [diff] [blame] | 1546 | LG_QUANTA="${LG_QUANTA}" |
| 1547 | LG_TINY_MIN=${LG_TINY_MIN} |
| 1548 | LG_PAGE_SIZES="${LG_PAGE_SIZES}" |
Jason Evans | fc0b3b7 | 2014-10-09 17:54:06 -0700 | [diff] [blame] | 1549 | LG_SIZE_CLASS_GROUP=${LG_SIZE_CLASS_GROUP} |
Jason Evans | b172610 | 2012-02-28 16:50:47 -0800 | [diff] [blame] | 1550 | ]) |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 1551 | AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_protos_jet.h], [ |
| 1552 | mkdir -p "${objroot}include/jemalloc" |
| 1553 | cat "${srcdir}/include/jemalloc/jemalloc_protos.h.in" | sed -e 's/@je_@/jet_/g' > "${objroot}include/jemalloc/jemalloc_protos_jet.h" |
Jason Evans | f234dc5 | 2014-01-16 17:38:01 -0800 | [diff] [blame] | 1554 | ], [ |
| 1555 | srcdir="${srcdir}" |
| 1556 | objroot="${objroot}" |
| 1557 | ]) |
| 1558 | AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_rename.h], [ |
| 1559 | mkdir -p "${objroot}include/jemalloc" |
| 1560 | "${srcdir}/include/jemalloc/jemalloc_rename.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" > "${objroot}include/jemalloc/jemalloc_rename.h" |
| 1561 | ], [ |
| 1562 | srcdir="${srcdir}" |
| 1563 | objroot="${objroot}" |
| 1564 | ]) |
| 1565 | AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_mangle.h], [ |
| 1566 | mkdir -p "${objroot}include/jemalloc" |
| 1567 | "${srcdir}/include/jemalloc/jemalloc_mangle.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" je_ > "${objroot}include/jemalloc/jemalloc_mangle.h" |
| 1568 | ], [ |
| 1569 | srcdir="${srcdir}" |
| 1570 | objroot="${objroot}" |
| 1571 | ]) |
| 1572 | AC_CONFIG_COMMANDS([include/jemalloc/jemalloc_mangle_jet.h], [ |
| 1573 | mkdir -p "${objroot}include/jemalloc" |
| 1574 | "${srcdir}/include/jemalloc/jemalloc_mangle.sh" "${objroot}include/jemalloc/internal/public_symbols.txt" jet_ > "${objroot}include/jemalloc/jemalloc_mangle_jet.h" |
| 1575 | ], [ |
| 1576 | srcdir="${srcdir}" |
| 1577 | objroot="${objroot}" |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 1578 | ]) |
| 1579 | AC_CONFIG_COMMANDS([include/jemalloc/jemalloc.h], [ |
| 1580 | mkdir -p "${objroot}include/jemalloc" |
| 1581 | "${srcdir}/include/jemalloc/jemalloc.sh" "${objroot}" > "${objroot}include/jemalloc/jemalloc${install_suffix}.h" |
Jason Evans | f234dc5 | 2014-01-16 17:38:01 -0800 | [diff] [blame] | 1582 | ], [ |
| 1583 | srcdir="${srcdir}" |
| 1584 | objroot="${objroot}" |
| 1585 | install_suffix="${install_suffix}" |
Jason Evans | 86abd0d | 2013-11-30 15:25:42 -0800 | [diff] [blame] | 1586 | ]) |
Jason Evans | b172610 | 2012-02-28 16:50:47 -0800 | [diff] [blame] | 1587 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1588 | dnl Process .in files. |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 1589 | AC_SUBST([cfghdrs_in]) |
| 1590 | AC_SUBST([cfghdrs_out]) |
Jason Evans | 0656ec0 | 2010-04-07 23:37:35 -0700 | [diff] [blame] | 1591 | AC_CONFIG_HEADERS([$cfghdrs_tup]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1592 | |
| 1593 | dnl ============================================================================ |
| 1594 | dnl Generate outputs. |
Jason Evans | 748dfac | 2013-12-06 18:27:33 -0800 | [diff] [blame] | 1595 | |
Jason Evans | bec6a8d | 2015-01-22 17:55:58 -0800 | [diff] [blame] | 1596 | AC_CONFIG_FILES([$cfgoutputs_tup config.stamp bin/jemalloc-config bin/jemalloc.sh]) |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 1597 | AC_SUBST([cfgoutputs_in]) |
| 1598 | AC_SUBST([cfgoutputs_out]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1599 | AC_OUTPUT |
| 1600 | |
| 1601 | dnl ============================================================================ |
| 1602 | dnl Print out the results of configuration. |
| 1603 | AC_MSG_RESULT([===============================================================================]) |
Jason Evans | f576c63 | 2011-11-01 22:27:41 -0700 | [diff] [blame] | 1604 | AC_MSG_RESULT([jemalloc version : ${jemalloc_version}]) |
| 1605 | AC_MSG_RESULT([library revision : ${rev}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1606 | AC_MSG_RESULT([]) |
Jason Evans | bec6a8d | 2015-01-22 17:55:58 -0800 | [diff] [blame] | 1607 | AC_MSG_RESULT([CONFIG : ${CONFIG}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1608 | AC_MSG_RESULT([CC : ${CC}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1609 | AC_MSG_RESULT([CFLAGS : ${CFLAGS}]) |
Jason Evans | bec6a8d | 2015-01-22 17:55:58 -0800 | [diff] [blame] | 1610 | AC_MSG_RESULT([CPPFLAGS : ${CPPFLAGS}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1611 | AC_MSG_RESULT([LDFLAGS : ${LDFLAGS}]) |
Jason Evans | 748dfac | 2013-12-06 18:27:33 -0800 | [diff] [blame] | 1612 | AC_MSG_RESULT([EXTRA_LDFLAGS : ${EXTRA_LDFLAGS}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1613 | AC_MSG_RESULT([LIBS : ${LIBS}]) |
| 1614 | AC_MSG_RESULT([RPATH_EXTRA : ${RPATH_EXTRA}]) |
| 1615 | AC_MSG_RESULT([]) |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 1616 | AC_MSG_RESULT([XSLTPROC : ${XSLTPROC}]) |
| 1617 | AC_MSG_RESULT([XSLROOT : ${XSLROOT}]) |
| 1618 | AC_MSG_RESULT([]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1619 | AC_MSG_RESULT([PREFIX : ${PREFIX}]) |
| 1620 | AC_MSG_RESULT([BINDIR : ${BINDIR}]) |
Jason Evans | bec6a8d | 2015-01-22 17:55:58 -0800 | [diff] [blame] | 1621 | AC_MSG_RESULT([DATADIR : ${DATADIR}]) |
Jason Evans | 662a017 | 2009-07-01 19:24:31 -0700 | [diff] [blame] | 1622 | AC_MSG_RESULT([INCLUDEDIR : ${INCLUDEDIR}]) |
| 1623 | AC_MSG_RESULT([LIBDIR : ${LIBDIR}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1624 | AC_MSG_RESULT([MANDIR : ${MANDIR}]) |
| 1625 | AC_MSG_RESULT([]) |
| 1626 | AC_MSG_RESULT([srcroot : ${srcroot}]) |
| 1627 | AC_MSG_RESULT([abs_srcroot : ${abs_srcroot}]) |
| 1628 | AC_MSG_RESULT([objroot : ${objroot}]) |
| 1629 | AC_MSG_RESULT([abs_objroot : ${abs_objroot}]) |
| 1630 | AC_MSG_RESULT([]) |
Jason Evans | 90895cf | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 1631 | AC_MSG_RESULT([JEMALLOC_PREFIX : ${JEMALLOC_PREFIX}]) |
Jason Evans | 746e77a | 2011-07-30 16:40:52 -0700 | [diff] [blame] | 1632 | AC_MSG_RESULT([JEMALLOC_PRIVATE_NAMESPACE]) |
| 1633 | AC_MSG_RESULT([ : ${JEMALLOC_PRIVATE_NAMESPACE}]) |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 1634 | AC_MSG_RESULT([install_suffix : ${install_suffix}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1635 | AC_MSG_RESULT([autogen : ${enable_autogen}]) |
Jason Evans | 355b438 | 2010-09-20 19:20:48 -0700 | [diff] [blame] | 1636 | AC_MSG_RESULT([cc-silence : ${enable_cc_silence}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1637 | AC_MSG_RESULT([debug : ${enable_debug}]) |
Jason Evans | 748dfac | 2013-12-06 18:27:33 -0800 | [diff] [blame] | 1638 | AC_MSG_RESULT([code-coverage : ${enable_code_coverage}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1639 | AC_MSG_RESULT([stats : ${enable_stats}]) |
Jason Evans | 6109fe0 | 2010-02-10 10:37:56 -0800 | [diff] [blame] | 1640 | AC_MSG_RESULT([prof : ${enable_prof}]) |
| 1641 | AC_MSG_RESULT([prof-libunwind : ${enable_prof_libunwind}]) |
Jason Evans | 77f350b | 2011-03-15 22:23:12 -0700 | [diff] [blame] | 1642 | AC_MSG_RESULT([prof-libgcc : ${enable_prof_libgcc}]) |
| 1643 | AC_MSG_RESULT([prof-gcc : ${enable_prof_gcc}]) |
Jason Evans | 84cbbcb | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 1644 | AC_MSG_RESULT([tcache : ${enable_tcache}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1645 | AC_MSG_RESULT([fill : ${enable_fill}]) |
Jason Evans | b147611 | 2012-04-05 13:36:17 -0700 | [diff] [blame] | 1646 | AC_MSG_RESULT([utrace : ${enable_utrace}]) |
Jason Evans | 122449b | 2012-04-06 00:35:09 -0700 | [diff] [blame] | 1647 | AC_MSG_RESULT([valgrind : ${enable_valgrind}]) |
| 1648 | AC_MSG_RESULT([xmalloc : ${enable_xmalloc}]) |
Jason Evans | 59ae276 | 2012-04-16 17:52:27 -0700 | [diff] [blame] | 1649 | AC_MSG_RESULT([munmap : ${enable_munmap}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1650 | AC_MSG_RESULT([lazy_lock : ${enable_lazy_lock}]) |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 1651 | AC_MSG_RESULT([tls : ${enable_tls}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1652 | AC_MSG_RESULT([===============================================================================]) |