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