gschem: change "Close without save" key-accel to "w"
[geda-gaf/whiteaudio.git] / m4 / geda-guile.m4
blob61f62f730005158ade07fb3d2403743d0a78e2d0
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   _found_pkg_config_guile=yes
38   PKG_CHECK_MODULES(GUILE, [guile-2.0 >= $GUILE_MIN_VER],
39                            [GUILE_PKG=guile-2.0], [_found_pkg_config_guile=no])
41   if test "${_found_pkg_config_guile}" = "no" ; then
42    PKG_CHECK_MODULES(GUILE, [guile-1.8 >= $GUILE_MIN_VER],
43                             [_found_pkg_config_guile=yes
44                              GUILE_PKG=guile-1.8],
45                             [_found_pkg_config_guile=no])
46   fi
48   if test "${_found_pkg_config_guile}" = "no" ; then
49     AC_MSG_ERROR([you need at least version ${GUILE_MIN_VER} of guile])
50   fi
52   AC_SUBST([GUILE_PKG])
54   # Check for the `guile' executable
55   # --------------------------------
56   AC_ARG_VAR([GUILE], [Path to guile executable])
57   AC_CHECK_PROG([GUILE], [guile], [guile], [no])
58   if test "X$GUILE" = "Xno"; then
59     AC_MSG_WARN([The `guile' interpreter could not be found. Some configuration checks
60 will not be able to be carried out.])
61   fi
63   # Check for the `guile-snarf' build tool
64   # --------------------------------------
65   AC_ARG_VAR([GUILE_SNARF], [path to guile-snarf utility])
67   AC_CHECK_PROGS([GUILE_SNARF], [guile-snarf guile-1.8-snarf], [no])
68   if test "x$GUILE_SNARF" = xno ; then
69     AC_MSG_ERROR([The `guile-snarf' tool could not be found. Please ensure that the
70 Guile development headers and tools are correctly installed, and rerun
71 configure.])
72   fi
74   # Check for behaviour of `scm_display_error'
75   # ------------------------------------------
76   if test "X$GUILE" != "Xno"; then
78     AC_MSG_CHECKING([whether scm_display_error expects a stack argument])
79     if $GUILE -c \
80 "(exit
81    (false-if-exception
82      (begin
83        (display-error (make-stack #t) (current-output-port) \"a\" \"b\" '() '())
84        #t)))" > /dev/null; then
85       AC_MSG_RESULT([yes])
86       AC_DEFINE([HAVE_SCM_DISPLAY_ERROR_STACK], 1,
87                 [Define to 1 if scm_display_error expects a stack as first argument.])
88     else
89       AC_MSG_RESULT([no])
90     fi
92     AC_MSG_CHECKING([whether scm_display_error expects a frame argument])
93     if $GUILE -c \
94 "(exit
95    (false-if-exception
96      (begin
97        (display-error (stack-ref (make-stack #t) 0)
98                       (current-output-port) \"a\" \"b\" '() '())
99        #t)))" > /dev/null; then
100       AC_MSG_RESULT([yes])
101       AC_DEFINE([HAVE_SCM_DISPLAY_ERROR_FRAME], 1,
102                 [Define to 1 if scm_display_error expects a frame as first argument.])
103     else
104       AC_MSG_RESULT([no])
105     fi
106   fi
108   # Check for functions in `libguile'
109   # ---------------------------------
111   # Save build-related variables
112   save_CFLAGS="${CFLAGS}"
113   save_LIBS="${LIBS}"
115   CFLAGS="${GUILE_CFLAGS} ${CFLAGS}"
116   LIBS="${GUILE_LIBS}"
118   AC_CHECK_FUNCS([scm_from_utf8_string])
119   AC_CHECK_FUNCS([scm_from_utf8_stringn])
120   AC_CHECK_FUNCS([scm_to_utf8_string])
121   AC_CHECK_FUNCS([scm_to_utf8_stringn])
122   AC_CHECK_FUNCS([scm_from_utf8_symbol])
123   AC_CHECK_FUNCS([scm_from_utf8_symboln])
125   # Restore build-related variables
126   CFLAGS="${save_CFLAGS}"
127   LIBS="${save_LIBS}"
129 ])dnl AX_CHECK_GUILE