Changed tarball name to be all lower case to make package maintainers happier
[geda-gaf/cesar.git] / m4 / geda-guile.m4
blob96abf1867bc373a32fdea4606371d2a86f124e9f
1 # geda-guile.m4                                           -*-Autoconf-*-
2 # serial 1
4 dnl Check for guile
5 dnl Copyright (C) 2009  Dan McMahill <dan@mcmahill.net>
6 dnl
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.
11 dnl
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.
16 dnl
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],
23   AC_PREREQ([2.60])dnl
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
27   GUILE_MIN_VER=[$1]
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])
41   fi
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])
48     fi
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;.*\.;;'`
58     _guile_ok=no
59     if test ${GUILE_MAJOR} -lt ${GUILE_MIN_MAJOR} ; then
60       # Our installed major version is less than the min major version
62       _guile_ok=no
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
70         _guile_ok=no
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
74           _guile_ok=no
75         else
76           _guile_ok=yes
77         fi
78       else
79         # majors match, minor is larger than min
80         _guile_ok=yes
81       fi
83     else
84       # Our installed major version is greater than the min major version
86       _guile_ok=yes
87     fi
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])
98     else
99         AC_MSG_ERROR([you need at least version ${GUILE_MIN_VER} of guile])
100     fi
101     AC_SUBST(GUILE_VER)
102     AC_SUBST(GUILE_CFLAGS)
103     AC_SUBST(GUILE_LIBS)
104   fi