michael@0: dnl Process this file with autoconf to produce a configure script. michael@0: AC_INIT([Makefile.in]) michael@0: michael@0: dnl ============================================================================ michael@0: dnl Custom macro definitions. michael@0: michael@0: dnl JE_CFLAGS_APPEND(cflag) michael@0: AC_DEFUN([JE_CFLAGS_APPEND], michael@0: [ michael@0: AC_MSG_CHECKING([whether compiler supports $1]) michael@0: TCFLAGS="${CFLAGS}" michael@0: if test "x${CFLAGS}" = "x" ; then michael@0: CFLAGS="$1" michael@0: else michael@0: CFLAGS="${CFLAGS} $1" michael@0: fi michael@0: AC_COMPILE_IFELSE([AC_LANG_PROGRAM( michael@0: [[ michael@0: ]], [[ michael@0: return 0; michael@0: ]])], michael@0: AC_MSG_RESULT([yes]), michael@0: AC_MSG_RESULT([no]) michael@0: [CFLAGS="${TCFLAGS}"] michael@0: ) michael@0: ]) michael@0: michael@0: dnl JE_COMPILABLE(label, hcode, mcode, rvar) michael@0: dnl michael@0: dnl Use AC_LINK_IFELSE() rather than AC_COMPILE_IFELSE() so that linker errors michael@0: dnl cause failure. michael@0: AC_DEFUN([JE_COMPILABLE], michael@0: [ michael@0: AC_CACHE_CHECK([whether $1 is compilable], michael@0: [$4], michael@0: [AC_LINK_IFELSE([AC_LANG_PROGRAM([$2], michael@0: [$3])], michael@0: [$4=yes], michael@0: [$4=no])]) michael@0: ]) michael@0: michael@0: dnl ============================================================================ michael@0: michael@0: dnl Library revision. michael@0: rev=1 michael@0: AC_SUBST([rev]) michael@0: michael@0: srcroot=$srcdir michael@0: if test "x${srcroot}" = "x." ; then michael@0: srcroot="" michael@0: else michael@0: srcroot="${srcroot}/" michael@0: fi michael@0: AC_SUBST([srcroot]) michael@0: abs_srcroot="`cd \"${srcdir}\"; pwd`/" michael@0: AC_SUBST([abs_srcroot]) michael@0: michael@0: objroot="" michael@0: AC_SUBST([objroot]) michael@0: abs_objroot="`pwd`/" michael@0: AC_SUBST([abs_objroot]) michael@0: michael@0: dnl Munge install path variables. michael@0: if test "x$prefix" = "xNONE" ; then michael@0: prefix="/usr/local" michael@0: fi michael@0: if test "x$exec_prefix" = "xNONE" ; then michael@0: exec_prefix=$prefix michael@0: fi michael@0: PREFIX=$prefix michael@0: AC_SUBST([PREFIX]) michael@0: BINDIR=`eval echo $bindir` michael@0: BINDIR=`eval echo $BINDIR` michael@0: AC_SUBST([BINDIR]) michael@0: INCLUDEDIR=`eval echo $includedir` michael@0: INCLUDEDIR=`eval echo $INCLUDEDIR` michael@0: AC_SUBST([INCLUDEDIR]) michael@0: LIBDIR=`eval echo $libdir` michael@0: LIBDIR=`eval echo $LIBDIR` michael@0: AC_SUBST([LIBDIR]) michael@0: DATADIR=`eval echo $datadir` michael@0: DATADIR=`eval echo $DATADIR` michael@0: AC_SUBST([DATADIR]) michael@0: MANDIR=`eval echo $mandir` michael@0: MANDIR=`eval echo $MANDIR` michael@0: AC_SUBST([MANDIR]) michael@0: michael@0: dnl Support for building documentation. michael@0: AC_PATH_PROG([XSLTPROC], [xsltproc], , [$PATH]) michael@0: if test -d "/usr/share/xml/docbook/stylesheet/docbook-xsl" ; then michael@0: DEFAULT_XSLROOT="/usr/share/xml/docbook/stylesheet/docbook-xsl" michael@0: elif test -d "/usr/share/sgml/docbook/xsl-stylesheets" ; then michael@0: DEFAULT_XSLROOT="/usr/share/sgml/docbook/xsl-stylesheets" michael@0: else michael@0: dnl Documentation building will fail if this default gets used. michael@0: DEFAULT_XSLROOT="" michael@0: fi michael@0: AC_ARG_WITH([xslroot], michael@0: [AS_HELP_STRING([--with-xslroot=], [XSL stylesheet root path])], [ michael@0: if test "x$with_xslroot" = "xno" ; then michael@0: XSLROOT="${DEFAULT_XSLROOT}" michael@0: else michael@0: XSLROOT="${with_xslroot}" michael@0: fi michael@0: ], michael@0: XSLROOT="${DEFAULT_XSLROOT}" michael@0: ) michael@0: AC_SUBST([XSLROOT]) michael@0: michael@0: dnl If CFLAGS isn't defined, set CFLAGS to something reasonable. Otherwise, michael@0: dnl just prevent autoconf from molesting CFLAGS. michael@0: CFLAGS=$CFLAGS michael@0: AC_PROG_CC michael@0: if test "x$GCC" != "xyes" ; then michael@0: AC_CACHE_CHECK([whether compiler is MSVC], michael@0: [je_cv_msvc], michael@0: [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], michael@0: [ michael@0: #ifndef _MSC_VER michael@0: int fail[-1]; michael@0: #endif michael@0: ])], michael@0: [je_cv_msvc=yes], michael@0: [je_cv_msvc=no])]) michael@0: fi michael@0: michael@0: if test "x$CFLAGS" = "x" ; then michael@0: no_CFLAGS="yes" michael@0: if test "x$GCC" = "xyes" ; then michael@0: JE_CFLAGS_APPEND([-std=gnu99]) michael@0: JE_CFLAGS_APPEND([-Wall]) michael@0: JE_CFLAGS_APPEND([-pipe]) michael@0: JE_CFLAGS_APPEND([-g3]) michael@0: elif test "x$je_cv_msvc" = "xyes" ; then michael@0: CC="$CC -nologo" michael@0: JE_CFLAGS_APPEND([-Zi]) michael@0: JE_CFLAGS_APPEND([-MT]) michael@0: JE_CFLAGS_APPEND([-W3]) michael@0: CPPFLAGS="$CPPFLAGS -I${srcroot}/include/msvc_compat" michael@0: fi michael@0: fi michael@0: dnl Append EXTRA_CFLAGS to CFLAGS, if defined. michael@0: if test "x$EXTRA_CFLAGS" != "x" ; then michael@0: JE_CFLAGS_APPEND([$EXTRA_CFLAGS]) michael@0: fi michael@0: AC_PROG_CPP michael@0: michael@0: AC_CHECK_SIZEOF([void *]) michael@0: if test "x${ac_cv_sizeof_void_p}" = "x8" ; then michael@0: LG_SIZEOF_PTR=3 michael@0: elif test "x${ac_cv_sizeof_void_p}" = "x4" ; then michael@0: LG_SIZEOF_PTR=2 michael@0: else michael@0: AC_MSG_ERROR([Unsupported pointer size: ${ac_cv_sizeof_void_p}]) michael@0: fi michael@0: AC_DEFINE_UNQUOTED([LG_SIZEOF_PTR], [$LG_SIZEOF_PTR]) michael@0: michael@0: AC_CHECK_SIZEOF([int]) michael@0: if test "x${ac_cv_sizeof_int}" = "x8" ; then michael@0: LG_SIZEOF_INT=3 michael@0: elif test "x${ac_cv_sizeof_int}" = "x4" ; then michael@0: LG_SIZEOF_INT=2 michael@0: else michael@0: AC_MSG_ERROR([Unsupported int size: ${ac_cv_sizeof_int}]) michael@0: fi michael@0: AC_DEFINE_UNQUOTED([LG_SIZEOF_INT], [$LG_SIZEOF_INT]) michael@0: michael@0: AC_CHECK_SIZEOF([long]) michael@0: if test "x${ac_cv_sizeof_long}" = "x8" ; then michael@0: LG_SIZEOF_LONG=3 michael@0: elif test "x${ac_cv_sizeof_long}" = "x4" ; then michael@0: LG_SIZEOF_LONG=2 michael@0: else michael@0: AC_MSG_ERROR([Unsupported long size: ${ac_cv_sizeof_long}]) michael@0: fi michael@0: AC_DEFINE_UNQUOTED([LG_SIZEOF_LONG], [$LG_SIZEOF_LONG]) michael@0: michael@0: AC_CHECK_SIZEOF([intmax_t]) michael@0: if test "x${ac_cv_sizeof_intmax_t}" = "x16" ; then michael@0: LG_SIZEOF_INTMAX_T=4 michael@0: elif test "x${ac_cv_sizeof_intmax_t}" = "x8" ; then michael@0: LG_SIZEOF_INTMAX_T=3 michael@0: elif test "x${ac_cv_sizeof_intmax_t}" = "x4" ; then michael@0: LG_SIZEOF_INTMAX_T=2 michael@0: else michael@0: AC_MSG_ERROR([Unsupported intmax_t size: ${ac_cv_sizeof_intmax_t}]) michael@0: fi michael@0: AC_DEFINE_UNQUOTED([LG_SIZEOF_INTMAX_T], [$LG_SIZEOF_INTMAX_T]) michael@0: michael@0: AC_CANONICAL_HOST michael@0: dnl CPU-specific settings. michael@0: CPU_SPINWAIT="" michael@0: case "${host_cpu}" in michael@0: i[[345]]86) michael@0: ;; michael@0: i686) michael@0: JE_COMPILABLE([__asm__], [], [[__asm__ volatile("pause"); return 0;]], michael@0: [je_cv_asm]) michael@0: if test "x${je_cv_asm}" = "xyes" ; then michael@0: CPU_SPINWAIT='__asm__ volatile("pause")' michael@0: fi michael@0: ;; michael@0: x86_64) michael@0: JE_COMPILABLE([__asm__ syntax], [], michael@0: [[__asm__ volatile("pause"); return 0;]], [je_cv_asm]) michael@0: if test "x${je_cv_asm}" = "xyes" ; then michael@0: CPU_SPINWAIT='__asm__ volatile("pause")' michael@0: fi michael@0: ;; michael@0: *) michael@0: ;; michael@0: esac michael@0: AC_DEFINE_UNQUOTED([CPU_SPINWAIT], [$CPU_SPINWAIT]) michael@0: michael@0: LD_PRELOAD_VAR="LD_PRELOAD" michael@0: so="so" michael@0: importlib="${so}" michael@0: o="$ac_objext" michael@0: a="a" michael@0: exe="$ac_exeext" michael@0: libprefix="lib" michael@0: DSO_LDFLAGS='-shared -Wl,-soname,$(@F)' michael@0: RPATH='-Wl,-rpath,$(1)' michael@0: SOREV="${so}.${rev}" michael@0: PIC_CFLAGS='-fPIC -DPIC' michael@0: CTARGET='-o $@' michael@0: LDTARGET='-o $@' michael@0: EXTRA_LDFLAGS= michael@0: MKLIB='ar crus $@' michael@0: CC_MM=1 michael@0: michael@0: dnl Platform-specific settings. abi and RPATH can probably be determined michael@0: dnl programmatically, but doing so is error-prone, which makes it generally michael@0: dnl not worth the trouble. michael@0: dnl michael@0: dnl Define cpp macros in CPPFLAGS, rather than doing AC_DEFINE(macro), since the michael@0: dnl definitions need to be seen before any headers are included, which is a pain michael@0: dnl to make happen otherwise. michael@0: default_munmap="1" michael@0: JEMALLOC_USABLE_SIZE_CONST="const" michael@0: case "${host}" in michael@0: *-*-darwin*) michael@0: CFLAGS="$CFLAGS" michael@0: abi="macho" michael@0: AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ]) michael@0: RPATH="" michael@0: LD_PRELOAD_VAR="DYLD_INSERT_LIBRARIES" michael@0: so="dylib" michael@0: importlib="${so}" michael@0: force_tls="0" michael@0: DSO_LDFLAGS='-shared -Wl,-dylib_install_name,$(@F)' michael@0: SOREV="${rev}.${so}" michael@0: ;; michael@0: *-*-freebsd*) michael@0: CFLAGS="$CFLAGS" michael@0: abi="elf" michael@0: AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ]) michael@0: force_lazy_lock="1" michael@0: ;; michael@0: *-*-linux*) michael@0: CFLAGS="$CFLAGS" michael@0: CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" michael@0: abi="elf" michael@0: AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED], [ ]) michael@0: AC_DEFINE([JEMALLOC_THREADED_INIT], [ ]) michael@0: JEMALLOC_USABLE_SIZE_CONST="" michael@0: default_munmap="0" michael@0: ;; michael@0: *-*-netbsd*) michael@0: AC_MSG_CHECKING([ABI]) michael@0: AC_COMPILE_IFELSE([AC_LANG_PROGRAM( michael@0: [[#ifdef __ELF__ michael@0: /* ELF */ michael@0: #else michael@0: #error aout michael@0: #endif michael@0: ]])], michael@0: [CFLAGS="$CFLAGS"; abi="elf"], michael@0: [abi="aout"]) michael@0: AC_MSG_RESULT([$abi]) michael@0: AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ]) michael@0: ;; michael@0: *-*-solaris2*) michael@0: CFLAGS="$CFLAGS" michael@0: abi="elf" michael@0: RPATH='-Wl,-R,$(1)' michael@0: dnl Solaris needs this for sigwait(). michael@0: CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS" michael@0: LIBS="$LIBS -lposix4 -lsocket -lnsl" michael@0: ;; michael@0: *-ibm-aix*) michael@0: if "$LG_SIZEOF_PTR" = "8"; then michael@0: dnl 64bit AIX michael@0: LD_PRELOAD_VAR="LDR_PRELOAD64" michael@0: else michael@0: dnl 32bit AIX michael@0: LD_PRELOAD_VAR="LDR_PRELOAD" michael@0: fi michael@0: abi="xcoff" michael@0: ;; michael@0: *-*-mingw*) michael@0: abi="pecoff" michael@0: force_tls="0" michael@0: RPATH="" michael@0: so="dll" michael@0: if test "x$je_cv_msvc" = "xyes" ; then michael@0: importlib="lib" michael@0: DSO_LDFLAGS="-LD" michael@0: EXTRA_LDFLAGS="-link -DEBUG" michael@0: CTARGET='-Fo$@' michael@0: LDTARGET='-Fe$@' michael@0: MKLIB='lib -nologo -out:$@' michael@0: CC_MM= michael@0: else michael@0: importlib="${so}" michael@0: DSO_LDFLAGS="-shared" michael@0: fi michael@0: a="lib" michael@0: libprefix="" michael@0: SOREV="${so}" michael@0: PIC_CFLAGS="" michael@0: ;; michael@0: *) michael@0: AC_MSG_RESULT([Unsupported operating system: ${host}]) michael@0: abi="elf" michael@0: ;; michael@0: esac michael@0: AC_DEFINE_UNQUOTED([JEMALLOC_USABLE_SIZE_CONST], [$JEMALLOC_USABLE_SIZE_CONST]) michael@0: AC_SUBST([abi]) michael@0: AC_SUBST([RPATH]) michael@0: AC_SUBST([LD_PRELOAD_VAR]) michael@0: AC_SUBST([so]) michael@0: AC_SUBST([importlib]) michael@0: AC_SUBST([o]) michael@0: AC_SUBST([a]) michael@0: AC_SUBST([exe]) michael@0: AC_SUBST([libprefix]) michael@0: AC_SUBST([DSO_LDFLAGS]) michael@0: AC_SUBST([EXTRA_LDFLAGS]) michael@0: AC_SUBST([SOREV]) michael@0: AC_SUBST([PIC_CFLAGS]) michael@0: AC_SUBST([CTARGET]) michael@0: AC_SUBST([LDTARGET]) michael@0: AC_SUBST([MKLIB]) michael@0: AC_SUBST([CC_MM]) michael@0: michael@0: if test "x$abi" != "xpecoff"; then michael@0: dnl Heap profiling uses the log(3) function. michael@0: LIBS="$LIBS -lm" michael@0: fi michael@0: michael@0: JE_COMPILABLE([__attribute__ syntax], michael@0: [static __attribute__((unused)) void foo(void){}], michael@0: [], michael@0: [je_cv_attribute]) michael@0: if test "x${je_cv_attribute}" = "xyes" ; then michael@0: AC_DEFINE([JEMALLOC_HAVE_ATTR], [ ]) michael@0: if test "x${GCC}" = "xyes" -a "x${abi}" = "xelf"; then michael@0: JE_CFLAGS_APPEND([-fvisibility=hidden]) michael@0: fi michael@0: fi michael@0: dnl Check for tls_model attribute support (clang 3.0 still lacks support). michael@0: SAVED_CFLAGS="${CFLAGS}" michael@0: JE_CFLAGS_APPEND([-Werror]) michael@0: JE_COMPILABLE([tls_model attribute], [], michael@0: [static __thread int michael@0: __attribute__((tls_model("initial-exec"))) foo; michael@0: foo = 0;], michael@0: [je_cv_tls_model]) michael@0: CFLAGS="${SAVED_CFLAGS}" michael@0: if test "x${je_cv_tls_model}" = "xyes" ; then michael@0: AC_DEFINE([JEMALLOC_TLS_MODEL], michael@0: [__attribute__((tls_model("initial-exec")))]) michael@0: else michael@0: AC_DEFINE([JEMALLOC_TLS_MODEL], [ ]) michael@0: fi michael@0: michael@0: dnl Support optional additions to rpath. michael@0: AC_ARG_WITH([rpath], michael@0: [AS_HELP_STRING([--with-rpath=], [Colon-separated rpath (ELF systems only)])], michael@0: if test "x$with_rpath" = "xno" ; then michael@0: RPATH_EXTRA= michael@0: else michael@0: RPATH_EXTRA="`echo $with_rpath | tr \":\" \" \"`" michael@0: fi, michael@0: RPATH_EXTRA= michael@0: ) michael@0: AC_SUBST([RPATH_EXTRA]) michael@0: michael@0: dnl Disable rules that do automatic regeneration of configure output by default. michael@0: AC_ARG_ENABLE([autogen], michael@0: [AS_HELP_STRING([--enable-autogen], [Automatically regenerate configure output])], michael@0: if test "x$enable_autogen" = "xno" ; then michael@0: enable_autogen="0" michael@0: else michael@0: enable_autogen="1" michael@0: fi michael@0: , michael@0: enable_autogen="0" michael@0: ) michael@0: AC_SUBST([enable_autogen]) michael@0: michael@0: AC_PROG_INSTALL michael@0: AC_PROG_RANLIB michael@0: AC_PATH_PROG([AR], [ar], , [$PATH]) michael@0: AC_PATH_PROG([LD], [ld], , [$PATH]) michael@0: AC_PATH_PROG([AUTOCONF], [autoconf], , [$PATH]) michael@0: michael@0: public_syms="malloc_conf malloc_message malloc calloc posix_memalign aligned_alloc realloc free malloc_usable_size malloc_stats_print mallctl mallctlnametomib mallctlbymib" michael@0: michael@0: dnl Check for allocator-related functions that should be wrapped. michael@0: AC_CHECK_FUNC([memalign], michael@0: [AC_DEFINE([JEMALLOC_OVERRIDE_MEMALIGN], [ ]) michael@0: public_syms="${public_syms} memalign"]) michael@0: AC_CHECK_FUNC([valloc], michael@0: [AC_DEFINE([JEMALLOC_OVERRIDE_VALLOC], [ ]) michael@0: public_syms="${public_syms} valloc"]) michael@0: michael@0: dnl Support the experimental API by default. michael@0: AC_ARG_ENABLE([experimental], michael@0: [AS_HELP_STRING([--disable-experimental], michael@0: [Disable support for the experimental API])], michael@0: [if test "x$enable_experimental" = "xno" ; then michael@0: enable_experimental="0" michael@0: else michael@0: enable_experimental="1" michael@0: fi michael@0: ], michael@0: [enable_experimental="1"] michael@0: ) michael@0: if test "x$enable_experimental" = "x1" ; then michael@0: AC_DEFINE([JEMALLOC_EXPERIMENTAL], [ ]) michael@0: public_syms="${public_syms} allocm dallocm nallocm rallocm sallocm" michael@0: fi michael@0: AC_SUBST([enable_experimental]) michael@0: michael@0: dnl Perform no name mangling by default. michael@0: AC_ARG_WITH([mangling], michael@0: [AS_HELP_STRING([--with-mangling=], [Mangle symbols in ])], michael@0: [mangling_map="$with_mangling"], [mangling_map=""]) michael@0: for nm in `echo ${mangling_map} |tr ',' ' '` ; do michael@0: k="`echo ${nm} |tr ':' ' ' |awk '{print $1}'`" michael@0: n="je_${k}" michael@0: m=`echo ${nm} |tr ':' ' ' |awk '{print $2}'` michael@0: AC_DEFINE_UNQUOTED([${n}], [${m}]) michael@0: dnl Remove key from public_syms so that it isn't redefined later. michael@0: public_syms=`for sym in ${public_syms}; do echo "${sym}"; done |grep -v "^${k}\$" |tr '\n' ' '` michael@0: done michael@0: michael@0: dnl Do not prefix public APIs by default. michael@0: AC_ARG_WITH([jemalloc_prefix], michael@0: [AS_HELP_STRING([--with-jemalloc-prefix=], [Prefix to prepend to all public APIs])], michael@0: [JEMALLOC_PREFIX="$with_jemalloc_prefix"], michael@0: [if test "x$abi" != "xmacho" -a "x$abi" != "xpecoff"; then michael@0: JEMALLOC_PREFIX="" michael@0: else michael@0: JEMALLOC_PREFIX="je_" michael@0: fi] michael@0: ) michael@0: if test "x$JEMALLOC_PREFIX" != "x" ; then michael@0: JEMALLOC_CPREFIX=`echo ${JEMALLOC_PREFIX} | tr "a-z" "A-Z"` michael@0: AC_DEFINE_UNQUOTED([JEMALLOC_PREFIX], ["$JEMALLOC_PREFIX"]) michael@0: AC_DEFINE_UNQUOTED([JEMALLOC_CPREFIX], ["$JEMALLOC_CPREFIX"]) michael@0: fi michael@0: dnl Generate macros to rename public symbols. All public symbols are prefixed michael@0: dnl with je_ in the source code, so these macro definitions are needed even if michael@0: dnl --with-jemalloc-prefix wasn't specified. michael@0: for stem in ${public_syms}; do michael@0: n="je_${stem}" michael@0: m="${JEMALLOC_PREFIX}${stem}" michael@0: AC_DEFINE_UNQUOTED([${n}], [${m}]) michael@0: done michael@0: michael@0: AC_ARG_WITH([export], michael@0: [AS_HELP_STRING([--without-export], [disable exporting jemalloc public APIs])], michael@0: [if test "x$with_export" = "xno"; then michael@0: AC_DEFINE([JEMALLOC_EXPORT],[])] michael@0: fi] michael@0: ) michael@0: michael@0: dnl Do not mangle library-private APIs by default. michael@0: AC_ARG_WITH([private_namespace], michael@0: [AS_HELP_STRING([--with-private-namespace=], [Prefix to prepend to all library-private APIs])], michael@0: [JEMALLOC_PRIVATE_NAMESPACE="$with_private_namespace"], michael@0: [JEMALLOC_PRIVATE_NAMESPACE=""] michael@0: ) michael@0: AC_DEFINE_UNQUOTED([JEMALLOC_PRIVATE_NAMESPACE], ["$JEMALLOC_PRIVATE_NAMESPACE"]) michael@0: if test "x$JEMALLOC_PRIVATE_NAMESPACE" != "x" ; then michael@0: 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]) michael@0: else michael@0: 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]) michael@0: fi michael@0: michael@0: dnl Do not add suffix to installed files by default. michael@0: AC_ARG_WITH([install_suffix], michael@0: [AS_HELP_STRING([--with-install-suffix=], [Suffix to append to all installed files])], michael@0: [INSTALL_SUFFIX="$with_install_suffix"], michael@0: [INSTALL_SUFFIX=] michael@0: ) michael@0: install_suffix="$INSTALL_SUFFIX" michael@0: AC_SUBST([install_suffix]) michael@0: michael@0: cfgoutputs_in="${srcroot}Makefile.in" michael@0: cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/html.xsl.in" michael@0: cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/manpages.xsl.in" michael@0: cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/jemalloc.xml.in" michael@0: cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/jemalloc.h.in" michael@0: cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/internal/jemalloc_internal.h.in" michael@0: cfgoutputs_in="${cfgoutputs_in} ${srcroot}test/jemalloc_test.h.in" michael@0: michael@0: cfgoutputs_out="Makefile" michael@0: cfgoutputs_out="${cfgoutputs_out} doc/html.xsl" michael@0: cfgoutputs_out="${cfgoutputs_out} doc/manpages.xsl" michael@0: cfgoutputs_out="${cfgoutputs_out} doc/jemalloc${install_suffix}.xml" michael@0: cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc${install_suffix}.h" michael@0: cfgoutputs_out="${cfgoutputs_out} include/jemalloc/internal/jemalloc_internal.h" michael@0: cfgoutputs_out="${cfgoutputs_out} test/jemalloc_test.h" michael@0: michael@0: cfgoutputs_tup="Makefile" michael@0: cfgoutputs_tup="${cfgoutputs_tup} doc/html.xsl:doc/html.xsl.in" michael@0: cfgoutputs_tup="${cfgoutputs_tup} doc/manpages.xsl:doc/manpages.xsl.in" michael@0: cfgoutputs_tup="${cfgoutputs_tup} doc/jemalloc${install_suffix}.xml:doc/jemalloc.xml.in" michael@0: cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc${install_suffix}.h:include/jemalloc/jemalloc.h.in" michael@0: cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/internal/jemalloc_internal.h" michael@0: cfgoutputs_tup="${cfgoutputs_tup} test/jemalloc_test.h:test/jemalloc_test.h.in" michael@0: michael@0: cfghdrs_in="${srcroot}include/jemalloc/jemalloc_defs.h.in" michael@0: cfghdrs_in="${cfghdrs_in} ${srcroot}include/jemalloc/internal/size_classes.sh" michael@0: michael@0: cfghdrs_out="include/jemalloc/jemalloc_defs${install_suffix}.h" michael@0: cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/size_classes.h" michael@0: michael@0: cfghdrs_tup="include/jemalloc/jemalloc_defs${install_suffix}.h:include/jemalloc/jemalloc_defs.h.in" michael@0: michael@0: dnl Do not silence irrelevant compiler warnings by default, since enabling this michael@0: dnl option incurs a performance penalty. michael@0: AC_ARG_ENABLE([cc-silence], michael@0: [AS_HELP_STRING([--enable-cc-silence], michael@0: [Silence irrelevant compiler warnings])], michael@0: [if test "x$enable_cc_silence" = "xno" ; then michael@0: enable_cc_silence="0" michael@0: else michael@0: enable_cc_silence="1" michael@0: fi michael@0: ], michael@0: [enable_cc_silence="0"] michael@0: ) michael@0: if test "x$enable_cc_silence" = "x1" ; then michael@0: AC_DEFINE([JEMALLOC_CC_SILENCE], [ ]) michael@0: fi michael@0: michael@0: dnl Do not compile with debugging by default. michael@0: AC_ARG_ENABLE([debug], michael@0: [AS_HELP_STRING([--enable-debug], [Build debugging code])], michael@0: [if test "x$enable_debug" = "xno" ; then michael@0: enable_debug="0" michael@0: else michael@0: enable_debug="1" michael@0: fi michael@0: ], michael@0: [enable_debug="0"] michael@0: ) michael@0: if test "x$enable_debug" = "x1" ; then michael@0: AC_DEFINE([JEMALLOC_DEBUG], [ ]) michael@0: AC_DEFINE([JEMALLOC_IVSALLOC], [ ]) michael@0: fi michael@0: AC_SUBST([enable_debug]) michael@0: michael@0: dnl Only optimize if not debugging. michael@0: if test "x$enable_debug" = "x0" -a "x$no_CFLAGS" = "xyes" ; then michael@0: dnl Make sure that an optimization flag was not specified in EXTRA_CFLAGS. michael@0: optimize="no" michael@0: echo "$EXTRA_CFLAGS" | grep "\-O" >/dev/null || optimize="yes" michael@0: if test "x${optimize}" = "xyes" ; then michael@0: if test "x$GCC" = "xyes" ; then michael@0: JE_CFLAGS_APPEND([-O3]) michael@0: JE_CFLAGS_APPEND([-funroll-loops]) michael@0: elif test "x$je_cv_msvc" = "xyes" ; then michael@0: JE_CFLAGS_APPEND([-O2]) michael@0: else michael@0: JE_CFLAGS_APPEND([-O]) michael@0: fi michael@0: fi michael@0: fi michael@0: michael@0: dnl Enable statistics calculation by default. michael@0: AC_ARG_ENABLE([stats], michael@0: [AS_HELP_STRING([--disable-stats], michael@0: [Disable statistics calculation/reporting])], michael@0: [if test "x$enable_stats" = "xno" ; then michael@0: enable_stats="0" michael@0: else michael@0: enable_stats="1" michael@0: fi michael@0: ], michael@0: [enable_stats="1"] michael@0: ) michael@0: if test "x$enable_stats" = "x1" ; then michael@0: AC_DEFINE([JEMALLOC_STATS], [ ]) michael@0: fi michael@0: AC_SUBST([enable_stats]) michael@0: michael@0: dnl Do not enable profiling by default. michael@0: AC_ARG_ENABLE([prof], michael@0: [AS_HELP_STRING([--enable-prof], [Enable allocation profiling])], michael@0: [if test "x$enable_prof" = "xno" ; then michael@0: enable_prof="0" michael@0: else michael@0: enable_prof="1" michael@0: fi michael@0: ], michael@0: [enable_prof="0"] michael@0: ) michael@0: if test "x$enable_prof" = "x1" ; then michael@0: backtrace_method="" michael@0: else michael@0: backtrace_method="N/A" michael@0: fi michael@0: michael@0: AC_ARG_ENABLE([prof-libunwind], michael@0: [AS_HELP_STRING([--enable-prof-libunwind], [Use libunwind for backtracing])], michael@0: [if test "x$enable_prof_libunwind" = "xno" ; then michael@0: enable_prof_libunwind="0" michael@0: else michael@0: enable_prof_libunwind="1" michael@0: fi michael@0: ], michael@0: [enable_prof_libunwind="0"] michael@0: ) michael@0: AC_ARG_WITH([static_libunwind], michael@0: [AS_HELP_STRING([--with-static-libunwind=], michael@0: [Path to static libunwind library; use rather than dynamically linking])], michael@0: if test "x$with_static_libunwind" = "xno" ; then michael@0: LUNWIND="-lunwind" michael@0: else michael@0: if test ! -f "$with_static_libunwind" ; then michael@0: AC_MSG_ERROR([Static libunwind not found: $with_static_libunwind]) michael@0: fi michael@0: LUNWIND="$with_static_libunwind" michael@0: fi, michael@0: LUNWIND="-lunwind" michael@0: ) michael@0: if test "x$backtrace_method" = "x" -a "x$enable_prof_libunwind" = "x1" ; then michael@0: AC_CHECK_HEADERS([libunwind.h], , [enable_prof_libunwind="0"]) michael@0: if test "x$LUNWIND" = "x-lunwind" ; then michael@0: AC_CHECK_LIB([unwind], [backtrace], [LIBS="$LIBS $LUNWIND"], michael@0: [enable_prof_libunwind="0"]) michael@0: else michael@0: LIBS="$LIBS $LUNWIND" michael@0: fi michael@0: if test "x${enable_prof_libunwind}" = "x1" ; then michael@0: backtrace_method="libunwind" michael@0: AC_DEFINE([JEMALLOC_PROF_LIBUNWIND], [ ]) michael@0: fi michael@0: fi michael@0: michael@0: AC_ARG_ENABLE([prof-libgcc], michael@0: [AS_HELP_STRING([--disable-prof-libgcc], michael@0: [Do not use libgcc for backtracing])], michael@0: [if test "x$enable_prof_libgcc" = "xno" ; then michael@0: enable_prof_libgcc="0" michael@0: else michael@0: enable_prof_libgcc="1" michael@0: fi michael@0: ], michael@0: [enable_prof_libgcc="1"] michael@0: ) michael@0: if test "x$backtrace_method" = "x" -a "x$enable_prof_libgcc" = "x1" \ michael@0: -a "x$GCC" = "xyes" ; then michael@0: AC_CHECK_HEADERS([unwind.h], , [enable_prof_libgcc="0"]) michael@0: AC_CHECK_LIB([gcc], [_Unwind_Backtrace], [LIBS="$LIBS -lgcc"], [enable_prof_libgcc="0"]) michael@0: dnl The following is conservative, in that it only has entries for CPUs on michael@0: dnl which jemalloc has been tested. michael@0: AC_MSG_CHECKING([libgcc-based backtracing reliability on ${host_cpu}]) michael@0: case "${host_cpu}" in michael@0: i[[3456]]86) michael@0: AC_MSG_RESULT([unreliable]) michael@0: enable_prof_libgcc="0"; michael@0: ;; michael@0: x86_64) michael@0: AC_MSG_RESULT([reliable]) michael@0: ;; michael@0: *) michael@0: AC_MSG_RESULT([unreliable]) michael@0: enable_prof_libgcc="0"; michael@0: ;; michael@0: esac michael@0: if test "x${enable_prof_libgcc}" = "x1" ; then michael@0: backtrace_method="libgcc" michael@0: AC_DEFINE([JEMALLOC_PROF_LIBGCC], [ ]) michael@0: fi michael@0: else michael@0: enable_prof_libgcc="0" michael@0: fi michael@0: michael@0: AC_ARG_ENABLE([prof-gcc], michael@0: [AS_HELP_STRING([--disable-prof-gcc], michael@0: [Do not use gcc intrinsics for backtracing])], michael@0: [if test "x$enable_prof_gcc" = "xno" ; then michael@0: enable_prof_gcc="0" michael@0: else michael@0: enable_prof_gcc="1" michael@0: fi michael@0: ], michael@0: [enable_prof_gcc="1"] michael@0: ) michael@0: if test "x$backtrace_method" = "x" -a "x$enable_prof_gcc" = "x1" \ michael@0: -a "x$GCC" = "xyes" ; then michael@0: backtrace_method="gcc intrinsics" michael@0: AC_DEFINE([JEMALLOC_PROF_GCC], [ ]) michael@0: else michael@0: enable_prof_gcc="0" michael@0: fi michael@0: michael@0: if test "x$backtrace_method" = "x" ; then michael@0: backtrace_method="none (disabling profiling)" michael@0: enable_prof="0" michael@0: fi michael@0: AC_MSG_CHECKING([configured backtracing method]) michael@0: AC_MSG_RESULT([$backtrace_method]) michael@0: if test "x$enable_prof" = "x1" ; then michael@0: if test "x${force_tls}" = "x0" ; then michael@0: AC_MSG_ERROR([Heap profiling requires TLS]); michael@0: fi michael@0: force_tls="1" michael@0: AC_DEFINE([JEMALLOC_PROF], [ ]) michael@0: fi michael@0: AC_SUBST([enable_prof]) michael@0: michael@0: dnl Enable thread-specific caching by default. michael@0: AC_ARG_ENABLE([tcache], michael@0: [AS_HELP_STRING([--disable-tcache], [Disable per thread caches])], michael@0: [if test "x$enable_tcache" = "xno" ; then michael@0: enable_tcache="0" michael@0: else michael@0: enable_tcache="1" michael@0: fi michael@0: ], michael@0: [enable_tcache="1"] michael@0: ) michael@0: if test "x$enable_tcache" = "x1" ; then michael@0: AC_DEFINE([JEMALLOC_TCACHE], [ ]) michael@0: fi michael@0: AC_SUBST([enable_tcache]) michael@0: michael@0: dnl Disable mremap() for huge realloc() by default. michael@0: AC_ARG_ENABLE([mremap], michael@0: [AS_HELP_STRING([--enable-mremap], [Enable mremap(2) for huge realloc()])], michael@0: [if test "x$enable_mremap" = "xno" ; then michael@0: enable_mremap="0" michael@0: else michael@0: enable_mremap="1" michael@0: fi michael@0: ], michael@0: [enable_mremap="0"] michael@0: ) michael@0: if test "x$enable_mremap" = "x1" ; then michael@0: JE_COMPILABLE([mremap(...MREMAP_FIXED...)], [ michael@0: #define _GNU_SOURCE michael@0: #include michael@0: ], [ michael@0: void *p = mremap((void *)0, 0, 0, MREMAP_MAYMOVE|MREMAP_FIXED, (void *)0); michael@0: ], [je_cv_mremap_fixed]) michael@0: if test "x${je_cv_mremap_fixed}" = "xno" ; then michael@0: enable_mremap="0" michael@0: fi michael@0: fi michael@0: if test "x$enable_mremap" = "x1" ; then michael@0: AC_DEFINE([JEMALLOC_MREMAP], [ ]) michael@0: fi michael@0: AC_SUBST([enable_mremap]) michael@0: michael@0: dnl Enable VM deallocation via munmap() by default. michael@0: AC_ARG_ENABLE([munmap], michael@0: [AS_HELP_STRING([--disable-munmap], [Disable VM deallocation via munmap(2)])], michael@0: [if test "x$enable_munmap" = "xno" ; then michael@0: enable_munmap="0" michael@0: else michael@0: enable_munmap="1" michael@0: fi michael@0: ], michael@0: [enable_munmap="${default_munmap}"] michael@0: ) michael@0: if test "x$enable_munmap" = "x1" ; then michael@0: AC_DEFINE([JEMALLOC_MUNMAP], [ ]) michael@0: fi michael@0: AC_SUBST([enable_munmap]) michael@0: michael@0: dnl Do not enable allocation from DSS by default. michael@0: AC_ARG_ENABLE([dss], michael@0: [AS_HELP_STRING([--enable-dss], [Enable allocation from DSS])], michael@0: [if test "x$enable_dss" = "xno" ; then michael@0: enable_dss="0" michael@0: else michael@0: enable_dss="1" michael@0: fi michael@0: ], michael@0: [enable_dss="0"] michael@0: ) michael@0: dnl Check whether the BSD/SUSv1 sbrk() exists. If not, disable DSS support. michael@0: AC_CHECK_FUNC([sbrk], [have_sbrk="1"], [have_sbrk="0"]) michael@0: if test "x$have_sbrk" = "x1" ; then michael@0: AC_DEFINE([JEMALLOC_HAVE_SBRK], [ ]) michael@0: else michael@0: enable_dss="0" michael@0: fi michael@0: michael@0: if test "x$enable_dss" = "x1" ; then michael@0: AC_DEFINE([JEMALLOC_DSS], [ ]) michael@0: fi michael@0: AC_SUBST([enable_dss]) michael@0: michael@0: dnl Support the junk/zero filling option by default. michael@0: AC_ARG_ENABLE([fill], michael@0: [AS_HELP_STRING([--disable-fill], michael@0: [Disable support for junk/zero filling, quarantine, and redzones])], michael@0: [if test "x$enable_fill" = "xno" ; then michael@0: enable_fill="0" michael@0: else michael@0: enable_fill="1" michael@0: fi michael@0: ], michael@0: [enable_fill="1"] michael@0: ) michael@0: if test "x$enable_fill" = "x1" ; then michael@0: AC_DEFINE([JEMALLOC_FILL], [ ]) michael@0: fi michael@0: AC_SUBST([enable_fill]) michael@0: michael@0: dnl Disable utrace(2)-based tracing by default. michael@0: AC_ARG_ENABLE([utrace], michael@0: [AS_HELP_STRING([--enable-utrace], [Enable utrace(2)-based tracing])], michael@0: [if test "x$enable_utrace" = "xno" ; then michael@0: enable_utrace="0" michael@0: else michael@0: enable_utrace="1" michael@0: fi michael@0: ], michael@0: [enable_utrace="0"] michael@0: ) michael@0: JE_COMPILABLE([utrace(2)], [ michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: #include michael@0: ], [ michael@0: utrace((void *)0, 0); michael@0: ], [je_cv_utrace]) michael@0: if test "x${je_cv_utrace}" = "xno" ; then michael@0: enable_utrace="0" michael@0: fi michael@0: if test "x$enable_utrace" = "x1" ; then michael@0: AC_DEFINE([JEMALLOC_UTRACE], [ ]) michael@0: fi michael@0: AC_SUBST([enable_utrace]) michael@0: michael@0: dnl Support Valgrind by default. michael@0: AC_ARG_ENABLE([valgrind], michael@0: [AS_HELP_STRING([--disable-valgrind], [Disable support for Valgrind])], michael@0: [if test "x$enable_valgrind" = "xno" ; then michael@0: enable_valgrind="0" michael@0: else michael@0: enable_valgrind="1" michael@0: fi michael@0: ], michael@0: [enable_valgrind="1"] michael@0: ) michael@0: if test "x$enable_valgrind" = "x1" ; then michael@0: JE_COMPILABLE([valgrind], [ michael@0: #include michael@0: #include michael@0: michael@0: #if !defined(VALGRIND_RESIZEINPLACE_BLOCK) michael@0: # error "Incompatible Valgrind version" michael@0: #endif michael@0: ], [], [je_cv_valgrind]) michael@0: if test "x${je_cv_valgrind}" = "xno" ; then michael@0: enable_valgrind="0" michael@0: fi michael@0: if test "x$enable_valgrind" = "x1" ; then michael@0: AC_DEFINE([JEMALLOC_VALGRIND], [ ]) michael@0: fi michael@0: fi michael@0: AC_SUBST([enable_valgrind]) michael@0: michael@0: dnl Do not support the xmalloc option by default. michael@0: AC_ARG_ENABLE([xmalloc], michael@0: [AS_HELP_STRING([--enable-xmalloc], [Support xmalloc option])], michael@0: [if test "x$enable_xmalloc" = "xno" ; then michael@0: enable_xmalloc="0" michael@0: else michael@0: enable_xmalloc="1" michael@0: fi michael@0: ], michael@0: [enable_xmalloc="0"] michael@0: ) michael@0: if test "x$enable_xmalloc" = "x1" ; then michael@0: AC_DEFINE([JEMALLOC_XMALLOC], [ ]) michael@0: fi michael@0: AC_SUBST([enable_xmalloc]) michael@0: michael@0: AC_CACHE_CHECK([STATIC_PAGE_SHIFT], michael@0: [je_cv_static_page_shift], michael@0: AC_RUN_IFELSE([AC_LANG_PROGRAM( michael@0: [[ michael@0: #include michael@0: #ifdef _WIN32 michael@0: #include michael@0: #else michael@0: #include michael@0: #endif michael@0: #include michael@0: ]], michael@0: [[ michael@0: long result; michael@0: FILE *f; michael@0: michael@0: #ifdef _WIN32 michael@0: SYSTEM_INFO si; michael@0: GetSystemInfo(&si); michael@0: result = si.dwPageSize; michael@0: #else michael@0: result = sysconf(_SC_PAGESIZE); michael@0: #endif michael@0: if (result == -1) { michael@0: return 1; michael@0: } michael@0: result = ffsl(result) - 1; michael@0: michael@0: f = fopen("conftest.out", "w"); michael@0: if (f == NULL) { michael@0: return 1; michael@0: } michael@0: fprintf(f, "%u\n", result); michael@0: fclose(f); michael@0: michael@0: return 0; michael@0: ]])], michael@0: [je_cv_static_page_shift=`cat conftest.out`], michael@0: [je_cv_static_page_shift=undefined])) michael@0: michael@0: if test "x$je_cv_static_page_shift" != "xundefined"; then michael@0: AC_DEFINE_UNQUOTED([STATIC_PAGE_SHIFT], [$je_cv_static_page_shift]) michael@0: else michael@0: AC_MSG_ERROR([cannot determine value for STATIC_PAGE_SHIFT]) michael@0: fi michael@0: michael@0: dnl ============================================================================ michael@0: dnl jemalloc configuration. michael@0: dnl michael@0: michael@0: dnl Set VERSION if source directory has an embedded git repository. michael@0: if test -d "${srcroot}.git" ; then michael@0: git describe --long --abbrev=40 > ${srcroot}VERSION michael@0: fi michael@0: jemalloc_version=`cat ${srcroot}VERSION` michael@0: jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'` michael@0: jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'` michael@0: jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'` michael@0: jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'` michael@0: jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'` michael@0: AC_SUBST([jemalloc_version]) michael@0: AC_SUBST([jemalloc_version_major]) michael@0: AC_SUBST([jemalloc_version_minor]) michael@0: AC_SUBST([jemalloc_version_bugfix]) michael@0: AC_SUBST([jemalloc_version_nrev]) michael@0: AC_SUBST([jemalloc_version_gid]) michael@0: michael@0: dnl ============================================================================ michael@0: dnl Configure pthreads. michael@0: michael@0: if test "x$abi" != "xpecoff" ; then michael@0: AC_CHECK_HEADERS([pthread.h], , [AC_MSG_ERROR([pthread.h is missing])]) michael@0: dnl Some systems may embed pthreads functionality in libc; check for libpthread michael@0: dnl first, but try libc too before failing. michael@0: AC_CHECK_LIB([pthread], [pthread_create], [LIBS="$LIBS -lpthread"], michael@0: [AC_SEARCH_LIBS([pthread_create], , , michael@0: AC_MSG_ERROR([libpthread is missing]))]) michael@0: fi michael@0: michael@0: CPPFLAGS="$CPPFLAGS -D_REENTRANT" michael@0: michael@0: dnl Check whether the BSD-specific _malloc_thread_cleanup() exists. If so, use michael@0: dnl it rather than pthreads TSD cleanup functions to support cleanup during michael@0: dnl thread exit, in order to avoid pthreads library recursion during michael@0: dnl bootstrapping. michael@0: AC_CHECK_FUNC([_malloc_thread_cleanup], michael@0: [have__malloc_thread_cleanup="1"], michael@0: [have__malloc_thread_cleanup="0"] michael@0: ) michael@0: if test "x$have__malloc_thread_cleanup" = "x1" ; then michael@0: AC_DEFINE([JEMALLOC_MALLOC_THREAD_CLEANUP], [ ]) michael@0: force_tls="1" michael@0: fi michael@0: michael@0: dnl Check whether the BSD-specific _pthread_mutex_init_calloc_cb() exists. If michael@0: dnl so, mutex initialization causes allocation, and we need to implement this michael@0: dnl callback function in order to prevent recursive allocation. michael@0: AC_CHECK_FUNC([_pthread_mutex_init_calloc_cb], michael@0: [have__pthread_mutex_init_calloc_cb="1"], michael@0: [have__pthread_mutex_init_calloc_cb="0"] michael@0: ) michael@0: if test "x$have__pthread_mutex_init_calloc_cb" = "x1" ; then michael@0: AC_DEFINE([JEMALLOC_MUTEX_INIT_CB]) michael@0: fi michael@0: michael@0: dnl Disable lazy locking by default. michael@0: AC_ARG_ENABLE([lazy_lock], michael@0: [AS_HELP_STRING([--enable-lazy-lock], michael@0: [Enable lazy locking (only lock when multi-threaded)])], michael@0: [if test "x$enable_lazy_lock" = "xno" ; then michael@0: enable_lazy_lock="0" michael@0: else michael@0: enable_lazy_lock="1" michael@0: fi michael@0: ], michael@0: [enable_lazy_lock="0"] michael@0: ) michael@0: if test "x$enable_lazy_lock" = "x0" -a "x${force_lazy_lock}" = "x1" ; then michael@0: AC_MSG_RESULT([Forcing lazy-lock to avoid allocator/threading bootstrap issues]) michael@0: enable_lazy_lock="1" michael@0: fi michael@0: if test "x$enable_lazy_lock" = "x1" ; then michael@0: if test "x$abi" != "xpecoff" ; then michael@0: AC_CHECK_HEADERS([dlfcn.h], , [AC_MSG_ERROR([dlfcn.h is missing])]) michael@0: AC_CHECK_FUNC([dlsym], [], michael@0: [AC_CHECK_LIB([dl], [dlsym], [LIBS="$LIBS -ldl"], michael@0: [AC_MSG_ERROR([libdl is missing])]) michael@0: ]) michael@0: fi michael@0: AC_DEFINE([JEMALLOC_LAZY_LOCK], [ ]) michael@0: fi michael@0: AC_SUBST([enable_lazy_lock]) michael@0: michael@0: AC_ARG_ENABLE([tls], michael@0: [AS_HELP_STRING([--disable-tls], [Disable thread-local storage (__thread keyword)])], michael@0: if test "x$enable_tls" = "xno" ; then michael@0: enable_tls="0" michael@0: else michael@0: enable_tls="1" michael@0: fi michael@0: , michael@0: enable_tls="1" michael@0: ) michael@0: if test "x${enable_tls}" = "x0" -a "x${force_tls}" = "x1" ; then michael@0: AC_MSG_RESULT([Forcing TLS to avoid allocator/threading bootstrap issues]) michael@0: enable_tls="1" michael@0: fi michael@0: if test "x${enable_tls}" = "x1" -a "x${force_tls}" = "x0" ; then michael@0: AC_MSG_RESULT([Forcing no TLS to avoid allocator/threading bootstrap issues]) michael@0: enable_tls="0" michael@0: fi michael@0: if test "x${enable_tls}" = "x1" ; then michael@0: AC_MSG_CHECKING([for TLS]) michael@0: AC_COMPILE_IFELSE([AC_LANG_PROGRAM( michael@0: [[ michael@0: __thread int x; michael@0: ]], [[ michael@0: x = 42; michael@0: michael@0: return 0; michael@0: ]])], michael@0: AC_MSG_RESULT([yes]), michael@0: AC_MSG_RESULT([no]) michael@0: enable_tls="0") michael@0: fi michael@0: AC_SUBST([enable_tls]) michael@0: if test "x${enable_tls}" = "x1" ; then michael@0: AC_DEFINE_UNQUOTED([JEMALLOC_TLS], [ ]) michael@0: elif test "x${force_tls}" = "x1" ; then michael@0: AC_MSG_ERROR([Failed to configure TLS, which is mandatory for correct function]) michael@0: fi michael@0: michael@0: dnl ============================================================================ michael@0: dnl Check for ffsl(3), and fail if not found. This function exists on all michael@0: dnl platforms that jemalloc currently has a chance of functioning on without michael@0: dnl modification. michael@0: JE_COMPILABLE([a program using ffsl], [ michael@0: #include michael@0: #include michael@0: ], [ michael@0: { michael@0: int rv = ffsl(0x08); michael@0: } michael@0: ], [je_cv_function_ffsl]) michael@0: if test "x${je_cv_function_ffsl}" != "xyes" ; then michael@0: AC_MSG_ERROR([Cannot build without ffsl(3)]) michael@0: fi michael@0: michael@0: dnl ============================================================================ michael@0: dnl Check for atomic(9) operations as provided on FreeBSD. michael@0: michael@0: JE_COMPILABLE([atomic(9)], [ michael@0: #include michael@0: #include michael@0: #include michael@0: ], [ michael@0: { michael@0: uint32_t x32 = 0; michael@0: volatile uint32_t *x32p = &x32; michael@0: atomic_fetchadd_32(x32p, 1); michael@0: } michael@0: { michael@0: unsigned long xlong = 0; michael@0: volatile unsigned long *xlongp = &xlong; michael@0: atomic_fetchadd_long(xlongp, 1); michael@0: } michael@0: ], [je_cv_atomic9]) michael@0: if test "x${je_cv_atomic9}" = "xyes" ; then michael@0: AC_DEFINE([JEMALLOC_ATOMIC9]) michael@0: fi michael@0: michael@0: dnl ============================================================================ michael@0: dnl Check for atomic(3) operations as provided on Darwin. michael@0: michael@0: JE_COMPILABLE([Darwin OSAtomic*()], [ michael@0: #include michael@0: #include michael@0: ], [ michael@0: { michael@0: int32_t x32 = 0; michael@0: volatile int32_t *x32p = &x32; michael@0: OSAtomicAdd32(1, x32p); michael@0: } michael@0: { michael@0: int64_t x64 = 0; michael@0: volatile int64_t *x64p = &x64; michael@0: OSAtomicAdd64(1, x64p); michael@0: } michael@0: ], [je_cv_osatomic]) michael@0: if test "x${je_cv_osatomic}" = "xyes" ; then michael@0: AC_DEFINE([JEMALLOC_OSATOMIC], [ ]) michael@0: fi michael@0: michael@0: dnl ============================================================================ michael@0: dnl Check whether __sync_{add,sub}_and_fetch() are available despite michael@0: dnl __GCC_HAVE_SYNC_COMPARE_AND_SWAP_n macros being undefined. michael@0: michael@0: AC_DEFUN([JE_SYNC_COMPARE_AND_SWAP_CHECK],[ michael@0: AC_CACHE_CHECK([whether to force $1-bit __sync_{add,sub}_and_fetch()], michael@0: [je_cv_sync_compare_and_swap_$2], michael@0: [AC_LINK_IFELSE([AC_LANG_PROGRAM([ michael@0: #include michael@0: ], michael@0: [ michael@0: #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2 michael@0: { michael@0: uint$1_t x$1 = 0; michael@0: __sync_add_and_fetch(&x$1, 42); michael@0: __sync_sub_and_fetch(&x$1, 1); michael@0: } michael@0: #else michael@0: #error __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2 is defined, no need to force michael@0: #endif michael@0: ])], michael@0: [je_cv_sync_compare_and_swap_$2=yes], michael@0: [je_cv_sync_compare_and_swap_$2=no])]) michael@0: michael@0: if test "x${je_cv_sync_compare_and_swap_$2}" = "xyes" ; then michael@0: AC_DEFINE([JE_FORCE_SYNC_COMPARE_AND_SWAP_$2], [ ]) michael@0: fi michael@0: ]) michael@0: michael@0: if test "x${je_cv_atomic9}" != "xyes" -a "x${je_cv_osatomic}" != "xyes" ; then michael@0: JE_SYNC_COMPARE_AND_SWAP_CHECK(32, 4) michael@0: JE_SYNC_COMPARE_AND_SWAP_CHECK(64, 8) michael@0: fi michael@0: michael@0: dnl ============================================================================ michael@0: dnl Check for spinlock(3) operations as provided on Darwin. michael@0: michael@0: JE_COMPILABLE([Darwin OSSpin*()], [ michael@0: #include michael@0: #include michael@0: ], [ michael@0: OSSpinLock lock = 0; michael@0: OSSpinLockLock(&lock); michael@0: OSSpinLockUnlock(&lock); michael@0: ], [je_cv_osspin]) michael@0: if test "x${je_cv_osspin}" = "xyes" ; then michael@0: AC_DEFINE([JEMALLOC_OSSPIN], [ ]) michael@0: fi michael@0: michael@0: dnl ============================================================================ michael@0: dnl Darwin-related configuration. michael@0: michael@0: if test "x${abi}" = "xmacho" ; then michael@0: AC_DEFINE([JEMALLOC_IVSALLOC], [ ]) michael@0: AC_DEFINE([JEMALLOC_ZONE], [ ]) michael@0: michael@0: dnl The szone version jumped from 3 to 6 between the OS X 10.5.x and 10.6 michael@0: dnl releases. malloc_zone_t and malloc_introspection_t have new fields in michael@0: dnl 10.6, which is the only source-level indication of the change. michael@0: AC_MSG_CHECKING([malloc zone version]) michael@0: AC_DEFUN([JE_ZONE_PROGRAM], michael@0: [AC_LANG_PROGRAM( michael@0: [#include ], michael@0: [static foo[[sizeof($1) $2 sizeof(void *) * $3 ? 1 : -1]]] michael@0: )]) michael@0: michael@0: AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,14)],[JEMALLOC_ZONE_VERSION=3],[ michael@0: AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,15)],[JEMALLOC_ZONE_VERSION=5],[ michael@0: AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,16)],[ michael@0: AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,9)],[JEMALLOC_ZONE_VERSION=6],[ michael@0: AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,13)],[JEMALLOC_ZONE_VERSION=7],[JEMALLOC_ZONE_VERSION=] michael@0: )])],[ michael@0: AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,17)],[JEMALLOC_ZONE_VERSION=8],[ michael@0: AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,>,17)],[JEMALLOC_ZONE_VERSION=9],[JEMALLOC_ZONE_VERSION=] michael@0: )])])])]) michael@0: if test "x${JEMALLOC_ZONE_VERSION}" = "x"; then michael@0: AC_MSG_RESULT([unsupported]) michael@0: AC_MSG_ERROR([Unsupported malloc zone version]) michael@0: fi michael@0: if test "${JEMALLOC_ZONE_VERSION}" = 9; then michael@0: JEMALLOC_ZONE_VERSION=8 michael@0: AC_MSG_RESULT([> 8]) michael@0: else michael@0: AC_MSG_RESULT([$JEMALLOC_ZONE_VERSION]) michael@0: fi michael@0: AC_DEFINE_UNQUOTED(JEMALLOC_ZONE_VERSION, [$JEMALLOC_ZONE_VERSION]) michael@0: fi michael@0: michael@0: dnl ============================================================================ michael@0: dnl Check for typedefs, structures, and compiler characteristics. michael@0: AC_HEADER_STDBOOL michael@0: michael@0: AC_CONFIG_COMMANDS([include/jemalloc/internal/size_classes.h], [ michael@0: mkdir -p "include/jemalloc/internal" michael@0: "${srcdir}/include/jemalloc/internal/size_classes.sh" > "${objroot}include/jemalloc/internal/size_classes.h" michael@0: ]) michael@0: michael@0: dnl Process .in files. michael@0: AC_SUBST([cfghdrs_in]) michael@0: AC_SUBST([cfghdrs_out]) michael@0: AC_CONFIG_HEADERS([$cfghdrs_tup]) michael@0: michael@0: dnl ============================================================================ michael@0: dnl Generate outputs. michael@0: AC_CONFIG_FILES([$cfgoutputs_tup config.stamp bin/jemalloc.sh]) michael@0: AC_SUBST([cfgoutputs_in]) michael@0: AC_SUBST([cfgoutputs_out]) michael@0: AC_OUTPUT michael@0: michael@0: dnl ============================================================================ michael@0: dnl Print out the results of configuration. michael@0: AC_MSG_RESULT([===============================================================================]) michael@0: AC_MSG_RESULT([jemalloc version : ${jemalloc_version}]) michael@0: AC_MSG_RESULT([library revision : ${rev}]) michael@0: AC_MSG_RESULT([]) michael@0: AC_MSG_RESULT([CC : ${CC}]) michael@0: AC_MSG_RESULT([CPPFLAGS : ${CPPFLAGS}]) michael@0: AC_MSG_RESULT([CFLAGS : ${CFLAGS}]) michael@0: AC_MSG_RESULT([LDFLAGS : ${LDFLAGS}]) michael@0: AC_MSG_RESULT([LIBS : ${LIBS}]) michael@0: AC_MSG_RESULT([RPATH_EXTRA : ${RPATH_EXTRA}]) michael@0: AC_MSG_RESULT([]) michael@0: AC_MSG_RESULT([XSLTPROC : ${XSLTPROC}]) michael@0: AC_MSG_RESULT([XSLROOT : ${XSLROOT}]) michael@0: AC_MSG_RESULT([]) michael@0: AC_MSG_RESULT([PREFIX : ${PREFIX}]) michael@0: AC_MSG_RESULT([BINDIR : ${BINDIR}]) michael@0: AC_MSG_RESULT([INCLUDEDIR : ${INCLUDEDIR}]) michael@0: AC_MSG_RESULT([LIBDIR : ${LIBDIR}]) michael@0: AC_MSG_RESULT([DATADIR : ${DATADIR}]) michael@0: AC_MSG_RESULT([MANDIR : ${MANDIR}]) michael@0: AC_MSG_RESULT([]) michael@0: AC_MSG_RESULT([srcroot : ${srcroot}]) michael@0: AC_MSG_RESULT([abs_srcroot : ${abs_srcroot}]) michael@0: AC_MSG_RESULT([objroot : ${objroot}]) michael@0: AC_MSG_RESULT([abs_objroot : ${abs_objroot}]) michael@0: AC_MSG_RESULT([]) michael@0: AC_MSG_RESULT([JEMALLOC_PREFIX : ${JEMALLOC_PREFIX}]) michael@0: AC_MSG_RESULT([JEMALLOC_PRIVATE_NAMESPACE]) michael@0: AC_MSG_RESULT([ : ${JEMALLOC_PRIVATE_NAMESPACE}]) michael@0: AC_MSG_RESULT([install_suffix : ${install_suffix}]) michael@0: AC_MSG_RESULT([autogen : ${enable_autogen}]) michael@0: AC_MSG_RESULT([experimental : ${enable_experimental}]) michael@0: AC_MSG_RESULT([cc-silence : ${enable_cc_silence}]) michael@0: AC_MSG_RESULT([debug : ${enable_debug}]) michael@0: AC_MSG_RESULT([stats : ${enable_stats}]) michael@0: AC_MSG_RESULT([prof : ${enable_prof}]) michael@0: AC_MSG_RESULT([prof-libunwind : ${enable_prof_libunwind}]) michael@0: AC_MSG_RESULT([prof-libgcc : ${enable_prof_libgcc}]) michael@0: AC_MSG_RESULT([prof-gcc : ${enable_prof_gcc}]) michael@0: AC_MSG_RESULT([tcache : ${enable_tcache}]) michael@0: AC_MSG_RESULT([fill : ${enable_fill}]) michael@0: AC_MSG_RESULT([utrace : ${enable_utrace}]) michael@0: AC_MSG_RESULT([valgrind : ${enable_valgrind}]) michael@0: AC_MSG_RESULT([xmalloc : ${enable_xmalloc}]) michael@0: AC_MSG_RESULT([mremap : ${enable_mremap}]) michael@0: AC_MSG_RESULT([munmap : ${enable_munmap}]) michael@0: AC_MSG_RESULT([dss : ${enable_dss}]) michael@0: AC_MSG_RESULT([lazy_lock : ${enable_lazy_lock}]) michael@0: AC_MSG_RESULT([tls : ${enable_tls}]) michael@0: AC_MSG_RESULT([===============================================================================])