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