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 | ]])], |
| 22 | AC_MSG_RESULT([yes]), |
| 23 | AC_MSG_RESULT([no]) |
| 24 | [CFLAGS="${TCFLAGS}"] |
| 25 | ) |
| 26 | ]) |
| 27 | |
| 28 | dnl JE_COMPILABLE(label, hcode, mcode, rvar) |
Jason Evans | 4c2faa8 | 2012-03-13 11:09:23 -0700 | [diff] [blame] | 29 | dnl |
Jason Evans | f3e139a | 2012-03-19 09:54:20 -0700 | [diff] [blame] | 30 | 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] | 31 | dnl cause failure. |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 32 | AC_DEFUN([JE_COMPILABLE], |
| 33 | [ |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 34 | AC_CACHE_CHECK([whether $1 is compilable], |
| 35 | [$4], |
Jason Evans | f3e139a | 2012-03-19 09:54:20 -0700 | [diff] [blame] | 36 | [AC_LINK_IFELSE([AC_LANG_PROGRAM([$2], |
| 37 | [$3])], |
| 38 | [$4=yes], |
| 39 | [$4=no])]) |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 40 | ]) |
| 41 | |
| 42 | dnl ============================================================================ |
| 43 | |
Jason Evans | f576c63 | 2011-11-01 22:27:41 -0700 | [diff] [blame] | 44 | dnl Library revision. |
| 45 | rev=1 |
| 46 | AC_SUBST([rev]) |
| 47 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 48 | srcroot=$srcdir |
| 49 | if test "x${srcroot}" = "x." ; then |
| 50 | srcroot="" |
| 51 | else |
| 52 | srcroot="${srcroot}/" |
| 53 | fi |
| 54 | AC_SUBST([srcroot]) |
| 55 | abs_srcroot="`cd \"${srcdir}\"; pwd`/" |
| 56 | AC_SUBST([abs_srcroot]) |
| 57 | |
| 58 | objroot="" |
| 59 | AC_SUBST([objroot]) |
| 60 | abs_objroot="`pwd`/" |
| 61 | AC_SUBST([abs_objroot]) |
| 62 | |
| 63 | dnl Munge install path variables. |
| 64 | if test "x$prefix" = "xNONE" ; then |
| 65 | prefix="/usr/local" |
| 66 | fi |
| 67 | if test "x$exec_prefix" = "xNONE" ; then |
| 68 | exec_prefix=$prefix |
| 69 | fi |
| 70 | PREFIX=$prefix |
| 71 | AC_SUBST([PREFIX]) |
| 72 | BINDIR=`eval echo $bindir` |
| 73 | BINDIR=`eval echo $BINDIR` |
| 74 | AC_SUBST([BINDIR]) |
| 75 | INCLUDEDIR=`eval echo $includedir` |
| 76 | INCLUDEDIR=`eval echo $INCLUDEDIR` |
| 77 | AC_SUBST([INCLUDEDIR]) |
| 78 | LIBDIR=`eval echo $libdir` |
| 79 | LIBDIR=`eval echo $LIBDIR` |
| 80 | AC_SUBST([LIBDIR]) |
| 81 | DATADIR=`eval echo $datadir` |
| 82 | DATADIR=`eval echo $DATADIR` |
| 83 | AC_SUBST([DATADIR]) |
| 84 | MANDIR=`eval echo $mandir` |
| 85 | MANDIR=`eval echo $MANDIR` |
| 86 | AC_SUBST([MANDIR]) |
| 87 | |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 88 | dnl Support for building documentation. |
| 89 | AC_PATH_PROG([XSLTPROC], [xsltproc], , [$PATH]) |
Jason Evans | 7091b41 | 2012-03-19 09:36:44 -0700 | [diff] [blame] | 90 | if test -d "/usr/share/xml/docbook/stylesheet/docbook-xsl" ; then |
| 91 | DEFAULT_XSLROOT="/usr/share/xml/docbook/stylesheet/docbook-xsl" |
| 92 | elif test -d "/usr/share/sgml/docbook/xsl-stylesheets" ; then |
| 93 | DEFAULT_XSLROOT="/usr/share/sgml/docbook/xsl-stylesheets" |
| 94 | else |
| 95 | dnl Documentation building will fail if this default gets used. |
| 96 | DEFAULT_XSLROOT="" |
| 97 | fi |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 98 | AC_ARG_WITH([xslroot], |
Jason Evans | 7091b41 | 2012-03-19 09:36:44 -0700 | [diff] [blame] | 99 | [AS_HELP_STRING([--with-xslroot=<path>], [XSL stylesheet root path])], [ |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 100 | if test "x$with_xslroot" = "xno" ; then |
Jason Evans | 7091b41 | 2012-03-19 09:36:44 -0700 | [diff] [blame] | 101 | XSLROOT="${DEFAULT_XSLROOT}" |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 102 | else |
| 103 | XSLROOT="${with_xslroot}" |
Jason Evans | 7091b41 | 2012-03-19 09:36:44 -0700 | [diff] [blame] | 104 | fi |
| 105 | ], |
| 106 | XSLROOT="${DEFAULT_XSLROOT}" |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 107 | ) |
| 108 | AC_SUBST([XSLROOT]) |
| 109 | |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 110 | dnl If CFLAGS isn't defined, set CFLAGS to something reasonable. Otherwise, |
| 111 | dnl just prevent autoconf from molesting CFLAGS. |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 112 | CFLAGS=$CFLAGS |
| 113 | AC_PROG_CC |
| 114 | if test "x$CFLAGS" = "x" ; then |
| 115 | no_CFLAGS="yes" |
Jason Evans | cfeccd3 | 2010-03-03 15:48:20 -0800 | [diff] [blame] | 116 | if test "x$GCC" = "xyes" ; then |
| 117 | JE_CFLAGS_APPEND([-std=gnu99]) |
| 118 | JE_CFLAGS_APPEND([-Wall]) |
| 119 | JE_CFLAGS_APPEND([-pipe]) |
| 120 | JE_CFLAGS_APPEND([-g3]) |
| 121 | fi |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 122 | fi |
| 123 | dnl Append EXTRA_CFLAGS to CFLAGS, if defined. |
| 124 | if test "x$EXTRA_CFLAGS" != "x" ; then |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 125 | JE_CFLAGS_APPEND([$EXTRA_CFLAGS]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 126 | fi |
| 127 | AC_PROG_CPP |
| 128 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 129 | AC_CHECK_SIZEOF([void *]) |
| 130 | if test "x${ac_cv_sizeof_void_p}" = "x8" ; then |
Jason Evans | 94ad2b5 | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 131 | LG_SIZEOF_PTR=3 |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 132 | elif test "x${ac_cv_sizeof_void_p}" = "x4" ; then |
Jason Evans | 94ad2b5 | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 133 | LG_SIZEOF_PTR=2 |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 134 | else |
| 135 | AC_MSG_ERROR([Unsupported pointer size: ${ac_cv_sizeof_void_p}]) |
| 136 | fi |
Jason Evans | 94ad2b5 | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 137 | AC_DEFINE_UNQUOTED([LG_SIZEOF_PTR], [$LG_SIZEOF_PTR]) |
| 138 | |
| 139 | AC_CHECK_SIZEOF([int]) |
| 140 | if test "x${ac_cv_sizeof_int}" = "x8" ; then |
| 141 | LG_SIZEOF_INT=3 |
| 142 | elif test "x${ac_cv_sizeof_int}" = "x4" ; then |
| 143 | LG_SIZEOF_INT=2 |
| 144 | else |
| 145 | AC_MSG_ERROR([Unsupported int size: ${ac_cv_sizeof_int}]) |
| 146 | fi |
| 147 | AC_DEFINE_UNQUOTED([LG_SIZEOF_INT], [$LG_SIZEOF_INT]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 148 | |
Jason Evans | 84c8eef | 2011-03-16 10:30:13 -0700 | [diff] [blame] | 149 | AC_CHECK_SIZEOF([long]) |
| 150 | if test "x${ac_cv_sizeof_long}" = "x8" ; then |
| 151 | LG_SIZEOF_LONG=3 |
| 152 | elif test "x${ac_cv_sizeof_long}" = "x4" ; then |
| 153 | LG_SIZEOF_LONG=2 |
| 154 | else |
| 155 | AC_MSG_ERROR([Unsupported long size: ${ac_cv_sizeof_long}]) |
| 156 | fi |
| 157 | AC_DEFINE_UNQUOTED([LG_SIZEOF_LONG], [$LG_SIZEOF_LONG]) |
| 158 | |
Jason Evans | d81e4bd | 2012-03-06 14:57:45 -0800 | [diff] [blame] | 159 | AC_CHECK_SIZEOF([intmax_t]) |
| 160 | if test "x${ac_cv_sizeof_intmax_t}" = "x16" ; then |
| 161 | LG_SIZEOF_INTMAX_T=4 |
| 162 | elif test "x${ac_cv_sizeof_intmax_t}" = "x8" ; then |
| 163 | LG_SIZEOF_INTMAX_T=3 |
| 164 | elif test "x${ac_cv_sizeof_intmax_t}" = "x4" ; then |
| 165 | LG_SIZEOF_INTMAX_T=2 |
| 166 | else |
| 167 | AC_MSG_ERROR([Unsupported intmax_t size: ${ac_cv_sizeof_long}]) |
| 168 | fi |
| 169 | AC_DEFINE_UNQUOTED([LG_SIZEOF_INTMAX_T], [$LG_SIZEOF_INTMAX_T]) |
| 170 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 171 | AC_CANONICAL_HOST |
| 172 | dnl CPU-specific settings. |
| 173 | CPU_SPINWAIT="" |
| 174 | case "${host_cpu}" in |
| 175 | i[[345]]86) |
| 176 | ;; |
| 177 | i686) |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 178 | JE_COMPILABLE([__asm__], [], [[__asm__ volatile("pause"); return 0;]], |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 179 | [je_cv_asm]) |
| 180 | if test "x${je_cv_asm}" = "xyes" ; then |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 181 | CPU_SPINWAIT='__asm__ volatile("pause")' |
| 182 | fi |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 183 | ;; |
| 184 | x86_64) |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 185 | JE_COMPILABLE([__asm__ syntax], [], |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 186 | [[__asm__ volatile("pause"); return 0;]], [je_cv_asm]) |
| 187 | if test "x${je_cv_asm}" = "xyes" ; then |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 188 | CPU_SPINWAIT='__asm__ volatile("pause")' |
| 189 | fi |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 190 | ;; |
| 191 | *) |
| 192 | ;; |
| 193 | esac |
| 194 | AC_DEFINE_UNQUOTED([CPU_SPINWAIT], [$CPU_SPINWAIT]) |
| 195 | |
Antony Dovgal | 2bd3cbc | 2011-10-13 09:33:33 +0400 | [diff] [blame] | 196 | LD_PRELOAD_VAR="LD_PRELOAD" |
Jason Evans | f576c63 | 2011-11-01 22:27:41 -0700 | [diff] [blame] | 197 | so="so" |
Antony Dovgal | 2bd3cbc | 2011-10-13 09:33:33 +0400 | [diff] [blame] | 198 | |
Jason Evans | 7372b15 | 2012-02-10 20:22:09 -0800 | [diff] [blame] | 199 | dnl Heap profiling uses the log(3) function. |
| 200 | LIBS="$LIBS -lm" |
| 201 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 202 | dnl Platform-specific settings. abi and RPATH can probably be determined |
| 203 | dnl programmatically, but doing so is error-prone, which makes it generally |
| 204 | dnl not worth the trouble. |
| 205 | dnl |
| 206 | dnl Define cpp macros in CPPFLAGS, rather than doing AC_DEFINE(macro), since the |
| 207 | dnl definitions need to be seen before any headers are included, which is a pain |
| 208 | dnl to make happen otherwise. |
Jason Evans | 59ae276 | 2012-04-16 17:52:27 -0700 | [diff] [blame^] | 209 | default_munmap="1" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 210 | case "${host}" in |
| 211 | *-*-darwin*) |
Jason Evans | 9022bf9 | 2012-03-23 16:14:08 -0700 | [diff] [blame] | 212 | CFLAGS="$CFLAGS -fno-common" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 213 | abi="macho" |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 214 | AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 215 | RPATH="" |
Antony Dovgal | 2bd3cbc | 2011-10-13 09:33:33 +0400 | [diff] [blame] | 216 | LD_PRELOAD_VAR="DYLD_INSERT_LIBRARIES" |
Jason Evans | f576c63 | 2011-11-01 22:27:41 -0700 | [diff] [blame] | 217 | so="dylib" |
Jason Evans | b80581d | 2012-03-23 16:17:43 -0700 | [diff] [blame] | 218 | force_tls="0" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 219 | ;; |
| 220 | *-*-freebsd*) |
| 221 | CFLAGS="$CFLAGS" |
| 222 | abi="elf" |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 223 | AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 224 | RPATH="-Wl,-rpath," |
Jason Evans | fd4fcef | 2012-03-23 17:40:58 -0700 | [diff] [blame] | 225 | force_lazy_lock="1" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 226 | ;; |
| 227 | *-*-linux*) |
| 228 | CFLAGS="$CFLAGS" |
| 229 | CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" |
| 230 | abi="elf" |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 231 | AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED], [ ]) |
Jason Evans | 02b2312 | 2012-04-05 11:06:23 -0700 | [diff] [blame] | 232 | AC_DEFINE([JEMALLOC_THREADED_INIT], [ ]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 233 | RPATH="-Wl,-rpath," |
Jason Evans | 59ae276 | 2012-04-16 17:52:27 -0700 | [diff] [blame^] | 234 | default_munmap="0" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 235 | ;; |
| 236 | *-*-netbsd*) |
| 237 | AC_MSG_CHECKING([ABI]) |
| 238 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM( |
| 239 | [[#ifdef __ELF__ |
| 240 | /* ELF */ |
| 241 | #else |
| 242 | #error aout |
| 243 | #endif |
| 244 | ]])], |
| 245 | [CFLAGS="$CFLAGS"; abi="elf"], |
| 246 | [abi="aout"]) |
| 247 | AC_MSG_RESULT([$abi]) |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 248 | AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 249 | RPATH="-Wl,-rpath," |
| 250 | ;; |
| 251 | *-*-solaris2*) |
| 252 | CFLAGS="$CFLAGS" |
| 253 | abi="elf" |
| 254 | RPATH="-Wl,-R," |
| 255 | dnl Solaris needs this for sigwait(). |
| 256 | CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS" |
| 257 | LIBS="$LIBS -lposix4 -lsocket -lnsl" |
| 258 | ;; |
Antony Dovgal | 2bd3cbc | 2011-10-13 09:33:33 +0400 | [diff] [blame] | 259 | *-ibm-aix*) |
| 260 | if "$LG_SIZEOF_PTR" = "8"; then |
| 261 | dnl 64bit AIX |
| 262 | LD_PRELOAD_VAR="LDR_PRELOAD64" |
| 263 | else |
| 264 | dnl 32bit AIX |
| 265 | LD_PRELOAD_VAR="LDR_PRELOAD" |
| 266 | fi |
| 267 | abi="xcoff" |
| 268 | RPATH="-Wl,-rpath," |
| 269 | ;; |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 270 | *) |
| 271 | AC_MSG_RESULT([Unsupported operating system: ${host}]) |
| 272 | abi="elf" |
| 273 | RPATH="-Wl,-rpath," |
| 274 | ;; |
| 275 | esac |
| 276 | AC_SUBST([abi]) |
| 277 | AC_SUBST([RPATH]) |
Antony Dovgal | 2bd3cbc | 2011-10-13 09:33:33 +0400 | [diff] [blame] | 278 | AC_SUBST([LD_PRELOAD_VAR]) |
Jason Evans | f576c63 | 2011-11-01 22:27:41 -0700 | [diff] [blame] | 279 | AC_SUBST([so]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 280 | |
Jason Evans | fa5d245 | 2011-03-15 10:25:59 -0700 | [diff] [blame] | 281 | JE_COMPILABLE([__attribute__ syntax], |
| 282 | [static __attribute__((unused)) void foo(void){}], |
| 283 | [], |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 284 | [je_cv_attribute]) |
| 285 | if test "x${je_cv_attribute}" = "xyes" ; then |
Jason Evans | fa5d245 | 2011-03-15 10:25:59 -0700 | [diff] [blame] | 286 | AC_DEFINE([JEMALLOC_HAVE_ATTR], [ ]) |
| 287 | if test "x${GCC}" = "xyes" -a "x${abi}" = "xelf"; then |
| 288 | JE_CFLAGS_APPEND([-fvisibility=hidden]) |
| 289 | fi |
| 290 | fi |
Jason Evans | 3cc1f1a | 2012-04-03 22:30:05 -0700 | [diff] [blame] | 291 | dnl Check for tls_model attribute support (clang 3.0 still lacks support). |
| 292 | SAVED_CFLAGS="${CFLAGS}" |
| 293 | JE_CFLAGS_APPEND([-Werror]) |
| 294 | JE_COMPILABLE([tls_model attribute], [], |
| 295 | [static __thread int |
| 296 | __attribute__((tls_model("initial-exec"))) foo; |
| 297 | foo = 0;], |
| 298 | [je_cv_tls_model]) |
| 299 | CFLAGS="${SAVED_CFLAGS}" |
| 300 | if test "x${je_cv_tls_model}" = "xyes" ; then |
| 301 | AC_DEFINE([JEMALLOC_TLS_MODEL], |
| 302 | [__attribute__((tls_model("initial-exec")))]) |
| 303 | else |
| 304 | AC_DEFINE([JEMALLOC_TLS_MODEL], [ ]) |
| 305 | fi |
Jason Evans | fa5d245 | 2011-03-15 10:25:59 -0700 | [diff] [blame] | 306 | |
Jason Evans | cfdc8cf | 2010-11-30 16:50:58 -0800 | [diff] [blame] | 307 | JE_COMPILABLE([mremap(...MREMAP_FIXED...)], [ |
| 308 | #define _GNU_SOURCE |
| 309 | #include <sys/mman.h> |
| 310 | ], [ |
| 311 | void *p = mremap((void *)0, 0, 0, MREMAP_MAYMOVE|MREMAP_FIXED, (void *)0); |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 312 | ], [je_cv_mremap_fixed]) |
| 313 | if test "x${je_cv_mremap_fixed}" = "xyes" ; then |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 314 | AC_DEFINE([JEMALLOC_MREMAP_FIXED], [ ]) |
Jason Evans | cfdc8cf | 2010-11-30 16:50:58 -0800 | [diff] [blame] | 315 | fi |
| 316 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 317 | dnl Support optional additions to rpath. |
| 318 | AC_ARG_WITH([rpath], |
Jason Evans | 90895cf | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 319 | [AS_HELP_STRING([--with-rpath=<rpath>], [Colon-separated rpath (ELF systems only)])], |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 320 | if test "x$with_rpath" = "xno" ; then |
| 321 | RPATH_EXTRA= |
| 322 | else |
| 323 | RPATH_EXTRA="`echo $with_rpath | tr \":\" \" \"`" |
| 324 | fi, |
| 325 | RPATH_EXTRA= |
| 326 | ) |
| 327 | AC_SUBST([RPATH_EXTRA]) |
| 328 | |
| 329 | dnl Disable rules that do automatic regeneration of configure output by default. |
| 330 | AC_ARG_ENABLE([autogen], |
Jason Evans | 78d815c | 2010-01-17 14:06:20 -0800 | [diff] [blame] | 331 | [AS_HELP_STRING([--enable-autogen], [Automatically regenerate configure output])], |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 332 | if test "x$enable_autogen" = "xno" ; then |
| 333 | enable_autogen="0" |
| 334 | else |
| 335 | enable_autogen="1" |
| 336 | fi |
| 337 | , |
| 338 | enable_autogen="0" |
| 339 | ) |
| 340 | AC_SUBST([enable_autogen]) |
| 341 | |
| 342 | AC_PROG_INSTALL |
| 343 | AC_PROG_RANLIB |
| 344 | AC_PATH_PROG([AR], [ar], , [$PATH]) |
| 345 | AC_PATH_PROG([LD], [ld], , [$PATH]) |
| 346 | AC_PATH_PROG([AUTOCONF], [autoconf], , [$PATH]) |
| 347 | |
Jason Evans | 0a0bbf6 | 2012-03-13 12:55:21 -0700 | [diff] [blame] | 348 | public_syms="malloc_conf malloc_message malloc calloc posix_memalign aligned_alloc realloc free malloc_usable_size malloc_stats_print mallctl mallctlnametomib mallctlbymib" |
Jason Evans | 7e77eaf | 2012-03-02 17:47:37 -0800 | [diff] [blame] | 349 | |
| 350 | dnl Check for allocator-related functions that should be wrapped. |
| 351 | AC_CHECK_FUNC([memalign], |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 352 | [AC_DEFINE([JEMALLOC_OVERRIDE_MEMALIGN], [ ]) |
Jason Evans | 7e77eaf | 2012-03-02 17:47:37 -0800 | [diff] [blame] | 353 | public_syms="${public_syms} memalign"]) |
| 354 | AC_CHECK_FUNC([valloc], |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 355 | [AC_DEFINE([JEMALLOC_OVERRIDE_VALLOC], [ ]) |
Jason Evans | 7e77eaf | 2012-03-02 17:47:37 -0800 | [diff] [blame] | 356 | public_syms="${public_syms} valloc"]) |
| 357 | |
| 358 | dnl Support the experimental API by default. |
| 359 | AC_ARG_ENABLE([experimental], |
| 360 | [AS_HELP_STRING([--disable-experimental], |
| 361 | [Disable support for the experimental API])], |
| 362 | [if test "x$enable_experimental" = "xno" ; then |
| 363 | enable_experimental="0" |
| 364 | else |
| 365 | enable_experimental="1" |
| 366 | fi |
| 367 | ], |
| 368 | [enable_experimental="1"] |
| 369 | ) |
| 370 | if test "x$enable_experimental" = "x1" ; then |
| 371 | AC_DEFINE([JEMALLOC_EXPERIMENTAL], [ ]) |
| 372 | public_syms="${public_syms} allocm dallocm nallocm rallocm sallocm" |
| 373 | fi |
| 374 | AC_SUBST([enable_experimental]) |
| 375 | |
Jason Evans | 0a5489e | 2012-03-01 17:19:20 -0800 | [diff] [blame] | 376 | dnl Perform no name mangling by default. |
| 377 | AC_ARG_WITH([mangling], |
| 378 | [AS_HELP_STRING([--with-mangling=<map>], [Mangle symbols in <map>])], |
| 379 | [mangling_map="$with_mangling"], [mangling_map=""]) |
| 380 | for nm in `echo ${mangling_map} |tr ',' ' '` ; do |
Jason Evans | 08fc3b2 | 2012-03-12 15:07:53 -0700 | [diff] [blame] | 381 | k="`echo ${nm} |tr ':' ' ' |awk '{print $1}'`" |
| 382 | n="je_${k}" |
Jason Evans | 0a5489e | 2012-03-01 17:19:20 -0800 | [diff] [blame] | 383 | m=`echo ${nm} |tr ':' ' ' |awk '{print $2}'` |
| 384 | AC_DEFINE_UNQUOTED([${n}], [${m}]) |
Jason Evans | 08fc3b2 | 2012-03-12 15:07:53 -0700 | [diff] [blame] | 385 | dnl Remove key from public_syms so that it isn't redefined later. |
| 386 | public_syms=`for sym in ${public_syms}; do echo "${sym}"; done |grep -v "^${k}\$" |tr '\n' ' '` |
Jason Evans | 0a5489e | 2012-03-01 17:19:20 -0800 | [diff] [blame] | 387 | done |
| 388 | |
Jason Evans | 90895cf | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 389 | dnl Do not prefix public APIs by default. |
| 390 | AC_ARG_WITH([jemalloc_prefix], |
| 391 | [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] | 392 | [JEMALLOC_PREFIX="$with_jemalloc_prefix"], |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 393 | [if test "x$abi" != "xmacho" ; then |
| 394 | JEMALLOC_PREFIX="" |
| 395 | else |
| 396 | JEMALLOC_PREFIX="je_" |
| 397 | fi] |
Jason Evans | 90895cf | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 398 | ) |
| 399 | if test "x$JEMALLOC_PREFIX" != "x" ; then |
Jason Evans | e733970 | 2010-10-23 18:37:06 -0700 | [diff] [blame] | 400 | JEMALLOC_CPREFIX=`echo ${JEMALLOC_PREFIX} | tr "a-z" "A-Z"` |
| 401 | AC_DEFINE_UNQUOTED([JEMALLOC_PREFIX], ["$JEMALLOC_PREFIX"]) |
| 402 | AC_DEFINE_UNQUOTED([JEMALLOC_CPREFIX], ["$JEMALLOC_CPREFIX"]) |
Jason Evans | 90895cf | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 403 | fi |
Jason Evans | 0a5489e | 2012-03-01 17:19:20 -0800 | [diff] [blame] | 404 | dnl Generate macros to rename public symbols. All public symbols are prefixed |
| 405 | dnl with je_ in the source code, so these macro definitions are needed even if |
| 406 | dnl --with-jemalloc-prefix wasn't specified. |
Jason Evans | 7e77eaf | 2012-03-02 17:47:37 -0800 | [diff] [blame] | 407 | for stem in ${public_syms}; do |
Jason Evans | 0a5489e | 2012-03-01 17:19:20 -0800 | [diff] [blame] | 408 | n="je_${stem}" |
| 409 | m="${JEMALLOC_PREFIX}${stem}" |
| 410 | AC_DEFINE_UNQUOTED([${n}], [${m}]) |
| 411 | done |
Jason Evans | 90895cf | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 412 | |
Jason Evans | 746e77a | 2011-07-30 16:40:52 -0700 | [diff] [blame] | 413 | dnl Do not mangle library-private APIs by default. |
| 414 | AC_ARG_WITH([private_namespace], |
| 415 | [AS_HELP_STRING([--with-private-namespace=<prefix>], [Prefix to prepend to all library-private APIs])], |
| 416 | [JEMALLOC_PRIVATE_NAMESPACE="$with_private_namespace"], |
| 417 | [JEMALLOC_PRIVATE_NAMESPACE=""] |
| 418 | ) |
| 419 | AC_DEFINE_UNQUOTED([JEMALLOC_PRIVATE_NAMESPACE], ["$JEMALLOC_PRIVATE_NAMESPACE"]) |
| 420 | if test "x$JEMALLOC_PRIVATE_NAMESPACE" != "x" ; then |
| 421 | AC_DEFINE_UNQUOTED([JEMALLOC_N(string_that_no_one_should_want_to_use_as_a_jemalloc_private_namespace_prefix)], [${JEMALLOC_PRIVATE_NAMESPACE}##string_that_no_one_should_want_to_use_as_a_jemalloc_private_namespace_prefix]) |
| 422 | else |
| 423 | AC_DEFINE_UNQUOTED([JEMALLOC_N(string_that_no_one_should_want_to_use_as_a_jemalloc_private_namespace_prefix)], [string_that_no_one_should_want_to_use_as_a_jemalloc_private_namespace_prefix]) |
| 424 | fi |
| 425 | |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 426 | dnl Do not add suffix to installed files by default. |
| 427 | AC_ARG_WITH([install_suffix], |
| 428 | [AS_HELP_STRING([--with-install-suffix=<suffix>], [Suffix to append to all installed files])], |
| 429 | [INSTALL_SUFFIX="$with_install_suffix"], |
| 430 | [INSTALL_SUFFIX=] |
| 431 | ) |
| 432 | install_suffix="$INSTALL_SUFFIX" |
| 433 | AC_SUBST([install_suffix]) |
| 434 | |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 435 | cfgoutputs_in="${srcroot}Makefile.in" |
| 436 | cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/html.xsl.in" |
| 437 | cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/manpages.xsl.in" |
| 438 | cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/jemalloc.xml.in" |
Jason Evans | 0656ec0 | 2010-04-07 23:37:35 -0700 | [diff] [blame] | 439 | cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/jemalloc.h.in" |
| 440 | cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/internal/jemalloc_internal.h.in" |
Jason Evans | 9f3b0a7 | 2010-10-07 09:53:26 -0700 | [diff] [blame] | 441 | cfgoutputs_in="${cfgoutputs_in} ${srcroot}test/jemalloc_test.h.in" |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 442 | |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 443 | cfgoutputs_out="Makefile" |
| 444 | cfgoutputs_out="${cfgoutputs_out} doc/html.xsl" |
| 445 | cfgoutputs_out="${cfgoutputs_out} doc/manpages.xsl" |
| 446 | cfgoutputs_out="${cfgoutputs_out} doc/jemalloc${install_suffix}.xml" |
Jason Evans | 376b152 | 2010-02-11 14:45:59 -0800 | [diff] [blame] | 447 | cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc${install_suffix}.h" |
| 448 | cfgoutputs_out="${cfgoutputs_out} include/jemalloc/internal/jemalloc_internal.h" |
Jason Evans | 9f3b0a7 | 2010-10-07 09:53:26 -0700 | [diff] [blame] | 449 | cfgoutputs_out="${cfgoutputs_out} test/jemalloc_test.h" |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 450 | |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 451 | cfgoutputs_tup="Makefile" |
| 452 | cfgoutputs_tup="${cfgoutputs_tup} doc/html.xsl:doc/html.xsl.in" |
| 453 | cfgoutputs_tup="${cfgoutputs_tup} doc/manpages.xsl:doc/manpages.xsl.in" |
| 454 | cfgoutputs_tup="${cfgoutputs_tup} doc/jemalloc${install_suffix}.xml:doc/jemalloc.xml.in" |
Jason Evans | 376b152 | 2010-02-11 14:45:59 -0800 | [diff] [blame] | 455 | cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc${install_suffix}.h:include/jemalloc/jemalloc.h.in" |
| 456 | cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/internal/jemalloc_internal.h" |
Jason Evans | 9f3b0a7 | 2010-10-07 09:53:26 -0700 | [diff] [blame] | 457 | cfgoutputs_tup="${cfgoutputs_tup} test/jemalloc_test.h:test/jemalloc_test.h.in" |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 458 | |
Jason Evans | 0656ec0 | 2010-04-07 23:37:35 -0700 | [diff] [blame] | 459 | cfghdrs_in="${srcroot}include/jemalloc/jemalloc_defs.h.in" |
Jason Evans | b172610 | 2012-02-28 16:50:47 -0800 | [diff] [blame] | 460 | cfghdrs_in="${cfghdrs_in} ${srcroot}include/jemalloc/internal/size_classes.sh" |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 461 | |
Jason Evans | 376b152 | 2010-02-11 14:45:59 -0800 | [diff] [blame] | 462 | cfghdrs_out="include/jemalloc/jemalloc_defs${install_suffix}.h" |
Jason Evans | b172610 | 2012-02-28 16:50:47 -0800 | [diff] [blame] | 463 | cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/size_classes.h" |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 464 | |
Jason Evans | 376b152 | 2010-02-11 14:45:59 -0800 | [diff] [blame] | 465 | cfghdrs_tup="include/jemalloc/jemalloc_defs${install_suffix}.h:include/jemalloc/jemalloc_defs.h.in" |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 466 | |
Jason Evans | 355b438 | 2010-09-20 19:20:48 -0700 | [diff] [blame] | 467 | dnl Do not silence irrelevant compiler warnings by default, since enabling this |
| 468 | dnl option incurs a performance penalty. |
| 469 | AC_ARG_ENABLE([cc-silence], |
| 470 | [AS_HELP_STRING([--enable-cc-silence], |
| 471 | [Silence irrelevant compiler warnings])], |
| 472 | [if test "x$enable_cc_silence" = "xno" ; then |
| 473 | enable_cc_silence="0" |
| 474 | else |
| 475 | enable_cc_silence="1" |
| 476 | fi |
| 477 | ], |
| 478 | [enable_cc_silence="0"] |
| 479 | ) |
| 480 | if test "x$enable_cc_silence" = "x1" ; then |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 481 | AC_DEFINE([JEMALLOC_CC_SILENCE], [ ]) |
Jason Evans | 355b438 | 2010-09-20 19:20:48 -0700 | [diff] [blame] | 482 | fi |
| 483 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 484 | dnl Do not compile with debugging by default. |
| 485 | AC_ARG_ENABLE([debug], |
| 486 | [AS_HELP_STRING([--enable-debug], [Build debugging code])], |
| 487 | [if test "x$enable_debug" = "xno" ; then |
| 488 | enable_debug="0" |
| 489 | else |
| 490 | enable_debug="1" |
| 491 | fi |
| 492 | ], |
| 493 | [enable_debug="0"] |
| 494 | ) |
| 495 | if test "x$enable_debug" = "x1" ; then |
| 496 | AC_DEFINE([JEMALLOC_DEBUG], [ ]) |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 497 | AC_DEFINE([JEMALLOC_IVSALLOC], [ ]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 498 | fi |
| 499 | AC_SUBST([enable_debug]) |
| 500 | |
| 501 | dnl Only optimize if not debugging. |
| 502 | if test "x$enable_debug" = "x0" -a "x$no_CFLAGS" = "xyes" ; then |
| 503 | 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] | 504 | optimize="no" |
| 505 | echo "$EXTRA_CFLAGS" | grep "\-O" >/dev/null || optimize="yes" |
| 506 | if test "x${optimize}" = "xyes" ; then |
| 507 | if test "x$GCC" = "xyes" ; then |
| 508 | JE_CFLAGS_APPEND([-O3]) |
| 509 | JE_CFLAGS_APPEND([-funroll-loops]) |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 510 | else |
| 511 | JE_CFLAGS_APPEND([-O]) |
| 512 | fi |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 513 | fi |
| 514 | fi |
| 515 | |
Jason Evans | d073a32 | 2012-02-28 20:41:16 -0800 | [diff] [blame] | 516 | dnl Enable statistics calculation by default. |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 517 | AC_ARG_ENABLE([stats], |
Jason Evans | 777c191 | 2012-02-28 20:49:22 -0800 | [diff] [blame] | 518 | [AS_HELP_STRING([--disable-stats], |
| 519 | [Disable statistics calculation/reporting])], |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 520 | [if test "x$enable_stats" = "xno" ; then |
| 521 | enable_stats="0" |
| 522 | else |
| 523 | enable_stats="1" |
| 524 | fi |
| 525 | ], |
Jason Evans | d073a32 | 2012-02-28 20:41:16 -0800 | [diff] [blame] | 526 | [enable_stats="1"] |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 527 | ) |
| 528 | if test "x$enable_stats" = "x1" ; then |
| 529 | AC_DEFINE([JEMALLOC_STATS], [ ]) |
| 530 | fi |
| 531 | AC_SUBST([enable_stats]) |
| 532 | |
Jason Evans | 6109fe0 | 2010-02-10 10:37:56 -0800 | [diff] [blame] | 533 | dnl Do not enable profiling by default. |
| 534 | AC_ARG_ENABLE([prof], |
| 535 | [AS_HELP_STRING([--enable-prof], [Enable allocation profiling])], |
| 536 | [if test "x$enable_prof" = "xno" ; then |
| 537 | enable_prof="0" |
| 538 | else |
| 539 | enable_prof="1" |
| 540 | fi |
| 541 | ], |
| 542 | [enable_prof="0"] |
| 543 | ) |
Jason Evans | 77f350b | 2011-03-15 22:23:12 -0700 | [diff] [blame] | 544 | if test "x$enable_prof" = "x1" ; then |
| 545 | backtrace_method="" |
Jason Evans | b27805b | 2010-02-10 18:15:53 -0800 | [diff] [blame] | 546 | else |
Jason Evans | 77f350b | 2011-03-15 22:23:12 -0700 | [diff] [blame] | 547 | backtrace_method="N/A" |
Jason Evans | b27805b | 2010-02-10 18:15:53 -0800 | [diff] [blame] | 548 | fi |
Jason Evans | 77f350b | 2011-03-15 22:23:12 -0700 | [diff] [blame] | 549 | |
Jason Evans | 6109fe0 | 2010-02-10 10:37:56 -0800 | [diff] [blame] | 550 | AC_ARG_ENABLE([prof-libunwind], |
| 551 | [AS_HELP_STRING([--enable-prof-libunwind], [Use libunwind for backtracing])], |
| 552 | [if test "x$enable_prof_libunwind" = "xno" ; then |
| 553 | enable_prof_libunwind="0" |
| 554 | else |
| 555 | enable_prof_libunwind="1" |
| 556 | fi |
| 557 | ], |
| 558 | [enable_prof_libunwind="0"] |
| 559 | ) |
Jason Evans | ca6bd4f | 2010-03-02 14:12:58 -0800 | [diff] [blame] | 560 | AC_ARG_WITH([static_libunwind], |
| 561 | [AS_HELP_STRING([--with-static-libunwind=<libunwind.a>], |
| 562 | [Path to static libunwind library; use rather than dynamically linking])], |
| 563 | if test "x$with_static_libunwind" = "xno" ; then |
| 564 | LUNWIND="-lunwind" |
| 565 | else |
| 566 | if test ! -f "$with_static_libunwind" ; then |
| 567 | AC_MSG_ERROR([Static libunwind not found: $with_static_libunwind]) |
| 568 | fi |
| 569 | LUNWIND="$with_static_libunwind" |
| 570 | fi, |
| 571 | LUNWIND="-lunwind" |
| 572 | ) |
Jason Evans | 77f350b | 2011-03-15 22:23:12 -0700 | [diff] [blame] | 573 | if test "x$backtrace_method" = "x" -a "x$enable_prof_libunwind" = "x1" ; then |
| 574 | AC_CHECK_HEADERS([libunwind.h], , [enable_prof_libunwind="0"]) |
| 575 | if test "x$LUNWIND" = "x-lunwind" ; then |
| 576 | AC_CHECK_LIB([unwind], [backtrace], [LIBS="$LIBS $LUNWIND"], |
| 577 | [enable_prof_libunwind="0"]) |
| 578 | else |
| 579 | LIBS="$LIBS $LUNWIND" |
| 580 | fi |
| 581 | if test "x${enable_prof_libunwind}" = "x1" ; then |
| 582 | backtrace_method="libunwind" |
| 583 | AC_DEFINE([JEMALLOC_PROF_LIBUNWIND], [ ]) |
| 584 | fi |
| 585 | fi |
| 586 | |
| 587 | AC_ARG_ENABLE([prof-libgcc], |
| 588 | [AS_HELP_STRING([--disable-prof-libgcc], |
| 589 | [Do not use libgcc for backtracing])], |
| 590 | [if test "x$enable_prof_libgcc" = "xno" ; then |
| 591 | enable_prof_libgcc="0" |
| 592 | else |
| 593 | enable_prof_libgcc="1" |
| 594 | fi |
| 595 | ], |
| 596 | [enable_prof_libgcc="1"] |
| 597 | ) |
| 598 | if test "x$backtrace_method" = "x" -a "x$enable_prof_libgcc" = "x1" \ |
| 599 | -a "x$GCC" = "xyes" ; then |
| 600 | AC_CHECK_HEADERS([unwind.h], , [enable_prof_libgcc="0"]) |
| 601 | AC_CHECK_LIB([gcc], [_Unwind_Backtrace], [LIBS="$LIBS -lgcc"], [enable_prof_libgcc="0"]) |
| 602 | dnl The following is conservative, in that it only has entries for CPUs on |
| 603 | dnl which jemalloc has been tested. |
| 604 | AC_MSG_CHECKING([libgcc-based backtracing reliability on ${host_cpu}]) |
| 605 | case "${host_cpu}" in |
| 606 | i[[3456]]86) |
| 607 | AC_MSG_RESULT([unreliable]) |
| 608 | enable_prof_libgcc="0"; |
| 609 | ;; |
| 610 | x86_64) |
| 611 | AC_MSG_RESULT([reliable]) |
| 612 | ;; |
| 613 | *) |
| 614 | AC_MSG_RESULT([unreliable]) |
| 615 | enable_prof_libgcc="0"; |
| 616 | ;; |
| 617 | esac |
| 618 | if test "x${enable_prof_libgcc}" = "x1" ; then |
| 619 | backtrace_method="libgcc" |
| 620 | AC_DEFINE([JEMALLOC_PROF_LIBGCC], [ ]) |
| 621 | fi |
| 622 | else |
| 623 | enable_prof_libgcc="0" |
| 624 | fi |
| 625 | |
| 626 | AC_ARG_ENABLE([prof-gcc], |
| 627 | [AS_HELP_STRING([--disable-prof-gcc], |
| 628 | [Do not use gcc intrinsics for backtracing])], |
| 629 | [if test "x$enable_prof_gcc" = "xno" ; then |
| 630 | enable_prof_gcc="0" |
| 631 | else |
| 632 | enable_prof_gcc="1" |
| 633 | fi |
| 634 | ], |
| 635 | [enable_prof_gcc="1"] |
| 636 | ) |
| 637 | if test "x$backtrace_method" = "x" -a "x$enable_prof_gcc" = "x1" \ |
| 638 | -a "x$GCC" = "xyes" ; then |
| 639 | backtrace_method="gcc intrinsics" |
| 640 | AC_DEFINE([JEMALLOC_PROF_GCC], [ ]) |
| 641 | else |
| 642 | enable_prof_gcc="0" |
| 643 | fi |
| 644 | |
| 645 | if test "x$backtrace_method" = "x" ; then |
| 646 | backtrace_method="none (disabling profiling)" |
| 647 | enable_prof="0" |
| 648 | fi |
| 649 | AC_MSG_CHECKING([configured backtracing method]) |
| 650 | AC_MSG_RESULT([$backtrace_method]) |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 651 | if test "x$enable_prof" = "x1" ; then |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 652 | AC_DEFINE([JEMALLOC_PROF], [ ]) |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 653 | fi |
| 654 | AC_SUBST([enable_prof]) |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 655 | |
Jason Evans | 84cbbcb | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 656 | dnl Enable thread-specific caching by default. |
| 657 | AC_ARG_ENABLE([tcache], |
| 658 | [AS_HELP_STRING([--disable-tcache], [Disable per thread caches])], |
| 659 | [if test "x$enable_tcache" = "xno" ; then |
| 660 | enable_tcache="0" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 661 | else |
Jason Evans | 84cbbcb | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 662 | enable_tcache="1" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 663 | fi |
| 664 | ], |
Jason Evans | 84cbbcb | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 665 | [enable_tcache="1"] |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 666 | ) |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 667 | if test "x$enable_tcache" = "x1" ; then |
| 668 | AC_DEFINE([JEMALLOC_TCACHE], [ ]) |
| 669 | fi |
| 670 | AC_SUBST([enable_tcache]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 671 | |
Jason Evans | 59ae276 | 2012-04-16 17:52:27 -0700 | [diff] [blame^] | 672 | dnl Enable VM deallocation via munmap() by default. |
| 673 | AC_ARG_ENABLE([munmap], |
| 674 | [AS_HELP_STRING([--disable-munmap], [Disable VM deallocation via munmap(2)])], |
| 675 | [if test "x$enable_munmap" = "xno" ; then |
| 676 | enable_munmap="0" |
| 677 | else |
| 678 | enable_munmap="1" |
| 679 | fi |
| 680 | ], |
| 681 | [enable_munmap="${default_munmap}"] |
| 682 | ) |
| 683 | if test "x$enable_munmap" = "x1" ; then |
| 684 | AC_DEFINE([JEMALLOC_MUNMAP], [ ]) |
| 685 | fi |
| 686 | AC_SUBST([enable_munmap]) |
| 687 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 688 | dnl Do not enable allocation from DSS by default. |
| 689 | AC_ARG_ENABLE([dss], |
| 690 | [AS_HELP_STRING([--enable-dss], [Enable allocation from DSS])], |
| 691 | [if test "x$enable_dss" = "xno" ; then |
| 692 | enable_dss="0" |
| 693 | else |
| 694 | enable_dss="1" |
| 695 | fi |
| 696 | ], |
| 697 | [enable_dss="0"] |
| 698 | ) |
Mike Hommey | 83c324a | 2012-04-12 10:13:03 +0200 | [diff] [blame] | 699 | dnl Check whether the BSD/SUSv1 sbrk() exists. If not, disable DSS support. |
| 700 | AC_CHECK_FUNC([sbrk], [have_sbrk="1"], [have_sbrk="0"]) |
| 701 | if test "x$have_sbrk" = "x1" ; then |
| 702 | AC_DEFINE([JEMALLOC_HAVE_SBRK], [ ]) |
| 703 | else |
| 704 | enable_dss="0" |
| 705 | fi |
| 706 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 707 | if test "x$enable_dss" = "x1" ; then |
| 708 | AC_DEFINE([JEMALLOC_DSS], [ ]) |
| 709 | fi |
| 710 | AC_SUBST([enable_dss]) |
| 711 | |
Jason Evans | 777c191 | 2012-02-28 20:49:22 -0800 | [diff] [blame] | 712 | dnl Support the junk/zero filling option by default. |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 713 | AC_ARG_ENABLE([fill], |
Jason Evans | 122449b | 2012-04-06 00:35:09 -0700 | [diff] [blame] | 714 | [AS_HELP_STRING([--disable-fill], |
| 715 | [Disable support for junk/zero filling, quarantine, and redzones])], |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 716 | [if test "x$enable_fill" = "xno" ; then |
| 717 | enable_fill="0" |
| 718 | else |
| 719 | enable_fill="1" |
| 720 | fi |
| 721 | ], |
Jason Evans | 777c191 | 2012-02-28 20:49:22 -0800 | [diff] [blame] | 722 | [enable_fill="1"] |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 723 | ) |
| 724 | if test "x$enable_fill" = "x1" ; then |
| 725 | AC_DEFINE([JEMALLOC_FILL], [ ]) |
| 726 | fi |
| 727 | AC_SUBST([enable_fill]) |
| 728 | |
Jason Evans | b147611 | 2012-04-05 13:36:17 -0700 | [diff] [blame] | 729 | dnl Disable utrace(2)-based tracing by default. |
| 730 | AC_ARG_ENABLE([utrace], |
| 731 | [AS_HELP_STRING([--enable-utrace], [Enable utrace(2)-based tracing])], |
| 732 | [if test "x$enable_utrace" = "xno" ; then |
| 733 | enable_utrace="0" |
| 734 | else |
| 735 | enable_utrace="1" |
| 736 | fi |
| 737 | ], |
| 738 | [enable_utrace="0"] |
| 739 | ) |
| 740 | JE_COMPILABLE([utrace(2)], [ |
| 741 | #include <sys/types.h> |
| 742 | #include <sys/param.h> |
| 743 | #include <sys/time.h> |
| 744 | #include <sys/uio.h> |
| 745 | #include <sys/ktrace.h> |
| 746 | ], [ |
| 747 | utrace((void *)0, 0); |
| 748 | ], [je_cv_utrace]) |
| 749 | if test "x${je_cv_utrace}" = "xno" ; then |
| 750 | enable_utrace="0" |
| 751 | fi |
| 752 | if test "x$enable_utrace" = "x1" ; then |
| 753 | AC_DEFINE([JEMALLOC_UTRACE], [ ]) |
| 754 | fi |
| 755 | AC_SUBST([enable_utrace]) |
| 756 | |
Jason Evans | 122449b | 2012-04-06 00:35:09 -0700 | [diff] [blame] | 757 | dnl Support Valgrind by default. |
| 758 | AC_ARG_ENABLE([valgrind], |
| 759 | [AS_HELP_STRING([--disable-valgrind], [Disable support for Valgrind])], |
| 760 | [if test "x$enable_valgrind" = "xno" ; then |
| 761 | enable_valgrind="0" |
| 762 | else |
| 763 | enable_valgrind="1" |
| 764 | fi |
| 765 | ], |
| 766 | [enable_valgrind="1"] |
| 767 | ) |
| 768 | if test "x$enable_valgrind" = "x1" ; then |
| 769 | JE_COMPILABLE([valgrind], [ |
| 770 | #include <valgrind/valgrind.h> |
| 771 | #include <valgrind/memcheck.h> |
| 772 | |
| 773 | #if defined(__VALGRIND_MAJOR__) && defined(__VALGRIND_MINOR__) \ |
| 774 | && (__VALGRIND_MAJOR__ > 3 || (__VALGRIND_MAJOR__ == 3 && \ |
| 775 | __VALGRIND_MINOR__ >= 6)) |
| 776 | #else |
| 777 | # error "Incompatible Valgrind version" |
| 778 | #endif |
| 779 | ], [], [je_cv_valgrind]) |
| 780 | if test "x${je_cv_valgrind}" = "xno" ; then |
| 781 | enable_valgrind="0" |
| 782 | fi |
| 783 | if test "x$enable_valgrind" = "x1" ; then |
| 784 | AC_DEFINE([JEMALLOC_VALGRIND], [ ]) |
| 785 | fi |
| 786 | fi |
| 787 | AC_SUBST([enable_valgrind]) |
| 788 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 789 | dnl Do not support the xmalloc option by default. |
| 790 | AC_ARG_ENABLE([xmalloc], |
| 791 | [AS_HELP_STRING([--enable-xmalloc], [Support xmalloc option])], |
| 792 | [if test "x$enable_xmalloc" = "xno" ; then |
| 793 | enable_xmalloc="0" |
| 794 | else |
| 795 | enable_xmalloc="1" |
| 796 | fi |
| 797 | ], |
| 798 | [enable_xmalloc="0"] |
| 799 | ) |
| 800 | if test "x$enable_xmalloc" = "x1" ; then |
| 801 | AC_DEFINE([JEMALLOC_XMALLOC], [ ]) |
| 802 | fi |
| 803 | AC_SUBST([enable_xmalloc]) |
| 804 | |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 805 | AC_CACHE_CHECK([STATIC_PAGE_SHIFT], |
| 806 | [je_cv_static_page_shift], |
| 807 | AC_RUN_IFELSE([AC_LANG_PROGRAM( |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 808 | [[#include <stdio.h> |
| 809 | #include <unistd.h> |
| 810 | #include <strings.h> |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 811 | ]], |
| 812 | [[ |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 813 | long result; |
| 814 | FILE *f; |
| 815 | |
| 816 | result = sysconf(_SC_PAGESIZE); |
| 817 | if (result == -1) { |
| 818 | return 1; |
| 819 | } |
| 820 | f = fopen("conftest.out", "w"); |
| 821 | if (f == NULL) { |
| 822 | return 1; |
| 823 | } |
| 824 | fprintf(f, "%u\n", ffs((int)result) - 1); |
Jason Evans | 3cc1f1a | 2012-04-03 22:30:05 -0700 | [diff] [blame] | 825 | fclose(f); |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 826 | |
| 827 | return 0; |
| 828 | ]])], |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 829 | [je_cv_static_page_shift=`cat conftest.out`], |
| 830 | [je_cv_static_page_shift=undefined])) |
| 831 | |
| 832 | if test "x$je_cv_static_page_shift" != "xundefined"; then |
| 833 | AC_DEFINE_UNQUOTED([STATIC_PAGE_SHIFT], [$je_cv_static_page_shift]) |
| 834 | else |
| 835 | AC_MSG_ERROR([cannot determine value for STATIC_PAGE_SHIFT]) |
| 836 | fi |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 837 | |
| 838 | dnl ============================================================================ |
| 839 | dnl jemalloc configuration. |
| 840 | dnl |
Jason Evans | a40bc7a | 2010-03-02 13:01:16 -0800 | [diff] [blame] | 841 | |
| 842 | dnl Set VERSION if source directory has an embedded git repository. |
Jason Evans | 955851f | 2011-03-31 22:38:51 -0700 | [diff] [blame] | 843 | if test -d "${srcroot}.git" ; then |
Jason Evans | 79d660d | 2010-09-17 17:38:24 -0700 | [diff] [blame] | 844 | git describe --long --abbrev=40 > ${srcroot}VERSION |
Jason Evans | a40bc7a | 2010-03-02 13:01:16 -0800 | [diff] [blame] | 845 | fi |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 846 | jemalloc_version=`cat ${srcroot}VERSION` |
Jason Evans | a40bc7a | 2010-03-02 13:01:16 -0800 | [diff] [blame] | 847 | jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'` |
| 848 | jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'` |
| 849 | jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'` |
| 850 | jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'` |
| 851 | jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'` |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 852 | AC_SUBST([jemalloc_version]) |
Jason Evans | a40bc7a | 2010-03-02 13:01:16 -0800 | [diff] [blame] | 853 | AC_SUBST([jemalloc_version_major]) |
| 854 | AC_SUBST([jemalloc_version_minor]) |
| 855 | AC_SUBST([jemalloc_version_bugfix]) |
| 856 | AC_SUBST([jemalloc_version_nrev]) |
| 857 | AC_SUBST([jemalloc_version_gid]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 858 | |
| 859 | dnl ============================================================================ |
| 860 | dnl Configure pthreads. |
| 861 | |
| 862 | AC_CHECK_HEADERS([pthread.h], , [AC_MSG_ERROR([pthread.h is missing])]) |
Jason Evans | 39006f9 | 2012-03-16 16:57:02 -0700 | [diff] [blame] | 863 | dnl Some systems may embed pthreads functionality in libc; check for libpthread |
| 864 | dnl first, but try libc too before failing. |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 865 | AC_CHECK_LIB([pthread], [pthread_create], [LIBS="$LIBS -lpthread"], |
Jason Evans | 39006f9 | 2012-03-16 16:57:02 -0700 | [diff] [blame] | 866 | [AC_SEARCH_LIBS([pthread_create], , , |
| 867 | AC_MSG_ERROR([libpthread is missing]))]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 868 | |
| 869 | CPPFLAGS="$CPPFLAGS -D_REENTRANT" |
| 870 | |
Jason Evans | cd9a134 | 2012-03-21 18:33:03 -0700 | [diff] [blame] | 871 | dnl Check whether the BSD-specific _malloc_thread_cleanup() exists. If so, use |
| 872 | dnl it rather than pthreads TSD cleanup functions to support cleanup during |
| 873 | dnl thread exit, in order to avoid pthreads library recursion during |
| 874 | dnl bootstrapping. |
Jason Evans | cd9a134 | 2012-03-21 18:33:03 -0700 | [diff] [blame] | 875 | AC_CHECK_FUNC([_malloc_thread_cleanup], |
| 876 | [have__malloc_thread_cleanup="1"], |
| 877 | [have__malloc_thread_cleanup="0"] |
| 878 | ) |
| 879 | if test "x$have__malloc_thread_cleanup" = "x1" ; then |
| 880 | AC_DEFINE([JEMALLOC_MALLOC_THREAD_CLEANUP], [ ]) |
| 881 | force_tls="1" |
| 882 | fi |
| 883 | |
Jason Evans | 41b6afb | 2012-02-02 22:04:57 -0800 | [diff] [blame] | 884 | dnl Check whether the BSD-specific _pthread_mutex_init_calloc_cb() exists. If |
| 885 | dnl so, mutex initialization causes allocation, and we need to implement this |
| 886 | dnl callback function in order to prevent recursive allocation. |
| 887 | AC_CHECK_FUNC([_pthread_mutex_init_calloc_cb], |
| 888 | [have__pthread_mutex_init_calloc_cb="1"], |
| 889 | [have__pthread_mutex_init_calloc_cb="0"] |
| 890 | ) |
| 891 | if test "x$have__pthread_mutex_init_calloc_cb" = "x1" ; then |
| 892 | AC_DEFINE([JEMALLOC_MUTEX_INIT_CB]) |
| 893 | fi |
| 894 | |
Jason Evans | 0fee70d | 2012-02-13 12:36:11 -0800 | [diff] [blame] | 895 | dnl Disable lazy locking by default. |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 896 | AC_ARG_ENABLE([lazy_lock], |
Jason Evans | 0fee70d | 2012-02-13 12:36:11 -0800 | [diff] [blame] | 897 | [AS_HELP_STRING([--enable-lazy-lock], |
| 898 | [Enable lazy locking (only lock when multi-threaded)])], |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 899 | [if test "x$enable_lazy_lock" = "xno" ; then |
| 900 | enable_lazy_lock="0" |
| 901 | else |
| 902 | enable_lazy_lock="1" |
| 903 | fi |
| 904 | ], |
Jason Evans | 0fee70d | 2012-02-13 12:36:11 -0800 | [diff] [blame] | 905 | [enable_lazy_lock="0"] |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 906 | ) |
Jason Evans | fd4fcef | 2012-03-23 17:40:58 -0700 | [diff] [blame] | 907 | if test "x$enable_lazy_lock" = "x0" -a "x${force_lazy_lock}" = "x1" ; then |
| 908 | AC_MSG_RESULT([Forcing lazy-lock to avoid allocator/threading bootstrap issues]) |
| 909 | enable_lazy_lock="1" |
| 910 | fi |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 911 | if test "x$enable_lazy_lock" = "x1" ; then |
| 912 | AC_CHECK_HEADERS([dlfcn.h], , [AC_MSG_ERROR([dlfcn.h is missing])]) |
Jason Evans | 650285d | 2012-03-19 10:25:27 -0700 | [diff] [blame] | 913 | AC_CHECK_FUNC([dlsym], [], |
| 914 | [AC_CHECK_LIB([dl], [dlsym], [LIBS="$LIBS -ldl"], |
| 915 | [AC_MSG_ERROR([libdl is missing])]) |
| 916 | ]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 917 | AC_DEFINE([JEMALLOC_LAZY_LOCK], [ ]) |
| 918 | fi |
| 919 | AC_SUBST([enable_lazy_lock]) |
| 920 | |
Jason Evans | 78d815c | 2010-01-17 14:06:20 -0800 | [diff] [blame] | 921 | AC_ARG_ENABLE([tls], |
| 922 | [AS_HELP_STRING([--disable-tls], [Disable thread-local storage (__thread keyword)])], |
| 923 | if test "x$enable_tls" = "xno" ; then |
| 924 | enable_tls="0" |
| 925 | else |
| 926 | enable_tls="1" |
| 927 | fi |
| 928 | , |
| 929 | enable_tls="1" |
| 930 | ) |
Jason Evans | cd9a134 | 2012-03-21 18:33:03 -0700 | [diff] [blame] | 931 | if test "x${enable_tls}" = "x0" -a "x${force_tls}" = "x1" ; then |
| 932 | AC_MSG_RESULT([Forcing TLS to avoid allocator/threading bootstrap issues]) |
| 933 | enable_tls="1" |
| 934 | fi |
Jason Evans | b80581d | 2012-03-23 16:17:43 -0700 | [diff] [blame] | 935 | if test "x${enable_tls}" = "x1" -a "x${force_tls}" = "x0" ; then |
| 936 | AC_MSG_RESULT([Forcing no TLS to avoid allocator/threading bootstrap issues]) |
| 937 | enable_tls="0" |
| 938 | fi |
Jason Evans | 78d815c | 2010-01-17 14:06:20 -0800 | [diff] [blame] | 939 | if test "x${enable_tls}" = "x1" ; then |
| 940 | AC_MSG_CHECKING([for TLS]) |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 941 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM( |
Jason Evans | 78d815c | 2010-01-17 14:06:20 -0800 | [diff] [blame] | 942 | [[ |
| 943 | __thread int x; |
| 944 | ]], [[ |
| 945 | x = 42; |
| 946 | |
| 947 | return 0; |
| 948 | ]])], |
| 949 | AC_MSG_RESULT([yes]), |
| 950 | AC_MSG_RESULT([no]) |
| 951 | enable_tls="0") |
| 952 | fi |
Jason Evans | b267d0f | 2010-08-13 15:42:29 -0700 | [diff] [blame] | 953 | AC_SUBST([enable_tls]) |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 954 | if test "x${enable_tls}" = "x1" ; then |
| 955 | AC_DEFINE_UNQUOTED([JEMALLOC_TLS], [ ]) |
Jason Evans | cd9a134 | 2012-03-21 18:33:03 -0700 | [diff] [blame] | 956 | elif test "x${force_tls}" = "x1" ; then |
| 957 | 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] | 958 | fi |
| 959 | |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 960 | dnl ============================================================================ |
Jason Evans | 84c8eef | 2011-03-16 10:30:13 -0700 | [diff] [blame] | 961 | dnl Check for ffsl(3), and fail if not found. This function exists on all |
| 962 | dnl platforms that jemalloc currently has a chance of functioning on without |
| 963 | dnl modification. |
Jason Evans | 4c2faa8 | 2012-03-13 11:09:23 -0700 | [diff] [blame] | 964 | JE_COMPILABLE([a program using ffsl], [ |
Jason Evans | 382132e | 2012-04-04 15:25:43 -0700 | [diff] [blame] | 965 | #include <strings.h> |
Jason Evans | 4c2faa8 | 2012-03-13 11:09:23 -0700 | [diff] [blame] | 966 | #include <string.h> |
| 967 | ], [ |
| 968 | { |
| 969 | int rv = ffsl(0x08); |
| 970 | } |
| 971 | ], [je_cv_function_ffsl]) |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 972 | if test "x${je_cv_function_ffsl}" != "xyes" ; then |
| 973 | AC_MSG_ERROR([Cannot build without ffsl(3)]) |
| 974 | fi |
Jason Evans | 84c8eef | 2011-03-16 10:30:13 -0700 | [diff] [blame] | 975 | |
| 976 | dnl ============================================================================ |
Jason Evans | 763baa6 | 2011-03-18 19:10:31 -0700 | [diff] [blame] | 977 | dnl Check for atomic(3) operations as provided on Darwin. |
| 978 | |
| 979 | JE_COMPILABLE([Darwin OSAtomic*()], [ |
| 980 | #include <libkern/OSAtomic.h> |
| 981 | #include <inttypes.h> |
| 982 | ], [ |
| 983 | { |
| 984 | int32_t x32 = 0; |
| 985 | volatile int32_t *x32p = &x32; |
| 986 | OSAtomicAdd32(1, x32p); |
| 987 | } |
| 988 | { |
| 989 | int64_t x64 = 0; |
| 990 | volatile int64_t *x64p = &x64; |
| 991 | OSAtomicAdd64(1, x64p); |
| 992 | } |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 993 | ], [je_cv_osatomic]) |
| 994 | if test "x${je_cv_osatomic}" = "xyes" ; then |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 995 | AC_DEFINE([JEMALLOC_OSATOMIC], [ ]) |
Jason Evans | 763baa6 | 2011-03-18 19:10:31 -0700 | [diff] [blame] | 996 | fi |
| 997 | |
| 998 | dnl ============================================================================ |
Mike Hommey | c1e567b | 2012-03-26 17:03:41 +0200 | [diff] [blame] | 999 | dnl Check whether __sync_{add,sub}_and_fetch() are available despite |
| 1000 | dnl __GCC_HAVE_SYNC_COMPARE_AND_SWAP_n macros being undefined. |
| 1001 | |
| 1002 | AC_DEFUN([JE_SYNC_COMPARE_AND_SWAP_CHECK],[ |
| 1003 | AC_CACHE_CHECK([whether to force $1-bit __sync_{add,sub}_and_fetch()], |
| 1004 | [je_cv_sync_compare_and_swap_$2], |
Mike Hommey | 2cfe6d6 | 2012-03-27 15:03:07 +0200 | [diff] [blame] | 1005 | [AC_LINK_IFELSE([AC_LANG_PROGRAM([ |
| 1006 | #include <stdint.h> |
| 1007 | ], |
| 1008 | [ |
| 1009 | #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2 |
| 1010 | { |
| 1011 | uint$1_t x$1 = 0; |
| 1012 | __sync_add_and_fetch(&x$1, 42); |
| 1013 | __sync_sub_and_fetch(&x$1, 1); |
| 1014 | } |
| 1015 | #else |
| 1016 | #error __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2 is defined, no need to force |
| 1017 | #endif |
| 1018 | ])], |
Mike Hommey | c1e567b | 2012-03-26 17:03:41 +0200 | [diff] [blame] | 1019 | [je_cv_sync_compare_and_swap_$2=yes], |
| 1020 | [je_cv_sync_compare_and_swap_$2=no])]) |
| 1021 | |
| 1022 | if test "x${je_cv_sync_compare_and_swap_$2}" = "xyes" ; then |
| 1023 | AC_DEFINE([JE_FORCE_SYNC_COMPARE_AND_SWAP_$2], [ ]) |
| 1024 | fi |
| 1025 | ]) |
| 1026 | |
| 1027 | if test "x${je_cv_osatomic}" != "xyes" ; then |
| 1028 | JE_SYNC_COMPARE_AND_SWAP_CHECK(32, 4) |
| 1029 | JE_SYNC_COMPARE_AND_SWAP_CHECK(64, 8) |
| 1030 | fi |
| 1031 | |
| 1032 | dnl ============================================================================ |
Jason Evans | 893a0ed | 2011-03-18 19:30:18 -0700 | [diff] [blame] | 1033 | dnl Check for spinlock(3) operations as provided on Darwin. |
| 1034 | |
| 1035 | JE_COMPILABLE([Darwin OSSpin*()], [ |
| 1036 | #include <libkern/OSAtomic.h> |
| 1037 | #include <inttypes.h> |
| 1038 | ], [ |
| 1039 | OSSpinLock lock = 0; |
| 1040 | OSSpinLockLock(&lock); |
| 1041 | OSSpinLockUnlock(&lock); |
Jason Evans | 6684cac | 2012-03-05 12:15:36 -0800 | [diff] [blame] | 1042 | ], [je_cv_osspin]) |
| 1043 | if test "x${je_cv_osspin}" = "xyes" ; then |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 1044 | AC_DEFINE([JEMALLOC_OSSPIN], [ ]) |
Jason Evans | 893a0ed | 2011-03-18 19:30:18 -0700 | [diff] [blame] | 1045 | fi |
| 1046 | |
| 1047 | dnl ============================================================================ |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 1048 | dnl Darwin-related configuration. |
Jason Evans | 78d815c | 2010-01-17 14:06:20 -0800 | [diff] [blame] | 1049 | |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 1050 | if test "x${abi}" = "xmacho" ; then |
Jason Evans | e24c7af | 2012-03-19 10:21:17 -0700 | [diff] [blame] | 1051 | AC_DEFINE([JEMALLOC_IVSALLOC], [ ]) |
| 1052 | AC_DEFINE([JEMALLOC_ZONE], [ ]) |
Jason Evans | 6109fe0 | 2010-02-10 10:37:56 -0800 | [diff] [blame] | 1053 | |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 1054 | dnl The szone version jumped from 3 to 6 between the OS X 10.5.x and 10.6 |
| 1055 | dnl releases. malloc_zone_t and malloc_introspection_t have new fields in |
| 1056 | dnl 10.6, which is the only source-level indication of the change. |
| 1057 | AC_MSG_CHECKING([malloc zone version]) |
Mike Hommey | 154829d | 2012-03-20 18:01:38 +0100 | [diff] [blame] | 1058 | AC_DEFUN([JE_ZONE_PROGRAM], |
| 1059 | [AC_LANG_PROGRAM( |
| 1060 | [#include <malloc/malloc.h>], |
| 1061 | [static foo[[sizeof($1) $2 sizeof(void *) * $3 ? 1 : -1]]] |
| 1062 | )]) |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 1063 | |
Mike Hommey | 154829d | 2012-03-20 18:01:38 +0100 | [diff] [blame] | 1064 | AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,14)],[JEMALLOC_ZONE_VERSION=3],[ |
| 1065 | AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,15)],[JEMALLOC_ZONE_VERSION=5],[ |
| 1066 | AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,16)],[ |
| 1067 | AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,9)],[JEMALLOC_ZONE_VERSION=6],[ |
| 1068 | AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,13)],[JEMALLOC_ZONE_VERSION=7],[JEMALLOC_ZONE_VERSION=] |
| 1069 | )])],[ |
| 1070 | AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,17)],[JEMALLOC_ZONE_VERSION=8],[ |
| 1071 | AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,>,17)],[JEMALLOC_ZONE_VERSION=9],[JEMALLOC_ZONE_VERSION=] |
| 1072 | )])])])]) |
| 1073 | if test "x${JEMALLOC_ZONE_VERSION}" = "x"; then |
| 1074 | AC_MSG_RESULT([unsupported]) |
| 1075 | AC_MSG_ERROR([Unsupported malloc zone version]) |
| 1076 | fi |
| 1077 | if test "${JEMALLOC_ZONE_VERSION}" = 9; then |
| 1078 | JEMALLOC_ZONE_VERSION=8 |
| 1079 | AC_MSG_RESULT([> 8]) |
| 1080 | else |
| 1081 | AC_MSG_RESULT([$JEMALLOC_ZONE_VERSION]) |
| 1082 | fi |
| 1083 | AC_DEFINE_UNQUOTED(JEMALLOC_ZONE_VERSION, [$JEMALLOC_ZONE_VERSION]) |
Jason Evans | b27805b | 2010-02-10 18:15:53 -0800 | [diff] [blame] | 1084 | fi |
| 1085 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1086 | dnl ============================================================================ |
| 1087 | dnl Check for typedefs, structures, and compiler characteristics. |
| 1088 | AC_HEADER_STDBOOL |
| 1089 | |
Jason Evans | b172610 | 2012-02-28 16:50:47 -0800 | [diff] [blame] | 1090 | AC_CONFIG_COMMANDS([include/jemalloc/internal/size_classes.h], [ |
| 1091 | mkdir -p "include/jemalloc/internal" |
| 1092 | "${srcdir}/include/jemalloc/internal/size_classes.sh" > "${objroot}include/jemalloc/internal/size_classes.h" |
| 1093 | ]) |
| 1094 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1095 | dnl Process .in files. |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 1096 | AC_SUBST([cfghdrs_in]) |
| 1097 | AC_SUBST([cfghdrs_out]) |
Jason Evans | 0656ec0 | 2010-04-07 23:37:35 -0700 | [diff] [blame] | 1098 | AC_CONFIG_HEADERS([$cfghdrs_tup]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1099 | |
| 1100 | dnl ============================================================================ |
| 1101 | dnl Generate outputs. |
Antony Dovgal | 2bd3cbc | 2011-10-13 09:33:33 +0400 | [diff] [blame] | 1102 | AC_CONFIG_FILES([$cfgoutputs_tup config.stamp bin/jemalloc.sh]) |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 1103 | AC_SUBST([cfgoutputs_in]) |
| 1104 | AC_SUBST([cfgoutputs_out]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1105 | AC_OUTPUT |
| 1106 | |
| 1107 | dnl ============================================================================ |
| 1108 | dnl Print out the results of configuration. |
| 1109 | AC_MSG_RESULT([===============================================================================]) |
Jason Evans | f576c63 | 2011-11-01 22:27:41 -0700 | [diff] [blame] | 1110 | AC_MSG_RESULT([jemalloc version : ${jemalloc_version}]) |
| 1111 | AC_MSG_RESULT([library revision : ${rev}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1112 | AC_MSG_RESULT([]) |
| 1113 | AC_MSG_RESULT([CC : ${CC}]) |
| 1114 | AC_MSG_RESULT([CPPFLAGS : ${CPPFLAGS}]) |
| 1115 | AC_MSG_RESULT([CFLAGS : ${CFLAGS}]) |
| 1116 | AC_MSG_RESULT([LDFLAGS : ${LDFLAGS}]) |
| 1117 | AC_MSG_RESULT([LIBS : ${LIBS}]) |
| 1118 | AC_MSG_RESULT([RPATH_EXTRA : ${RPATH_EXTRA}]) |
| 1119 | AC_MSG_RESULT([]) |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 1120 | AC_MSG_RESULT([XSLTPROC : ${XSLTPROC}]) |
| 1121 | AC_MSG_RESULT([XSLROOT : ${XSLROOT}]) |
| 1122 | AC_MSG_RESULT([]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1123 | AC_MSG_RESULT([PREFIX : ${PREFIX}]) |
| 1124 | AC_MSG_RESULT([BINDIR : ${BINDIR}]) |
Jason Evans | 662a017 | 2009-07-01 19:24:31 -0700 | [diff] [blame] | 1125 | AC_MSG_RESULT([INCLUDEDIR : ${INCLUDEDIR}]) |
| 1126 | AC_MSG_RESULT([LIBDIR : ${LIBDIR}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1127 | AC_MSG_RESULT([DATADIR : ${DATADIR}]) |
| 1128 | AC_MSG_RESULT([MANDIR : ${MANDIR}]) |
| 1129 | AC_MSG_RESULT([]) |
| 1130 | AC_MSG_RESULT([srcroot : ${srcroot}]) |
| 1131 | AC_MSG_RESULT([abs_srcroot : ${abs_srcroot}]) |
| 1132 | AC_MSG_RESULT([objroot : ${objroot}]) |
| 1133 | AC_MSG_RESULT([abs_objroot : ${abs_objroot}]) |
| 1134 | AC_MSG_RESULT([]) |
Jason Evans | 90895cf | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 1135 | AC_MSG_RESULT([JEMALLOC_PREFIX : ${JEMALLOC_PREFIX}]) |
Jason Evans | 746e77a | 2011-07-30 16:40:52 -0700 | [diff] [blame] | 1136 | AC_MSG_RESULT([JEMALLOC_PRIVATE_NAMESPACE]) |
| 1137 | AC_MSG_RESULT([ : ${JEMALLOC_PRIVATE_NAMESPACE}]) |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 1138 | AC_MSG_RESULT([install_suffix : ${install_suffix}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1139 | AC_MSG_RESULT([autogen : ${enable_autogen}]) |
Jason Evans | 7e77eaf | 2012-03-02 17:47:37 -0800 | [diff] [blame] | 1140 | AC_MSG_RESULT([experimental : ${enable_experimental}]) |
Jason Evans | 355b438 | 2010-09-20 19:20:48 -0700 | [diff] [blame] | 1141 | AC_MSG_RESULT([cc-silence : ${enable_cc_silence}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1142 | AC_MSG_RESULT([debug : ${enable_debug}]) |
| 1143 | AC_MSG_RESULT([stats : ${enable_stats}]) |
Jason Evans | 6109fe0 | 2010-02-10 10:37:56 -0800 | [diff] [blame] | 1144 | AC_MSG_RESULT([prof : ${enable_prof}]) |
| 1145 | AC_MSG_RESULT([prof-libunwind : ${enable_prof_libunwind}]) |
Jason Evans | 77f350b | 2011-03-15 22:23:12 -0700 | [diff] [blame] | 1146 | AC_MSG_RESULT([prof-libgcc : ${enable_prof_libgcc}]) |
| 1147 | AC_MSG_RESULT([prof-gcc : ${enable_prof_gcc}]) |
Jason Evans | 84cbbcb | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 1148 | AC_MSG_RESULT([tcache : ${enable_tcache}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1149 | AC_MSG_RESULT([fill : ${enable_fill}]) |
Jason Evans | b147611 | 2012-04-05 13:36:17 -0700 | [diff] [blame] | 1150 | AC_MSG_RESULT([utrace : ${enable_utrace}]) |
Jason Evans | 122449b | 2012-04-06 00:35:09 -0700 | [diff] [blame] | 1151 | AC_MSG_RESULT([valgrind : ${enable_valgrind}]) |
| 1152 | AC_MSG_RESULT([xmalloc : ${enable_xmalloc}]) |
Jason Evans | 59ae276 | 2012-04-16 17:52:27 -0700 | [diff] [blame^] | 1153 | AC_MSG_RESULT([munmap : ${enable_munmap}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1154 | AC_MSG_RESULT([dss : ${enable_dss}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1155 | AC_MSG_RESULT([lazy_lock : ${enable_lazy_lock}]) |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 1156 | AC_MSG_RESULT([tls : ${enable_tls}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 1157 | AC_MSG_RESULT([===============================================================================]) |