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