Menu

#7 Autoconf code/docs for Boehm GC handling

closed-out-of-date
nobody
None
5
2007-11-19
2007-08-19
No

This is code and documentation for use in configure.ac to detect the version of the Boehm GC, to check to make sure it is compiled with c++ support, etc. It doesn't include the debug switch, which is separate. It also does not concern itself with building the GC, which is a distinct issue. It goes with the documentation in the attached INSTALL file. That file differs from the current INSTALL file: it begins with the standard INSTALL file, followed by a section on Asymptote-specific instructions.

-gregg

dnl ################ BOEHM GC
AC_ARG_WITH([boehm-gc],
[AS_HELP_STRING([--without-boehm-gc],
[disable support for boehm garbage collector])
],
[],
[with_boehm_gc=yes]
)

AS_CASE(
["x$with_boehm_gc"],
[[xyes]],
[
X_LIBS=$LIBS
LIBS+=-lgc
X_LDFLAGS=$LDFLAGS
LDFLAGS+=-L/usr/local/lib
AC_MSG_CHECKING([for boehm gc in default install dirs])
AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[[
#include <stdio.h>
#include <gc.h>
extern unsigned GC_version;
]],
[[
FILE* fp;
if (fp = fopen("conftest.out", "w"))
;
else return -1;

if (fprintf(fp, "%d.%x", GC_version>>16, (GC_version & 0x00FFFF)>>8) > 0)
return 0;
else return -1;
]])],
[
bv=`cat conftest.out`; AC_MSG_RESULT(version $bv)
],
[
LIBS=$X_LIBS
LDFLAGS=$X_LDFLAGS
AC_MSG_RESULT([Cannot discover Boehm version])
AC_MSG_ERROR([See the "Memory Management" section of INSTALL for remedies.])
]
)
]
[AC_MSG_CHECKING([for c++ support in boehm gc])
AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[[
#include <iostream>
#include <gc.h>
#include <gc/gc_allocator.h>
#include <gc/gc_cpp.h>
]],
[[
GC_INIT();
gc_allocator<int> mygc;
std::cout << "ok";
return 0;
]])
],
[AC_MSG_RESULT([])],
[
LIBS=$X_LIBS
LDFLAGS=$X_LDFLAGS
AC_MSG_RESULT([not found])
AC_MSG_ERROR([See the "Memory Management" section of INSTALL for remedies.])
]
)
],
[xno], [AC_MSG_NOTICE([Disabling Garbage Collection; using standard C++ memory managment])],

[
X_LIBS=$LIBS
LIBS+=-lgc
X_LDFLAGS=$LDFLAGS
BGCDIR=`(cd $with_boehm_gc; pwd)`
LDFLAGS+=-L$BGCDIR
AC_MSG_CHECKING([for boehm gc at $BGCDIR])
AC_RUN_IFELSE(
[AC_LANG_PROGRAM(
[[
#include <stdio.h>
#include <gc.h>
extern unsigned GC_version;
]],
[[
FILE* fp;
if (fp = fopen("conftest.out", "w"))
;
else return -1;

if (fprintf(fp, "%d.%x", GC_version>>16, (GC_version & 0x00FFFF)>>8) > 0)
return 0;
else return -1;
]])],
[bv=`cat conftest.out`; AC_MSG_RESULT(version $bv)],
[
LIBS=$X_LIBS
LDFLAGS=$X_LDFLAGS
AC_MSG_RESULT([Cannot discover Boehm version at $BGCDIR])
AC_MSG_ERROR([See the "Memory Management" section of INSTALL for remedies.])
])]
)

Discussion

  • Gregg Reynolds

    Gregg Reynolds - 2007-08-19

    Standard INSTALL file, plus asymptote-specific instructions

     
  • John Bowman

    John Bowman - 2007-11-19

    Logged In: YES
    user_id=808099
    Originator: NO

    Motivated by these suggestions, in the latest svn code, configure now uses the system version of Boehm GC if the recommended local version is not installed in the Asymptote source directory. I believe that takes care of all of the issues here, without breaking any existing behaviour.

    For advanced users, I appended the proposed generic configure instructions (slightly modified) to the existing INSTALL, leaving the quick install instructions at the top.

     
  • John Bowman

    John Bowman - 2007-11-19
    • status: open --> closed-out-of-date
     

Log in to post a comment.