[Gc] autoconf on 6.3/6.4

Kees Cook kees at outflux.net
Fri Jan 28 18:27:38 PST 2005


On Fri, Jan 28, 2005 at 05:33:13PM -0800, Boehm, Hans wrote:
> Look at version.h in the main directory.  It defines GC_VERSION_MINOR.
> 
> By default, it also declares and initializes GC_version.  The
> file is included by exactly one of the GC library files (which is ugly,
> but ...).  Thus you should just be able to link against the library
> and test GC_version.

Cool.  I found it just after mental asked the list.  ;)  For anyone else 
interested, here's our entire autoconf section for dealing with libgc.  
If anyone has ideas for improvement, I'd love to incorporate them.


AC_CHECK_HEADERS([gc.h gc/gc.h],
                 [
                    # To test for the different required libs, I have to
                    # overcome autoconf's caching system, so I change the
                    # desired function name.  They're all in libgc.
                    # The "break" will exit from the top level
                    # AC_CHECK_HEADERS.
                    gc_libs=""
                    AC_CHECK_LIB(gc, GC_init,
                                 [gc_ok=yes;
                                  LIBS="-lgc $gc_libs $LIBS";
                                  break], [gc_ok=no], [$gc_libs])
                    gc_libs="-lpthread"
                    AC_CHECK_LIB(gc, GC_malloc,
                                 [gc_ok=yes;
                                  LIBS="-lgc $gc_libs $LIBS";
                                  break], [gc_ok=no], [$gc_libs])
                    gc_libs="-ldl"
                    AC_CHECK_LIB(gc, GC_realloc,
                                 [gc_ok=yes;
                                  LIBS="-lgc $gc_libs $LIBS";
                                  break], [gc_ok=no], [$gc_libs])
                    gc_libs="-lpthread -ldl"
                    AC_CHECK_LIB(gc, GC_free,
                                 [gc_ok=yes;
                                  LIBS="-lgc $gc_libs $LIBS";
                                  break], [gc_ok=no], [$gc_libs])
                    break],
                 [gc_ok=no])
if test "x$gc_ok" == "xyes"; then
        AC_MSG_CHECKING([libgc version 6.4+])
        AC_RUN_IFELSE(
                [AC_LANG_SOURCE([[
                        #ifdef HAVE_GC_GC_H
                        # include <gc/gc.h>
                        #else
                        # include <gc.h>
                        #endif
                        extern unsigned GC_version;
                        int main(void){
                                unsigned min = ((6 << 16) | (4 << 8) | 0);
                                if (GC_version>=min) return 0;
                                return 1;
                        }]])],
                [gc_ok=yes],
                [gc_ok=no]
        )
        AC_MSG_RESULT([$gc_ok])
fi
if test "x$gc_ok" != "xyes"; then
        AC_MSG_ERROR([libgc (the Boehm Conservative Collector) 6.4+, is needed to compile inkscape])
fi


-- 
Kees Cook                                            @outflux.net


More information about the Gc mailing list