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