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