Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | dnl Process this file with autoconf to produce a configure script. |
michael@0 | 2 | AC_INIT([Makefile.in]) |
michael@0 | 3 | |
michael@0 | 4 | dnl ============================================================================ |
michael@0 | 5 | dnl Custom macro definitions. |
michael@0 | 6 | |
michael@0 | 7 | dnl JE_CFLAGS_APPEND(cflag) |
michael@0 | 8 | AC_DEFUN([JE_CFLAGS_APPEND], |
michael@0 | 9 | [ |
michael@0 | 10 | AC_MSG_CHECKING([whether compiler supports $1]) |
michael@0 | 11 | TCFLAGS="${CFLAGS}" |
michael@0 | 12 | if test "x${CFLAGS}" = "x" ; then |
michael@0 | 13 | CFLAGS="$1" |
michael@0 | 14 | else |
michael@0 | 15 | CFLAGS="${CFLAGS} $1" |
michael@0 | 16 | fi |
michael@0 | 17 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM( |
michael@0 | 18 | [[ |
michael@0 | 19 | ]], [[ |
michael@0 | 20 | return 0; |
michael@0 | 21 | ]])], |
michael@0 | 22 | AC_MSG_RESULT([yes]), |
michael@0 | 23 | AC_MSG_RESULT([no]) |
michael@0 | 24 | [CFLAGS="${TCFLAGS}"] |
michael@0 | 25 | ) |
michael@0 | 26 | ]) |
michael@0 | 27 | |
michael@0 | 28 | dnl JE_COMPILABLE(label, hcode, mcode, rvar) |
michael@0 | 29 | dnl |
michael@0 | 30 | dnl Use AC_LINK_IFELSE() rather than AC_COMPILE_IFELSE() so that linker errors |
michael@0 | 31 | dnl cause failure. |
michael@0 | 32 | AC_DEFUN([JE_COMPILABLE], |
michael@0 | 33 | [ |
michael@0 | 34 | AC_CACHE_CHECK([whether $1 is compilable], |
michael@0 | 35 | [$4], |
michael@0 | 36 | [AC_LINK_IFELSE([AC_LANG_PROGRAM([$2], |
michael@0 | 37 | [$3])], |
michael@0 | 38 | [$4=yes], |
michael@0 | 39 | [$4=no])]) |
michael@0 | 40 | ]) |
michael@0 | 41 | |
michael@0 | 42 | dnl ============================================================================ |
michael@0 | 43 | |
michael@0 | 44 | dnl Library revision. |
michael@0 | 45 | rev=1 |
michael@0 | 46 | AC_SUBST([rev]) |
michael@0 | 47 | |
michael@0 | 48 | srcroot=$srcdir |
michael@0 | 49 | if test "x${srcroot}" = "x." ; then |
michael@0 | 50 | srcroot="" |
michael@0 | 51 | else |
michael@0 | 52 | srcroot="${srcroot}/" |
michael@0 | 53 | fi |
michael@0 | 54 | AC_SUBST([srcroot]) |
michael@0 | 55 | abs_srcroot="`cd \"${srcdir}\"; pwd`/" |
michael@0 | 56 | AC_SUBST([abs_srcroot]) |
michael@0 | 57 | |
michael@0 | 58 | objroot="" |
michael@0 | 59 | AC_SUBST([objroot]) |
michael@0 | 60 | abs_objroot="`pwd`/" |
michael@0 | 61 | AC_SUBST([abs_objroot]) |
michael@0 | 62 | |
michael@0 | 63 | dnl Munge install path variables. |
michael@0 | 64 | if test "x$prefix" = "xNONE" ; then |
michael@0 | 65 | prefix="/usr/local" |
michael@0 | 66 | fi |
michael@0 | 67 | if test "x$exec_prefix" = "xNONE" ; then |
michael@0 | 68 | exec_prefix=$prefix |
michael@0 | 69 | fi |
michael@0 | 70 | PREFIX=$prefix |
michael@0 | 71 | AC_SUBST([PREFIX]) |
michael@0 | 72 | BINDIR=`eval echo $bindir` |
michael@0 | 73 | BINDIR=`eval echo $BINDIR` |
michael@0 | 74 | AC_SUBST([BINDIR]) |
michael@0 | 75 | INCLUDEDIR=`eval echo $includedir` |
michael@0 | 76 | INCLUDEDIR=`eval echo $INCLUDEDIR` |
michael@0 | 77 | AC_SUBST([INCLUDEDIR]) |
michael@0 | 78 | LIBDIR=`eval echo $libdir` |
michael@0 | 79 | LIBDIR=`eval echo $LIBDIR` |
michael@0 | 80 | AC_SUBST([LIBDIR]) |
michael@0 | 81 | DATADIR=`eval echo $datadir` |
michael@0 | 82 | DATADIR=`eval echo $DATADIR` |
michael@0 | 83 | AC_SUBST([DATADIR]) |
michael@0 | 84 | MANDIR=`eval echo $mandir` |
michael@0 | 85 | MANDIR=`eval echo $MANDIR` |
michael@0 | 86 | AC_SUBST([MANDIR]) |
michael@0 | 87 | |
michael@0 | 88 | dnl Support for building documentation. |
michael@0 | 89 | AC_PATH_PROG([XSLTPROC], [xsltproc], , [$PATH]) |
michael@0 | 90 | if test -d "/usr/share/xml/docbook/stylesheet/docbook-xsl" ; then |
michael@0 | 91 | DEFAULT_XSLROOT="/usr/share/xml/docbook/stylesheet/docbook-xsl" |
michael@0 | 92 | elif test -d "/usr/share/sgml/docbook/xsl-stylesheets" ; then |
michael@0 | 93 | DEFAULT_XSLROOT="/usr/share/sgml/docbook/xsl-stylesheets" |
michael@0 | 94 | else |
michael@0 | 95 | dnl Documentation building will fail if this default gets used. |
michael@0 | 96 | DEFAULT_XSLROOT="" |
michael@0 | 97 | fi |
michael@0 | 98 | AC_ARG_WITH([xslroot], |
michael@0 | 99 | [AS_HELP_STRING([--with-xslroot=<path>], [XSL stylesheet root path])], [ |
michael@0 | 100 | if test "x$with_xslroot" = "xno" ; then |
michael@0 | 101 | XSLROOT="${DEFAULT_XSLROOT}" |
michael@0 | 102 | else |
michael@0 | 103 | XSLROOT="${with_xslroot}" |
michael@0 | 104 | fi |
michael@0 | 105 | ], |
michael@0 | 106 | XSLROOT="${DEFAULT_XSLROOT}" |
michael@0 | 107 | ) |
michael@0 | 108 | AC_SUBST([XSLROOT]) |
michael@0 | 109 | |
michael@0 | 110 | dnl If CFLAGS isn't defined, set CFLAGS to something reasonable. Otherwise, |
michael@0 | 111 | dnl just prevent autoconf from molesting CFLAGS. |
michael@0 | 112 | CFLAGS=$CFLAGS |
michael@0 | 113 | AC_PROG_CC |
michael@0 | 114 | if test "x$GCC" != "xyes" ; then |
michael@0 | 115 | AC_CACHE_CHECK([whether compiler is MSVC], |
michael@0 | 116 | [je_cv_msvc], |
michael@0 | 117 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], |
michael@0 | 118 | [ |
michael@0 | 119 | #ifndef _MSC_VER |
michael@0 | 120 | int fail[-1]; |
michael@0 | 121 | #endif |
michael@0 | 122 | ])], |
michael@0 | 123 | [je_cv_msvc=yes], |
michael@0 | 124 | [je_cv_msvc=no])]) |
michael@0 | 125 | fi |
michael@0 | 126 | |
michael@0 | 127 | if test "x$CFLAGS" = "x" ; then |
michael@0 | 128 | no_CFLAGS="yes" |
michael@0 | 129 | if test "x$GCC" = "xyes" ; then |
michael@0 | 130 | JE_CFLAGS_APPEND([-std=gnu99]) |
michael@0 | 131 | JE_CFLAGS_APPEND([-Wall]) |
michael@0 | 132 | JE_CFLAGS_APPEND([-pipe]) |
michael@0 | 133 | JE_CFLAGS_APPEND([-g3]) |
michael@0 | 134 | elif test "x$je_cv_msvc" = "xyes" ; then |
michael@0 | 135 | CC="$CC -nologo" |
michael@0 | 136 | JE_CFLAGS_APPEND([-Zi]) |
michael@0 | 137 | JE_CFLAGS_APPEND([-MT]) |
michael@0 | 138 | JE_CFLAGS_APPEND([-W3]) |
michael@0 | 139 | CPPFLAGS="$CPPFLAGS -I${srcroot}/include/msvc_compat" |
michael@0 | 140 | fi |
michael@0 | 141 | fi |
michael@0 | 142 | dnl Append EXTRA_CFLAGS to CFLAGS, if defined. |
michael@0 | 143 | if test "x$EXTRA_CFLAGS" != "x" ; then |
michael@0 | 144 | JE_CFLAGS_APPEND([$EXTRA_CFLAGS]) |
michael@0 | 145 | fi |
michael@0 | 146 | AC_PROG_CPP |
michael@0 | 147 | |
michael@0 | 148 | AC_CHECK_SIZEOF([void *]) |
michael@0 | 149 | if test "x${ac_cv_sizeof_void_p}" = "x8" ; then |
michael@0 | 150 | LG_SIZEOF_PTR=3 |
michael@0 | 151 | elif test "x${ac_cv_sizeof_void_p}" = "x4" ; then |
michael@0 | 152 | LG_SIZEOF_PTR=2 |
michael@0 | 153 | else |
michael@0 | 154 | AC_MSG_ERROR([Unsupported pointer size: ${ac_cv_sizeof_void_p}]) |
michael@0 | 155 | fi |
michael@0 | 156 | AC_DEFINE_UNQUOTED([LG_SIZEOF_PTR], [$LG_SIZEOF_PTR]) |
michael@0 | 157 | |
michael@0 | 158 | AC_CHECK_SIZEOF([int]) |
michael@0 | 159 | if test "x${ac_cv_sizeof_int}" = "x8" ; then |
michael@0 | 160 | LG_SIZEOF_INT=3 |
michael@0 | 161 | elif test "x${ac_cv_sizeof_int}" = "x4" ; then |
michael@0 | 162 | LG_SIZEOF_INT=2 |
michael@0 | 163 | else |
michael@0 | 164 | AC_MSG_ERROR([Unsupported int size: ${ac_cv_sizeof_int}]) |
michael@0 | 165 | fi |
michael@0 | 166 | AC_DEFINE_UNQUOTED([LG_SIZEOF_INT], [$LG_SIZEOF_INT]) |
michael@0 | 167 | |
michael@0 | 168 | AC_CHECK_SIZEOF([long]) |
michael@0 | 169 | if test "x${ac_cv_sizeof_long}" = "x8" ; then |
michael@0 | 170 | LG_SIZEOF_LONG=3 |
michael@0 | 171 | elif test "x${ac_cv_sizeof_long}" = "x4" ; then |
michael@0 | 172 | LG_SIZEOF_LONG=2 |
michael@0 | 173 | else |
michael@0 | 174 | AC_MSG_ERROR([Unsupported long size: ${ac_cv_sizeof_long}]) |
michael@0 | 175 | fi |
michael@0 | 176 | AC_DEFINE_UNQUOTED([LG_SIZEOF_LONG], [$LG_SIZEOF_LONG]) |
michael@0 | 177 | |
michael@0 | 178 | AC_CHECK_SIZEOF([intmax_t]) |
michael@0 | 179 | if test "x${ac_cv_sizeof_intmax_t}" = "x16" ; then |
michael@0 | 180 | LG_SIZEOF_INTMAX_T=4 |
michael@0 | 181 | elif test "x${ac_cv_sizeof_intmax_t}" = "x8" ; then |
michael@0 | 182 | LG_SIZEOF_INTMAX_T=3 |
michael@0 | 183 | elif test "x${ac_cv_sizeof_intmax_t}" = "x4" ; then |
michael@0 | 184 | LG_SIZEOF_INTMAX_T=2 |
michael@0 | 185 | else |
michael@0 | 186 | AC_MSG_ERROR([Unsupported intmax_t size: ${ac_cv_sizeof_intmax_t}]) |
michael@0 | 187 | fi |
michael@0 | 188 | AC_DEFINE_UNQUOTED([LG_SIZEOF_INTMAX_T], [$LG_SIZEOF_INTMAX_T]) |
michael@0 | 189 | |
michael@0 | 190 | AC_CANONICAL_HOST |
michael@0 | 191 | dnl CPU-specific settings. |
michael@0 | 192 | CPU_SPINWAIT="" |
michael@0 | 193 | case "${host_cpu}" in |
michael@0 | 194 | i[[345]]86) |
michael@0 | 195 | ;; |
michael@0 | 196 | i686) |
michael@0 | 197 | JE_COMPILABLE([__asm__], [], [[__asm__ volatile("pause"); return 0;]], |
michael@0 | 198 | [je_cv_asm]) |
michael@0 | 199 | if test "x${je_cv_asm}" = "xyes" ; then |
michael@0 | 200 | CPU_SPINWAIT='__asm__ volatile("pause")' |
michael@0 | 201 | fi |
michael@0 | 202 | ;; |
michael@0 | 203 | x86_64) |
michael@0 | 204 | JE_COMPILABLE([__asm__ syntax], [], |
michael@0 | 205 | [[__asm__ volatile("pause"); return 0;]], [je_cv_asm]) |
michael@0 | 206 | if test "x${je_cv_asm}" = "xyes" ; then |
michael@0 | 207 | CPU_SPINWAIT='__asm__ volatile("pause")' |
michael@0 | 208 | fi |
michael@0 | 209 | ;; |
michael@0 | 210 | *) |
michael@0 | 211 | ;; |
michael@0 | 212 | esac |
michael@0 | 213 | AC_DEFINE_UNQUOTED([CPU_SPINWAIT], [$CPU_SPINWAIT]) |
michael@0 | 214 | |
michael@0 | 215 | LD_PRELOAD_VAR="LD_PRELOAD" |
michael@0 | 216 | so="so" |
michael@0 | 217 | importlib="${so}" |
michael@0 | 218 | o="$ac_objext" |
michael@0 | 219 | a="a" |
michael@0 | 220 | exe="$ac_exeext" |
michael@0 | 221 | libprefix="lib" |
michael@0 | 222 | DSO_LDFLAGS='-shared -Wl,-soname,$(@F)' |
michael@0 | 223 | RPATH='-Wl,-rpath,$(1)' |
michael@0 | 224 | SOREV="${so}.${rev}" |
michael@0 | 225 | PIC_CFLAGS='-fPIC -DPIC' |
michael@0 | 226 | CTARGET='-o $@' |
michael@0 | 227 | LDTARGET='-o $@' |
michael@0 | 228 | EXTRA_LDFLAGS= |
michael@0 | 229 | MKLIB='ar crus $@' |
michael@0 | 230 | CC_MM=1 |
michael@0 | 231 | |
michael@0 | 232 | dnl Platform-specific settings. abi and RPATH can probably be determined |
michael@0 | 233 | dnl programmatically, but doing so is error-prone, which makes it generally |
michael@0 | 234 | dnl not worth the trouble. |
michael@0 | 235 | dnl |
michael@0 | 236 | dnl Define cpp macros in CPPFLAGS, rather than doing AC_DEFINE(macro), since the |
michael@0 | 237 | dnl definitions need to be seen before any headers are included, which is a pain |
michael@0 | 238 | dnl to make happen otherwise. |
michael@0 | 239 | default_munmap="1" |
michael@0 | 240 | JEMALLOC_USABLE_SIZE_CONST="const" |
michael@0 | 241 | case "${host}" in |
michael@0 | 242 | *-*-darwin*) |
michael@0 | 243 | CFLAGS="$CFLAGS" |
michael@0 | 244 | abi="macho" |
michael@0 | 245 | AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ]) |
michael@0 | 246 | RPATH="" |
michael@0 | 247 | LD_PRELOAD_VAR="DYLD_INSERT_LIBRARIES" |
michael@0 | 248 | so="dylib" |
michael@0 | 249 | importlib="${so}" |
michael@0 | 250 | force_tls="0" |
michael@0 | 251 | DSO_LDFLAGS='-shared -Wl,-dylib_install_name,$(@F)' |
michael@0 | 252 | SOREV="${rev}.${so}" |
michael@0 | 253 | ;; |
michael@0 | 254 | *-*-freebsd*) |
michael@0 | 255 | CFLAGS="$CFLAGS" |
michael@0 | 256 | abi="elf" |
michael@0 | 257 | AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ]) |
michael@0 | 258 | force_lazy_lock="1" |
michael@0 | 259 | ;; |
michael@0 | 260 | *-*-linux*) |
michael@0 | 261 | CFLAGS="$CFLAGS" |
michael@0 | 262 | CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE" |
michael@0 | 263 | abi="elf" |
michael@0 | 264 | AC_DEFINE([JEMALLOC_PURGE_MADVISE_DONTNEED], [ ]) |
michael@0 | 265 | AC_DEFINE([JEMALLOC_THREADED_INIT], [ ]) |
michael@0 | 266 | JEMALLOC_USABLE_SIZE_CONST="" |
michael@0 | 267 | default_munmap="0" |
michael@0 | 268 | ;; |
michael@0 | 269 | *-*-netbsd*) |
michael@0 | 270 | AC_MSG_CHECKING([ABI]) |
michael@0 | 271 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM( |
michael@0 | 272 | [[#ifdef __ELF__ |
michael@0 | 273 | /* ELF */ |
michael@0 | 274 | #else |
michael@0 | 275 | #error aout |
michael@0 | 276 | #endif |
michael@0 | 277 | ]])], |
michael@0 | 278 | [CFLAGS="$CFLAGS"; abi="elf"], |
michael@0 | 279 | [abi="aout"]) |
michael@0 | 280 | AC_MSG_RESULT([$abi]) |
michael@0 | 281 | AC_DEFINE([JEMALLOC_PURGE_MADVISE_FREE], [ ]) |
michael@0 | 282 | ;; |
michael@0 | 283 | *-*-solaris2*) |
michael@0 | 284 | CFLAGS="$CFLAGS" |
michael@0 | 285 | abi="elf" |
michael@0 | 286 | RPATH='-Wl,-R,$(1)' |
michael@0 | 287 | dnl Solaris needs this for sigwait(). |
michael@0 | 288 | CPPFLAGS="$CPPFLAGS -D_POSIX_PTHREAD_SEMANTICS" |
michael@0 | 289 | LIBS="$LIBS -lposix4 -lsocket -lnsl" |
michael@0 | 290 | ;; |
michael@0 | 291 | *-ibm-aix*) |
michael@0 | 292 | if "$LG_SIZEOF_PTR" = "8"; then |
michael@0 | 293 | dnl 64bit AIX |
michael@0 | 294 | LD_PRELOAD_VAR="LDR_PRELOAD64" |
michael@0 | 295 | else |
michael@0 | 296 | dnl 32bit AIX |
michael@0 | 297 | LD_PRELOAD_VAR="LDR_PRELOAD" |
michael@0 | 298 | fi |
michael@0 | 299 | abi="xcoff" |
michael@0 | 300 | ;; |
michael@0 | 301 | *-*-mingw*) |
michael@0 | 302 | abi="pecoff" |
michael@0 | 303 | force_tls="0" |
michael@0 | 304 | RPATH="" |
michael@0 | 305 | so="dll" |
michael@0 | 306 | if test "x$je_cv_msvc" = "xyes" ; then |
michael@0 | 307 | importlib="lib" |
michael@0 | 308 | DSO_LDFLAGS="-LD" |
michael@0 | 309 | EXTRA_LDFLAGS="-link -DEBUG" |
michael@0 | 310 | CTARGET='-Fo$@' |
michael@0 | 311 | LDTARGET='-Fe$@' |
michael@0 | 312 | MKLIB='lib -nologo -out:$@' |
michael@0 | 313 | CC_MM= |
michael@0 | 314 | else |
michael@0 | 315 | importlib="${so}" |
michael@0 | 316 | DSO_LDFLAGS="-shared" |
michael@0 | 317 | fi |
michael@0 | 318 | a="lib" |
michael@0 | 319 | libprefix="" |
michael@0 | 320 | SOREV="${so}" |
michael@0 | 321 | PIC_CFLAGS="" |
michael@0 | 322 | ;; |
michael@0 | 323 | *) |
michael@0 | 324 | AC_MSG_RESULT([Unsupported operating system: ${host}]) |
michael@0 | 325 | abi="elf" |
michael@0 | 326 | ;; |
michael@0 | 327 | esac |
michael@0 | 328 | AC_DEFINE_UNQUOTED([JEMALLOC_USABLE_SIZE_CONST], [$JEMALLOC_USABLE_SIZE_CONST]) |
michael@0 | 329 | AC_SUBST([abi]) |
michael@0 | 330 | AC_SUBST([RPATH]) |
michael@0 | 331 | AC_SUBST([LD_PRELOAD_VAR]) |
michael@0 | 332 | AC_SUBST([so]) |
michael@0 | 333 | AC_SUBST([importlib]) |
michael@0 | 334 | AC_SUBST([o]) |
michael@0 | 335 | AC_SUBST([a]) |
michael@0 | 336 | AC_SUBST([exe]) |
michael@0 | 337 | AC_SUBST([libprefix]) |
michael@0 | 338 | AC_SUBST([DSO_LDFLAGS]) |
michael@0 | 339 | AC_SUBST([EXTRA_LDFLAGS]) |
michael@0 | 340 | AC_SUBST([SOREV]) |
michael@0 | 341 | AC_SUBST([PIC_CFLAGS]) |
michael@0 | 342 | AC_SUBST([CTARGET]) |
michael@0 | 343 | AC_SUBST([LDTARGET]) |
michael@0 | 344 | AC_SUBST([MKLIB]) |
michael@0 | 345 | AC_SUBST([CC_MM]) |
michael@0 | 346 | |
michael@0 | 347 | if test "x$abi" != "xpecoff"; then |
michael@0 | 348 | dnl Heap profiling uses the log(3) function. |
michael@0 | 349 | LIBS="$LIBS -lm" |
michael@0 | 350 | fi |
michael@0 | 351 | |
michael@0 | 352 | JE_COMPILABLE([__attribute__ syntax], |
michael@0 | 353 | [static __attribute__((unused)) void foo(void){}], |
michael@0 | 354 | [], |
michael@0 | 355 | [je_cv_attribute]) |
michael@0 | 356 | if test "x${je_cv_attribute}" = "xyes" ; then |
michael@0 | 357 | AC_DEFINE([JEMALLOC_HAVE_ATTR], [ ]) |
michael@0 | 358 | if test "x${GCC}" = "xyes" -a "x${abi}" = "xelf"; then |
michael@0 | 359 | JE_CFLAGS_APPEND([-fvisibility=hidden]) |
michael@0 | 360 | fi |
michael@0 | 361 | fi |
michael@0 | 362 | dnl Check for tls_model attribute support (clang 3.0 still lacks support). |
michael@0 | 363 | SAVED_CFLAGS="${CFLAGS}" |
michael@0 | 364 | JE_CFLAGS_APPEND([-Werror]) |
michael@0 | 365 | JE_COMPILABLE([tls_model attribute], [], |
michael@0 | 366 | [static __thread int |
michael@0 | 367 | __attribute__((tls_model("initial-exec"))) foo; |
michael@0 | 368 | foo = 0;], |
michael@0 | 369 | [je_cv_tls_model]) |
michael@0 | 370 | CFLAGS="${SAVED_CFLAGS}" |
michael@0 | 371 | if test "x${je_cv_tls_model}" = "xyes" ; then |
michael@0 | 372 | AC_DEFINE([JEMALLOC_TLS_MODEL], |
michael@0 | 373 | [__attribute__((tls_model("initial-exec")))]) |
michael@0 | 374 | else |
michael@0 | 375 | AC_DEFINE([JEMALLOC_TLS_MODEL], [ ]) |
michael@0 | 376 | fi |
michael@0 | 377 | |
michael@0 | 378 | dnl Support optional additions to rpath. |
michael@0 | 379 | AC_ARG_WITH([rpath], |
michael@0 | 380 | [AS_HELP_STRING([--with-rpath=<rpath>], [Colon-separated rpath (ELF systems only)])], |
michael@0 | 381 | if test "x$with_rpath" = "xno" ; then |
michael@0 | 382 | RPATH_EXTRA= |
michael@0 | 383 | else |
michael@0 | 384 | RPATH_EXTRA="`echo $with_rpath | tr \":\" \" \"`" |
michael@0 | 385 | fi, |
michael@0 | 386 | RPATH_EXTRA= |
michael@0 | 387 | ) |
michael@0 | 388 | AC_SUBST([RPATH_EXTRA]) |
michael@0 | 389 | |
michael@0 | 390 | dnl Disable rules that do automatic regeneration of configure output by default. |
michael@0 | 391 | AC_ARG_ENABLE([autogen], |
michael@0 | 392 | [AS_HELP_STRING([--enable-autogen], [Automatically regenerate configure output])], |
michael@0 | 393 | if test "x$enable_autogen" = "xno" ; then |
michael@0 | 394 | enable_autogen="0" |
michael@0 | 395 | else |
michael@0 | 396 | enable_autogen="1" |
michael@0 | 397 | fi |
michael@0 | 398 | , |
michael@0 | 399 | enable_autogen="0" |
michael@0 | 400 | ) |
michael@0 | 401 | AC_SUBST([enable_autogen]) |
michael@0 | 402 | |
michael@0 | 403 | AC_PROG_INSTALL |
michael@0 | 404 | AC_PROG_RANLIB |
michael@0 | 405 | AC_PATH_PROG([AR], [ar], , [$PATH]) |
michael@0 | 406 | AC_PATH_PROG([LD], [ld], , [$PATH]) |
michael@0 | 407 | AC_PATH_PROG([AUTOCONF], [autoconf], , [$PATH]) |
michael@0 | 408 | |
michael@0 | 409 | 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 | 410 | |
michael@0 | 411 | dnl Check for allocator-related functions that should be wrapped. |
michael@0 | 412 | AC_CHECK_FUNC([memalign], |
michael@0 | 413 | [AC_DEFINE([JEMALLOC_OVERRIDE_MEMALIGN], [ ]) |
michael@0 | 414 | public_syms="${public_syms} memalign"]) |
michael@0 | 415 | AC_CHECK_FUNC([valloc], |
michael@0 | 416 | [AC_DEFINE([JEMALLOC_OVERRIDE_VALLOC], [ ]) |
michael@0 | 417 | public_syms="${public_syms} valloc"]) |
michael@0 | 418 | |
michael@0 | 419 | dnl Support the experimental API by default. |
michael@0 | 420 | AC_ARG_ENABLE([experimental], |
michael@0 | 421 | [AS_HELP_STRING([--disable-experimental], |
michael@0 | 422 | [Disable support for the experimental API])], |
michael@0 | 423 | [if test "x$enable_experimental" = "xno" ; then |
michael@0 | 424 | enable_experimental="0" |
michael@0 | 425 | else |
michael@0 | 426 | enable_experimental="1" |
michael@0 | 427 | fi |
michael@0 | 428 | ], |
michael@0 | 429 | [enable_experimental="1"] |
michael@0 | 430 | ) |
michael@0 | 431 | if test "x$enable_experimental" = "x1" ; then |
michael@0 | 432 | AC_DEFINE([JEMALLOC_EXPERIMENTAL], [ ]) |
michael@0 | 433 | public_syms="${public_syms} allocm dallocm nallocm rallocm sallocm" |
michael@0 | 434 | fi |
michael@0 | 435 | AC_SUBST([enable_experimental]) |
michael@0 | 436 | |
michael@0 | 437 | dnl Perform no name mangling by default. |
michael@0 | 438 | AC_ARG_WITH([mangling], |
michael@0 | 439 | [AS_HELP_STRING([--with-mangling=<map>], [Mangle symbols in <map>])], |
michael@0 | 440 | [mangling_map="$with_mangling"], [mangling_map=""]) |
michael@0 | 441 | for nm in `echo ${mangling_map} |tr ',' ' '` ; do |
michael@0 | 442 | k="`echo ${nm} |tr ':' ' ' |awk '{print $1}'`" |
michael@0 | 443 | n="je_${k}" |
michael@0 | 444 | m=`echo ${nm} |tr ':' ' ' |awk '{print $2}'` |
michael@0 | 445 | AC_DEFINE_UNQUOTED([${n}], [${m}]) |
michael@0 | 446 | dnl Remove key from public_syms so that it isn't redefined later. |
michael@0 | 447 | public_syms=`for sym in ${public_syms}; do echo "${sym}"; done |grep -v "^${k}\$" |tr '\n' ' '` |
michael@0 | 448 | done |
michael@0 | 449 | |
michael@0 | 450 | dnl Do not prefix public APIs by default. |
michael@0 | 451 | AC_ARG_WITH([jemalloc_prefix], |
michael@0 | 452 | [AS_HELP_STRING([--with-jemalloc-prefix=<prefix>], [Prefix to prepend to all public APIs])], |
michael@0 | 453 | [JEMALLOC_PREFIX="$with_jemalloc_prefix"], |
michael@0 | 454 | [if test "x$abi" != "xmacho" -a "x$abi" != "xpecoff"; then |
michael@0 | 455 | JEMALLOC_PREFIX="" |
michael@0 | 456 | else |
michael@0 | 457 | JEMALLOC_PREFIX="je_" |
michael@0 | 458 | fi] |
michael@0 | 459 | ) |
michael@0 | 460 | if test "x$JEMALLOC_PREFIX" != "x" ; then |
michael@0 | 461 | JEMALLOC_CPREFIX=`echo ${JEMALLOC_PREFIX} | tr "a-z" "A-Z"` |
michael@0 | 462 | AC_DEFINE_UNQUOTED([JEMALLOC_PREFIX], ["$JEMALLOC_PREFIX"]) |
michael@0 | 463 | AC_DEFINE_UNQUOTED([JEMALLOC_CPREFIX], ["$JEMALLOC_CPREFIX"]) |
michael@0 | 464 | fi |
michael@0 | 465 | dnl Generate macros to rename public symbols. All public symbols are prefixed |
michael@0 | 466 | dnl with je_ in the source code, so these macro definitions are needed even if |
michael@0 | 467 | dnl --with-jemalloc-prefix wasn't specified. |
michael@0 | 468 | for stem in ${public_syms}; do |
michael@0 | 469 | n="je_${stem}" |
michael@0 | 470 | m="${JEMALLOC_PREFIX}${stem}" |
michael@0 | 471 | AC_DEFINE_UNQUOTED([${n}], [${m}]) |
michael@0 | 472 | done |
michael@0 | 473 | |
michael@0 | 474 | AC_ARG_WITH([export], |
michael@0 | 475 | [AS_HELP_STRING([--without-export], [disable exporting jemalloc public APIs])], |
michael@0 | 476 | [if test "x$with_export" = "xno"; then |
michael@0 | 477 | AC_DEFINE([JEMALLOC_EXPORT],[])] |
michael@0 | 478 | fi] |
michael@0 | 479 | ) |
michael@0 | 480 | |
michael@0 | 481 | dnl Do not mangle library-private APIs by default. |
michael@0 | 482 | AC_ARG_WITH([private_namespace], |
michael@0 | 483 | [AS_HELP_STRING([--with-private-namespace=<prefix>], [Prefix to prepend to all library-private APIs])], |
michael@0 | 484 | [JEMALLOC_PRIVATE_NAMESPACE="$with_private_namespace"], |
michael@0 | 485 | [JEMALLOC_PRIVATE_NAMESPACE=""] |
michael@0 | 486 | ) |
michael@0 | 487 | AC_DEFINE_UNQUOTED([JEMALLOC_PRIVATE_NAMESPACE], ["$JEMALLOC_PRIVATE_NAMESPACE"]) |
michael@0 | 488 | if test "x$JEMALLOC_PRIVATE_NAMESPACE" != "x" ; then |
michael@0 | 489 | 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 | 490 | else |
michael@0 | 491 | 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 | 492 | fi |
michael@0 | 493 | |
michael@0 | 494 | dnl Do not add suffix to installed files by default. |
michael@0 | 495 | AC_ARG_WITH([install_suffix], |
michael@0 | 496 | [AS_HELP_STRING([--with-install-suffix=<suffix>], [Suffix to append to all installed files])], |
michael@0 | 497 | [INSTALL_SUFFIX="$with_install_suffix"], |
michael@0 | 498 | [INSTALL_SUFFIX=] |
michael@0 | 499 | ) |
michael@0 | 500 | install_suffix="$INSTALL_SUFFIX" |
michael@0 | 501 | AC_SUBST([install_suffix]) |
michael@0 | 502 | |
michael@0 | 503 | cfgoutputs_in="${srcroot}Makefile.in" |
michael@0 | 504 | cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/html.xsl.in" |
michael@0 | 505 | cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/manpages.xsl.in" |
michael@0 | 506 | cfgoutputs_in="${cfgoutputs_in} ${srcroot}doc/jemalloc.xml.in" |
michael@0 | 507 | cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/jemalloc.h.in" |
michael@0 | 508 | cfgoutputs_in="${cfgoutputs_in} ${srcroot}include/jemalloc/internal/jemalloc_internal.h.in" |
michael@0 | 509 | cfgoutputs_in="${cfgoutputs_in} ${srcroot}test/jemalloc_test.h.in" |
michael@0 | 510 | |
michael@0 | 511 | cfgoutputs_out="Makefile" |
michael@0 | 512 | cfgoutputs_out="${cfgoutputs_out} doc/html.xsl" |
michael@0 | 513 | cfgoutputs_out="${cfgoutputs_out} doc/manpages.xsl" |
michael@0 | 514 | cfgoutputs_out="${cfgoutputs_out} doc/jemalloc${install_suffix}.xml" |
michael@0 | 515 | cfgoutputs_out="${cfgoutputs_out} include/jemalloc/jemalloc${install_suffix}.h" |
michael@0 | 516 | cfgoutputs_out="${cfgoutputs_out} include/jemalloc/internal/jemalloc_internal.h" |
michael@0 | 517 | cfgoutputs_out="${cfgoutputs_out} test/jemalloc_test.h" |
michael@0 | 518 | |
michael@0 | 519 | cfgoutputs_tup="Makefile" |
michael@0 | 520 | cfgoutputs_tup="${cfgoutputs_tup} doc/html.xsl:doc/html.xsl.in" |
michael@0 | 521 | cfgoutputs_tup="${cfgoutputs_tup} doc/manpages.xsl:doc/manpages.xsl.in" |
michael@0 | 522 | cfgoutputs_tup="${cfgoutputs_tup} doc/jemalloc${install_suffix}.xml:doc/jemalloc.xml.in" |
michael@0 | 523 | cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/jemalloc${install_suffix}.h:include/jemalloc/jemalloc.h.in" |
michael@0 | 524 | cfgoutputs_tup="${cfgoutputs_tup} include/jemalloc/internal/jemalloc_internal.h" |
michael@0 | 525 | cfgoutputs_tup="${cfgoutputs_tup} test/jemalloc_test.h:test/jemalloc_test.h.in" |
michael@0 | 526 | |
michael@0 | 527 | cfghdrs_in="${srcroot}include/jemalloc/jemalloc_defs.h.in" |
michael@0 | 528 | cfghdrs_in="${cfghdrs_in} ${srcroot}include/jemalloc/internal/size_classes.sh" |
michael@0 | 529 | |
michael@0 | 530 | cfghdrs_out="include/jemalloc/jemalloc_defs${install_suffix}.h" |
michael@0 | 531 | cfghdrs_out="${cfghdrs_out} include/jemalloc/internal/size_classes.h" |
michael@0 | 532 | |
michael@0 | 533 | cfghdrs_tup="include/jemalloc/jemalloc_defs${install_suffix}.h:include/jemalloc/jemalloc_defs.h.in" |
michael@0 | 534 | |
michael@0 | 535 | dnl Do not silence irrelevant compiler warnings by default, since enabling this |
michael@0 | 536 | dnl option incurs a performance penalty. |
michael@0 | 537 | AC_ARG_ENABLE([cc-silence], |
michael@0 | 538 | [AS_HELP_STRING([--enable-cc-silence], |
michael@0 | 539 | [Silence irrelevant compiler warnings])], |
michael@0 | 540 | [if test "x$enable_cc_silence" = "xno" ; then |
michael@0 | 541 | enable_cc_silence="0" |
michael@0 | 542 | else |
michael@0 | 543 | enable_cc_silence="1" |
michael@0 | 544 | fi |
michael@0 | 545 | ], |
michael@0 | 546 | [enable_cc_silence="0"] |
michael@0 | 547 | ) |
michael@0 | 548 | if test "x$enable_cc_silence" = "x1" ; then |
michael@0 | 549 | AC_DEFINE([JEMALLOC_CC_SILENCE], [ ]) |
michael@0 | 550 | fi |
michael@0 | 551 | |
michael@0 | 552 | dnl Do not compile with debugging by default. |
michael@0 | 553 | AC_ARG_ENABLE([debug], |
michael@0 | 554 | [AS_HELP_STRING([--enable-debug], [Build debugging code])], |
michael@0 | 555 | [if test "x$enable_debug" = "xno" ; then |
michael@0 | 556 | enable_debug="0" |
michael@0 | 557 | else |
michael@0 | 558 | enable_debug="1" |
michael@0 | 559 | fi |
michael@0 | 560 | ], |
michael@0 | 561 | [enable_debug="0"] |
michael@0 | 562 | ) |
michael@0 | 563 | if test "x$enable_debug" = "x1" ; then |
michael@0 | 564 | AC_DEFINE([JEMALLOC_DEBUG], [ ]) |
michael@0 | 565 | AC_DEFINE([JEMALLOC_IVSALLOC], [ ]) |
michael@0 | 566 | fi |
michael@0 | 567 | AC_SUBST([enable_debug]) |
michael@0 | 568 | |
michael@0 | 569 | dnl Only optimize if not debugging. |
michael@0 | 570 | if test "x$enable_debug" = "x0" -a "x$no_CFLAGS" = "xyes" ; then |
michael@0 | 571 | dnl Make sure that an optimization flag was not specified in EXTRA_CFLAGS. |
michael@0 | 572 | optimize="no" |
michael@0 | 573 | echo "$EXTRA_CFLAGS" | grep "\-O" >/dev/null || optimize="yes" |
michael@0 | 574 | if test "x${optimize}" = "xyes" ; then |
michael@0 | 575 | if test "x$GCC" = "xyes" ; then |
michael@0 | 576 | JE_CFLAGS_APPEND([-O3]) |
michael@0 | 577 | JE_CFLAGS_APPEND([-funroll-loops]) |
michael@0 | 578 | elif test "x$je_cv_msvc" = "xyes" ; then |
michael@0 | 579 | JE_CFLAGS_APPEND([-O2]) |
michael@0 | 580 | else |
michael@0 | 581 | JE_CFLAGS_APPEND([-O]) |
michael@0 | 582 | fi |
michael@0 | 583 | fi |
michael@0 | 584 | fi |
michael@0 | 585 | |
michael@0 | 586 | dnl Enable statistics calculation by default. |
michael@0 | 587 | AC_ARG_ENABLE([stats], |
michael@0 | 588 | [AS_HELP_STRING([--disable-stats], |
michael@0 | 589 | [Disable statistics calculation/reporting])], |
michael@0 | 590 | [if test "x$enable_stats" = "xno" ; then |
michael@0 | 591 | enable_stats="0" |
michael@0 | 592 | else |
michael@0 | 593 | enable_stats="1" |
michael@0 | 594 | fi |
michael@0 | 595 | ], |
michael@0 | 596 | [enable_stats="1"] |
michael@0 | 597 | ) |
michael@0 | 598 | if test "x$enable_stats" = "x1" ; then |
michael@0 | 599 | AC_DEFINE([JEMALLOC_STATS], [ ]) |
michael@0 | 600 | fi |
michael@0 | 601 | AC_SUBST([enable_stats]) |
michael@0 | 602 | |
michael@0 | 603 | dnl Do not enable profiling by default. |
michael@0 | 604 | AC_ARG_ENABLE([prof], |
michael@0 | 605 | [AS_HELP_STRING([--enable-prof], [Enable allocation profiling])], |
michael@0 | 606 | [if test "x$enable_prof" = "xno" ; then |
michael@0 | 607 | enable_prof="0" |
michael@0 | 608 | else |
michael@0 | 609 | enable_prof="1" |
michael@0 | 610 | fi |
michael@0 | 611 | ], |
michael@0 | 612 | [enable_prof="0"] |
michael@0 | 613 | ) |
michael@0 | 614 | if test "x$enable_prof" = "x1" ; then |
michael@0 | 615 | backtrace_method="" |
michael@0 | 616 | else |
michael@0 | 617 | backtrace_method="N/A" |
michael@0 | 618 | fi |
michael@0 | 619 | |
michael@0 | 620 | AC_ARG_ENABLE([prof-libunwind], |
michael@0 | 621 | [AS_HELP_STRING([--enable-prof-libunwind], [Use libunwind for backtracing])], |
michael@0 | 622 | [if test "x$enable_prof_libunwind" = "xno" ; then |
michael@0 | 623 | enable_prof_libunwind="0" |
michael@0 | 624 | else |
michael@0 | 625 | enable_prof_libunwind="1" |
michael@0 | 626 | fi |
michael@0 | 627 | ], |
michael@0 | 628 | [enable_prof_libunwind="0"] |
michael@0 | 629 | ) |
michael@0 | 630 | AC_ARG_WITH([static_libunwind], |
michael@0 | 631 | [AS_HELP_STRING([--with-static-libunwind=<libunwind.a>], |
michael@0 | 632 | [Path to static libunwind library; use rather than dynamically linking])], |
michael@0 | 633 | if test "x$with_static_libunwind" = "xno" ; then |
michael@0 | 634 | LUNWIND="-lunwind" |
michael@0 | 635 | else |
michael@0 | 636 | if test ! -f "$with_static_libunwind" ; then |
michael@0 | 637 | AC_MSG_ERROR([Static libunwind not found: $with_static_libunwind]) |
michael@0 | 638 | fi |
michael@0 | 639 | LUNWIND="$with_static_libunwind" |
michael@0 | 640 | fi, |
michael@0 | 641 | LUNWIND="-lunwind" |
michael@0 | 642 | ) |
michael@0 | 643 | if test "x$backtrace_method" = "x" -a "x$enable_prof_libunwind" = "x1" ; then |
michael@0 | 644 | AC_CHECK_HEADERS([libunwind.h], , [enable_prof_libunwind="0"]) |
michael@0 | 645 | if test "x$LUNWIND" = "x-lunwind" ; then |
michael@0 | 646 | AC_CHECK_LIB([unwind], [backtrace], [LIBS="$LIBS $LUNWIND"], |
michael@0 | 647 | [enable_prof_libunwind="0"]) |
michael@0 | 648 | else |
michael@0 | 649 | LIBS="$LIBS $LUNWIND" |
michael@0 | 650 | fi |
michael@0 | 651 | if test "x${enable_prof_libunwind}" = "x1" ; then |
michael@0 | 652 | backtrace_method="libunwind" |
michael@0 | 653 | AC_DEFINE([JEMALLOC_PROF_LIBUNWIND], [ ]) |
michael@0 | 654 | fi |
michael@0 | 655 | fi |
michael@0 | 656 | |
michael@0 | 657 | AC_ARG_ENABLE([prof-libgcc], |
michael@0 | 658 | [AS_HELP_STRING([--disable-prof-libgcc], |
michael@0 | 659 | [Do not use libgcc for backtracing])], |
michael@0 | 660 | [if test "x$enable_prof_libgcc" = "xno" ; then |
michael@0 | 661 | enable_prof_libgcc="0" |
michael@0 | 662 | else |
michael@0 | 663 | enable_prof_libgcc="1" |
michael@0 | 664 | fi |
michael@0 | 665 | ], |
michael@0 | 666 | [enable_prof_libgcc="1"] |
michael@0 | 667 | ) |
michael@0 | 668 | if test "x$backtrace_method" = "x" -a "x$enable_prof_libgcc" = "x1" \ |
michael@0 | 669 | -a "x$GCC" = "xyes" ; then |
michael@0 | 670 | AC_CHECK_HEADERS([unwind.h], , [enable_prof_libgcc="0"]) |
michael@0 | 671 | AC_CHECK_LIB([gcc], [_Unwind_Backtrace], [LIBS="$LIBS -lgcc"], [enable_prof_libgcc="0"]) |
michael@0 | 672 | dnl The following is conservative, in that it only has entries for CPUs on |
michael@0 | 673 | dnl which jemalloc has been tested. |
michael@0 | 674 | AC_MSG_CHECKING([libgcc-based backtracing reliability on ${host_cpu}]) |
michael@0 | 675 | case "${host_cpu}" in |
michael@0 | 676 | i[[3456]]86) |
michael@0 | 677 | AC_MSG_RESULT([unreliable]) |
michael@0 | 678 | enable_prof_libgcc="0"; |
michael@0 | 679 | ;; |
michael@0 | 680 | x86_64) |
michael@0 | 681 | AC_MSG_RESULT([reliable]) |
michael@0 | 682 | ;; |
michael@0 | 683 | *) |
michael@0 | 684 | AC_MSG_RESULT([unreliable]) |
michael@0 | 685 | enable_prof_libgcc="0"; |
michael@0 | 686 | ;; |
michael@0 | 687 | esac |
michael@0 | 688 | if test "x${enable_prof_libgcc}" = "x1" ; then |
michael@0 | 689 | backtrace_method="libgcc" |
michael@0 | 690 | AC_DEFINE([JEMALLOC_PROF_LIBGCC], [ ]) |
michael@0 | 691 | fi |
michael@0 | 692 | else |
michael@0 | 693 | enable_prof_libgcc="0" |
michael@0 | 694 | fi |
michael@0 | 695 | |
michael@0 | 696 | AC_ARG_ENABLE([prof-gcc], |
michael@0 | 697 | [AS_HELP_STRING([--disable-prof-gcc], |
michael@0 | 698 | [Do not use gcc intrinsics for backtracing])], |
michael@0 | 699 | [if test "x$enable_prof_gcc" = "xno" ; then |
michael@0 | 700 | enable_prof_gcc="0" |
michael@0 | 701 | else |
michael@0 | 702 | enable_prof_gcc="1" |
michael@0 | 703 | fi |
michael@0 | 704 | ], |
michael@0 | 705 | [enable_prof_gcc="1"] |
michael@0 | 706 | ) |
michael@0 | 707 | if test "x$backtrace_method" = "x" -a "x$enable_prof_gcc" = "x1" \ |
michael@0 | 708 | -a "x$GCC" = "xyes" ; then |
michael@0 | 709 | backtrace_method="gcc intrinsics" |
michael@0 | 710 | AC_DEFINE([JEMALLOC_PROF_GCC], [ ]) |
michael@0 | 711 | else |
michael@0 | 712 | enable_prof_gcc="0" |
michael@0 | 713 | fi |
michael@0 | 714 | |
michael@0 | 715 | if test "x$backtrace_method" = "x" ; then |
michael@0 | 716 | backtrace_method="none (disabling profiling)" |
michael@0 | 717 | enable_prof="0" |
michael@0 | 718 | fi |
michael@0 | 719 | AC_MSG_CHECKING([configured backtracing method]) |
michael@0 | 720 | AC_MSG_RESULT([$backtrace_method]) |
michael@0 | 721 | if test "x$enable_prof" = "x1" ; then |
michael@0 | 722 | if test "x${force_tls}" = "x0" ; then |
michael@0 | 723 | AC_MSG_ERROR([Heap profiling requires TLS]); |
michael@0 | 724 | fi |
michael@0 | 725 | force_tls="1" |
michael@0 | 726 | AC_DEFINE([JEMALLOC_PROF], [ ]) |
michael@0 | 727 | fi |
michael@0 | 728 | AC_SUBST([enable_prof]) |
michael@0 | 729 | |
michael@0 | 730 | dnl Enable thread-specific caching by default. |
michael@0 | 731 | AC_ARG_ENABLE([tcache], |
michael@0 | 732 | [AS_HELP_STRING([--disable-tcache], [Disable per thread caches])], |
michael@0 | 733 | [if test "x$enable_tcache" = "xno" ; then |
michael@0 | 734 | enable_tcache="0" |
michael@0 | 735 | else |
michael@0 | 736 | enable_tcache="1" |
michael@0 | 737 | fi |
michael@0 | 738 | ], |
michael@0 | 739 | [enable_tcache="1"] |
michael@0 | 740 | ) |
michael@0 | 741 | if test "x$enable_tcache" = "x1" ; then |
michael@0 | 742 | AC_DEFINE([JEMALLOC_TCACHE], [ ]) |
michael@0 | 743 | fi |
michael@0 | 744 | AC_SUBST([enable_tcache]) |
michael@0 | 745 | |
michael@0 | 746 | dnl Disable mremap() for huge realloc() by default. |
michael@0 | 747 | AC_ARG_ENABLE([mremap], |
michael@0 | 748 | [AS_HELP_STRING([--enable-mremap], [Enable mremap(2) for huge realloc()])], |
michael@0 | 749 | [if test "x$enable_mremap" = "xno" ; then |
michael@0 | 750 | enable_mremap="0" |
michael@0 | 751 | else |
michael@0 | 752 | enable_mremap="1" |
michael@0 | 753 | fi |
michael@0 | 754 | ], |
michael@0 | 755 | [enable_mremap="0"] |
michael@0 | 756 | ) |
michael@0 | 757 | if test "x$enable_mremap" = "x1" ; then |
michael@0 | 758 | JE_COMPILABLE([mremap(...MREMAP_FIXED...)], [ |
michael@0 | 759 | #define _GNU_SOURCE |
michael@0 | 760 | #include <sys/mman.h> |
michael@0 | 761 | ], [ |
michael@0 | 762 | void *p = mremap((void *)0, 0, 0, MREMAP_MAYMOVE|MREMAP_FIXED, (void *)0); |
michael@0 | 763 | ], [je_cv_mremap_fixed]) |
michael@0 | 764 | if test "x${je_cv_mremap_fixed}" = "xno" ; then |
michael@0 | 765 | enable_mremap="0" |
michael@0 | 766 | fi |
michael@0 | 767 | fi |
michael@0 | 768 | if test "x$enable_mremap" = "x1" ; then |
michael@0 | 769 | AC_DEFINE([JEMALLOC_MREMAP], [ ]) |
michael@0 | 770 | fi |
michael@0 | 771 | AC_SUBST([enable_mremap]) |
michael@0 | 772 | |
michael@0 | 773 | dnl Enable VM deallocation via munmap() by default. |
michael@0 | 774 | AC_ARG_ENABLE([munmap], |
michael@0 | 775 | [AS_HELP_STRING([--disable-munmap], [Disable VM deallocation via munmap(2)])], |
michael@0 | 776 | [if test "x$enable_munmap" = "xno" ; then |
michael@0 | 777 | enable_munmap="0" |
michael@0 | 778 | else |
michael@0 | 779 | enable_munmap="1" |
michael@0 | 780 | fi |
michael@0 | 781 | ], |
michael@0 | 782 | [enable_munmap="${default_munmap}"] |
michael@0 | 783 | ) |
michael@0 | 784 | if test "x$enable_munmap" = "x1" ; then |
michael@0 | 785 | AC_DEFINE([JEMALLOC_MUNMAP], [ ]) |
michael@0 | 786 | fi |
michael@0 | 787 | AC_SUBST([enable_munmap]) |
michael@0 | 788 | |
michael@0 | 789 | dnl Do not enable allocation from DSS by default. |
michael@0 | 790 | AC_ARG_ENABLE([dss], |
michael@0 | 791 | [AS_HELP_STRING([--enable-dss], [Enable allocation from DSS])], |
michael@0 | 792 | [if test "x$enable_dss" = "xno" ; then |
michael@0 | 793 | enable_dss="0" |
michael@0 | 794 | else |
michael@0 | 795 | enable_dss="1" |
michael@0 | 796 | fi |
michael@0 | 797 | ], |
michael@0 | 798 | [enable_dss="0"] |
michael@0 | 799 | ) |
michael@0 | 800 | dnl Check whether the BSD/SUSv1 sbrk() exists. If not, disable DSS support. |
michael@0 | 801 | AC_CHECK_FUNC([sbrk], [have_sbrk="1"], [have_sbrk="0"]) |
michael@0 | 802 | if test "x$have_sbrk" = "x1" ; then |
michael@0 | 803 | AC_DEFINE([JEMALLOC_HAVE_SBRK], [ ]) |
michael@0 | 804 | else |
michael@0 | 805 | enable_dss="0" |
michael@0 | 806 | fi |
michael@0 | 807 | |
michael@0 | 808 | if test "x$enable_dss" = "x1" ; then |
michael@0 | 809 | AC_DEFINE([JEMALLOC_DSS], [ ]) |
michael@0 | 810 | fi |
michael@0 | 811 | AC_SUBST([enable_dss]) |
michael@0 | 812 | |
michael@0 | 813 | dnl Support the junk/zero filling option by default. |
michael@0 | 814 | AC_ARG_ENABLE([fill], |
michael@0 | 815 | [AS_HELP_STRING([--disable-fill], |
michael@0 | 816 | [Disable support for junk/zero filling, quarantine, and redzones])], |
michael@0 | 817 | [if test "x$enable_fill" = "xno" ; then |
michael@0 | 818 | enable_fill="0" |
michael@0 | 819 | else |
michael@0 | 820 | enable_fill="1" |
michael@0 | 821 | fi |
michael@0 | 822 | ], |
michael@0 | 823 | [enable_fill="1"] |
michael@0 | 824 | ) |
michael@0 | 825 | if test "x$enable_fill" = "x1" ; then |
michael@0 | 826 | AC_DEFINE([JEMALLOC_FILL], [ ]) |
michael@0 | 827 | fi |
michael@0 | 828 | AC_SUBST([enable_fill]) |
michael@0 | 829 | |
michael@0 | 830 | dnl Disable utrace(2)-based tracing by default. |
michael@0 | 831 | AC_ARG_ENABLE([utrace], |
michael@0 | 832 | [AS_HELP_STRING([--enable-utrace], [Enable utrace(2)-based tracing])], |
michael@0 | 833 | [if test "x$enable_utrace" = "xno" ; then |
michael@0 | 834 | enable_utrace="0" |
michael@0 | 835 | else |
michael@0 | 836 | enable_utrace="1" |
michael@0 | 837 | fi |
michael@0 | 838 | ], |
michael@0 | 839 | [enable_utrace="0"] |
michael@0 | 840 | ) |
michael@0 | 841 | JE_COMPILABLE([utrace(2)], [ |
michael@0 | 842 | #include <sys/types.h> |
michael@0 | 843 | #include <sys/param.h> |
michael@0 | 844 | #include <sys/time.h> |
michael@0 | 845 | #include <sys/uio.h> |
michael@0 | 846 | #include <sys/ktrace.h> |
michael@0 | 847 | ], [ |
michael@0 | 848 | utrace((void *)0, 0); |
michael@0 | 849 | ], [je_cv_utrace]) |
michael@0 | 850 | if test "x${je_cv_utrace}" = "xno" ; then |
michael@0 | 851 | enable_utrace="0" |
michael@0 | 852 | fi |
michael@0 | 853 | if test "x$enable_utrace" = "x1" ; then |
michael@0 | 854 | AC_DEFINE([JEMALLOC_UTRACE], [ ]) |
michael@0 | 855 | fi |
michael@0 | 856 | AC_SUBST([enable_utrace]) |
michael@0 | 857 | |
michael@0 | 858 | dnl Support Valgrind by default. |
michael@0 | 859 | AC_ARG_ENABLE([valgrind], |
michael@0 | 860 | [AS_HELP_STRING([--disable-valgrind], [Disable support for Valgrind])], |
michael@0 | 861 | [if test "x$enable_valgrind" = "xno" ; then |
michael@0 | 862 | enable_valgrind="0" |
michael@0 | 863 | else |
michael@0 | 864 | enable_valgrind="1" |
michael@0 | 865 | fi |
michael@0 | 866 | ], |
michael@0 | 867 | [enable_valgrind="1"] |
michael@0 | 868 | ) |
michael@0 | 869 | if test "x$enable_valgrind" = "x1" ; then |
michael@0 | 870 | JE_COMPILABLE([valgrind], [ |
michael@0 | 871 | #include <valgrind/valgrind.h> |
michael@0 | 872 | #include <valgrind/memcheck.h> |
michael@0 | 873 | |
michael@0 | 874 | #if !defined(VALGRIND_RESIZEINPLACE_BLOCK) |
michael@0 | 875 | # error "Incompatible Valgrind version" |
michael@0 | 876 | #endif |
michael@0 | 877 | ], [], [je_cv_valgrind]) |
michael@0 | 878 | if test "x${je_cv_valgrind}" = "xno" ; then |
michael@0 | 879 | enable_valgrind="0" |
michael@0 | 880 | fi |
michael@0 | 881 | if test "x$enable_valgrind" = "x1" ; then |
michael@0 | 882 | AC_DEFINE([JEMALLOC_VALGRIND], [ ]) |
michael@0 | 883 | fi |
michael@0 | 884 | fi |
michael@0 | 885 | AC_SUBST([enable_valgrind]) |
michael@0 | 886 | |
michael@0 | 887 | dnl Do not support the xmalloc option by default. |
michael@0 | 888 | AC_ARG_ENABLE([xmalloc], |
michael@0 | 889 | [AS_HELP_STRING([--enable-xmalloc], [Support xmalloc option])], |
michael@0 | 890 | [if test "x$enable_xmalloc" = "xno" ; then |
michael@0 | 891 | enable_xmalloc="0" |
michael@0 | 892 | else |
michael@0 | 893 | enable_xmalloc="1" |
michael@0 | 894 | fi |
michael@0 | 895 | ], |
michael@0 | 896 | [enable_xmalloc="0"] |
michael@0 | 897 | ) |
michael@0 | 898 | if test "x$enable_xmalloc" = "x1" ; then |
michael@0 | 899 | AC_DEFINE([JEMALLOC_XMALLOC], [ ]) |
michael@0 | 900 | fi |
michael@0 | 901 | AC_SUBST([enable_xmalloc]) |
michael@0 | 902 | |
michael@0 | 903 | AC_CACHE_CHECK([STATIC_PAGE_SHIFT], |
michael@0 | 904 | [je_cv_static_page_shift], |
michael@0 | 905 | AC_RUN_IFELSE([AC_LANG_PROGRAM( |
michael@0 | 906 | [[ |
michael@0 | 907 | #include <strings.h> |
michael@0 | 908 | #ifdef _WIN32 |
michael@0 | 909 | #include <windows.h> |
michael@0 | 910 | #else |
michael@0 | 911 | #include <unistd.h> |
michael@0 | 912 | #endif |
michael@0 | 913 | #include <stdio.h> |
michael@0 | 914 | ]], |
michael@0 | 915 | [[ |
michael@0 | 916 | long result; |
michael@0 | 917 | FILE *f; |
michael@0 | 918 | |
michael@0 | 919 | #ifdef _WIN32 |
michael@0 | 920 | SYSTEM_INFO si; |
michael@0 | 921 | GetSystemInfo(&si); |
michael@0 | 922 | result = si.dwPageSize; |
michael@0 | 923 | #else |
michael@0 | 924 | result = sysconf(_SC_PAGESIZE); |
michael@0 | 925 | #endif |
michael@0 | 926 | if (result == -1) { |
michael@0 | 927 | return 1; |
michael@0 | 928 | } |
michael@0 | 929 | result = ffsl(result) - 1; |
michael@0 | 930 | |
michael@0 | 931 | f = fopen("conftest.out", "w"); |
michael@0 | 932 | if (f == NULL) { |
michael@0 | 933 | return 1; |
michael@0 | 934 | } |
michael@0 | 935 | fprintf(f, "%u\n", result); |
michael@0 | 936 | fclose(f); |
michael@0 | 937 | |
michael@0 | 938 | return 0; |
michael@0 | 939 | ]])], |
michael@0 | 940 | [je_cv_static_page_shift=`cat conftest.out`], |
michael@0 | 941 | [je_cv_static_page_shift=undefined])) |
michael@0 | 942 | |
michael@0 | 943 | if test "x$je_cv_static_page_shift" != "xundefined"; then |
michael@0 | 944 | AC_DEFINE_UNQUOTED([STATIC_PAGE_SHIFT], [$je_cv_static_page_shift]) |
michael@0 | 945 | else |
michael@0 | 946 | AC_MSG_ERROR([cannot determine value for STATIC_PAGE_SHIFT]) |
michael@0 | 947 | fi |
michael@0 | 948 | |
michael@0 | 949 | dnl ============================================================================ |
michael@0 | 950 | dnl jemalloc configuration. |
michael@0 | 951 | dnl |
michael@0 | 952 | |
michael@0 | 953 | dnl Set VERSION if source directory has an embedded git repository. |
michael@0 | 954 | if test -d "${srcroot}.git" ; then |
michael@0 | 955 | git describe --long --abbrev=40 > ${srcroot}VERSION |
michael@0 | 956 | fi |
michael@0 | 957 | jemalloc_version=`cat ${srcroot}VERSION` |
michael@0 | 958 | jemalloc_version_major=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]1}'` |
michael@0 | 959 | jemalloc_version_minor=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]2}'` |
michael@0 | 960 | jemalloc_version_bugfix=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]3}'` |
michael@0 | 961 | jemalloc_version_nrev=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]4}'` |
michael@0 | 962 | jemalloc_version_gid=`echo ${jemalloc_version} | tr ".g-" " " | awk '{print [$]5}'` |
michael@0 | 963 | AC_SUBST([jemalloc_version]) |
michael@0 | 964 | AC_SUBST([jemalloc_version_major]) |
michael@0 | 965 | AC_SUBST([jemalloc_version_minor]) |
michael@0 | 966 | AC_SUBST([jemalloc_version_bugfix]) |
michael@0 | 967 | AC_SUBST([jemalloc_version_nrev]) |
michael@0 | 968 | AC_SUBST([jemalloc_version_gid]) |
michael@0 | 969 | |
michael@0 | 970 | dnl ============================================================================ |
michael@0 | 971 | dnl Configure pthreads. |
michael@0 | 972 | |
michael@0 | 973 | if test "x$abi" != "xpecoff" ; then |
michael@0 | 974 | AC_CHECK_HEADERS([pthread.h], , [AC_MSG_ERROR([pthread.h is missing])]) |
michael@0 | 975 | dnl Some systems may embed pthreads functionality in libc; check for libpthread |
michael@0 | 976 | dnl first, but try libc too before failing. |
michael@0 | 977 | AC_CHECK_LIB([pthread], [pthread_create], [LIBS="$LIBS -lpthread"], |
michael@0 | 978 | [AC_SEARCH_LIBS([pthread_create], , , |
michael@0 | 979 | AC_MSG_ERROR([libpthread is missing]))]) |
michael@0 | 980 | fi |
michael@0 | 981 | |
michael@0 | 982 | CPPFLAGS="$CPPFLAGS -D_REENTRANT" |
michael@0 | 983 | |
michael@0 | 984 | dnl Check whether the BSD-specific _malloc_thread_cleanup() exists. If so, use |
michael@0 | 985 | dnl it rather than pthreads TSD cleanup functions to support cleanup during |
michael@0 | 986 | dnl thread exit, in order to avoid pthreads library recursion during |
michael@0 | 987 | dnl bootstrapping. |
michael@0 | 988 | AC_CHECK_FUNC([_malloc_thread_cleanup], |
michael@0 | 989 | [have__malloc_thread_cleanup="1"], |
michael@0 | 990 | [have__malloc_thread_cleanup="0"] |
michael@0 | 991 | ) |
michael@0 | 992 | if test "x$have__malloc_thread_cleanup" = "x1" ; then |
michael@0 | 993 | AC_DEFINE([JEMALLOC_MALLOC_THREAD_CLEANUP], [ ]) |
michael@0 | 994 | force_tls="1" |
michael@0 | 995 | fi |
michael@0 | 996 | |
michael@0 | 997 | dnl Check whether the BSD-specific _pthread_mutex_init_calloc_cb() exists. If |
michael@0 | 998 | dnl so, mutex initialization causes allocation, and we need to implement this |
michael@0 | 999 | dnl callback function in order to prevent recursive allocation. |
michael@0 | 1000 | AC_CHECK_FUNC([_pthread_mutex_init_calloc_cb], |
michael@0 | 1001 | [have__pthread_mutex_init_calloc_cb="1"], |
michael@0 | 1002 | [have__pthread_mutex_init_calloc_cb="0"] |
michael@0 | 1003 | ) |
michael@0 | 1004 | if test "x$have__pthread_mutex_init_calloc_cb" = "x1" ; then |
michael@0 | 1005 | AC_DEFINE([JEMALLOC_MUTEX_INIT_CB]) |
michael@0 | 1006 | fi |
michael@0 | 1007 | |
michael@0 | 1008 | dnl Disable lazy locking by default. |
michael@0 | 1009 | AC_ARG_ENABLE([lazy_lock], |
michael@0 | 1010 | [AS_HELP_STRING([--enable-lazy-lock], |
michael@0 | 1011 | [Enable lazy locking (only lock when multi-threaded)])], |
michael@0 | 1012 | [if test "x$enable_lazy_lock" = "xno" ; then |
michael@0 | 1013 | enable_lazy_lock="0" |
michael@0 | 1014 | else |
michael@0 | 1015 | enable_lazy_lock="1" |
michael@0 | 1016 | fi |
michael@0 | 1017 | ], |
michael@0 | 1018 | [enable_lazy_lock="0"] |
michael@0 | 1019 | ) |
michael@0 | 1020 | if test "x$enable_lazy_lock" = "x0" -a "x${force_lazy_lock}" = "x1" ; then |
michael@0 | 1021 | AC_MSG_RESULT([Forcing lazy-lock to avoid allocator/threading bootstrap issues]) |
michael@0 | 1022 | enable_lazy_lock="1" |
michael@0 | 1023 | fi |
michael@0 | 1024 | if test "x$enable_lazy_lock" = "x1" ; then |
michael@0 | 1025 | if test "x$abi" != "xpecoff" ; then |
michael@0 | 1026 | AC_CHECK_HEADERS([dlfcn.h], , [AC_MSG_ERROR([dlfcn.h is missing])]) |
michael@0 | 1027 | AC_CHECK_FUNC([dlsym], [], |
michael@0 | 1028 | [AC_CHECK_LIB([dl], [dlsym], [LIBS="$LIBS -ldl"], |
michael@0 | 1029 | [AC_MSG_ERROR([libdl is missing])]) |
michael@0 | 1030 | ]) |
michael@0 | 1031 | fi |
michael@0 | 1032 | AC_DEFINE([JEMALLOC_LAZY_LOCK], [ ]) |
michael@0 | 1033 | fi |
michael@0 | 1034 | AC_SUBST([enable_lazy_lock]) |
michael@0 | 1035 | |
michael@0 | 1036 | AC_ARG_ENABLE([tls], |
michael@0 | 1037 | [AS_HELP_STRING([--disable-tls], [Disable thread-local storage (__thread keyword)])], |
michael@0 | 1038 | if test "x$enable_tls" = "xno" ; then |
michael@0 | 1039 | enable_tls="0" |
michael@0 | 1040 | else |
michael@0 | 1041 | enable_tls="1" |
michael@0 | 1042 | fi |
michael@0 | 1043 | , |
michael@0 | 1044 | enable_tls="1" |
michael@0 | 1045 | ) |
michael@0 | 1046 | if test "x${enable_tls}" = "x0" -a "x${force_tls}" = "x1" ; then |
michael@0 | 1047 | AC_MSG_RESULT([Forcing TLS to avoid allocator/threading bootstrap issues]) |
michael@0 | 1048 | enable_tls="1" |
michael@0 | 1049 | fi |
michael@0 | 1050 | if test "x${enable_tls}" = "x1" -a "x${force_tls}" = "x0" ; then |
michael@0 | 1051 | AC_MSG_RESULT([Forcing no TLS to avoid allocator/threading bootstrap issues]) |
michael@0 | 1052 | enable_tls="0" |
michael@0 | 1053 | fi |
michael@0 | 1054 | if test "x${enable_tls}" = "x1" ; then |
michael@0 | 1055 | AC_MSG_CHECKING([for TLS]) |
michael@0 | 1056 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM( |
michael@0 | 1057 | [[ |
michael@0 | 1058 | __thread int x; |
michael@0 | 1059 | ]], [[ |
michael@0 | 1060 | x = 42; |
michael@0 | 1061 | |
michael@0 | 1062 | return 0; |
michael@0 | 1063 | ]])], |
michael@0 | 1064 | AC_MSG_RESULT([yes]), |
michael@0 | 1065 | AC_MSG_RESULT([no]) |
michael@0 | 1066 | enable_tls="0") |
michael@0 | 1067 | fi |
michael@0 | 1068 | AC_SUBST([enable_tls]) |
michael@0 | 1069 | if test "x${enable_tls}" = "x1" ; then |
michael@0 | 1070 | AC_DEFINE_UNQUOTED([JEMALLOC_TLS], [ ]) |
michael@0 | 1071 | elif test "x${force_tls}" = "x1" ; then |
michael@0 | 1072 | AC_MSG_ERROR([Failed to configure TLS, which is mandatory for correct function]) |
michael@0 | 1073 | fi |
michael@0 | 1074 | |
michael@0 | 1075 | dnl ============================================================================ |
michael@0 | 1076 | dnl Check for ffsl(3), and fail if not found. This function exists on all |
michael@0 | 1077 | dnl platforms that jemalloc currently has a chance of functioning on without |
michael@0 | 1078 | dnl modification. |
michael@0 | 1079 | JE_COMPILABLE([a program using ffsl], [ |
michael@0 | 1080 | #include <strings.h> |
michael@0 | 1081 | #include <string.h> |
michael@0 | 1082 | ], [ |
michael@0 | 1083 | { |
michael@0 | 1084 | int rv = ffsl(0x08); |
michael@0 | 1085 | } |
michael@0 | 1086 | ], [je_cv_function_ffsl]) |
michael@0 | 1087 | if test "x${je_cv_function_ffsl}" != "xyes" ; then |
michael@0 | 1088 | AC_MSG_ERROR([Cannot build without ffsl(3)]) |
michael@0 | 1089 | fi |
michael@0 | 1090 | |
michael@0 | 1091 | dnl ============================================================================ |
michael@0 | 1092 | dnl Check for atomic(9) operations as provided on FreeBSD. |
michael@0 | 1093 | |
michael@0 | 1094 | JE_COMPILABLE([atomic(9)], [ |
michael@0 | 1095 | #include <sys/types.h> |
michael@0 | 1096 | #include <machine/atomic.h> |
michael@0 | 1097 | #include <inttypes.h> |
michael@0 | 1098 | ], [ |
michael@0 | 1099 | { |
michael@0 | 1100 | uint32_t x32 = 0; |
michael@0 | 1101 | volatile uint32_t *x32p = &x32; |
michael@0 | 1102 | atomic_fetchadd_32(x32p, 1); |
michael@0 | 1103 | } |
michael@0 | 1104 | { |
michael@0 | 1105 | unsigned long xlong = 0; |
michael@0 | 1106 | volatile unsigned long *xlongp = &xlong; |
michael@0 | 1107 | atomic_fetchadd_long(xlongp, 1); |
michael@0 | 1108 | } |
michael@0 | 1109 | ], [je_cv_atomic9]) |
michael@0 | 1110 | if test "x${je_cv_atomic9}" = "xyes" ; then |
michael@0 | 1111 | AC_DEFINE([JEMALLOC_ATOMIC9]) |
michael@0 | 1112 | fi |
michael@0 | 1113 | |
michael@0 | 1114 | dnl ============================================================================ |
michael@0 | 1115 | dnl Check for atomic(3) operations as provided on Darwin. |
michael@0 | 1116 | |
michael@0 | 1117 | JE_COMPILABLE([Darwin OSAtomic*()], [ |
michael@0 | 1118 | #include <libkern/OSAtomic.h> |
michael@0 | 1119 | #include <inttypes.h> |
michael@0 | 1120 | ], [ |
michael@0 | 1121 | { |
michael@0 | 1122 | int32_t x32 = 0; |
michael@0 | 1123 | volatile int32_t *x32p = &x32; |
michael@0 | 1124 | OSAtomicAdd32(1, x32p); |
michael@0 | 1125 | } |
michael@0 | 1126 | { |
michael@0 | 1127 | int64_t x64 = 0; |
michael@0 | 1128 | volatile int64_t *x64p = &x64; |
michael@0 | 1129 | OSAtomicAdd64(1, x64p); |
michael@0 | 1130 | } |
michael@0 | 1131 | ], [je_cv_osatomic]) |
michael@0 | 1132 | if test "x${je_cv_osatomic}" = "xyes" ; then |
michael@0 | 1133 | AC_DEFINE([JEMALLOC_OSATOMIC], [ ]) |
michael@0 | 1134 | fi |
michael@0 | 1135 | |
michael@0 | 1136 | dnl ============================================================================ |
michael@0 | 1137 | dnl Check whether __sync_{add,sub}_and_fetch() are available despite |
michael@0 | 1138 | dnl __GCC_HAVE_SYNC_COMPARE_AND_SWAP_n macros being undefined. |
michael@0 | 1139 | |
michael@0 | 1140 | AC_DEFUN([JE_SYNC_COMPARE_AND_SWAP_CHECK],[ |
michael@0 | 1141 | AC_CACHE_CHECK([whether to force $1-bit __sync_{add,sub}_and_fetch()], |
michael@0 | 1142 | [je_cv_sync_compare_and_swap_$2], |
michael@0 | 1143 | [AC_LINK_IFELSE([AC_LANG_PROGRAM([ |
michael@0 | 1144 | #include <stdint.h> |
michael@0 | 1145 | ], |
michael@0 | 1146 | [ |
michael@0 | 1147 | #ifndef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2 |
michael@0 | 1148 | { |
michael@0 | 1149 | uint$1_t x$1 = 0; |
michael@0 | 1150 | __sync_add_and_fetch(&x$1, 42); |
michael@0 | 1151 | __sync_sub_and_fetch(&x$1, 1); |
michael@0 | 1152 | } |
michael@0 | 1153 | #else |
michael@0 | 1154 | #error __GCC_HAVE_SYNC_COMPARE_AND_SWAP_$2 is defined, no need to force |
michael@0 | 1155 | #endif |
michael@0 | 1156 | ])], |
michael@0 | 1157 | [je_cv_sync_compare_and_swap_$2=yes], |
michael@0 | 1158 | [je_cv_sync_compare_and_swap_$2=no])]) |
michael@0 | 1159 | |
michael@0 | 1160 | if test "x${je_cv_sync_compare_and_swap_$2}" = "xyes" ; then |
michael@0 | 1161 | AC_DEFINE([JE_FORCE_SYNC_COMPARE_AND_SWAP_$2], [ ]) |
michael@0 | 1162 | fi |
michael@0 | 1163 | ]) |
michael@0 | 1164 | |
michael@0 | 1165 | if test "x${je_cv_atomic9}" != "xyes" -a "x${je_cv_osatomic}" != "xyes" ; then |
michael@0 | 1166 | JE_SYNC_COMPARE_AND_SWAP_CHECK(32, 4) |
michael@0 | 1167 | JE_SYNC_COMPARE_AND_SWAP_CHECK(64, 8) |
michael@0 | 1168 | fi |
michael@0 | 1169 | |
michael@0 | 1170 | dnl ============================================================================ |
michael@0 | 1171 | dnl Check for spinlock(3) operations as provided on Darwin. |
michael@0 | 1172 | |
michael@0 | 1173 | JE_COMPILABLE([Darwin OSSpin*()], [ |
michael@0 | 1174 | #include <libkern/OSAtomic.h> |
michael@0 | 1175 | #include <inttypes.h> |
michael@0 | 1176 | ], [ |
michael@0 | 1177 | OSSpinLock lock = 0; |
michael@0 | 1178 | OSSpinLockLock(&lock); |
michael@0 | 1179 | OSSpinLockUnlock(&lock); |
michael@0 | 1180 | ], [je_cv_osspin]) |
michael@0 | 1181 | if test "x${je_cv_osspin}" = "xyes" ; then |
michael@0 | 1182 | AC_DEFINE([JEMALLOC_OSSPIN], [ ]) |
michael@0 | 1183 | fi |
michael@0 | 1184 | |
michael@0 | 1185 | dnl ============================================================================ |
michael@0 | 1186 | dnl Darwin-related configuration. |
michael@0 | 1187 | |
michael@0 | 1188 | if test "x${abi}" = "xmacho" ; then |
michael@0 | 1189 | AC_DEFINE([JEMALLOC_IVSALLOC], [ ]) |
michael@0 | 1190 | AC_DEFINE([JEMALLOC_ZONE], [ ]) |
michael@0 | 1191 | |
michael@0 | 1192 | dnl The szone version jumped from 3 to 6 between the OS X 10.5.x and 10.6 |
michael@0 | 1193 | dnl releases. malloc_zone_t and malloc_introspection_t have new fields in |
michael@0 | 1194 | dnl 10.6, which is the only source-level indication of the change. |
michael@0 | 1195 | AC_MSG_CHECKING([malloc zone version]) |
michael@0 | 1196 | AC_DEFUN([JE_ZONE_PROGRAM], |
michael@0 | 1197 | [AC_LANG_PROGRAM( |
michael@0 | 1198 | [#include <malloc/malloc.h>], |
michael@0 | 1199 | [static foo[[sizeof($1) $2 sizeof(void *) * $3 ? 1 : -1]]] |
michael@0 | 1200 | )]) |
michael@0 | 1201 | |
michael@0 | 1202 | AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,14)],[JEMALLOC_ZONE_VERSION=3],[ |
michael@0 | 1203 | AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,15)],[JEMALLOC_ZONE_VERSION=5],[ |
michael@0 | 1204 | AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,16)],[ |
michael@0 | 1205 | AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,9)],[JEMALLOC_ZONE_VERSION=6],[ |
michael@0 | 1206 | AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_introspection_t,==,13)],[JEMALLOC_ZONE_VERSION=7],[JEMALLOC_ZONE_VERSION=] |
michael@0 | 1207 | )])],[ |
michael@0 | 1208 | AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,==,17)],[JEMALLOC_ZONE_VERSION=8],[ |
michael@0 | 1209 | AC_COMPILE_IFELSE([JE_ZONE_PROGRAM(malloc_zone_t,>,17)],[JEMALLOC_ZONE_VERSION=9],[JEMALLOC_ZONE_VERSION=] |
michael@0 | 1210 | )])])])]) |
michael@0 | 1211 | if test "x${JEMALLOC_ZONE_VERSION}" = "x"; then |
michael@0 | 1212 | AC_MSG_RESULT([unsupported]) |
michael@0 | 1213 | AC_MSG_ERROR([Unsupported malloc zone version]) |
michael@0 | 1214 | fi |
michael@0 | 1215 | if test "${JEMALLOC_ZONE_VERSION}" = 9; then |
michael@0 | 1216 | JEMALLOC_ZONE_VERSION=8 |
michael@0 | 1217 | AC_MSG_RESULT([> 8]) |
michael@0 | 1218 | else |
michael@0 | 1219 | AC_MSG_RESULT([$JEMALLOC_ZONE_VERSION]) |
michael@0 | 1220 | fi |
michael@0 | 1221 | AC_DEFINE_UNQUOTED(JEMALLOC_ZONE_VERSION, [$JEMALLOC_ZONE_VERSION]) |
michael@0 | 1222 | fi |
michael@0 | 1223 | |
michael@0 | 1224 | dnl ============================================================================ |
michael@0 | 1225 | dnl Check for typedefs, structures, and compiler characteristics. |
michael@0 | 1226 | AC_HEADER_STDBOOL |
michael@0 | 1227 | |
michael@0 | 1228 | AC_CONFIG_COMMANDS([include/jemalloc/internal/size_classes.h], [ |
michael@0 | 1229 | mkdir -p "include/jemalloc/internal" |
michael@0 | 1230 | "${srcdir}/include/jemalloc/internal/size_classes.sh" > "${objroot}include/jemalloc/internal/size_classes.h" |
michael@0 | 1231 | ]) |
michael@0 | 1232 | |
michael@0 | 1233 | dnl Process .in files. |
michael@0 | 1234 | AC_SUBST([cfghdrs_in]) |
michael@0 | 1235 | AC_SUBST([cfghdrs_out]) |
michael@0 | 1236 | AC_CONFIG_HEADERS([$cfghdrs_tup]) |
michael@0 | 1237 | |
michael@0 | 1238 | dnl ============================================================================ |
michael@0 | 1239 | dnl Generate outputs. |
michael@0 | 1240 | AC_CONFIG_FILES([$cfgoutputs_tup config.stamp bin/jemalloc.sh]) |
michael@0 | 1241 | AC_SUBST([cfgoutputs_in]) |
michael@0 | 1242 | AC_SUBST([cfgoutputs_out]) |
michael@0 | 1243 | AC_OUTPUT |
michael@0 | 1244 | |
michael@0 | 1245 | dnl ============================================================================ |
michael@0 | 1246 | dnl Print out the results of configuration. |
michael@0 | 1247 | AC_MSG_RESULT([===============================================================================]) |
michael@0 | 1248 | AC_MSG_RESULT([jemalloc version : ${jemalloc_version}]) |
michael@0 | 1249 | AC_MSG_RESULT([library revision : ${rev}]) |
michael@0 | 1250 | AC_MSG_RESULT([]) |
michael@0 | 1251 | AC_MSG_RESULT([CC : ${CC}]) |
michael@0 | 1252 | AC_MSG_RESULT([CPPFLAGS : ${CPPFLAGS}]) |
michael@0 | 1253 | AC_MSG_RESULT([CFLAGS : ${CFLAGS}]) |
michael@0 | 1254 | AC_MSG_RESULT([LDFLAGS : ${LDFLAGS}]) |
michael@0 | 1255 | AC_MSG_RESULT([LIBS : ${LIBS}]) |
michael@0 | 1256 | AC_MSG_RESULT([RPATH_EXTRA : ${RPATH_EXTRA}]) |
michael@0 | 1257 | AC_MSG_RESULT([]) |
michael@0 | 1258 | AC_MSG_RESULT([XSLTPROC : ${XSLTPROC}]) |
michael@0 | 1259 | AC_MSG_RESULT([XSLROOT : ${XSLROOT}]) |
michael@0 | 1260 | AC_MSG_RESULT([]) |
michael@0 | 1261 | AC_MSG_RESULT([PREFIX : ${PREFIX}]) |
michael@0 | 1262 | AC_MSG_RESULT([BINDIR : ${BINDIR}]) |
michael@0 | 1263 | AC_MSG_RESULT([INCLUDEDIR : ${INCLUDEDIR}]) |
michael@0 | 1264 | AC_MSG_RESULT([LIBDIR : ${LIBDIR}]) |
michael@0 | 1265 | AC_MSG_RESULT([DATADIR : ${DATADIR}]) |
michael@0 | 1266 | AC_MSG_RESULT([MANDIR : ${MANDIR}]) |
michael@0 | 1267 | AC_MSG_RESULT([]) |
michael@0 | 1268 | AC_MSG_RESULT([srcroot : ${srcroot}]) |
michael@0 | 1269 | AC_MSG_RESULT([abs_srcroot : ${abs_srcroot}]) |
michael@0 | 1270 | AC_MSG_RESULT([objroot : ${objroot}]) |
michael@0 | 1271 | AC_MSG_RESULT([abs_objroot : ${abs_objroot}]) |
michael@0 | 1272 | AC_MSG_RESULT([]) |
michael@0 | 1273 | AC_MSG_RESULT([JEMALLOC_PREFIX : ${JEMALLOC_PREFIX}]) |
michael@0 | 1274 | AC_MSG_RESULT([JEMALLOC_PRIVATE_NAMESPACE]) |
michael@0 | 1275 | AC_MSG_RESULT([ : ${JEMALLOC_PRIVATE_NAMESPACE}]) |
michael@0 | 1276 | AC_MSG_RESULT([install_suffix : ${install_suffix}]) |
michael@0 | 1277 | AC_MSG_RESULT([autogen : ${enable_autogen}]) |
michael@0 | 1278 | AC_MSG_RESULT([experimental : ${enable_experimental}]) |
michael@0 | 1279 | AC_MSG_RESULT([cc-silence : ${enable_cc_silence}]) |
michael@0 | 1280 | AC_MSG_RESULT([debug : ${enable_debug}]) |
michael@0 | 1281 | AC_MSG_RESULT([stats : ${enable_stats}]) |
michael@0 | 1282 | AC_MSG_RESULT([prof : ${enable_prof}]) |
michael@0 | 1283 | AC_MSG_RESULT([prof-libunwind : ${enable_prof_libunwind}]) |
michael@0 | 1284 | AC_MSG_RESULT([prof-libgcc : ${enable_prof_libgcc}]) |
michael@0 | 1285 | AC_MSG_RESULT([prof-gcc : ${enable_prof_gcc}]) |
michael@0 | 1286 | AC_MSG_RESULT([tcache : ${enable_tcache}]) |
michael@0 | 1287 | AC_MSG_RESULT([fill : ${enable_fill}]) |
michael@0 | 1288 | AC_MSG_RESULT([utrace : ${enable_utrace}]) |
michael@0 | 1289 | AC_MSG_RESULT([valgrind : ${enable_valgrind}]) |
michael@0 | 1290 | AC_MSG_RESULT([xmalloc : ${enable_xmalloc}]) |
michael@0 | 1291 | AC_MSG_RESULT([mremap : ${enable_mremap}]) |
michael@0 | 1292 | AC_MSG_RESULT([munmap : ${enable_munmap}]) |
michael@0 | 1293 | AC_MSG_RESULT([dss : ${enable_dss}]) |
michael@0 | 1294 | AC_MSG_RESULT([lazy_lock : ${enable_lazy_lock}]) |
michael@0 | 1295 | AC_MSG_RESULT([tls : ${enable_tls}]) |
michael@0 | 1296 | AC_MSG_RESULT([===============================================================================]) |