memleak fixes - 1 of ?
[geda-gaf.git] / m4 / geda-guile.m4
blobd63ddf2899d327ad23d4ff0bb034ac6624b2d767
1 # geda-guile.m4                                           -*-Autoconf-*-
2 # serial 3
4 dnl Check for guile
5 dnl Copyright (C) 2009  Dan McMahill <dan@mcmahill.net>
6 dnl Copyright (C) 2010-2011  Peter Brett <peter@peter-b.co.uk>
7 dnl
8 dnl This program is free software; you can redistribute it and/or modify
9 dnl it under the terms of the GNU General Public License as published by
10 dnl the Free Software Foundation; either version 2 of the License, or
11 dnl (at your option) any later version.
12 dnl
13 dnl This program is distributed in the hope that it will be useful,
14 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
15 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 dnl GNU General Public License for more details.
17 dnl
18 dnl You should have received a copy of the GNU General Public License
19 dnl along with this program; if not, write to the Free Software
20 dnl Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 AC_DEFUN([AX_CHECK_GUILE],
24   AC_PREREQ([2.60])dnl
26   # First check for the libguile library
27   # ------------------------------------
29   # Argument is the minimum guile version.  For example
30   # AX_CHECK_GUILE([1.8.0]) makes sure we have at least version 1.8.0
31   GUILE_MIN_VER=[$1]
32   GUILE_MIN_MAJOR=`echo ${GUILE_MIN_VER} | sed 's;\..*;;g'`
33   # the double brackets are to get past m4's expansion
34   GUILE_MIN_MINOR=`echo ${GUILE_MIN_VER} | sed -e 's;[[^\.]]*\.;;' -e 's;\..*;;g'`
35   GUILE_MIN_TEENY=`echo ${GUILE_MIN_VER} | sed -e 's;.*\.;;'`
37   PKG_CHECK_MODULES(GUILE, [guile-2.2 >= $GUILE_MIN_VER],
38                            [GUILE_PKG_NAME=guile-2.2],
39                            [AC_MSG_ERROR([you need Guile 2.2 (at least version ${GUILE_MIN_VER})])])
41   AC_SUBST([GUILE_PKG_NAME])
43   # Check for the `guile' executable
44   # --------------------------------
45   AC_ARG_VAR([GUILE], [Path to guile executable])
46   AC_CHECK_PROG([GUILE], [guile], [guile], [no])
47   if test "X$GUILE" = "Xno"; then
48     AC_MSG_WARN([The `guile' interpreter could not be found. Some configuration checks
49 will not be able to be carried out.])
50   fi
52   # Check for the `guile-snarf' build tool
53   # --------------------------------------
54   AC_ARG_VAR([GUILE_SNARF], [path to guile-snarf utility])
56   AC_CHECK_PROG([GUILE_SNARF], [guile-snarf], [guile-snarf], [no])
57   if test "x$GUILE_SNARF" = xno ; then
58     AC_MSG_ERROR([The `guile-snarf' tool could not be found. Please ensure that the
59 Guile development headers and tools are correctly installed, and rerun
60 configure.])
61   fi
63   # Check for behaviour of `scm_display_error'
64   # ------------------------------------------
65   if test "X$GUILE" != "Xno"; then
67     AC_MSG_CHECKING([whether scm_display_error accepts a stack])
68     if $GUILE -c \
69 "(exit
70    (false-if-exception
71      (begin
72        (display-error (make-stack #t) (current-output-port) \"a\" \"b\" '() '())
73        #t)))" > /dev/null 2>&1; then
74       AC_MSG_RESULT([yes])
75       AC_DEFINE([HAVE_SCM_DISPLAY_ERROR_STACK], 1,
76                 [Define to 1 if scm_display_error accepts a stack as first argument.])
77     else
78       AC_MSG_RESULT([no])
79     fi
81     AC_MSG_CHECKING([whether scm_display_error accepts a frame])
82     if $GUILE -c \
83 "(exit
84    (false-if-exception
85      (begin
86        (display-error (stack-ref (make-stack #t) 0)
87                       (current-output-port) \"a\" \"b\" '() '())
88        #t)))" > /dev/null 2>&1; then
89       AC_MSG_RESULT([yes])
90       AC_DEFINE([HAVE_SCM_DISPLAY_ERROR_FRAME], 1,
91                 [Define to 1 if scm_display_error expects a frame as first argument.])
92     else
93       AC_MSG_RESULT([no])
94     fi
95   fi
97 ])dnl AX_CHECK_GUILE