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 |
| 17 | AC_RUN_IFELSE([AC_LANG_PROGRAM( |
| 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) |
| 29 | AC_DEFUN([JE_COMPILABLE], |
| 30 | [ |
| 31 | AC_MSG_CHECKING([whether $1 is compilable]) |
Jason Evans | 9f949f9 | 2011-03-22 20:44:40 -0700 | [diff] [blame] | 32 | AC_RUN_IFELSE([AC_LANG_PROGRAM( |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 33 | [$2], [$3])], |
| 34 | AC_MSG_RESULT([yes]) |
| 35 | [$4="yes"], |
| 36 | AC_MSG_RESULT([no]) |
| 37 | [$4="no"] |
| 38 | ) |
| 39 | ]) |
| 40 | |
| 41 | dnl ============================================================================ |
| 42 | |
Jason Evans | f576c63 | 2011-11-01 22:27:41 -0700 | [diff] [blame] | 43 | dnl Library revision. |
| 44 | rev=1 |
| 45 | AC_SUBST([rev]) |
| 46 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 47 | srcroot=$srcdir |
| 48 | if test "x${srcroot}" = "x." ; then |
| 49 | srcroot="" |
| 50 | else |
| 51 | srcroot="${srcroot}/" |
| 52 | fi |
| 53 | AC_SUBST([srcroot]) |
| 54 | abs_srcroot="`cd \"${srcdir}\"; pwd`/" |
| 55 | AC_SUBST([abs_srcroot]) |
| 56 | |
| 57 | objroot="" |
| 58 | AC_SUBST([objroot]) |
| 59 | abs_objroot="`pwd`/" |
| 60 | AC_SUBST([abs_objroot]) |
| 61 | |
| 62 | dnl Munge install path variables. |
| 63 | if test "x$prefix" = "xNONE" ; then |
| 64 | prefix="/usr/local" |
| 65 | fi |
| 66 | if test "x$exec_prefix" = "xNONE" ; then |
| 67 | exec_prefix=$prefix |
| 68 | fi |
| 69 | PREFIX=$prefix |
| 70 | AC_SUBST([PREFIX]) |
| 71 | BINDIR=`eval echo $bindir` |
| 72 | BINDIR=`eval echo $BINDIR` |
| 73 | AC_SUBST([BINDIR]) |
| 74 | INCLUDEDIR=`eval echo $includedir` |
| 75 | INCLUDEDIR=`eval echo $INCLUDEDIR` |
| 76 | AC_SUBST([INCLUDEDIR]) |
| 77 | LIBDIR=`eval echo $libdir` |
| 78 | LIBDIR=`eval echo $LIBDIR` |
| 79 | AC_SUBST([LIBDIR]) |
| 80 | DATADIR=`eval echo $datadir` |
| 81 | DATADIR=`eval echo $DATADIR` |
| 82 | AC_SUBST([DATADIR]) |
| 83 | MANDIR=`eval echo $mandir` |
| 84 | MANDIR=`eval echo $MANDIR` |
| 85 | AC_SUBST([MANDIR]) |
| 86 | |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 87 | dnl Support for building documentation. |
| 88 | AC_PATH_PROG([XSLTPROC], [xsltproc], , [$PATH]) |
| 89 | AC_ARG_WITH([xslroot], |
| 90 | [AS_HELP_STRING([--with-xslroot=<path>], [XSL stylesheet root path])], |
| 91 | if test "x$with_xslroot" = "xno" ; then |
| 92 | XSLROOT="/usr/share/xml/docbook/stylesheet/docbook-xsl" |
| 93 | else |
| 94 | XSLROOT="${with_xslroot}" |
| 95 | fi, |
| 96 | XSLROOT="/usr/share/xml/docbook/stylesheet/docbook-xsl" |
| 97 | ) |
| 98 | AC_SUBST([XSLROOT]) |
| 99 | |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 100 | dnl If CFLAGS isn't defined, set CFLAGS to something reasonable. Otherwise, |
| 101 | dnl just prevent autoconf from molesting CFLAGS. |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 102 | CFLAGS=$CFLAGS |
| 103 | AC_PROG_CC |
| 104 | if test "x$CFLAGS" = "x" ; then |
| 105 | no_CFLAGS="yes" |
Jason Evans | cfeccd3 | 2010-03-03 15:48:20 -0800 | [diff] [blame] | 106 | if test "x$GCC" = "xyes" ; then |
| 107 | JE_CFLAGS_APPEND([-std=gnu99]) |
| 108 | JE_CFLAGS_APPEND([-Wall]) |
| 109 | JE_CFLAGS_APPEND([-pipe]) |
| 110 | JE_CFLAGS_APPEND([-g3]) |
| 111 | fi |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 112 | fi |
| 113 | dnl Append EXTRA_CFLAGS to CFLAGS, if defined. |
| 114 | if test "x$EXTRA_CFLAGS" != "x" ; then |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 115 | JE_CFLAGS_APPEND([$EXTRA_CFLAGS]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 116 | fi |
| 117 | AC_PROG_CPP |
| 118 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 119 | AC_CHECK_SIZEOF([void *]) |
| 120 | if test "x${ac_cv_sizeof_void_p}" = "x8" ; then |
Jason Evans | 94ad2b5 | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 121 | LG_SIZEOF_PTR=3 |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 122 | elif test "x${ac_cv_sizeof_void_p}" = "x4" ; then |
Jason Evans | 94ad2b5 | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 123 | LG_SIZEOF_PTR=2 |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 124 | else |
| 125 | AC_MSG_ERROR([Unsupported pointer size: ${ac_cv_sizeof_void_p}]) |
| 126 | fi |
Jason Evans | 94ad2b5 | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 127 | AC_DEFINE_UNQUOTED([LG_SIZEOF_PTR], [$LG_SIZEOF_PTR]) |
| 128 | |
| 129 | AC_CHECK_SIZEOF([int]) |
| 130 | if test "x${ac_cv_sizeof_int}" = "x8" ; then |
| 131 | LG_SIZEOF_INT=3 |
| 132 | elif test "x${ac_cv_sizeof_int}" = "x4" ; then |
| 133 | LG_SIZEOF_INT=2 |
| 134 | else |
| 135 | AC_MSG_ERROR([Unsupported int size: ${ac_cv_sizeof_int}]) |
| 136 | fi |
| 137 | AC_DEFINE_UNQUOTED([LG_SIZEOF_INT], [$LG_SIZEOF_INT]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 138 | |
Jason Evans | 84c8eef | 2011-03-16 10:30:13 -0700 | [diff] [blame] | 139 | AC_CHECK_SIZEOF([long]) |
| 140 | if test "x${ac_cv_sizeof_long}" = "x8" ; then |
| 141 | LG_SIZEOF_LONG=3 |
| 142 | elif test "x${ac_cv_sizeof_long}" = "x4" ; then |
| 143 | LG_SIZEOF_LONG=2 |
| 144 | else |
| 145 | AC_MSG_ERROR([Unsupported long size: ${ac_cv_sizeof_long}]) |
| 146 | fi |
| 147 | AC_DEFINE_UNQUOTED([LG_SIZEOF_LONG], [$LG_SIZEOF_LONG]) |
| 148 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 149 | AC_CANONICAL_HOST |
| 150 | dnl CPU-specific settings. |
| 151 | CPU_SPINWAIT="" |
| 152 | case "${host_cpu}" in |
| 153 | i[[345]]86) |
| 154 | ;; |
| 155 | i686) |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 156 | JE_COMPILABLE([__asm__], [], [[__asm__ volatile("pause"); return 0;]], |
| 157 | [asm]) |
| 158 | if test "x${asm}" = "xyes" ; then |
| 159 | CPU_SPINWAIT='__asm__ volatile("pause")' |
| 160 | fi |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 161 | ;; |
| 162 | x86_64) |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 163 | JE_COMPILABLE([__asm__ syntax], [], |
| 164 | [[__asm__ volatile("pause"); return 0;]], [asm]) |
| 165 | if test "x${asm}" = "xyes" ; then |
| 166 | CPU_SPINWAIT='__asm__ volatile("pause")' |
| 167 | fi |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 168 | ;; |
| 169 | *) |
| 170 | ;; |
| 171 | esac |
| 172 | AC_DEFINE_UNQUOTED([CPU_SPINWAIT], [$CPU_SPINWAIT]) |
| 173 | |
Antony Dovgal | 2bd3cbc | 2011-10-13 09:33:33 +0400 | [diff] [blame] | 174 | LD_PRELOAD_VAR="LD_PRELOAD" |
Jason Evans | f576c63 | 2011-11-01 22:27:41 -0700 | [diff] [blame] | 175 | so="so" |
Antony Dovgal | 2bd3cbc | 2011-10-13 09:33:33 +0400 | [diff] [blame] | 176 | |
Jason Evans | 7372b15 | 2012-02-10 20:22:09 -0800 | [diff] [blame] | 177 | dnl Heap profiling uses the log(3) function. |
| 178 | LIBS="$LIBS -lm" |
| 179 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 180 | dnl Platform-specific settings. abi and RPATH can probably be determined |
| 181 | dnl programmatically, but doing so is error-prone, which makes it generally |
| 182 | dnl not worth the trouble. |
| 183 | dnl |
| 184 | dnl Define cpp macros in CPPFLAGS, rather than doing AC_DEFINE(macro), since the |
| 185 | dnl definitions need to be seen before any headers are included, which is a pain |
| 186 | dnl to make happen otherwise. |
| 187 | case "${host}" in |
| 188 | *-*-darwin*) |
| 189 | CFLAGS="$CFLAGS -fno-common -no-cpp-precomp" |
| 190 | abi="macho" |
Jason Evans | ce93055 | 2010-10-24 13:03:07 -0700 | [diff] [blame] | 191 | AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 192 | RPATH="" |
Antony Dovgal | 2bd3cbc | 2011-10-13 09:33:33 +0400 | [diff] [blame] | 193 | LD_PRELOAD_VAR="DYLD_INSERT_LIBRARIES" |
Jason Evans | f576c63 | 2011-11-01 22:27:41 -0700 | [diff] [blame] | 194 | so="dylib" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 195 | ;; |
| 196 | *-*-freebsd*) |
| 197 | CFLAGS="$CFLAGS" |
| 198 | abi="elf" |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 199 | AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 200 | RPATH="-Wl,-rpath," |
| 201 | ;; |
| 202 | *-*-linux*) |
| 203 | CFLAGS="$CFLAGS" |
| 204 | CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" |
| 205 | abi="elf" |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 206 | AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 207 | RPATH="-Wl,-rpath," |
| 208 | ;; |
| 209 | *-*-netbsd*) |
| 210 | AC_MSG_CHECKING([ABI]) |
| 211 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM( |
| 212 | [[#ifdef __ELF__ |
| 213 | /* ELF */ |
| 214 | #else |
| 215 | #error aout |
| 216 | #endif |
| 217 | ]])], |
| 218 | [CFLAGS="$CFLAGS"; abi="elf"], |
| 219 | [abi="aout"]) |
| 220 | AC_MSG_RESULT([$abi]) |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 221 | AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 222 | RPATH="-Wl,-rpath," |
| 223 | ;; |
| 224 | *-*-solaris2*) |
| 225 | CFLAGS="$CFLAGS" |
| 226 | abi="elf" |
| 227 | RPATH="-Wl,-R," |
| 228 | dnl Solaris needs this for sigwait(). |
| 229 | CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS" |
| 230 | LIBS="$LIBS -lposix4 -lsocket -lnsl" |
| 231 | ;; |
Antony Dovgal | 2bd3cbc | 2011-10-13 09:33:33 +0400 | [diff] [blame] | 232 | *-ibm-aix*) |
| 233 | if "$LG_SIZEOF_PTR" = "8"; then |
| 234 | dnl 64bit AIX |
| 235 | LD_PRELOAD_VAR="LDR_PRELOAD64" |
| 236 | else |
| 237 | dnl 32bit AIX |
| 238 | LD_PRELOAD_VAR="LDR_PRELOAD" |
| 239 | fi |
| 240 | abi="xcoff" |
| 241 | RPATH="-Wl,-rpath," |
| 242 | ;; |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 243 | *) |
| 244 | AC_MSG_RESULT([Unsupported operating system: ${host}]) |
| 245 | abi="elf" |
| 246 | RPATH="-Wl,-rpath," |
| 247 | ;; |
| 248 | esac |
| 249 | AC_SUBST([abi]) |
| 250 | AC_SUBST([RPATH]) |
Antony Dovgal | 2bd3cbc | 2011-10-13 09:33:33 +0400 | [diff] [blame] | 251 | AC_SUBST([LD_PRELOAD_VAR]) |
Jason Evans | f576c63 | 2011-11-01 22:27:41 -0700 | [diff] [blame] | 252 | AC_SUBST([so]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 253 | |
Jason Evans | fa5d245 | 2011-03-15 10:25:59 -0700 | [diff] [blame] | 254 | JE_COMPILABLE([__attribute__ syntax], |
| 255 | [static __attribute__((unused)) void foo(void){}], |
| 256 | [], |
| 257 | [attribute]) |
| 258 | if test "x${attribute}" = "xyes" ; then |
| 259 | AC_DEFINE([JEMALLOC_HAVE_ATTR], [ ]) |
| 260 | if test "x${GCC}" = "xyes" -a "x${abi}" = "xelf"; then |
| 261 | JE_CFLAGS_APPEND([-fvisibility=hidden]) |
| 262 | fi |
| 263 | fi |
| 264 | |
Jason Evans | cfdc8cf | 2010-11-30 16:50:58 -0800 | [diff] [blame] | 265 | JE_COMPILABLE([mremap(...MREMAP_FIXED...)], [ |
| 266 | #define _GNU_SOURCE |
| 267 | #include <sys/mman.h> |
| 268 | ], [ |
| 269 | void *p = mremap((void *)0, 0, 0, MREMAP_MAYMOVE|MREMAP_FIXED, (void *)0); |
| 270 | ], [mremap_fixed]) |
| 271 | if test "x${mremap_fixed}" = "xyes" ; then |
| 272 | AC_DEFINE([JEMALLOC_MREMAP_FIXED]) |
| 273 | fi |
| 274 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 275 | dnl Support optional additions to rpath. |
| 276 | AC_ARG_WITH([rpath], |
Jason Evans | 90895cf | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 277 | [AS_HELP_STRING([--with-rpath=<rpath>], [Colon-separated rpath (ELF systems only)])], |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 278 | if test "x$with_rpath" = "xno" ; then |
| 279 | RPATH_EXTRA= |
| 280 | else |
| 281 | RPATH_EXTRA="`echo $with_rpath | tr \":\" \" \"`" |
| 282 | fi, |
| 283 | RPATH_EXTRA= |
| 284 | ) |
| 285 | AC_SUBST([RPATH_EXTRA]) |
| 286 | |
| 287 | dnl Disable rules that do automatic regeneration of configure output by default. |
| 288 | AC_ARG_ENABLE([autogen], |
Jason Evans | 78d815c | 2010-01-17 14:06:20 -0800 | [diff] [blame] | 289 | [AS_HELP_STRING([--enable-autogen], [Automatically regenerate configure output])], |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 290 | if test "x$enable_autogen" = "xno" ; then |
| 291 | enable_autogen="0" |
| 292 | else |
| 293 | enable_autogen="1" |
| 294 | fi |
| 295 | , |
| 296 | enable_autogen="0" |
| 297 | ) |
| 298 | AC_SUBST([enable_autogen]) |
| 299 | |
| 300 | AC_PROG_INSTALL |
| 301 | AC_PROG_RANLIB |
| 302 | AC_PATH_PROG([AR], [ar], , [$PATH]) |
| 303 | AC_PATH_PROG([LD], [ld], , [$PATH]) |
| 304 | AC_PATH_PROG([AUTOCONF], [autoconf], , [$PATH]) |
| 305 | |
Jason Evans | 90895cf | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 306 | dnl Do not prefix public APIs by default. |
| 307 | AC_ARG_WITH([jemalloc_prefix], |
| 308 | [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] | 309 | [JEMALLOC_PREFIX="$with_jemalloc_prefix"], |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 310 | [if test "x$abi" != "xmacho" ; then |
| 311 | JEMALLOC_PREFIX="" |
| 312 | else |
| 313 | JEMALLOC_PREFIX="je_" |
| 314 | fi] |
Jason Evans | 90895cf | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 315 | ) |
| 316 | if test "x$JEMALLOC_PREFIX" != "x" ; then |
Jason Evans | e733970 | 2010-10-23 18:37:06 -0700 | [diff] [blame] | 317 | JEMALLOC_CPREFIX=`echo ${JEMALLOC_PREFIX} | tr "a-z" "A-Z"` |
| 318 | AC_DEFINE_UNQUOTED([JEMALLOC_PREFIX], ["$JEMALLOC_PREFIX"]) |
| 319 | AC_DEFINE_UNQUOTED([JEMALLOC_CPREFIX], ["$JEMALLOC_CPREFIX"]) |
Jason Evans | e476f8a | 2010-01-16 09:53:50 -0800 | [diff] [blame] | 320 | AC_DEFINE_UNQUOTED([JEMALLOC_P(string_that_no_one_should_want_to_use_as_a_jemalloc_API_prefix)], [${JEMALLOC_PREFIX}##string_that_no_one_should_want_to_use_as_a_jemalloc_API_prefix]) |
Jason Evans | 90895cf | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 321 | fi |
| 322 | |
Jason Evans | 746e77a | 2011-07-30 16:40:52 -0700 | [diff] [blame] | 323 | dnl Do not mangle library-private APIs by default. |
| 324 | AC_ARG_WITH([private_namespace], |
| 325 | [AS_HELP_STRING([--with-private-namespace=<prefix>], [Prefix to prepend to all library-private APIs])], |
| 326 | [JEMALLOC_PRIVATE_NAMESPACE="$with_private_namespace"], |
| 327 | [JEMALLOC_PRIVATE_NAMESPACE=""] |
| 328 | ) |
| 329 | AC_DEFINE_UNQUOTED([JEMALLOC_PRIVATE_NAMESPACE], ["$JEMALLOC_PRIVATE_NAMESPACE"]) |
| 330 | if test "x$JEMALLOC_PRIVATE_NAMESPACE" != "x" ; then |
| 331 | 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]) |
| 332 | else |
| 333 | 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]) |
| 334 | fi |
| 335 | |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 336 | dnl Do not add suffix to installed files by default. |
| 337 | AC_ARG_WITH([install_suffix], |
| 338 | [AS_HELP_STRING([--with-install-suffix=<suffix>], [Suffix to append to all installed files])], |
| 339 | [INSTALL_SUFFIX="$with_install_suffix"], |
| 340 | [INSTALL_SUFFIX=] |
| 341 | ) |
| 342 | install_suffix="$INSTALL_SUFFIX" |
| 343 | AC_SUBST([install_suffix]) |
| 344 | |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 345 | cfgoutputs_in="${srcroot}Makefile.in" |
| 346 | cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/html.xsl.in" |
| 347 | cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/manpages.xsl.in" |
| 348 | cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/jemalloc.xml.in" |
Jason Evans | 0656ec0 | 2010-04-07 23:37:35 -0700 | [diff] [blame] | 349 | cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/jemalloc.h.in" |
| 350 | cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/internal/jemalloc_internal.h.in" |
Jason Evans | 9f3b0a7 | 2010-10-07 09:53:26 -0700 | [diff] [blame] | 351 | cfgoutputs_in="${cfgoutputs_in} ${srcroot}test/jemalloc_test.h.in" |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 352 | |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 353 | cfgoutputs_out="Makefile" |
| 354 | cfgoutputs_out="${cfgoutputs_out} doc/html.xsl" |
| 355 | cfgoutputs_out="${cfgoutputs_out} doc/manpages.xsl" |
| 356 | cfgoutputs_out="${cfgoutputs_out} doc/jemalloc${install_suffix}.xml" |
Jason Evans | 376b152 | 2010-02-11 14:45:59 -0800 | [diff] [blame] | 357 | cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc${install_suffix}.h" |
| 358 | cfgoutputs_out="${cfgoutputs_out} include/jemalloc/internal/jemalloc_internal.h" |
Jason Evans | 9f3b0a7 | 2010-10-07 09:53:26 -0700 | [diff] [blame] | 359 | cfgoutputs_out="${cfgoutputs_out} test/jemalloc_test.h" |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 360 | |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 361 | cfgoutputs_tup="Makefile" |
| 362 | cfgoutputs_tup="${cfgoutputs_tup} doc/html.xsl:doc/html.xsl.in" |
| 363 | cfgoutputs_tup="${cfgoutputs_tup} doc/manpages.xsl:doc/manpages.xsl.in" |
| 364 | 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] | 365 | cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc${install_suffix}.h:include/jemalloc/jemalloc.h.in" |
| 366 | cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/internal/jemalloc_internal.h" |
Jason Evans | 9f3b0a7 | 2010-10-07 09:53:26 -0700 | [diff] [blame] | 367 | 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] | 368 | |
Jason Evans | 0656ec0 | 2010-04-07 23:37:35 -0700 | [diff] [blame] | 369 | cfghdrs_in="${srcroot}include/jemalloc/jemalloc_defs.h.in" |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 370 | |
Jason Evans | 376b152 | 2010-02-11 14:45:59 -0800 | [diff] [blame] | 371 | cfghdrs_out="include/jemalloc/jemalloc_defs${install_suffix}.h" |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 372 | |
Jason Evans | 376b152 | 2010-02-11 14:45:59 -0800 | [diff] [blame] | 373 | 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] | 374 | |
Jason Evans | 355b438 | 2010-09-20 19:20:48 -0700 | [diff] [blame] | 375 | dnl Do not silence irrelevant compiler warnings by default, since enabling this |
| 376 | dnl option incurs a performance penalty. |
| 377 | AC_ARG_ENABLE([cc-silence], |
| 378 | [AS_HELP_STRING([--enable-cc-silence], |
| 379 | [Silence irrelevant compiler warnings])], |
| 380 | [if test "x$enable_cc_silence" = "xno" ; then |
| 381 | enable_cc_silence="0" |
| 382 | else |
| 383 | enable_cc_silence="1" |
| 384 | fi |
| 385 | ], |
| 386 | [enable_cc_silence="0"] |
| 387 | ) |
| 388 | if test "x$enable_cc_silence" = "x1" ; then |
| 389 | AC_DEFINE([JEMALLOC_CC_SILENCE]) |
| 390 | fi |
| 391 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 392 | dnl Do not compile with debugging by default. |
| 393 | AC_ARG_ENABLE([debug], |
| 394 | [AS_HELP_STRING([--enable-debug], [Build debugging code])], |
| 395 | [if test "x$enable_debug" = "xno" ; then |
| 396 | enable_debug="0" |
| 397 | else |
| 398 | enable_debug="1" |
| 399 | fi |
| 400 | ], |
| 401 | [enable_debug="0"] |
| 402 | ) |
| 403 | if test "x$enable_debug" = "x1" ; then |
| 404 | AC_DEFINE([JEMALLOC_DEBUG], [ ]) |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 405 | AC_DEFINE([JEMALLOC_IVSALLOC], [ ]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 406 | fi |
| 407 | AC_SUBST([enable_debug]) |
| 408 | |
| 409 | dnl Only optimize if not debugging. |
| 410 | if test "x$enable_debug" = "x0" -a "x$no_CFLAGS" = "xyes" ; then |
| 411 | 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] | 412 | optimize="no" |
| 413 | echo "$EXTRA_CFLAGS" | grep "\-O" >/dev/null || optimize="yes" |
| 414 | if test "x${optimize}" = "xyes" ; then |
| 415 | if test "x$GCC" = "xyes" ; then |
| 416 | JE_CFLAGS_APPEND([-O3]) |
| 417 | JE_CFLAGS_APPEND([-funroll-loops]) |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 418 | else |
| 419 | JE_CFLAGS_APPEND([-O]) |
| 420 | fi |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 421 | fi |
| 422 | fi |
| 423 | |
| 424 | dnl Do not enable statistics calculation by default. |
| 425 | AC_ARG_ENABLE([stats], |
| 426 | [AS_HELP_STRING([--enable-stats], [Enable statistics calculation/reporting])], |
| 427 | [if test "x$enable_stats" = "xno" ; then |
| 428 | enable_stats="0" |
| 429 | else |
| 430 | enable_stats="1" |
| 431 | fi |
| 432 | ], |
| 433 | [enable_stats="0"] |
| 434 | ) |
| 435 | if test "x$enable_stats" = "x1" ; then |
| 436 | AC_DEFINE([JEMALLOC_STATS], [ ]) |
| 437 | fi |
| 438 | AC_SUBST([enable_stats]) |
| 439 | |
Jason Evans | 6109fe0 | 2010-02-10 10:37:56 -0800 | [diff] [blame] | 440 | dnl Do not enable profiling by default. |
| 441 | AC_ARG_ENABLE([prof], |
| 442 | [AS_HELP_STRING([--enable-prof], [Enable allocation profiling])], |
| 443 | [if test "x$enable_prof" = "xno" ; then |
| 444 | enable_prof="0" |
| 445 | else |
| 446 | enable_prof="1" |
| 447 | fi |
| 448 | ], |
| 449 | [enable_prof="0"] |
| 450 | ) |
Jason Evans | 77f350b | 2011-03-15 22:23:12 -0700 | [diff] [blame] | 451 | if test "x$enable_prof" = "x1" ; then |
| 452 | backtrace_method="" |
Jason Evans | b27805b | 2010-02-10 18:15:53 -0800 | [diff] [blame] | 453 | else |
Jason Evans | 77f350b | 2011-03-15 22:23:12 -0700 | [diff] [blame] | 454 | backtrace_method="N/A" |
Jason Evans | b27805b | 2010-02-10 18:15:53 -0800 | [diff] [blame] | 455 | fi |
Jason Evans | 77f350b | 2011-03-15 22:23:12 -0700 | [diff] [blame] | 456 | |
Jason Evans | 6109fe0 | 2010-02-10 10:37:56 -0800 | [diff] [blame] | 457 | AC_ARG_ENABLE([prof-libunwind], |
| 458 | [AS_HELP_STRING([--enable-prof-libunwind], [Use libunwind for backtracing])], |
| 459 | [if test "x$enable_prof_libunwind" = "xno" ; then |
| 460 | enable_prof_libunwind="0" |
| 461 | else |
| 462 | enable_prof_libunwind="1" |
| 463 | fi |
| 464 | ], |
| 465 | [enable_prof_libunwind="0"] |
| 466 | ) |
Jason Evans | ca6bd4f | 2010-03-02 14:12:58 -0800 | [diff] [blame] | 467 | AC_ARG_WITH([static_libunwind], |
| 468 | [AS_HELP_STRING([--with-static-libunwind=<libunwind.a>], |
| 469 | [Path to static libunwind library; use rather than dynamically linking])], |
| 470 | if test "x$with_static_libunwind" = "xno" ; then |
| 471 | LUNWIND="-lunwind" |
| 472 | else |
| 473 | if test ! -f "$with_static_libunwind" ; then |
| 474 | AC_MSG_ERROR([Static libunwind not found: $with_static_libunwind]) |
| 475 | fi |
| 476 | LUNWIND="$with_static_libunwind" |
| 477 | fi, |
| 478 | LUNWIND="-lunwind" |
| 479 | ) |
Jason Evans | 77f350b | 2011-03-15 22:23:12 -0700 | [diff] [blame] | 480 | if test "x$backtrace_method" = "x" -a "x$enable_prof_libunwind" = "x1" ; then |
| 481 | AC_CHECK_HEADERS([libunwind.h], , [enable_prof_libunwind="0"]) |
| 482 | if test "x$LUNWIND" = "x-lunwind" ; then |
| 483 | AC_CHECK_LIB([unwind], [backtrace], [LIBS="$LIBS $LUNWIND"], |
| 484 | [enable_prof_libunwind="0"]) |
| 485 | else |
| 486 | LIBS="$LIBS $LUNWIND" |
| 487 | fi |
| 488 | if test "x${enable_prof_libunwind}" = "x1" ; then |
| 489 | backtrace_method="libunwind" |
| 490 | AC_DEFINE([JEMALLOC_PROF_LIBUNWIND], [ ]) |
| 491 | fi |
| 492 | fi |
| 493 | |
| 494 | AC_ARG_ENABLE([prof-libgcc], |
| 495 | [AS_HELP_STRING([--disable-prof-libgcc], |
| 496 | [Do not use libgcc for backtracing])], |
| 497 | [if test "x$enable_prof_libgcc" = "xno" ; then |
| 498 | enable_prof_libgcc="0" |
| 499 | else |
| 500 | enable_prof_libgcc="1" |
| 501 | fi |
| 502 | ], |
| 503 | [enable_prof_libgcc="1"] |
| 504 | ) |
| 505 | if test "x$backtrace_method" = "x" -a "x$enable_prof_libgcc" = "x1" \ |
| 506 | -a "x$GCC" = "xyes" ; then |
| 507 | AC_CHECK_HEADERS([unwind.h], , [enable_prof_libgcc="0"]) |
| 508 | AC_CHECK_LIB([gcc], [_Unwind_Backtrace], [LIBS="$LIBS -lgcc"], [enable_prof_libgcc="0"]) |
| 509 | dnl The following is conservative, in that it only has entries for CPUs on |
| 510 | dnl which jemalloc has been tested. |
| 511 | AC_MSG_CHECKING([libgcc-based backtracing reliability on ${host_cpu}]) |
| 512 | case "${host_cpu}" in |
| 513 | i[[3456]]86) |
| 514 | AC_MSG_RESULT([unreliable]) |
| 515 | enable_prof_libgcc="0"; |
| 516 | ;; |
| 517 | x86_64) |
| 518 | AC_MSG_RESULT([reliable]) |
| 519 | ;; |
| 520 | *) |
| 521 | AC_MSG_RESULT([unreliable]) |
| 522 | enable_prof_libgcc="0"; |
| 523 | ;; |
| 524 | esac |
| 525 | if test "x${enable_prof_libgcc}" = "x1" ; then |
| 526 | backtrace_method="libgcc" |
| 527 | AC_DEFINE([JEMALLOC_PROF_LIBGCC], [ ]) |
| 528 | fi |
| 529 | else |
| 530 | enable_prof_libgcc="0" |
| 531 | fi |
| 532 | |
| 533 | AC_ARG_ENABLE([prof-gcc], |
| 534 | [AS_HELP_STRING([--disable-prof-gcc], |
| 535 | [Do not use gcc intrinsics for backtracing])], |
| 536 | [if test "x$enable_prof_gcc" = "xno" ; then |
| 537 | enable_prof_gcc="0" |
| 538 | else |
| 539 | enable_prof_gcc="1" |
| 540 | fi |
| 541 | ], |
| 542 | [enable_prof_gcc="1"] |
| 543 | ) |
| 544 | if test "x$backtrace_method" = "x" -a "x$enable_prof_gcc" = "x1" \ |
| 545 | -a "x$GCC" = "xyes" ; then |
| 546 | backtrace_method="gcc intrinsics" |
| 547 | AC_DEFINE([JEMALLOC_PROF_GCC], [ ]) |
| 548 | else |
| 549 | enable_prof_gcc="0" |
| 550 | fi |
| 551 | |
| 552 | if test "x$backtrace_method" = "x" ; then |
| 553 | backtrace_method="none (disabling profiling)" |
| 554 | enable_prof="0" |
| 555 | fi |
| 556 | AC_MSG_CHECKING([configured backtracing method]) |
| 557 | AC_MSG_RESULT([$backtrace_method]) |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 558 | if test "x$enable_prof" = "x1" ; then |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 559 | AC_DEFINE([JEMALLOC_PROF], [ ]) |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 560 | fi |
| 561 | AC_SUBST([enable_prof]) |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 562 | |
Jason Evans | 84cbbcb | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 563 | dnl Enable thread-specific caching by default. |
| 564 | AC_ARG_ENABLE([tcache], |
| 565 | [AS_HELP_STRING([--disable-tcache], [Disable per thread caches])], |
| 566 | [if test "x$enable_tcache" = "xno" ; then |
| 567 | enable_tcache="0" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 568 | else |
Jason Evans | 84cbbcb | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 569 | enable_tcache="1" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 570 | fi |
| 571 | ], |
Jason Evans | 84cbbcb | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 572 | [enable_tcache="1"] |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 573 | ) |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 574 | if test "x$enable_tcache" = "x1" ; then |
| 575 | AC_DEFINE([JEMALLOC_TCACHE], [ ]) |
| 576 | fi |
| 577 | AC_SUBST([enable_tcache]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 578 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 579 | dnl Do not enable allocation from DSS by default. |
| 580 | AC_ARG_ENABLE([dss], |
| 581 | [AS_HELP_STRING([--enable-dss], [Enable allocation from DSS])], |
| 582 | [if test "x$enable_dss" = "xno" ; then |
| 583 | enable_dss="0" |
| 584 | else |
| 585 | enable_dss="1" |
| 586 | fi |
| 587 | ], |
| 588 | [enable_dss="0"] |
| 589 | ) |
| 590 | if test "x$enable_dss" = "x1" ; then |
| 591 | AC_DEFINE([JEMALLOC_DSS], [ ]) |
| 592 | fi |
| 593 | AC_SUBST([enable_dss]) |
| 594 | |
| 595 | dnl Do not support the junk/zero filling option by default. |
| 596 | AC_ARG_ENABLE([fill], |
| 597 | [AS_HELP_STRING([--enable-fill], [Support junk/zero filling option])], |
| 598 | [if test "x$enable_fill" = "xno" ; then |
| 599 | enable_fill="0" |
| 600 | else |
| 601 | enable_fill="1" |
| 602 | fi |
| 603 | ], |
| 604 | [enable_fill="0"] |
| 605 | ) |
| 606 | if test "x$enable_fill" = "x1" ; then |
| 607 | AC_DEFINE([JEMALLOC_FILL], [ ]) |
| 608 | fi |
| 609 | AC_SUBST([enable_fill]) |
| 610 | |
| 611 | dnl Do not support the xmalloc option by default. |
| 612 | AC_ARG_ENABLE([xmalloc], |
| 613 | [AS_HELP_STRING([--enable-xmalloc], [Support xmalloc option])], |
| 614 | [if test "x$enable_xmalloc" = "xno" ; then |
| 615 | enable_xmalloc="0" |
| 616 | else |
| 617 | enable_xmalloc="1" |
| 618 | fi |
| 619 | ], |
| 620 | [enable_xmalloc="0"] |
| 621 | ) |
| 622 | if test "x$enable_xmalloc" = "x1" ; then |
| 623 | AC_DEFINE([JEMALLOC_XMALLOC], [ ]) |
| 624 | fi |
| 625 | AC_SUBST([enable_xmalloc]) |
| 626 | |
| 627 | dnl Do not support the SYSV option by default. |
| 628 | AC_ARG_ENABLE([sysv], |
| 629 | [AS_HELP_STRING([--enable-sysv], [Support SYSV semantics option])], |
| 630 | [if test "x$enable_sysv" = "xno" ; then |
| 631 | enable_sysv="0" |
| 632 | else |
| 633 | enable_sysv="1" |
| 634 | fi |
| 635 | ], |
| 636 | [enable_sysv="0"] |
| 637 | ) |
| 638 | if test "x$enable_sysv" = "x1" ; then |
| 639 | AC_DEFINE([JEMALLOC_SYSV], [ ]) |
| 640 | fi |
| 641 | AC_SUBST([enable_sysv]) |
| 642 | |
| 643 | dnl Do not determine page shift at run time by default. |
| 644 | AC_ARG_ENABLE([dynamic_page_shift], |
| 645 | [AS_HELP_STRING([--enable-dynamic-page-shift], |
| 646 | [Determine page size at run time (don't trust configure result)])], |
| 647 | [if test "x$enable_dynamic_page_shift" = "xno" ; then |
| 648 | enable_dynamic_page_shift="0" |
| 649 | else |
| 650 | enable_dynamic_page_shift="1" |
| 651 | fi |
| 652 | ], |
| 653 | [enable_dynamic_page_shift="0"] |
| 654 | ) |
| 655 | if test "x$enable_dynamic_page_shift" = "x1" ; then |
| 656 | AC_DEFINE([DYNAMIC_PAGE_SHIFT], [ ]) |
| 657 | fi |
| 658 | AC_SUBST([enable_dynamic_page_shift]) |
| 659 | |
| 660 | AC_MSG_CHECKING([STATIC_PAGE_SHIFT]) |
| 661 | AC_RUN_IFELSE([AC_LANG_PROGRAM( |
| 662 | [[#include <stdio.h> |
| 663 | #include <unistd.h> |
| 664 | #include <strings.h> |
| 665 | ]], [[ |
| 666 | long result; |
| 667 | FILE *f; |
| 668 | |
| 669 | result = sysconf(_SC_PAGESIZE); |
| 670 | if (result == -1) { |
| 671 | return 1; |
| 672 | } |
| 673 | f = fopen("conftest.out", "w"); |
| 674 | if (f == NULL) { |
| 675 | return 1; |
| 676 | } |
| 677 | fprintf(f, "%u\n", ffs((int)result) - 1); |
| 678 | close(f); |
| 679 | |
| 680 | return 0; |
| 681 | ]])], |
| 682 | [STATIC_PAGE_SHIFT=`cat conftest.out`] |
| 683 | AC_MSG_RESULT([$STATIC_PAGE_SHIFT]) |
| 684 | AC_DEFINE_UNQUOTED([STATIC_PAGE_SHIFT], [$STATIC_PAGE_SHIFT]), |
| 685 | AC_MSG_RESULT([error])) |
| 686 | |
| 687 | dnl ============================================================================ |
| 688 | dnl jemalloc configuration. |
| 689 | dnl |
Jason Evans | a40bc7a | 2010-03-02 13:01:16 -0800 | [diff] [blame] | 690 | |
| 691 | dnl Set VERSION if source directory has an embedded git repository. |
Jason Evans | 955851f | 2011-03-31 22:38:51 -0700 | [diff] [blame] | 692 | if test -d "${srcroot}.git" ; then |
Jason Evans | 79d660d | 2010-09-17 17:38:24 -0700 | [diff] [blame] | 693 | git describe --long --abbrev=40 > ${srcroot}VERSION |
Jason Evans | a40bc7a | 2010-03-02 13:01:16 -0800 | [diff] [blame] | 694 | fi |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 695 | jemalloc_version=`cat ${srcroot}VERSION` |
Jason Evans | a40bc7a | 2010-03-02 13:01:16 -0800 | [diff] [blame] | 696 | jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'` |
| 697 | jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'` |
| 698 | jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'` |
| 699 | jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'` |
| 700 | jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'` |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 701 | AC_SUBST([jemalloc_version]) |
Jason Evans | a40bc7a | 2010-03-02 13:01:16 -0800 | [diff] [blame] | 702 | AC_SUBST([jemalloc_version_major]) |
| 703 | AC_SUBST([jemalloc_version_minor]) |
| 704 | AC_SUBST([jemalloc_version_bugfix]) |
| 705 | AC_SUBST([jemalloc_version_nrev]) |
| 706 | AC_SUBST([jemalloc_version_gid]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 707 | |
| 708 | dnl ============================================================================ |
| 709 | dnl Configure pthreads. |
| 710 | |
| 711 | AC_CHECK_HEADERS([pthread.h], , [AC_MSG_ERROR([pthread.h is missing])]) |
| 712 | AC_CHECK_LIB([pthread], [pthread_create], [LIBS="$LIBS -lpthread"], |
| 713 | [AC_MSG_ERROR([libpthread is missing])]) |
| 714 | |
| 715 | CPPFLAGS="$CPPFLAGS -D_REENTRANT" |
| 716 | |
Jason Evans | 0fee70d | 2012-02-13 12:36:11 -0800 | [diff] [blame] | 717 | dnl Disable lazy locking by default. |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 718 | AC_ARG_ENABLE([lazy_lock], |
Jason Evans | 0fee70d | 2012-02-13 12:36:11 -0800 | [diff] [blame] | 719 | [AS_HELP_STRING([--enable-lazy-lock], |
| 720 | [Enable lazy locking (only lock when multi-threaded)])], |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 721 | [if test "x$enable_lazy_lock" = "xno" ; then |
| 722 | enable_lazy_lock="0" |
| 723 | else |
| 724 | enable_lazy_lock="1" |
| 725 | fi |
| 726 | ], |
Jason Evans | 0fee70d | 2012-02-13 12:36:11 -0800 | [diff] [blame] | 727 | [enable_lazy_lock="0"] |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 728 | ) |
| 729 | if test "x$enable_lazy_lock" = "x1" ; then |
| 730 | AC_CHECK_HEADERS([dlfcn.h], , [AC_MSG_ERROR([dlfcn.h is missing])]) |
| 731 | AC_CHECK_LIB([dl], [dlopen], [LIBS="$LIBS -ldl"], |
| 732 | [AC_MSG_ERROR([libdl is missing])]) |
| 733 | AC_DEFINE([JEMALLOC_LAZY_LOCK], [ ]) |
| 734 | fi |
| 735 | AC_SUBST([enable_lazy_lock]) |
| 736 | |
Jason Evans | 78d815c | 2010-01-17 14:06:20 -0800 | [diff] [blame] | 737 | AC_ARG_ENABLE([tls], |
| 738 | [AS_HELP_STRING([--disable-tls], [Disable thread-local storage (__thread keyword)])], |
| 739 | if test "x$enable_tls" = "xno" ; then |
| 740 | enable_tls="0" |
| 741 | else |
| 742 | enable_tls="1" |
| 743 | fi |
| 744 | , |
| 745 | enable_tls="1" |
| 746 | ) |
| 747 | if test "x${enable_tls}" = "x1" ; then |
| 748 | AC_MSG_CHECKING([for TLS]) |
| 749 | AC_RUN_IFELSE([AC_LANG_PROGRAM( |
| 750 | [[ |
| 751 | __thread int x; |
| 752 | ]], [[ |
| 753 | x = 42; |
| 754 | |
| 755 | return 0; |
| 756 | ]])], |
| 757 | AC_MSG_RESULT([yes]), |
| 758 | AC_MSG_RESULT([no]) |
| 759 | enable_tls="0") |
| 760 | fi |
Jason Evans | b267d0f | 2010-08-13 15:42:29 -0700 | [diff] [blame] | 761 | AC_SUBST([enable_tls]) |
Jason Evans | 78d815c | 2010-01-17 14:06:20 -0800 | [diff] [blame] | 762 | if test "x${enable_tls}" = "x0" ; then |
| 763 | AC_DEFINE_UNQUOTED([NO_TLS], [ ]) |
| 764 | fi |
| 765 | |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 766 | dnl ============================================================================ |
Jason Evans | 84c8eef | 2011-03-16 10:30:13 -0700 | [diff] [blame] | 767 | dnl Check for ffsl(3), and fail if not found. This function exists on all |
| 768 | dnl platforms that jemalloc currently has a chance of functioning on without |
| 769 | dnl modification. |
| 770 | |
| 771 | AC_CHECK_FUNC([ffsl], [], |
| 772 | [AC_MSG_ERROR([Cannot build without ffsl(3)])]) |
| 773 | |
| 774 | dnl ============================================================================ |
Jason Evans | 763baa6 | 2011-03-18 19:10:31 -0700 | [diff] [blame] | 775 | dnl Check for atomic(3) operations as provided on Darwin. |
| 776 | |
| 777 | JE_COMPILABLE([Darwin OSAtomic*()], [ |
| 778 | #include <libkern/OSAtomic.h> |
| 779 | #include <inttypes.h> |
| 780 | ], [ |
| 781 | { |
| 782 | int32_t x32 = 0; |
| 783 | volatile int32_t *x32p = &x32; |
| 784 | OSAtomicAdd32(1, x32p); |
| 785 | } |
| 786 | { |
| 787 | int64_t x64 = 0; |
| 788 | volatile int64_t *x64p = &x64; |
| 789 | OSAtomicAdd64(1, x64p); |
| 790 | } |
| 791 | ], [osatomic]) |
| 792 | if test "x${osatomic}" = "xyes" ; then |
| 793 | AC_DEFINE([JEMALLOC_OSATOMIC]) |
| 794 | fi |
| 795 | |
| 796 | dnl ============================================================================ |
Jason Evans | 893a0ed | 2011-03-18 19:30:18 -0700 | [diff] [blame] | 797 | dnl Check for spinlock(3) operations as provided on Darwin. |
| 798 | |
| 799 | JE_COMPILABLE([Darwin OSSpin*()], [ |
| 800 | #include <libkern/OSAtomic.h> |
| 801 | #include <inttypes.h> |
| 802 | ], [ |
| 803 | OSSpinLock lock = 0; |
| 804 | OSSpinLockLock(&lock); |
| 805 | OSSpinLockUnlock(&lock); |
| 806 | ], [osspin]) |
| 807 | if test "x${osspin}" = "xyes" ; then |
| 808 | AC_DEFINE([JEMALLOC_OSSPIN]) |
| 809 | fi |
| 810 | |
| 811 | dnl ============================================================================ |
Jason Evans | 6a0d291 | 2010-09-20 16:44:23 -0700 | [diff] [blame] | 812 | dnl Check for allocator-related functions that should be wrapped. |
| 813 | |
| 814 | AC_CHECK_FUNC([memalign], |
| 815 | [AC_DEFINE([JEMALLOC_OVERRIDE_MEMALIGN])]) |
| 816 | AC_CHECK_FUNC([valloc], |
| 817 | [AC_DEFINE([JEMALLOC_OVERRIDE_VALLOC])]) |
| 818 | |
| 819 | dnl ============================================================================ |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 820 | dnl Darwin-related configuration. |
Jason Evans | 78d815c | 2010-01-17 14:06:20 -0800 | [diff] [blame] | 821 | |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 822 | if test "x${abi}" = "xmacho" ; then |
| 823 | AC_DEFINE([JEMALLOC_IVSALLOC]) |
| 824 | AC_DEFINE([JEMALLOC_ZONE]) |
Jason Evans | 6109fe0 | 2010-02-10 10:37:56 -0800 | [diff] [blame] | 825 | |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 826 | dnl The szone version jumped from 3 to 6 between the OS X 10.5.x and 10.6 |
| 827 | dnl releases. malloc_zone_t and malloc_introspection_t have new fields in |
| 828 | dnl 10.6, which is the only source-level indication of the change. |
| 829 | AC_MSG_CHECKING([malloc zone version]) |
| 830 | AC_TRY_COMPILE([#include <stdlib.h> |
| 831 | #include <malloc/malloc.h>], [ |
| 832 | static malloc_zone_t zone; |
| 833 | static struct malloc_introspection_t zone_introspect; |
| 834 | |
| 835 | zone.size = NULL; |
| 836 | zone.malloc = NULL; |
| 837 | zone.calloc = NULL; |
| 838 | zone.valloc = NULL; |
| 839 | zone.free = NULL; |
| 840 | zone.realloc = NULL; |
| 841 | zone.destroy = NULL; |
| 842 | zone.zone_name = "jemalloc_zone"; |
| 843 | zone.batch_malloc = NULL; |
| 844 | zone.batch_free = NULL; |
| 845 | zone.introspect = &zone_introspect; |
| 846 | zone.version = 6; |
| 847 | zone.memalign = NULL; |
| 848 | zone.free_definite_size = NULL; |
| 849 | |
| 850 | zone_introspect.enumerator = NULL; |
| 851 | zone_introspect.good_size = NULL; |
| 852 | zone_introspect.check = NULL; |
| 853 | zone_introspect.print = NULL; |
| 854 | zone_introspect.log = NULL; |
| 855 | zone_introspect.force_lock = NULL; |
| 856 | zone_introspect.force_unlock = NULL; |
| 857 | zone_introspect.statistics = NULL; |
| 858 | zone_introspect.zone_locked = NULL; |
| 859 | ], [AC_DEFINE_UNQUOTED([JEMALLOC_ZONE_VERSION], [6]) |
| 860 | AC_MSG_RESULT([6])], |
| 861 | [AC_DEFINE_UNQUOTED([JEMALLOC_ZONE_VERSION], [3]) |
| 862 | AC_MSG_RESULT([3])]) |
Jason Evans | b27805b | 2010-02-10 18:15:53 -0800 | [diff] [blame] | 863 | fi |
| 864 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 865 | dnl ============================================================================ |
| 866 | dnl Check for typedefs, structures, and compiler characteristics. |
| 867 | AC_HEADER_STDBOOL |
| 868 | |
| 869 | dnl Process .in files. |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 870 | AC_SUBST([cfghdrs_in]) |
| 871 | AC_SUBST([cfghdrs_out]) |
Jason Evans | 0656ec0 | 2010-04-07 23:37:35 -0700 | [diff] [blame] | 872 | AC_CONFIG_HEADERS([$cfghdrs_tup]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 873 | |
| 874 | dnl ============================================================================ |
| 875 | dnl Generate outputs. |
Antony Dovgal | 2bd3cbc | 2011-10-13 09:33:33 +0400 | [diff] [blame] | 876 | AC_CONFIG_FILES([$cfgoutputs_tup config.stamp bin/jemalloc.sh]) |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 877 | AC_SUBST([cfgoutputs_in]) |
| 878 | AC_SUBST([cfgoutputs_out]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 879 | AC_OUTPUT |
| 880 | |
| 881 | dnl ============================================================================ |
| 882 | dnl Print out the results of configuration. |
| 883 | AC_MSG_RESULT([===============================================================================]) |
Jason Evans | f576c63 | 2011-11-01 22:27:41 -0700 | [diff] [blame] | 884 | AC_MSG_RESULT([jemalloc version : ${jemalloc_version}]) |
| 885 | AC_MSG_RESULT([library revision : ${rev}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 886 | AC_MSG_RESULT([]) |
| 887 | AC_MSG_RESULT([CC : ${CC}]) |
| 888 | AC_MSG_RESULT([CPPFLAGS : ${CPPFLAGS}]) |
| 889 | AC_MSG_RESULT([CFLAGS : ${CFLAGS}]) |
| 890 | AC_MSG_RESULT([LDFLAGS : ${LDFLAGS}]) |
| 891 | AC_MSG_RESULT([LIBS : ${LIBS}]) |
| 892 | AC_MSG_RESULT([RPATH_EXTRA : ${RPATH_EXTRA}]) |
| 893 | AC_MSG_RESULT([]) |
Jason Evans | aee7fd2 | 2010-11-24 22:00:02 -0800 | [diff] [blame] | 894 | AC_MSG_RESULT([XSLTPROC : ${XSLTPROC}]) |
| 895 | AC_MSG_RESULT([XSLROOT : ${XSLROOT}]) |
| 896 | AC_MSG_RESULT([]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 897 | AC_MSG_RESULT([PREFIX : ${PREFIX}]) |
| 898 | AC_MSG_RESULT([BINDIR : ${BINDIR}]) |
Jason Evans | 662a017 | 2009-07-01 19:24:31 -0700 | [diff] [blame] | 899 | AC_MSG_RESULT([INCLUDEDIR : ${INCLUDEDIR}]) |
| 900 | AC_MSG_RESULT([LIBDIR : ${LIBDIR}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 901 | AC_MSG_RESULT([DATADIR : ${DATADIR}]) |
| 902 | AC_MSG_RESULT([MANDIR : ${MANDIR}]) |
| 903 | AC_MSG_RESULT([]) |
| 904 | AC_MSG_RESULT([srcroot : ${srcroot}]) |
| 905 | AC_MSG_RESULT([abs_srcroot : ${abs_srcroot}]) |
| 906 | AC_MSG_RESULT([objroot : ${objroot}]) |
| 907 | AC_MSG_RESULT([abs_objroot : ${abs_objroot}]) |
| 908 | AC_MSG_RESULT([]) |
Jason Evans | 90895cf | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 909 | AC_MSG_RESULT([JEMALLOC_PREFIX : ${JEMALLOC_PREFIX}]) |
Jason Evans | 746e77a | 2011-07-30 16:40:52 -0700 | [diff] [blame] | 910 | AC_MSG_RESULT([JEMALLOC_PRIVATE_NAMESPACE]) |
| 911 | AC_MSG_RESULT([ : ${JEMALLOC_PRIVATE_NAMESPACE}]) |
Jason Evans | b0fd501 | 2010-01-17 01:49:20 -0800 | [diff] [blame] | 912 | AC_MSG_RESULT([install_suffix : ${install_suffix}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 913 | AC_MSG_RESULT([autogen : ${enable_autogen}]) |
Jason Evans | 355b438 | 2010-09-20 19:20:48 -0700 | [diff] [blame] | 914 | AC_MSG_RESULT([cc-silence : ${enable_cc_silence}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 915 | AC_MSG_RESULT([debug : ${enable_debug}]) |
| 916 | AC_MSG_RESULT([stats : ${enable_stats}]) |
Jason Evans | 6109fe0 | 2010-02-10 10:37:56 -0800 | [diff] [blame] | 917 | AC_MSG_RESULT([prof : ${enable_prof}]) |
| 918 | AC_MSG_RESULT([prof-libunwind : ${enable_prof_libunwind}]) |
Jason Evans | 77f350b | 2011-03-15 22:23:12 -0700 | [diff] [blame] | 919 | AC_MSG_RESULT([prof-libgcc : ${enable_prof_libgcc}]) |
| 920 | AC_MSG_RESULT([prof-gcc : ${enable_prof_gcc}]) |
Jason Evans | 84cbbcb | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 921 | AC_MSG_RESULT([tcache : ${enable_tcache}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 922 | AC_MSG_RESULT([fill : ${enable_fill}]) |
| 923 | AC_MSG_RESULT([xmalloc : ${enable_xmalloc}]) |
| 924 | AC_MSG_RESULT([sysv : ${enable_sysv}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 925 | AC_MSG_RESULT([dss : ${enable_dss}]) |
| 926 | AC_MSG_RESULT([dynamic_page_shift : ${enable_dynamic_page_shift}]) |
| 927 | AC_MSG_RESULT([lazy_lock : ${enable_lazy_lock}]) |
Jason Evans | 2dbecf1 | 2010-09-05 10:35:13 -0700 | [diff] [blame] | 928 | AC_MSG_RESULT([tls : ${enable_tls}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 929 | AC_MSG_RESULT([===============================================================================]) |