[66502b8] | 1 | dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll |
---|
[c2eb2e] | 2 | dnl File: configure.ac |
---|
[66502b8] | 3 | dnl Purpose: Process this file with autoconf to produce configure |
---|
| 4 | dnl Author: obachman@mathematik.uni-kl.de (Olaf Bachmann) |
---|
| 5 | dnl Created: 11/99 |
---|
| 6 | dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll |
---|
| 7 | |
---|
[ab788d] | 8 | AC_INIT([omalloc],[0.9.6]) |
---|
[9634a6] | 9 | |
---|
[60bdf0] | 10 | AC_CONFIG_MACRO_DIR([../m4]) |
---|
[9634a6] | 11 | AC_CONFIG_AUX_DIR([.]) |
---|
[60bdf0] | 12 | AC_CONFIG_SRCDIR(om_Alloc.c) |
---|
[49ea49] | 13 | AC_CONFIG_HEADER(omConfig.h) |
---|
| 14 | |
---|
[60bdf0] | 15 | SING_RESET_FLAGS() |
---|
| 16 | |
---|
[ea0001] | 17 | AM_MAINTAINER_MODE |
---|
[24a77fb] | 18 | AM_INIT_AUTOMAKE([-Wall foreign subdir-objects]) # -Wno-extra-portability -Werror silent-rules |
---|
[25761d] | 19 | m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) |
---|
[280286e] | 20 | m4_ifdef([AM_PROG_AR], [AM_PROG_AR]) |
---|
[2e984a] | 21 | |
---|
[60bdf0] | 22 | AM_SANITY_CHECK |
---|
| 23 | |
---|
[49ea49] | 24 | # Add pre'prefixed config |
---|
| 25 | AX_PREFIX_CONFIG_H([omConfig.h],[],[omConfig.h]) |
---|
| 26 | |
---|
[19efd96] | 27 | # SING_CHECK_SET_ARGS() |
---|
| 28 | |
---|
[60bdf0] | 29 | AC_SUBST(VERSION) |
---|
| 30 | |
---|
[66502b8] | 31 | dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll |
---|
| 32 | dnl help for configure |
---|
| 33 | dnl |
---|
[2b43ac] | 34 | |
---|
[66502b8] | 35 | AC_ARG_WITH( |
---|
[3df5b10] | 36 | external-config_h, |
---|
[be7466] | 37 | [ --with-external-config_h=HEADER_FILE |
---|
| 38 | use HEADER_FILE for external configuration]) |
---|
[66502b8] | 39 | AC_ARG_WITH( |
---|
[3df5b10] | 40 | external-config_c, |
---|
[be7466] | 41 | [ --with-external-config_c=C_FILE |
---|
| 42 | use C_FILE for external implementations]) |
---|
[212fc04] | 43 | AC_ARG_WITH( |
---|
[be7466] | 44 | malloc, |
---|
[09ed77] | 45 | [ --with-malloc=system|external |
---|
[1122b2] | 46 | which malloc to use, default: malloc ]) |
---|
[be7466] | 47 | AC_ARG_WITH( |
---|
[3df5b10] | 48 | external-malloc_h, |
---|
[be7466] | 49 | [ --with-external-malloc-h=HEADER_FILE |
---|
| 50 | use HEADER_FILE for external malloc declaration]) |
---|
| 51 | AC_ARG_WITH( |
---|
[3df5b10] | 52 | external-malloc_c, |
---|
| 53 | [ --with-external-malloc-c=C_FILE |
---|
[be7466] | 54 | use C_FILE for external malloc implementation]) |
---|
| 55 | AC_ARG_WITH( |
---|
| 56 | valloc, |
---|
[50c8e82] | 57 | [ --with-valloc=mmap|system|emulate |
---|
[be7466] | 58 | how to get page-aligned memory, default: use first possible]) |
---|
| 59 | AC_ARG_WITH( |
---|
| 60 | align, |
---|
[8d0069] | 61 | [ --with-align=8|sloppy|strict |
---|
| 62 | how memory is aligned, |
---|
[be7466] | 63 | default: if possible sloppy, else strict]) |
---|
| 64 | AC_ARG_WITH( |
---|
[3df5b10] | 65 | dense-bins, |
---|
[be7466] | 66 | [ --with-dense-bins use dense bin distribution]) |
---|
| 67 | AC_ARG_WITH( |
---|
| 68 | inline, |
---|
| 69 | [ --without-inline do not inline]) |
---|
| 70 | AC_ARG_WITH( |
---|
[3df5b10] | 71 | debug, |
---|
| 72 | [ --without-debug disable all debugging facilities]) |
---|
[be7466] | 73 | AC_ARG_WITH( |
---|
[3df5b10] | 74 | track, |
---|
| 75 | [ --without-track disable debug tracking functionality]) |
---|
[212fc04] | 76 | AC_ARG_WITH( |
---|
[3df5b10] | 77 | track-fl, |
---|
| 78 | [ --with-track-fl track file and line numbers]) |
---|
[be7466] | 79 | AC_ARG_WITH( |
---|
[3df5b10] | 80 | track-return, |
---|
| 81 | [ --with-track-return track return addresses]) |
---|
| 82 | AC_ARG_WITH( |
---|
| 83 | track-backtrace, |
---|
| 84 | [ --with-track-backtrace track stack backtraces]) |
---|
[fe7bd4] | 85 | AC_ARG_WITH( |
---|
[76801a] | 86 | track-custom, |
---|
[8d0069] | 87 | [ --with-track-custom track custom values]) |
---|
[3df5b10] | 88 | AC_ARG_WITH( |
---|
| 89 | internal_debug, |
---|
[8d0069] | 90 | [ --with-internal-debug |
---|
[3df5b10] | 91 | turn on internal debugging]) |
---|
[66502b8] | 92 | dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll |
---|
| 93 | dnl compiler/make config |
---|
| 94 | dnl |
---|
[3df5b10] | 95 | dnl I'm not sure why I did this |
---|
| 96 | dnl if test "${CFLAGS+set}" != set; then |
---|
| 97 | dnl CFLAGS="-O" |
---|
| 98 | dnl ac_cflags_set=no |
---|
| 99 | dnl fi |
---|
| 100 | |
---|
[e92dc4a] | 101 | CPPFLAGS="-I.. -I." |
---|
[66502b8] | 102 | AC_PROG_MAKE_SET |
---|
| 103 | AC_PROG_CC |
---|
| 104 | AC_PROG_CPP |
---|
[80c102] | 105 | |
---|
[be7466] | 106 | AC_PROG_LN_S |
---|
[3df5b10] | 107 | AC_PROG_INSTALL |
---|
[97b5d5] | 108 | AM_PROG_CC_C_O |
---|
[e078e0] | 109 | # AM_PROG_AR |
---|
[3df5b10] | 110 | AC_C_CONST |
---|
| 111 | AC_C_INLINE |
---|
[be7466] | 112 | |
---|
[80c102] | 113 | LT_INIT |
---|
| 114 | |
---|
| 115 | |
---|
[be7466] | 116 | dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll |
---|
| 117 | dnl check for programs |
---|
| 118 | dnl |
---|
[66502b8] | 119 | AC_CHECK_PROG(AR, ar, ar, :) |
---|
| 120 | if test "$ac_cv_prog_AR" != ar; then |
---|
| 121 | AC_MSG_ERROR(*** ar program not found) |
---|
| 122 | fi |
---|
[78f1ab] | 123 | AC_CHECK_PROGS(PERL, perl, "no") |
---|
| 124 | if test "$ac_cv_prog_PERL" = no; then |
---|
[66502b8] | 125 | AC_MSG_ERROR(*** perl program not found) |
---|
| 126 | fi |
---|
| 127 | |
---|
| 128 | AC_CHECK_PROG(ADDR2LINE, addr2line, addr2line, no) |
---|
| 129 | if test "$ac_cv_prog_ADDR2LINE" = addr2line; then |
---|
[97b5d5] | 130 | AC_DEFINE_UNQUOTED(OM_PROG_ADDR2LINE, "$ac_cv_prog_ADDR2LINE", "Name of addr2line") |
---|
[66502b8] | 131 | fi |
---|
| 132 | |
---|
[be7466] | 133 | dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll |
---|
| 134 | dnl header file checks |
---|
| 135 | dnl |
---|
[66502b8] | 136 | AC_HEADER_STDC |
---|
| 137 | AC_CHECK_HEADERS(limits.h,, |
---|
| 138 | AC_MSG_ERROR(Can not compile without limits.h)) |
---|
[8fee84] | 139 | |
---|
[6acb5a5] | 140 | AC_CHECK_HEADERS(unistd.h sys/mman.h fcntl.h /usr/include/malloc.h) |
---|
[66502b8] | 141 | |
---|
[8fee84] | 142 | AC_CHECK_FUNCS(popen mmap sbrk random) |
---|
[66502b8] | 143 | |
---|
[be7466] | 144 | dnl llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll |
---|
| 145 | dnl Find out more about particularity of the system |
---|
| 146 | dnl |
---|
[66502b8] | 147 | |
---|
[be7466] | 148 | # sizes |
---|
| 149 | AC_CHECK_SIZEOF(long,4) |
---|
| 150 | AC_CHECK_SIZEOF(void*,4) |
---|
| 151 | AC_CHECK_SIZEOF(double, 8) |
---|
| 152 | AC_CHECK_SIZEOF(size_t, 4) |
---|
| 153 | |
---|
| 154 | if test "$ac_cv_sizeof_long" != "$ac_cv_sizeof_voidp"; then |
---|
| 155 | AC_MSG_ERROR(need equal sizes for long and void*) |
---|
| 156 | fi |
---|
| 157 | if test "$ac_cv_sizeof_voidp" != 4 && test "$ac_cv_sizeof_voidp" != 8; then |
---|
| 158 | AC_MSG_ERROR(need void* to be 4 or 8 bytes long) |
---|
| 159 | fi |
---|
| 160 | if test "$ac_cv_sizeof_double" != 4 && test "$ac_cv_sizeof_double" != 8; then |
---|
| 161 | AC_MSG_ERROR(need double to be 4 or 8 bytes long) |
---|
| 162 | fi |
---|
| 163 | |
---|
[adb2ed] | 164 | dnl Set compiler, linker flags so that we can work with omalloc |
---|
| 165 | BACKUP_CFLAGS=$CFLAGS |
---|
| 166 | BACKUP_CXXFLAGS=$CXXFLAGS |
---|
| 167 | BACKUP_LDFLAGS=$LDFLAGS |
---|
[9cf75aa] | 168 | |
---|
[adb2ed] | 169 | CFLAGS="$CFLAGS -I$srcdir" |
---|
| 170 | CXXFLAGS="$CXXFLAGS -I$srcdir" |
---|
| 171 | |
---|
[be7466] | 172 | dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll |
---|
| 173 | dnl figure out page size of the system |
---|
| 174 | dnl |
---|
| 175 | AC_MSG_CHECKING(size of system page) |
---|
| 176 | AC_CACHE_VAL(ac_cv_pagesize, |
---|
| 177 | AC_TRY_RUN([#include <stdio.h> |
---|
[e078e0] | 178 | #include <stdlib.h> |
---|
[be7466] | 179 | #include "omGetPageSize.h" |
---|
| 180 | |
---|
| 181 | main() |
---|
| 182 | { |
---|
| 183 | FILE *f=fopen("conftestval", "w"); |
---|
| 184 | if (!f) exit(1); |
---|
| 185 | fprintf(f, "%d\n", omalloc_getpagesize); |
---|
| 186 | exit(0); |
---|
| 187 | }], ac_cv_pagesize=`cat conftestval`, ac_cv_pagesize=0, ac_cv_pagesize=0)) |
---|
[8d0069] | 188 | # can not really handle pagesizes which are greater -- there must be a |
---|
[1d905d] | 189 | # bug somewhere |
---|
| 190 | if test $ac_cv_pagesize -gt 8192; then |
---|
| 191 | ac_cv_pagesize=8192 |
---|
| 192 | fi |
---|
[be7466] | 193 | AC_MSG_RESULT($ac_cv_pagesize) |
---|
| 194 | if test "$ac_cv_pagesize" = 4096 || test "$ac_cv_pagesize" = 8192; then |
---|
[97b5d5] | 195 | AC_DEFINE_UNQUOTED(SIZEOF_SYSTEM_PAGE, $ac_cv_pagesize, "Page-size of the build-system") |
---|
[be7466] | 196 | else |
---|
[adb2ed] | 197 | AC_MSG_ERROR([need sytem page to be of size 4096 or 8192, but is $ac_cv_pagesize]) |
---|
[be7466] | 198 | fi |
---|
[212fc04] | 199 | |
---|
[66602d] | 200 | AC_DEFINE_UNQUOTED(SIZEOF_OM_PAGE,SIZEOF_SYSTEM_PAGE,Page-size of the build-system) |
---|
| 201 | |
---|
[be7466] | 202 | dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll |
---|
| 203 | dnl check whether mmap actually works |
---|
| 204 | dnl |
---|
| 205 | if test "$ac_cv_func_mmap" = yes; then |
---|
| 206 | AC_MSG_CHECKING(whether mmap works) |
---|
| 207 | AC_CACHE_VAL(ac_cv_working_mmap, |
---|
| 208 | AC_TRY_RUN([ |
---|
[e078e0] | 209 | #include <stdlib.h> |
---|
[be7466] | 210 | #include "omMmap.c" |
---|
| 211 | main() |
---|
| 212 | { |
---|
| 213 | void* addr = omVallocMmap(128*${ac_cv_pagesize}); |
---|
| 214 | if (addr == 0 || ((unsigned long) addr % ${ac_cv_pagesize})) |
---|
| 215 | exit(1); |
---|
| 216 | exit(omVfreeMmap(addr, 128*${ac_cv_pagesize})); |
---|
| 217 | }], ac_cv_working_mmap=yes, ac_cv_working_mmap=no, ac_cv_working_mmap=no)) |
---|
| 218 | AC_MSG_RESULT($ac_cv_working_mmap) |
---|
| 219 | if test "$ac_cv_working_mmap" = yes; then |
---|
[97b5d5] | 220 | AC_DEFINE(HAVE_WORKING_MMAP,1,"Whether we have a working mmap") |
---|
[be7466] | 221 | fi |
---|
| 222 | fi |
---|
| 223 | |
---|
| 224 | dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll |
---|
| 225 | dnl for strict alignment |
---|
| 226 | dnl |
---|
| 227 | AC_CACHE_CHECK(whether alignment needs to be strict, ac_cv_align_need_strict, |
---|
[8d0069] | 228 | AC_TRY_RUN([ |
---|
[e078e0] | 229 | #include <stdlib.h> |
---|
[8d0069] | 230 | main() |
---|
[be7466] | 231 | { |
---|
[8d0069] | 232 | void* ptr = (void*) malloc(12); |
---|
[58d429] | 233 | volatile double* d_ptr; |
---|
[8d0069] | 234 | if ((unsigned long) ptr % 8 == 0) ptr = ptr + 4; |
---|
[be7466] | 235 | d_ptr = (double*) ptr; |
---|
[58d429] | 236 | *d_ptr = (double) 1.25; |
---|
| 237 | if (*d_ptr != (double) 1.25) exit(1); |
---|
[be7466] | 238 | else exit(0); |
---|
| 239 | } |
---|
| 240 | ], ac_cv_align_need_strict=no, ac_cv_align_need_strict=yes, ac_cv_align_need_strict=yes)) |
---|
| 241 | |
---|
| 242 | dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll |
---|
| 243 | dnl external config files |
---|
| 244 | dnl |
---|
| 245 | AC_MSG_CHECKING(for external config files) |
---|
| 246 | if test "${with_external_config_h+set}" = set; then |
---|
[97b5d5] | 247 | AC_DEFINE(OM_HAVE_EXTERNAL_CONFIG_H,1,"Whether we have external config.h") |
---|
[be7466] | 248 | EXTERNAL_CONFIG_HEADER=${with_external_config_h} |
---|
[3df5b10] | 249 | rm -f omExternalConfig.h |
---|
| 250 | cp ${with_external_config_h} omExternalConfig.h |
---|
[be7466] | 251 | fi |
---|
| 252 | if test "${with_external_config_c+set}" = set; then |
---|
[97b5d5] | 253 | AC_DEFINE(OM_HAVE_EXTERNAL_CONFIG_C,1,"Wether we have an external config.c") |
---|
[be7466] | 254 | EXTERNAL_CONFIG_SOURCE=${with_external_config_c} |
---|
| 255 | fi |
---|
| 256 | AC_SUBST(EXTERNAL_CONFIG_HEADER) |
---|
| 257 | AC_SUBST(EXTERNAL_CONFIG_SOURCE) |
---|
| 258 | if test "${EXTERNAL_CONFIG_HEADER+set}" = set || test "${EXTERNAL_CONFIG_SOURCE+set}" = set; then |
---|
| 259 | AC_MSG_RESULT(${EXTERNAL_CONFIG_HEADER} ${EXTERNAL_CONFIG_SOURCE}) |
---|
| 260 | else |
---|
| 261 | AC_MSG_RESULT(none) |
---|
| 262 | fi |
---|
| 263 | |
---|
| 264 | dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll |
---|
| 265 | dnl for malloc |
---|
| 266 | dnl |
---|
| 267 | AC_MSG_CHECKING(which malloc to use) |
---|
| 268 | if test "${with_malloc}" = system; then |
---|
| 269 | OM_MALLOC_HEADER=omMallocSystem.h |
---|
[a2f973] | 270 | AC_DEFINE(OMALLOC_USES_MALLOC,1,the system allocator is called malloc) |
---|
| 271 | AC_DEFINE(OMALLOC_USES_SYSTEM_MALLOC,1,use system malloc as system allocator) |
---|
[be7466] | 272 | elif test "${with_malloc}" = external; then |
---|
[8d0069] | 273 | if test "${with_external_malloc_h+set}" != set; then |
---|
[be7466] | 274 | AC_MSG_ERROR(need --with_external_malloc_h for external malloc) |
---|
| 275 | fi |
---|
[a2f973] | 276 | AC_DEFINE(OMALLOC_USES_EXTERNAL_MALLOC,1,use external malloc as system allocator) |
---|
[be7466] | 277 | OM_MALLOC_HEADER=$with_external_malloc_h |
---|
| 278 | OM_MALLOC_SOURCE=$with_external_malloc_c |
---|
[a2f973] | 279 | AC_DEFINE(OMALLOC_USES_MALLOC,1,the system allocator is called malloc) |
---|
| 280 | else ## default |
---|
[1122b2] | 281 | OM_MALLOC_HEADER=omMallocSystem.h |
---|
[a2f973] | 282 | AC_DEFINE(OMALLOC_USES_MALLOC,1,the system allocator is called malloc) |
---|
| 283 | AC_DEFINE(OMALLOC_USES_SYSTEM_MALLOC,1,use system malloc as system allocator) |
---|
[be7466] | 284 | fi |
---|
| 285 | AC_MSG_RESULT($with_malloc) |
---|
[fe6cc2] | 286 | |
---|
[be7466] | 287 | AC_SUBST(OM_MALLOC_HEADER) |
---|
| 288 | AC_SUBST(OM_MALLOC_SOURCE) |
---|
| 289 | if test "${OM_MALLOC_SOURCE+set}" = set; then |
---|
[97b5d5] | 290 | AC_DEFINE(OM_HAVE_MALLOC_SOURCE,1,"Whether we have the source for malloc ()") |
---|
[be7466] | 291 | fi |
---|
| 292 | |
---|
| 293 | AC_MSG_CHECKING(whether malloc provides SizeOfAddr) |
---|
| 294 | if test "${ac_cv_malloc_sizeof_addr}" = no; then |
---|
| 295 | AC_MSG_RESULT( (cached) no) |
---|
| 296 | elif test "${ac_cv_malloc_sizeof_addr}" = "${OM_MALLOC_HEADER}_${OM_MALLOC_SOURCE}"; then |
---|
| 297 | AC_MSG_RESULT( (cached) yes) |
---|
| 298 | else |
---|
| 299 | AC_TRY_RUN([ |
---|
[e078e0] | 300 | #include <stdlib.h> |
---|
[be7466] | 301 | #include "$OM_MALLOC_HEADER" |
---|
| 302 | #ifdef OM_HAVE_MALLOC_SOURCE |
---|
| 303 | #include "$OM_MALLOC_SOURCE" |
---|
| 304 | #endif |
---|
| 305 | |
---|
| 306 | main() |
---|
| 307 | { |
---|
| 308 | void* addr = OM_MALLOC_MALLOC(512); |
---|
[9cf75aa] | 309 | #ifdef OM_MALLOC_SIZEOF_ADDR |
---|
[be7466] | 310 | if (OM_MALLOC_SIZEOF_ADDR(addr) < 512) |
---|
| 311 | exit(1); |
---|
| 312 | exit(0); |
---|
[9cf75aa] | 313 | #else |
---|
| 314 | exit(1); |
---|
| 315 | #endif |
---|
[be7466] | 316 | } |
---|
| 317 | ], ac_cv_malloc_sizeof_addr="${OM_MALLOC_HEADER}_${OM_MALLOC_SOURCE}", ac_cv_malloc_sizeof_addr=no, ac_cv_malloc_sizeof_addr=no) |
---|
| 318 | if test "${ac_cv_malloc_sizeof_addr}" = no; then |
---|
| 319 | AC_MSG_RESULT(no) |
---|
| 320 | else |
---|
| 321 | AC_MSG_RESULT(yes) |
---|
| 322 | fi |
---|
| 323 | fi |
---|
| 324 | if test "$ac_cv_malloc_sizeof_addr" != no; then |
---|
[97b5d5] | 325 | AC_DEFINE(OM_MALLOC_PROVIDES_SIZEOF_ADDR,1,"Whether malloc provides SIZEOF_ADDR") |
---|
[be7466] | 326 | fi |
---|
[8d0069] | 327 | |
---|
[be7466] | 328 | dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll |
---|
| 329 | dnl check whether valloc is provided and that it works |
---|
| 330 | dnl |
---|
| 331 | AC_MSG_CHECKING(whether working valloc exists) |
---|
| 332 | if test "${ac_cv_working_valloc}" = no; then |
---|
| 333 | AC_MSG_RESULT( (cached) no) |
---|
| 334 | elif test "${ac_cv_working_valloc}" = "${OM_MALLOC_HEADER}_${OM_MALLOC_SOURCE}"; then |
---|
| 335 | AC_MSG_RESULT( (cached) yes) |
---|
| 336 | else |
---|
| 337 | AC_TRY_RUN([ |
---|
[e078e0] | 338 | #include <stdlib.h> |
---|
[be7466] | 339 | #include "$OM_MALLOC_HEADER" |
---|
| 340 | #ifdef OM_HAVE_MALLOC_SOURCE |
---|
| 341 | #include "$OM_MALLOC_SOURCE" |
---|
| 342 | #endif |
---|
| 343 | |
---|
| 344 | main() |
---|
| 345 | { |
---|
| 346 | void* addr = OM_MALLOC_VALLOC(128*${ac_cv_pagesize}); |
---|
| 347 | if (addr == 0 || ((unsigned long) addr % ${ac_cv_pagesize})) |
---|
| 348 | exit(1); |
---|
| 349 | OM_MALLOC_VFREE(addr, 128*${ac_cv_pagesize}); |
---|
| 350 | exit(0); |
---|
| 351 | } |
---|
| 352 | ], ac_cv_working_valloc="${OM_MALLOC_HEADER}_${OM_MALLOC_SOURCE}", ac_cv_working_valloc=no, ac_cv_working_valloc=no) |
---|
| 353 | if test "${ac_cv_working_valloc}" = no; then |
---|
| 354 | AC_MSG_RESULT(no) |
---|
| 355 | else |
---|
| 356 | AC_MSG_RESULT(yes) |
---|
| 357 | fi |
---|
| 358 | fi |
---|
| 359 | |
---|
| 360 | dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll |
---|
| 361 | dnl for valloc |
---|
| 362 | dnl |
---|
| 363 | AC_MSG_CHECKING(which valloc to use) |
---|
| 364 | if test "${with_valloc+set}" != set || test "${with_valloc}" = mmap; then |
---|
| 365 | if test "${ac_cv_working_mmap}" = yes; then |
---|
| 366 | with_valloc=mmap |
---|
[97b5d5] | 367 | AC_DEFINE(OM_HAVE_VALLOC_MMAP,1,"Have valloc") |
---|
[be7466] | 368 | else |
---|
| 369 | with_valloc=malloc |
---|
| 370 | fi |
---|
| 371 | fi |
---|
| 372 | if test "${with_valloc}" = malloc; then |
---|
[d83977] | 373 | if test "${ac_cv_working_valloc}" != no; then |
---|
[97b5d5] | 374 | AC_DEFINE(OM_HAVE_VALLOC_MALLOC,1,"Have valloc") |
---|
[be7466] | 375 | else |
---|
| 376 | with_valloc=emulate |
---|
| 377 | fi |
---|
| 378 | fi |
---|
| 379 | AC_MSG_RESULT($with_valloc) |
---|
| 380 | |
---|
| 381 | dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll |
---|
[8d0069] | 382 | dnl alignment |
---|
[be7466] | 383 | dnl |
---|
| 384 | AC_MSG_CHECKING(how to align) |
---|
| 385 | if test "$with_align" = 8 || test "$ac_cv_sizeof_long" = 8; then |
---|
| 386 | ac_cv_align=8 |
---|
[97b5d5] | 387 | AC_DEFINE(OM_ALIGN_8,1,"Align to 8 bytes") |
---|
[be7466] | 388 | else |
---|
| 389 | if test "$ac_cv_align_need_strict" = "yes" || test "$with_align" = "strict"; then |
---|
[97b5d5] | 390 | AC_DEFINE(OM_ALIGNMENT_NEEDS_WORK,1,"Whether alignment needs work") |
---|
[be7466] | 391 | ac_cv_align="strict" |
---|
| 392 | else |
---|
| 393 | ac_cv_align="sloppy" |
---|
[8d0069] | 394 | fi |
---|
[be7466] | 395 | fi |
---|
| 396 | AC_MSG_RESULT($ac_cv_align) |
---|
| 397 | |
---|
| 398 | dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll |
---|
| 399 | dnl dense bins |
---|
| 400 | dnl |
---|
| 401 | AC_MSG_CHECKING(whether to use dense bins) |
---|
| 402 | if test "$with_dense_bins" = yes; then |
---|
| 403 | AC_MSG_RESULT(yes) |
---|
[97b5d5] | 404 | AC_DEFINE(OM_HAVE_DENSE_BIN_DISTRIBUTION,1,"Whether we have dense bins") |
---|
[be7466] | 405 | else |
---|
| 406 | AC_MSG_RESULT(no) |
---|
| 407 | fi |
---|
| 408 | |
---|
| 409 | dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll |
---|
| 410 | dnl debug and inline |
---|
| 411 | dnl |
---|
[3df5b10] | 412 | AC_MSG_CHECKING(whether to disable debugging) |
---|
| 413 | if test "$with_debug" != no; then |
---|
| 414 | AC_MSG_RESULT(no) |
---|
| 415 | else |
---|
| 416 | AC_MSG_RESULT(yes) |
---|
[97b5d5] | 417 | AC_DEFINE(OM_NDEBUG,1,"Disable debug") |
---|
[3df5b10] | 418 | with_track=no |
---|
| 419 | fi |
---|
| 420 | |
---|
| 421 | AC_MSG_CHECKING(whether to have tracking debug functionality) |
---|
| 422 | if test "$with_track" != no; then |
---|
| 423 | AC_MSG_RESULT(yes) |
---|
[97b5d5] | 424 | AC_DEFINE(OM_HAVE_TRACK,1,"Have track") |
---|
[3df5b10] | 425 | else |
---|
| 426 | AC_MSG_RESULT(no) |
---|
| 427 | fi |
---|
| 428 | |
---|
[be7466] | 429 | AC_MSG_CHECKING(whether to use internal debug) |
---|
| 430 | if test "$with_internal_debug" = yes; then |
---|
| 431 | AC_MSG_RESULT(yes) |
---|
[97b5d5] | 432 | AC_DEFINE(OM_INTERNAL_DEBUG,1,"Internal debug") |
---|
[be7466] | 433 | with_inline=no |
---|
| 434 | else |
---|
| 435 | AC_MSG_RESULT(no) |
---|
| 436 | fi |
---|
| 437 | |
---|
| 438 | AC_MSG_CHECKING(whether to inline) |
---|
| 439 | if test "$ac_cv_c_inline" != no && test "$with_inline" != no; then |
---|
[97b5d5] | 440 | AC_DEFINE_UNQUOTED(OM_INLINE, static $ac_cv_c_inline, "inline-declaration") |
---|
| 441 | AC_DEFINE_UNQUOTED(OM_INLINE_DECL, static $ac_cv_c_inline, "inline-declaration") |
---|
| 442 | AC_DEFINE_UNQUOTED(OM_INLINE_IMPL, static $ac_cv_c_inline, "inline-declaration") |
---|
| 443 | AC_DEFINE_UNQUOTED(OM_INLINE_LOCAL, static $ac_cv_c_inline, "inline-declaration") |
---|
[be7466] | 444 | AC_MSG_RESULT(yes) |
---|
| 445 | else |
---|
[97b5d5] | 446 | AC_DEFINE_UNQUOTED(OM_INLINE_DECL, extern, "inline-declaration") |
---|
| 447 | AC_DEFINE_UNQUOTED(OM_INLINE_IMPL,, "inline-declaration") |
---|
| 448 | AC_DEFINE_UNQUOTED(OM_INLINE_LOCAL, static, "inline-declaration") |
---|
[be7466] | 449 | AC_MSG_RESULT(no) |
---|
| 450 | fi |
---|
| 451 | |
---|
| 452 | dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll |
---|
[3df5b10] | 453 | dnl backtrace business |
---|
[be7466] | 454 | dnl |
---|
[3df5b10] | 455 | AC_MSG_CHECKING(whether GET_RET_ADDR works) |
---|
| 456 | AC_CACHE_VAL(ac_cv_get_return_addr_works, |
---|
[66502b8] | 457 | AC_TRY_RUN([ |
---|
[e078e0] | 458 | #include <stdlib.h> |
---|
[3df5b10] | 459 | #include "omReturn.h" |
---|
[66502b8] | 460 | int test_return_addr() |
---|
| 461 | { |
---|
[3df5b10] | 462 | char* f; |
---|
| 463 | GET_RET_ADDR(f); |
---|
[e078e0] | 464 | return (int)(long) f; |
---|
[66502b8] | 465 | } |
---|
| 466 | int main() |
---|
| 467 | { |
---|
[3df5b10] | 468 | exit(! test_return_addr()); |
---|
[66502b8] | 469 | } |
---|
[8d0069] | 470 | ], ac_cv_get_return_addr_works=yes, |
---|
[3df5b10] | 471 | ac_cv_get_return_addr_works=no, |
---|
| 472 | ac_cv_get_return_addr_works=no)) |
---|
| 473 | AC_MSG_RESULT($ac_cv_get_return_addr_works) |
---|
| 474 | if test "$ac_cv_get_return_addr_works" = yes; then |
---|
[97b5d5] | 475 | AC_DEFINE(OM_GET_RETURN_ADDR_WORKS,1, "Whether get return address works") |
---|
[3df5b10] | 476 | fi |
---|
| 477 | |
---|
| 478 | AC_MSG_CHECKING(whether omGetBackTrace works) |
---|
| 479 | AC_CACHE_VAL(ac_cv_get_backtrace_works, |
---|
[212fc04] | 480 | AC_TRY_RUN([ |
---|
[3df5b10] | 481 | #include <stdio.h> |
---|
[e078e0] | 482 | #include <stdlib.h> |
---|
| 483 | #include "omGetBackTrace.c" |
---|
[3df5b10] | 484 | int test_backtrace() |
---|
[212fc04] | 485 | { |
---|
[3df5b10] | 486 | void* bt; |
---|
| 487 | int i = omGetBackTrace(&bt, 0, 10); |
---|
| 488 | return i; |
---|
[212fc04] | 489 | } |
---|
| 490 | int main() |
---|
| 491 | { |
---|
[8d0069] | 492 | int i; |
---|
[3df5b10] | 493 | omInitGetBackTrace(); |
---|
| 494 | i = test_backtrace(); |
---|
[8291be] | 495 | if (i > 0) exit(0); |
---|
| 496 | else exit(i+10); |
---|
[212fc04] | 497 | } |
---|
[8d0069] | 498 | ], ac_cv_get_backtrace_works=yes, |
---|
[3df5b10] | 499 | ac_cv_get_backtrace_works=no, |
---|
| 500 | ac_cv_get_backtrace_works=no)) |
---|
| 501 | AC_MSG_RESULT($ac_cv_get_backtrace_works) |
---|
| 502 | if test "$ac_cv_get_backtrace_works" = yes; then |
---|
[97b5d5] | 503 | AC_DEFINE(OM_GET_BACKTRACE_WORKS,1,"Whether omInitGetBackTrace () works") |
---|
[212fc04] | 504 | fi |
---|
| 505 | |
---|
[b98efa] | 506 | AC_MSG_CHECKING(whether addr2line works) |
---|
| 507 | AC_CACHE_VAL(ac_cv_prog_addr2line_works, |
---|
| 508 | AC_TRY_RUN([ |
---|
[e078e0] | 509 | #include <stdlib.h> |
---|
[b98efa] | 510 | #undef OM_GET_BACKTRACE_WORKS |
---|
| 511 | #include "omReturn.h" |
---|
| 512 | #include "omStructs.h" |
---|
| 513 | #include "omGetBackTrace.h" |
---|
| 514 | #include "omRet2Info.c" |
---|
| 515 | |
---|
| 516 | int test_Ret_2_Info() |
---|
| 517 | { |
---|
| 518 | void* bt; |
---|
| 519 | int i; |
---|
| 520 | struct omRetInfo_s info; |
---|
[8d0069] | 521 | |
---|
[b98efa] | 522 | GET_RET_ADDR(bt); |
---|
| 523 | i = omBackTrace_2_RetInfo(&bt, &info, 1); |
---|
| 524 | return i; |
---|
| 525 | } |
---|
| 526 | |
---|
| 527 | int main(int argc, char** argv) |
---|
| 528 | { |
---|
| 529 | int i; |
---|
| 530 | omInitRet_2_Info(*argv); |
---|
| 531 | i = test_Ret_2_Info(); |
---|
| 532 | if (i==1) exit(0); |
---|
| 533 | else exit (i+10); |
---|
| 534 | } |
---|
[8d0069] | 535 | ], ac_cv_prog_addr2line_works=yes, |
---|
[b98efa] | 536 | ac_cv_prog_addr2line_works=no, |
---|
| 537 | ac_cv_prog_addr2line_works=no)) |
---|
| 538 | AC_MSG_RESULT($ac_cv_prog_addr2line_works) |
---|
[8d0069] | 539 | |
---|
[3df5b10] | 540 | AC_MSG_CHECKING(whether to track return addresses) |
---|
[444bcf] | 541 | if test "$with_track_return" = no || test "$ac_cv_get_return_addr_works" = no || test "$ac_cv_prog_addr2line_works" != yes; then |
---|
[3df5b10] | 542 | with_track_return=no |
---|
[212fc04] | 543 | else |
---|
[97b5d5] | 544 | AC_DEFINE(OM_TRACK_RETURN,1,"Whether to track return") |
---|
[3df5b10] | 545 | with_track_return=yes |
---|
[212fc04] | 546 | fi |
---|
[3df5b10] | 547 | AC_MSG_RESULT($with_track_return) |
---|
[212fc04] | 548 | |
---|
[3df5b10] | 549 | AC_MSG_CHECKING(whether to track files and line numbers) |
---|
| 550 | if test "$with_track_fl" = no && test "$with_track_return" = no; then |
---|
| 551 | with_track_fl=yes |
---|
| 552 | fi |
---|
[8d0069] | 553 | if test "${with_track_fl+set}" != set; then |
---|
[3df5b10] | 554 | if test "$with_track_return" = yes; then |
---|
| 555 | with_track_fl=no |
---|
| 556 | else |
---|
| 557 | with_track_fl=yes |
---|
| 558 | fi |
---|
| 559 | fi |
---|
| 560 | AC_MSG_RESULT($with_track_fl) |
---|
[8d0069] | 561 | if test "$with_track_fl" = yes; then |
---|
[97b5d5] | 562 | AC_DEFINE(OM_TRACK_FILE_LINE,1,"Whether to track file-line") |
---|
[66502b8] | 563 | fi |
---|
| 564 | |
---|
[3df5b10] | 565 | AC_MSG_CHECKING(whether to track stack backtraces) |
---|
[b98efa] | 566 | if test "$with_track" != no && test "$ac_cv_get_backtrace_works" = yes && test "$with_track_backtrace" != no && test "$ac_cv_prog_addr2line_works" = yes; then |
---|
[3df5b10] | 567 | with_track_backtrace=yes |
---|
[97b5d5] | 568 | AC_DEFINE(OM_TRACK_BACKTRACE,1,"Whether to track backtrace") |
---|
[3df5b10] | 569 | else |
---|
| 570 | with_track_backtrace=no |
---|
| 571 | fi |
---|
| 572 | AC_MSG_RESULT($with_track_backtrace) |
---|
[fe7bd4] | 573 | |
---|
[8d0069] | 574 | AC_MSG_CHECKING(whether to track custom values) |
---|
[fe7bd4] | 575 | if test "$with_track" != no && test "$with_track_custom" = yes; then |
---|
[97b5d5] | 576 | AC_DEFINE(OM_TRACK_CUSTOM,1,"Enable custom tracking") |
---|
[fe7bd4] | 577 | else |
---|
| 578 | with_track_custom=no |
---|
| 579 | fi |
---|
| 580 | AC_MSG_RESULT($with_track_custom) |
---|
| 581 | |
---|
[fe6cc2] | 582 | dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll |
---|
| 583 | dnl figure out the return type of sbrk |
---|
| 584 | dnl |
---|
| 585 | |
---|
| 586 | AC_MSG_CHECKING(return type of sbrk) |
---|
| 587 | AC_TRY_LINK( |
---|
| 588 | #define __USE_MISC |
---|
| 589 | #include <unistd.h> |
---|
| 590 | , |
---|
| 591 | void *sbrk(); |
---|
| 592 | , |
---|
[97b5d5] | 593 | AC_DEFINE(Void_t,void,"Type of void"), |
---|
| 594 | AC_DEFINE(Void_t,char,"Type of void"), |
---|
[fe6cc2] | 595 | ) |
---|
| 596 | AC_MSG_RESULT(Void_t) |
---|
| 597 | |
---|
| 598 | |
---|
[715936] | 599 | AC_DEFINE(OM_PROVIDE_MALLOC,0,[Provide NO standard routines!]) |
---|
| 600 | |
---|
| 601 | |
---|
[9cf75aa] | 602 | dnl Restore user-specified CFLAGS, CXXFLAGS, LIBS |
---|
| 603 | |
---|
| 604 | CFLAGS=$BACKUP_CFLAGS |
---|
| 605 | CXXFLAGS=$BACKUP_CXXFLAGS |
---|
| 606 | LDFLAGS=$BACKUP_LDFLAGS |
---|
[fe6cc2] | 607 | |
---|
[be7466] | 608 | dnl lllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllll |
---|
[3df5b10] | 609 | dnl wrap it up |
---|
[66502b8] | 610 | dnl |
---|
[c2eb2e] | 611 | AC_CONFIG_FILES([Makefile]) |
---|
| 612 | AC_OUTPUT |
---|
[fe6cc2] | 613 | |
---|