1 # geda-guile.m4 -*-Autoconf-*-
5 dnl Copyright (C) 2009 Dan McMahill <dan@mcmahill.net>
7 dnl This program is free software; you can redistribute it and/or modify
8 dnl it under the terms of the GNU General Public License as published by
9 dnl the Free Software Foundation; either version 2 of the License, or
10 dnl (at your option) any later version.
12 dnl This program is distributed in the hope that it will be useful,
13 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
14 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 dnl GNU General Public License for more details.
17 dnl You should have received a copy of the GNU General Public License
18 dnl along with this program; if not, write to the Free Software
19 dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21 AC_DEFUN([AX_CHECK_GUILE],
25 # Argument is the minimum guile version. For example
26 # AX_CHECK_GUILE([1.8.0]) makes sure we have at least version 1.8.0
28 GUILE_MIN_MAJOR=`echo ${GUILE_MIN_VER} | sed 's;\..*;;g'`
29 # the double brackets are to get past m4's expansion
30 GUILE_MIN_MINOR=`echo ${GUILE_MIN_VER} | sed -e 's;[[^\.]]*\.;;' -e 's;\..*;;g'`
31 GUILE_MIN_TEENY=`echo ${GUILE_MIN_VER} | sed -e 's;.*\.;;'`
33 _found_pkg_config_guile=yes
34 PKG_CHECK_MODULES(GUILE, [guile-1.8] , ,
35 [_found_pkg_config_guile=no])
37 if test "${_found_pkg_config_guile}" = "no" ; then
38 _found_pkg_config_guile=yes
39 PKG_CHECK_MODULES(GUILE, [guile-2.0] , ,
40 [_found_pkg_config_guile=no])
43 if test "${_found_pkg_config_guile}" = "no" ; then
44 AC_PATH_PROG([GUILE_CONFIG], [guile-config], [notfound])
46 if test "${GUILE_CONFIG}" = "notfound" ; then
47 AC_ERROR([${PKG_CONFIG} could not locate guile and guile-config was not found])
50 AC_MSG_CHECKING([if guile is version ${GUILE_MIN_VER} or later])
51 GUILE_VER=`${GUILE_CONFIG} --version 2>&1 | awk '{print $NF}'`
53 GUILE_MAJOR=`echo ${GUILE_VER} | sed 's;\..*;;g'`
54 # the double brackets are to get past m4's expansion
55 GUILE_MINOR=`echo ${GUILE_VER} | sed -e 's;[[^\.]]*\.;;' -e 's;\..*;;g'`
56 GUILE_TEENY=`echo ${GUILE_VER} | sed -e 's;.*\.;;'`
59 if test ${GUILE_MAJOR} -lt ${GUILE_MIN_MAJOR} ; then
60 # Our installed major version is less than the min major version
64 elif test ${GUILE_MAJOR} -eq ${GUILE_MIN_MAJOR} ; then
65 # Our installed major version is equal the min major version
66 # so we need to check the minor version
68 if test ${GUILE_MINOR} -lt ${GUILE_MIN_MINOR} ; then
69 # majors match, minor is too small
71 elif test ${GUILE_MINOR} -eq ${GUILE_MIN_MINOR} ; then
72 # majors match, minors match, check teeny
73 if test ${GUILE_TEENY} -lt ${GUILE_MIN_TEENY} ; then
79 # majors match, minor is larger than min
84 # Our installed major version is greater than the min major version
89 if test "${_guile_ok}" = "yes" ; then
90 AC_MSG_RESULT([yes (${GUILE_VER})])
91 AC_MSG_CHECKING([for guile CFLAGS])
92 GUILE_CFLAGS=`${GUILE_CONFIG} compile`
93 AC_MSG_RESULT([${GUILE_CFLAGS}])
95 AC_MSG_CHECKING([for guile libs])
96 GUILE_LIBS=`${GUILE_CONFIG} link`
97 AC_MSG_RESULT([$GUILE_LIBS])
99 AC_MSG_ERROR([you need at least version ${GUILE_MIN_VER} of guile])
102 AC_SUBST(GUILE_CFLAGS)