back again !!!
[platform/upstream/gnome-common.git] / macros / gnome-guile-checks.m4
1 dnl
2 dnl GNOME_CHECK_GUILE (failflag)
3 dnl
4 dnl if failflag is "fail" then GNOME_CHECK_GUILE will abort if guile is not found.
5 dnl
6
7 AC_DEFUN([GNOME_CHECK_GUILE],
8 [
9 dnl     AC_MSG_WARN([Withval is: $withval])
10         guile_msg = 'Huh?'
11 if test x$withval = xno ; then
12         guile_msg = 'disabled'
13         GUILE_LIBS=
14         GUILE_INCS=
15         AC_SUBST(GUILE_LIBS)
16         AC_SUBST(GUILE_INCS)
17         AM_CONDITIONAL(GUILE, /bin/false)
18 else
19         guile_msg="no"
20
21         saved_ldflags="$LDFLAGS"
22         saved_cppflags="$CPPFLAGS"
23         LDFLAGS="$LDFLAGS $GNOME_LIBDIR"
24
25         AC_CHECK_LIB(qthreads,qt_null,[
26                 QTTHREADS_LIB="-lqthreads"
27         ],[
28                 AC_CHECK_LIB(qt, qt_null, QTTHREADS_LIB="-lqt")
29         ],$LIBS)
30         AC_SUBST(QTTHREADS_LIB)
31
32         AC_CHECK_LIB(termcap,main,TERMCAP_LIB="-ltermcap")
33         AC_CHECK_LIB(readline,main,READLINE_LIB="-lreadline",,$TERMCAP_LIB)
34
35         AC_SUBST(TERMCAP_LIB)
36         AC_SUBST(READLINE_LIB)
37
38         if test "x$cross_compiling" = "xyes" ; then
39           name_build_guile="$target_alias-guile-config"
40         else
41           name_build_guile="guile-config"
42         fi
43
44         AC_CHECK_PROG(BUILD_GUILE, $name_build_guile, yes, no)
45
46         if test "x$BUILD_GUILE" = "xyes"; then
47             AC_MSG_CHECKING(whether $name_build_guile works)
48             if test x`$name_build_guile --version >/dev/null 2>&1 || \
49                 echo no` = xno; then
50                 BUILD_GUILE=no
51             fi
52             AC_MSG_RESULT($BUILD_GUILE)
53         else
54
55             if test "x$cross_compiling" = "xyes" ; then
56                 name_build_guile="$target_alias-build-guile"
57             else        
58                 name_build_guile="build-guile"
59             fi
60
61             AC_CHECK_PROG(BUILD_GUILE, $name_build_guile, yes, no)
62
63             if test "x$BUILD_GUILE" = "xyes"; then
64                 AC_MSG_CHECKING(whether $name_build_guile works)
65                 if test x`$name_build_guile --version >/dev/null 2>&1 || \
66                     echo no` = xno; then
67                     BUILD_GUILE=no
68                 fi
69                 AC_MSG_RESULT($BUILD_GUILE)
70             fi
71         fi
72
73         AC_CHECK_LIB(m, sin)
74
75         if test "x$BUILD_GUILE" = "xyes"; then
76                 AC_MSG_CHECKING(for guile libraries)
77                 GUILE_LIBS="`$name_build_guile link`"
78                 AC_MSG_RESULT($GUILE_LIBS)
79                 AC_MSG_CHECKING(for guile headers)
80                 GUILE_INCS="`$name_build_guile compile`"
81                 AC_MSG_RESULT($GUILE_INCS)
82         else
83                 GUILE_LIBS="$GNOME_LIBDIR"
84                 GUILE_INCS="$GNOME_INCLUDEDIR"
85                 AC_CHECK_LIB(rx, main, GUILE_LIBS="-lrx $GUILE_LIBS")
86                 AC_CHECK_LIB(qt, qt_null, GUILE_LIBS="-lqt $GUILE_LIBS")
87                 AC_CHECK_LIB(dl, dlopen, GUILE_LIBS="-ldl $GUILE_LIBS")
88                 AC_CHECK_LIB(nsl, t_accept, GUILE_LIBS="$GUILE_LIBS -lnsl")
89                 AC_CHECK_LIB(socket, socket, GUILE_LIBS="$GUILE_LIBS -lsocket")
90                 GUILE_LIBS="-lguile $GUILE_LIBS $QTTHREADS_LIB $READLINE_LIB $TERMCAP_LIB"
91         fi
92
93         AC_SUBST(GUILE_LIBS)
94         AC_SUBST(GUILE_INCS)
95
96         saved_LIBS="$LIBS"
97         LIBS="$LIBS $GUILE_LIBS"
98         CPPFLAGS="$saved_cppflags $GUILE_INCS"
99
100         AC_MSG_CHECKING(whether guile works)
101         AC_TRY_LINK([
102                 #include <libguile.h>
103                 #include <guile/gh.h>
104         ],[
105                 gh_eval_str("(newline)");
106                 scm_boot_guile(0,NULL,NULL,NULL);
107         ],[
108                 ac_cv_guile_found=yes
109                 AC_DEFINE(HAVE_GUILE)
110         ],[
111                 ac_cv_guile_found=no
112         ])
113         AC_MSG_RESULT($ac_cv_guile_found)
114
115         guile_msg=$ac_cv_guile_found
116
117         if test x$ac_cv_guile_found = xno ; then
118                 if test x$1 = xfail ; then
119                   AC_MSG_ERROR(Can not find Guile on this system)
120                 else
121                   AC_MSG_WARN(Can not find Guile on this system)
122                 fi
123                 ac_cv_guile_found=no
124                 GUILE_LIBS= GUILE_INCS=
125         fi
126
127         LIBS="$saved_LIBS"
128         LDFLAGS="$saved_ldflags"
129         CPPFLAGS="$saved_cppflags"
130
131         AC_SUBST(GUILE_LIBS)
132         AM_CONDITIONAL(GUILE, test x$ac_cv_guile_found = xyes)
133 fi
134 ])