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 | cc00a15 | 2009-06-25 18:06:48 -0700 | [diff] [blame] | 83 | cfgoutputs="Makefile doc/jemalloc.3" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 84 | cfghdrs="src/jemalloc_defs.h" |
| 85 | |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 86 | dnl If CFLAGS isn't defined, set CFLAGS to something reasonable. Otherwise, |
| 87 | dnl just prevent autoconf from molesting CFLAGS. |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 88 | CFLAGS=$CFLAGS |
| 89 | AC_PROG_CC |
| 90 | if test "x$CFLAGS" = "x" ; then |
| 91 | no_CFLAGS="yes" |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 92 | JE_CFLAGS_APPEND([-std=gnu99]) |
| 93 | JE_CFLAGS_APPEND([-Wall]) |
| 94 | JE_CFLAGS_APPEND([-pipe]) |
| 95 | JE_CFLAGS_APPEND([-g3]) |
| 96 | JE_CFLAGS_APPEND([-march=native]) |
| 97 | JE_CFLAGS_APPEND([-ftls-model=initial-exec]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 98 | fi |
| 99 | dnl Append EXTRA_CFLAGS to CFLAGS, if defined. |
| 100 | if test "x$EXTRA_CFLAGS" != "x" ; then |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 101 | JE_CFLAGS_APPEND([$EXTRA_CFLAGS]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 102 | fi |
| 103 | AC_PROG_CPP |
| 104 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 105 | AC_CHECK_SIZEOF([void *]) |
| 106 | if test "x${ac_cv_sizeof_void_p}" = "x8" ; then |
Jason Evans | 94ad2b5 | 2009-12-29 00:09:15 -0800 | [diff] [blame^] | 107 | LG_SIZEOF_PTR=3 |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 108 | elif test "x${ac_cv_sizeof_void_p}" = "x4" ; then |
Jason Evans | 94ad2b5 | 2009-12-29 00:09:15 -0800 | [diff] [blame^] | 109 | LG_SIZEOF_PTR=2 |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 110 | else |
| 111 | AC_MSG_ERROR([Unsupported pointer size: ${ac_cv_sizeof_void_p}]) |
| 112 | fi |
Jason Evans | 94ad2b5 | 2009-12-29 00:09:15 -0800 | [diff] [blame^] | 113 | AC_DEFINE_UNQUOTED([LG_SIZEOF_PTR], [$LG_SIZEOF_PTR]) |
| 114 | |
| 115 | AC_CHECK_SIZEOF([int]) |
| 116 | if test "x${ac_cv_sizeof_int}" = "x8" ; then |
| 117 | LG_SIZEOF_INT=3 |
| 118 | elif test "x${ac_cv_sizeof_int}" = "x4" ; then |
| 119 | LG_SIZEOF_INT=2 |
| 120 | else |
| 121 | AC_MSG_ERROR([Unsupported int size: ${ac_cv_sizeof_int}]) |
| 122 | fi |
| 123 | AC_DEFINE_UNQUOTED([LG_SIZEOF_INT], [$LG_SIZEOF_INT]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 124 | |
| 125 | AC_CANONICAL_HOST |
| 126 | dnl CPU-specific settings. |
| 127 | CPU_SPINWAIT="" |
| 128 | case "${host_cpu}" in |
| 129 | i[[345]]86) |
| 130 | ;; |
| 131 | i686) |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 132 | JE_COMPILABLE([__asm__], [], [[__asm__ volatile("pause"); return 0;]], |
| 133 | [asm]) |
| 134 | if test "x${asm}" = "xyes" ; then |
| 135 | CPU_SPINWAIT='__asm__ volatile("pause")' |
| 136 | fi |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 137 | ;; |
| 138 | x86_64) |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 139 | JE_COMPILABLE([__asm__ syntax], [], |
| 140 | [[__asm__ volatile("pause"); return 0;]], [asm]) |
| 141 | if test "x${asm}" = "xyes" ; then |
| 142 | CPU_SPINWAIT='__asm__ volatile("pause")' |
| 143 | fi |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 144 | ;; |
| 145 | *) |
| 146 | ;; |
| 147 | esac |
| 148 | AC_DEFINE_UNQUOTED([CPU_SPINWAIT], [$CPU_SPINWAIT]) |
| 149 | |
Jason Evans | f3340ca | 2009-06-30 16:17:05 -0700 | [diff] [blame] | 150 | JE_COMPILABLE([__attribute__ syntax], |
| 151 | [static __attribute__((unused)) void foo(void){}], |
| 152 | [], |
| 153 | [attribute]) |
| 154 | if test "x${attribute}" = "xyes" ; then |
| 155 | AC_DEFINE_UNQUOTED([JEMALLOC_UNUSED], [__attribute__((unused))]) |
| 156 | else |
| 157 | AC_DEFINE_UNQUOTED([JEMALLOC_UNUSED], []) |
| 158 | fi |
| 159 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 160 | dnl Platform-specific settings. abi and RPATH can probably be determined |
| 161 | dnl programmatically, but doing so is error-prone, which makes it generally |
| 162 | dnl not worth the trouble. |
| 163 | dnl |
| 164 | dnl Define cpp macros in CPPFLAGS, rather than doing AC_DEFINE(macro), since the |
| 165 | dnl definitions need to be seen before any headers are included, which is a pain |
| 166 | dnl to make happen otherwise. |
| 167 | case "${host}" in |
| 168 | *-*-darwin*) |
| 169 | CFLAGS="$CFLAGS -fno-common -no-cpp-precomp" |
| 170 | abi="macho" |
| 171 | RPATH="" |
| 172 | ;; |
| 173 | *-*-freebsd*) |
| 174 | CFLAGS="$CFLAGS" |
| 175 | abi="elf" |
| 176 | RPATH="-Wl,-rpath," |
| 177 | ;; |
| 178 | *-*-linux*) |
| 179 | CFLAGS="$CFLAGS" |
| 180 | CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" |
| 181 | abi="elf" |
| 182 | RPATH="-Wl,-rpath," |
| 183 | ;; |
| 184 | *-*-netbsd*) |
| 185 | AC_MSG_CHECKING([ABI]) |
| 186 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM( |
| 187 | [[#ifdef __ELF__ |
| 188 | /* ELF */ |
| 189 | #else |
| 190 | #error aout |
| 191 | #endif |
| 192 | ]])], |
| 193 | [CFLAGS="$CFLAGS"; abi="elf"], |
| 194 | [abi="aout"]) |
| 195 | AC_MSG_RESULT([$abi]) |
| 196 | RPATH="-Wl,-rpath," |
| 197 | ;; |
| 198 | *-*-solaris2*) |
| 199 | CFLAGS="$CFLAGS" |
| 200 | abi="elf" |
| 201 | RPATH="-Wl,-R," |
| 202 | dnl Solaris needs this for sigwait(). |
| 203 | CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS" |
| 204 | LIBS="$LIBS -lposix4 -lsocket -lnsl" |
| 205 | ;; |
| 206 | *) |
| 207 | AC_MSG_RESULT([Unsupported operating system: ${host}]) |
| 208 | abi="elf" |
| 209 | RPATH="-Wl,-rpath," |
| 210 | ;; |
| 211 | esac |
| 212 | AC_SUBST([abi]) |
| 213 | AC_SUBST([RPATH]) |
| 214 | |
| 215 | dnl Support optional additions to rpath. |
| 216 | AC_ARG_WITH([rpath], |
Jason Evans | 90895cf | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 217 | [AS_HELP_STRING([--with-rpath=<rpath>], [Colon-separated rpath (ELF systems only)])], |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 218 | if test "x$with_rpath" = "xno" ; then |
| 219 | RPATH_EXTRA= |
| 220 | else |
| 221 | RPATH_EXTRA="`echo $with_rpath | tr \":\" \" \"`" |
| 222 | fi, |
| 223 | RPATH_EXTRA= |
| 224 | ) |
| 225 | AC_SUBST([RPATH_EXTRA]) |
| 226 | |
| 227 | dnl Disable rules that do automatic regeneration of configure output by default. |
| 228 | AC_ARG_ENABLE([autogen], |
| 229 | [AS_HELP_STRING[--enable-autogen], [Automatically regenerate configure output])], |
| 230 | if test "x$enable_autogen" = "xno" ; then |
| 231 | enable_autogen="0" |
| 232 | else |
| 233 | enable_autogen="1" |
| 234 | fi |
| 235 | , |
| 236 | enable_autogen="0" |
| 237 | ) |
| 238 | AC_SUBST([enable_autogen]) |
| 239 | |
| 240 | AC_PROG_INSTALL |
| 241 | AC_PROG_RANLIB |
| 242 | AC_PATH_PROG([AR], [ar], , [$PATH]) |
| 243 | AC_PATH_PROG([LD], [ld], , [$PATH]) |
| 244 | AC_PATH_PROG([AUTOCONF], [autoconf], , [$PATH]) |
| 245 | |
Jason Evans | 90895cf | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 246 | dnl Do not prefix public APIs by default. |
| 247 | AC_ARG_WITH([jemalloc_prefix], |
| 248 | [AS_HELP_STRING([--with-jemalloc-prefix=<prefix>], [Prefix to prepend to all public APIs])], |
| 249 | if test "x$with_jemalloc_prefix" = "xno" ; then |
| 250 | JEMALLOC_PREFIX= |
| 251 | else |
| 252 | JEMALLOC_PREFIX="$with_jemalloc_prefix" |
| 253 | fi, |
| 254 | JEMALLOC_PREFIX= |
| 255 | ) |
| 256 | if test "x$JEMALLOC_PREFIX" != "x" ; then |
| 257 | AC_DEFINE([JEMALLOC_PREFIX], [ ]) |
| 258 | jemalloc_prefix=$JEMALLOC_PREFIX |
| 259 | AC_SUBST([jemalloc_prefix]) |
| 260 | AC_DEFINE_UNQUOTED([malloc], [${JEMALLOC_PREFIX}malloc]) |
| 261 | AC_DEFINE_UNQUOTED([calloc], [${JEMALLOC_PREFIX}calloc]) |
| 262 | AC_DEFINE_UNQUOTED([posix_memalign], [${JEMALLOC_PREFIX}posix_memalign]) |
| 263 | AC_DEFINE_UNQUOTED([realloc], [${JEMALLOC_PREFIX}realloc]) |
| 264 | AC_DEFINE_UNQUOTED([free], [${JEMALLOC_PREFIX}free]) |
| 265 | AC_DEFINE_UNQUOTED([malloc_usable_size], [${JEMALLOC_PREFIX}malloc_usable_size]) |
Jason Evans | 84cbbcb | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 266 | AC_DEFINE_UNQUOTED([malloc_tcache_flush], [${JEMALLOC_PREFIX}malloc_tcache_flush]) |
Jason Evans | 90895cf | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 267 | AC_DEFINE_UNQUOTED([malloc_options], [${JEMALLOC_PREFIX}malloc_options]) |
| 268 | AC_DEFINE_UNQUOTED([malloc_message], [${JEMALLOC_PREFIX}malloc_message]) |
| 269 | fi |
| 270 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 271 | dnl Do not compile with debugging by default. |
| 272 | AC_ARG_ENABLE([debug], |
| 273 | [AS_HELP_STRING([--enable-debug], [Build debugging code])], |
| 274 | [if test "x$enable_debug" = "xno" ; then |
| 275 | enable_debug="0" |
| 276 | else |
| 277 | enable_debug="1" |
| 278 | fi |
| 279 | ], |
| 280 | [enable_debug="0"] |
| 281 | ) |
| 282 | if test "x$enable_debug" = "x1" ; then |
| 283 | AC_DEFINE([JEMALLOC_DEBUG], [ ]) |
| 284 | fi |
| 285 | AC_SUBST([enable_debug]) |
| 286 | |
| 287 | dnl Only optimize if not debugging. |
| 288 | if test "x$enable_debug" = "x0" -a "x$no_CFLAGS" = "xyes" ; then |
| 289 | 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] | 290 | optimize="no" |
| 291 | echo "$EXTRA_CFLAGS" | grep "\-O" >/dev/null || optimize="yes" |
| 292 | if test "x${optimize}" = "xyes" ; then |
| 293 | if test "x$GCC" = "xyes" ; then |
| 294 | JE_CFLAGS_APPEND([-O3]) |
| 295 | JE_CFLAGS_APPEND([-funroll-loops]) |
| 296 | JE_CFLAGS_APPEND([-fomit-frame-pointer]) |
| 297 | else |
| 298 | JE_CFLAGS_APPEND([-O]) |
| 299 | fi |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 300 | fi |
| 301 | fi |
| 302 | |
| 303 | dnl Do not enable statistics calculation by default. |
| 304 | AC_ARG_ENABLE([stats], |
| 305 | [AS_HELP_STRING([--enable-stats], [Enable statistics calculation/reporting])], |
| 306 | [if test "x$enable_stats" = "xno" ; then |
| 307 | enable_stats="0" |
| 308 | else |
| 309 | enable_stats="1" |
| 310 | fi |
| 311 | ], |
| 312 | [enable_stats="0"] |
| 313 | ) |
| 314 | if test "x$enable_stats" = "x1" ; then |
| 315 | AC_DEFINE([JEMALLOC_STATS], [ ]) |
| 316 | fi |
| 317 | AC_SUBST([enable_stats]) |
Jason Evans | cc00a15 | 2009-06-25 18:06:48 -0700 | [diff] [blame] | 318 | if test "x$enable_stats" = "x0" ; then |
| 319 | roff_stats=".\\\" " |
| 320 | else |
| 321 | roff_stats="" |
| 322 | fi |
| 323 | AC_SUBST([roff_stats]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 324 | |
Jason Evans | 569432c | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 325 | dnl Do not enable tracing by default. |
| 326 | AC_ARG_ENABLE([trace], |
| 327 | [AS_HELP_STRING([--enable-trace], [Enable allocation tracing (logging)])], |
| 328 | [if test "x$enable_trace" = "xno" ; then |
| 329 | enable_trace="0" |
| 330 | else |
| 331 | enable_trace="1" |
| 332 | fi |
| 333 | ], |
| 334 | [enable_trace="0"] |
| 335 | ) |
| 336 | if test "x$enable_trace" = "x1" ; then |
| 337 | AC_DEFINE([JEMALLOC_TRACE], [ ]) |
| 338 | fi |
| 339 | AC_SUBST([enable_trace]) |
| 340 | if test "x$enable_trace" = "x0" ; then |
| 341 | roff_trace=".\\\" " |
| 342 | else |
| 343 | roff_trace="" |
| 344 | fi |
| 345 | AC_SUBST([roff_trace]) |
| 346 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 347 | dnl Enable tiny allocations by default. |
| 348 | AC_ARG_ENABLE([tiny], |
| 349 | [AS_HELP_STRING([--disable-tiny], [Disable tiny (sub-quantum) allocations])], |
| 350 | [if test "x$enable_tiny" = "xno" ; then |
| 351 | enable_tiny="0" |
| 352 | else |
| 353 | enable_tiny="1" |
| 354 | fi |
| 355 | ], |
| 356 | [enable_tiny="1"] |
| 357 | ) |
| 358 | if test "x$enable_tiny" = "x1" ; then |
| 359 | AC_DEFINE([JEMALLOC_TINY], [ ]) |
| 360 | fi |
| 361 | AC_SUBST([enable_tiny]) |
Jason Evans | cc00a15 | 2009-06-25 18:06:48 -0700 | [diff] [blame] | 362 | if test "x$enable_tiny" = "x0" ; then |
| 363 | roff_tiny=".\\\" " |
| 364 | roff_no_tiny="" |
| 365 | else |
| 366 | roff_tiny="" |
| 367 | roff_no_tiny=".\\\" " |
| 368 | fi |
| 369 | AC_SUBST([roff_tiny]) |
| 370 | AC_SUBST([roff_no_tiny]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 371 | |
Jason Evans | 84cbbcb | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 372 | dnl Enable thread-specific caching by default. |
| 373 | AC_ARG_ENABLE([tcache], |
| 374 | [AS_HELP_STRING([--disable-tcache], [Disable per thread caches])], |
| 375 | [if test "x$enable_tcache" = "xno" ; then |
| 376 | enable_tcache="0" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 377 | else |
Jason Evans | 84cbbcb | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 378 | enable_tcache="1" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 379 | fi |
| 380 | ], |
Jason Evans | 84cbbcb | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 381 | [enable_tcache="1"] |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 382 | ) |
Jason Evans | 84cbbcb | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 383 | dnl Finish tcache-related definitions below, once TLS configuration is done. |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 384 | |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 385 | dnl Do not enable allocation from DSS by default. |
| 386 | AC_ARG_ENABLE([dss], |
| 387 | [AS_HELP_STRING([--enable-dss], [Enable allocation from DSS])], |
| 388 | [if test "x$enable_dss" = "xno" ; then |
| 389 | enable_dss="0" |
| 390 | else |
| 391 | enable_dss="1" |
| 392 | fi |
| 393 | ], |
| 394 | [enable_dss="0"] |
| 395 | ) |
| 396 | if test "x$enable_dss" = "x1" ; then |
| 397 | AC_DEFINE([JEMALLOC_DSS], [ ]) |
| 398 | fi |
| 399 | AC_SUBST([enable_dss]) |
Jason Evans | cc00a15 | 2009-06-25 18:06:48 -0700 | [diff] [blame] | 400 | if test "x$enable_dss" = "x0" ; then |
| 401 | roff_dss=".\\\" " |
| 402 | else |
| 403 | roff_dss="" |
| 404 | fi |
| 405 | AC_SUBST([roff_dss]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 406 | |
| 407 | dnl Do not support the junk/zero filling option by default. |
| 408 | AC_ARG_ENABLE([fill], |
| 409 | [AS_HELP_STRING([--enable-fill], [Support junk/zero filling option])], |
| 410 | [if test "x$enable_fill" = "xno" ; then |
| 411 | enable_fill="0" |
| 412 | else |
| 413 | enable_fill="1" |
| 414 | fi |
| 415 | ], |
| 416 | [enable_fill="0"] |
| 417 | ) |
| 418 | if test "x$enable_fill" = "x1" ; then |
| 419 | AC_DEFINE([JEMALLOC_FILL], [ ]) |
| 420 | fi |
| 421 | AC_SUBST([enable_fill]) |
Jason Evans | cc00a15 | 2009-06-25 18:06:48 -0700 | [diff] [blame] | 422 | if test "x$enable_fill" = "x0" ; then |
| 423 | roff_fill=".\\\" " |
| 424 | else |
| 425 | roff_fill="" |
| 426 | fi |
| 427 | AC_SUBST([roff_fill]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 428 | |
| 429 | dnl Do not support the xmalloc option by default. |
| 430 | AC_ARG_ENABLE([xmalloc], |
| 431 | [AS_HELP_STRING([--enable-xmalloc], [Support xmalloc option])], |
| 432 | [if test "x$enable_xmalloc" = "xno" ; then |
| 433 | enable_xmalloc="0" |
| 434 | else |
| 435 | enable_xmalloc="1" |
| 436 | fi |
| 437 | ], |
| 438 | [enable_xmalloc="0"] |
| 439 | ) |
| 440 | if test "x$enable_xmalloc" = "x1" ; then |
| 441 | AC_DEFINE([JEMALLOC_XMALLOC], [ ]) |
| 442 | fi |
| 443 | AC_SUBST([enable_xmalloc]) |
Jason Evans | cc00a15 | 2009-06-25 18:06:48 -0700 | [diff] [blame] | 444 | if test "x$enable_xmalloc" = "x0" ; then |
| 445 | roff_xmalloc=".\\\" " |
| 446 | else |
| 447 | roff_xmalloc="" |
| 448 | fi |
| 449 | AC_SUBST([roff_xmalloc]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 450 | |
| 451 | dnl Do not support the SYSV option by default. |
| 452 | AC_ARG_ENABLE([sysv], |
| 453 | [AS_HELP_STRING([--enable-sysv], [Support SYSV semantics option])], |
| 454 | [if test "x$enable_sysv" = "xno" ; then |
| 455 | enable_sysv="0" |
| 456 | else |
| 457 | enable_sysv="1" |
| 458 | fi |
| 459 | ], |
| 460 | [enable_sysv="0"] |
| 461 | ) |
| 462 | if test "x$enable_sysv" = "x1" ; then |
| 463 | AC_DEFINE([JEMALLOC_SYSV], [ ]) |
| 464 | fi |
| 465 | AC_SUBST([enable_sysv]) |
Jason Evans | cc00a15 | 2009-06-25 18:06:48 -0700 | [diff] [blame] | 466 | if test "x$enable_sysv" = "x0" ; then |
| 467 | roff_sysv=".\\\" " |
| 468 | else |
| 469 | roff_sysv="" |
| 470 | fi |
| 471 | AC_SUBST([roff_sysv]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 472 | |
| 473 | dnl Do not determine page shift at run time by default. |
| 474 | AC_ARG_ENABLE([dynamic_page_shift], |
| 475 | [AS_HELP_STRING([--enable-dynamic-page-shift], |
| 476 | [Determine page size at run time (don't trust configure result)])], |
| 477 | [if test "x$enable_dynamic_page_shift" = "xno" ; then |
| 478 | enable_dynamic_page_shift="0" |
| 479 | else |
| 480 | enable_dynamic_page_shift="1" |
| 481 | fi |
| 482 | ], |
| 483 | [enable_dynamic_page_shift="0"] |
| 484 | ) |
| 485 | if test "x$enable_dynamic_page_shift" = "x1" ; then |
| 486 | AC_DEFINE([DYNAMIC_PAGE_SHIFT], [ ]) |
| 487 | fi |
| 488 | AC_SUBST([enable_dynamic_page_shift]) |
| 489 | |
| 490 | AC_MSG_CHECKING([STATIC_PAGE_SHIFT]) |
| 491 | AC_RUN_IFELSE([AC_LANG_PROGRAM( |
| 492 | [[#include <stdio.h> |
| 493 | #include <unistd.h> |
| 494 | #include <strings.h> |
| 495 | ]], [[ |
| 496 | long result; |
| 497 | FILE *f; |
| 498 | |
| 499 | result = sysconf(_SC_PAGESIZE); |
| 500 | if (result == -1) { |
| 501 | return 1; |
| 502 | } |
| 503 | f = fopen("conftest.out", "w"); |
| 504 | if (f == NULL) { |
| 505 | return 1; |
| 506 | } |
| 507 | fprintf(f, "%u\n", ffs((int)result) - 1); |
| 508 | close(f); |
| 509 | |
| 510 | return 0; |
| 511 | ]])], |
| 512 | [STATIC_PAGE_SHIFT=`cat conftest.out`] |
| 513 | AC_MSG_RESULT([$STATIC_PAGE_SHIFT]) |
| 514 | AC_DEFINE_UNQUOTED([STATIC_PAGE_SHIFT], [$STATIC_PAGE_SHIFT]), |
| 515 | AC_MSG_RESULT([error])) |
| 516 | |
| 517 | dnl ============================================================================ |
| 518 | dnl jemalloc configuration. |
| 519 | dnl |
| 520 | jemalloc_version=`cat ${srcroot}VERSION` |
Jason Evans | cc00a15 | 2009-06-25 18:06:48 -0700 | [diff] [blame] | 521 | AC_DEFINE_UNQUOTED([JEMALLOC_VERSION], ["$jemalloc_version"]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 522 | AC_SUBST([jemalloc_version]) |
| 523 | |
| 524 | dnl ============================================================================ |
| 525 | dnl Configure pthreads. |
| 526 | |
| 527 | AC_CHECK_HEADERS([pthread.h], , [AC_MSG_ERROR([pthread.h is missing])]) |
| 528 | AC_CHECK_LIB([pthread], [pthread_create], [LIBS="$LIBS -lpthread"], |
| 529 | [AC_MSG_ERROR([libpthread is missing])]) |
| 530 | |
| 531 | CPPFLAGS="$CPPFLAGS -D_REENTRANT" |
| 532 | |
| 533 | AC_MSG_CHECKING([for TLS]) |
| 534 | AC_RUN_IFELSE([AC_LANG_PROGRAM( |
| 535 | [[ |
| 536 | __thread int x; |
| 537 | ]], [[ |
| 538 | x = 42; |
| 539 | |
| 540 | return 0; |
| 541 | ]])], |
Jason Evans | cc00a15 | 2009-06-25 18:06:48 -0700 | [diff] [blame] | 542 | AC_MSG_RESULT([yes]) |
Jason Evans | 84cbbcb | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 543 | have_tls="1", |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 544 | AC_MSG_RESULT([no]) |
Jason Evans | 84cbbcb | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 545 | have_tls="0" |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 546 | AC_DEFINE_UNQUOTED([NO_TLS], [ ])) |
Jason Evans | 84cbbcb | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 547 | |
| 548 | dnl Finish tcache-related definitions, now that TLS configuration is done. |
| 549 | if test "x$have_tls" = "x0" ; then |
| 550 | enable_tcache="0" |
| 551 | fi |
| 552 | if test "x$enable_tcache" = "x1" ; then |
| 553 | AC_DEFINE([JEMALLOC_TCACHE], [ ]) |
| 554 | fi |
| 555 | AC_SUBST([enable_tcache]) |
| 556 | if test "x$enable_tcache" = "x0" ; then |
| 557 | roff_tcache=".\\\" " |
| 558 | roff_no_tcache="" |
| 559 | else |
| 560 | roff_tcache="" |
| 561 | roff_no_tcache=".\\\" " |
| 562 | fi |
| 563 | AC_SUBST([roff_tcache]) |
| 564 | AC_SUBST([roff_no_tcache]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 565 | |
Jason Evans | cc00a15 | 2009-06-25 18:06:48 -0700 | [diff] [blame] | 566 | dnl Enable lazy locking by default. |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 567 | AC_ARG_ENABLE([lazy_lock], |
Jason Evans | a162402 | 2009-11-09 14:58:12 -0800 | [diff] [blame] | 568 | [AS_HELP_STRING([--disable-lazy-lock], |
Jason Evans | cc00a15 | 2009-06-25 18:06:48 -0700 | [diff] [blame] | 569 | [Disable lazy locking (always lock, even when single-threaded)])], |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 570 | [if test "x$enable_lazy_lock" = "xno" ; then |
| 571 | enable_lazy_lock="0" |
| 572 | else |
| 573 | enable_lazy_lock="1" |
| 574 | fi |
| 575 | ], |
Jason Evans | cc00a15 | 2009-06-25 18:06:48 -0700 | [diff] [blame] | 576 | [enable_lazy_lock="1"] |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 577 | ) |
| 578 | if test "x$enable_lazy_lock" = "x1" ; then |
| 579 | AC_CHECK_HEADERS([dlfcn.h], , [AC_MSG_ERROR([dlfcn.h is missing])]) |
| 580 | AC_CHECK_LIB([dl], [dlopen], [LIBS="$LIBS -ldl"], |
| 581 | [AC_MSG_ERROR([libdl is missing])]) |
| 582 | AC_DEFINE([JEMALLOC_LAZY_LOCK], [ ]) |
| 583 | fi |
| 584 | AC_SUBST([enable_lazy_lock]) |
| 585 | |
| 586 | dnl ============================================================================ |
Jason Evans | 662a017 | 2009-07-01 19:24:31 -0700 | [diff] [blame] | 587 | dnl Configure libgd for mtrgraph. |
Jason Evans | 569432c | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 588 | bins="${objroot}bin/jemtr2mtr ${objroot}bin/mtrplay" |
Jason Evans | 662a017 | 2009-07-01 19:24:31 -0700 | [diff] [blame] | 589 | GDLIBS="" |
| 590 | |
| 591 | have_libgd="yes" |
| 592 | AC_CHECK_HEADERS([gd.h], , [have_libgd="no"]) |
| 593 | AC_CHECK_HEADERS([gdfontt.h], , [have_libgd="no"]) |
| 594 | AC_CHECK_HEADERS([gdfonts.h], , [have_libgd="no"]) |
| 595 | AC_CHECK_HEADERS([gdfontmb.h], , [have_libgd="no"]) |
| 596 | AC_CHECK_HEADERS([gdfontl.h], , [have_libgd="no"]) |
| 597 | AC_CHECK_HEADERS([gdfontg.h], , [have_libgd="no"]) |
| 598 | AC_CHECK_LIB([gd], [gdImageCreate], [GDLIBS="-lgd"], [have_libgd="no"]) |
| 599 | |
| 600 | if test "x${have_libgd}" = "xyes" ; then |
| 601 | bins="${bins} ${objroot}bin/mtrgraph" |
| 602 | fi |
| 603 | AC_SUBST([bins]) |
| 604 | AC_SUBST([GDLIBS]) |
| 605 | |
| 606 | dnl ============================================================================ |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 607 | dnl Check for typedefs, structures, and compiler characteristics. |
| 608 | AC_HEADER_STDBOOL |
| 609 | |
| 610 | dnl Process .in files. |
| 611 | AC_SUBST([cfghdrs]) |
| 612 | AC_CONFIG_HEADERS([$cfghdrs cfghdrs.stamp]) |
| 613 | |
| 614 | dnl ============================================================================ |
| 615 | dnl Generate outputs. |
| 616 | AC_CONFIG_FILES([$cfgoutputs cfgoutputs.stamp]) |
| 617 | AC_SUBST([cfgoutputs]) |
| 618 | AC_OUTPUT |
| 619 | |
| 620 | dnl ============================================================================ |
| 621 | dnl Print out the results of configuration. |
| 622 | AC_MSG_RESULT([===============================================================================]) |
| 623 | AC_MSG_RESULT([jemalloc version : $jemalloc_version]) |
| 624 | AC_MSG_RESULT([]) |
| 625 | AC_MSG_RESULT([CC : ${CC}]) |
| 626 | AC_MSG_RESULT([CPPFLAGS : ${CPPFLAGS}]) |
| 627 | AC_MSG_RESULT([CFLAGS : ${CFLAGS}]) |
| 628 | AC_MSG_RESULT([LDFLAGS : ${LDFLAGS}]) |
| 629 | AC_MSG_RESULT([LIBS : ${LIBS}]) |
| 630 | AC_MSG_RESULT([RPATH_EXTRA : ${RPATH_EXTRA}]) |
| 631 | AC_MSG_RESULT([]) |
| 632 | AC_MSG_RESULT([PREFIX : ${PREFIX}]) |
| 633 | AC_MSG_RESULT([BINDIR : ${BINDIR}]) |
Jason Evans | 662a017 | 2009-07-01 19:24:31 -0700 | [diff] [blame] | 634 | AC_MSG_RESULT([INCLUDEDIR : ${INCLUDEDIR}]) |
| 635 | AC_MSG_RESULT([LIBDIR : ${LIBDIR}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 636 | AC_MSG_RESULT([DATADIR : ${DATADIR}]) |
| 637 | AC_MSG_RESULT([MANDIR : ${MANDIR}]) |
| 638 | AC_MSG_RESULT([]) |
| 639 | AC_MSG_RESULT([srcroot : ${srcroot}]) |
| 640 | AC_MSG_RESULT([abs_srcroot : ${abs_srcroot}]) |
| 641 | AC_MSG_RESULT([objroot : ${objroot}]) |
| 642 | AC_MSG_RESULT([abs_objroot : ${abs_objroot}]) |
| 643 | AC_MSG_RESULT([]) |
Jason Evans | 662a017 | 2009-07-01 19:24:31 -0700 | [diff] [blame] | 644 | AC_MSG_RESULT([bins : ${bins}]) |
| 645 | AC_MSG_RESULT([]) |
Jason Evans | 90895cf | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 646 | AC_MSG_RESULT([JEMALLOC_PREFIX : ${JEMALLOC_PREFIX}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 647 | AC_MSG_RESULT([autogen : ${enable_autogen}]) |
| 648 | AC_MSG_RESULT([debug : ${enable_debug}]) |
| 649 | AC_MSG_RESULT([stats : ${enable_stats}]) |
Jason Evans | 569432c | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 650 | AC_MSG_RESULT([trace : ${enable_trace}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 651 | AC_MSG_RESULT([tiny : ${enable_tiny}]) |
Jason Evans | 84cbbcb | 2009-12-29 00:09:15 -0800 | [diff] [blame] | 652 | AC_MSG_RESULT([tcache : ${enable_tcache}]) |
Jason Evans | b7924f5 | 2009-06-23 19:01:18 -0700 | [diff] [blame] | 653 | AC_MSG_RESULT([fill : ${enable_fill}]) |
| 654 | AC_MSG_RESULT([xmalloc : ${enable_xmalloc}]) |
| 655 | AC_MSG_RESULT([sysv : ${enable_sysv}]) |
| 656 | AC_MSG_RESULT([dss : ${enable_dss}]) |
| 657 | AC_MSG_RESULT([dynamic_page_shift : ${enable_dynamic_page_shift}]) |
| 658 | AC_MSG_RESULT([lazy_lock : ${enable_lazy_lock}]) |
| 659 | AC_MSG_RESULT([===============================================================================]) |