Added SILC Thread Queue API
[crypto.git] / apps / silcer / macros / gnome-bonobo-check.m4
1 # Configure paths for Bonobo
2 # Miguel de Icaza, 99-04-12
3 # Stolen from Chris Lahey       99-2-5
4 # stolen from Manish Singh again
5 # stolen back from Frank Belew
6 # stolen from Manish Singh
7 # Shamelessly stolen from Owen Taylor
8
9 dnl AM_PATH_BONOBO ([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
10 dnl Test for Bonobo, and define BONOBO_CFLAGS and BONOBO_LIBS
11 dnl
12 AC_DEFUN([AM_PATH_BONOBO],
13 [
14 dnl 
15 dnl Get the cflags and libraries from the gnome-config script
16 dnl
17 AC_ARG_WITH(bonobo-prefix,[  --with-bonobo-prefix=PFX   Prefix where Bonobo is installed (optional)],
18             bonobo_prefix="$withval", bonobo_prefix="")
19 AC_ARG_WITH(bonobo-exec-prefix,[  --with-bonobo-exec-prefix=PFX Exec prefix where Bonobo is installed (optional)],
20             bonobo_exec_prefix="$withval", bonobo_exec_prefix="")
21 AC_ARG_ENABLE(bonobotest, [  --disable-bonobotest       Do not try to compile and run a test Bonobo program],
22                     , enable_bonobotest=yes)
23
24   if test x$bonobo_exec_prefix != x ; then
25      bonobo_args="$bonobo_args --exec-prefix=$bonobo_exec_prefix"
26      if test x${GNOME_CONFIG+set} != xset ; then
27         GNOME_CONFIG=$bonobo_exec_prefix/bin/gnome-config
28      fi
29   fi
30   if test x$bonobo_prefix != x ; then
31      bonobo_args="$bonobo_args --prefix=$bonobo_prefix"
32      if test x${GNOME_CONFIG+set} != xset ; then
33         GNOME_CONFIG=$bonobo_prefix/bin/gnome-config
34      fi
35   fi
36
37   AC_PATH_PROG(GNOME_CONFIG, gnome-config, no)
38   min_bonobo_version=ifelse([$1], ,0.1.0,$1)
39   AC_MSG_CHECKING(for BONOBO - version >= $min_bonobo_version)
40   no_bonobo=""
41   if test "$GNOME_CONFIG" = "no" ; then
42     no_bonobo=yes
43   else
44     BONOBO_CFLAGS=`$GNOME_CONFIG $bonoboconf_args --cflags bonobo bonobox`
45     BONOBO_LIBS=`$GNOME_CONFIG $bonoboconf_args --libs bonobo bonobox`
46
47     bonobo_major_version=`$GNOME_CONFIG $bonobo_args --version | \
48            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
49     bonobo_minor_version=`$GNOME_CONFIG $bonobo_args --version | \
50            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
51     bonobo_micro_version=`$GNOME_CONFIG $bonobo_config_args --version | \
52            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
53     if test "x$enable_bonobotest" = "xyes" ; then
54       ac_save_CFLAGS="$CFLAGS"
55       ac_save_LIBS="$LIBS"
56       CFLAGS="$CFLAGS $BONOBO_CFLAGS"
57       LIBS="$LIBS $BONOBO_LIBS"
58 dnl
59 dnl Now check if the installed BONOBO is sufficiently new. (Also sanity
60 dnl checks the results of gnome-config to some extent
61 dnl
62       rm -f conf.bonobotest
63       AC_TRY_RUN([
64 #include <stdio.h>
65 #include <stdlib.h>
66 #include <string.h>
67 #include <bonobo.h>
68
69 static char*
70 my_strdup (char *str)
71 {
72   char *new_str;
73   
74   if (str)
75     {
76       new_str = malloc ((strlen (str) + 1) * sizeof(char));
77       strcpy (new_str, str);
78     }
79   else
80     new_str = NULL;
81   
82   return new_str;
83 }
84
85 int main ()
86 {
87   int major, minor, micro;
88   char *tmp_version;
89
90   system ("touch conf.bonobotest");
91   bonobo_object_get_type ();
92   return 0;
93 }
94
95 ],, no_bonobo=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
96        CFLAGS="$ac_save_CFLAGS"
97        LIBS="$ac_save_LIBS"
98      fi
99   fi
100   if test "x$no_bonobo" = x ; then
101      AC_MSG_RESULT(yes)
102      ifelse([$2], , :, [$2])     
103   else
104      AC_MSG_RESULT(no)
105      if test "$GNOME_CONFIG" = "no" ; then
106        echo "*** The gnome-config script installed by GNOME-LIBS could not be found"
107        echo "*** If BONOBO was installed in PREFIX, make sure PREFIX/bin is in"
108        echo "*** your path, or set the GNOME_CONFIG environment variable to the"
109        echo "*** full path to gnome-config."
110      else
111        if test -f conf.bonobotest ; then
112         :
113        else
114           echo "*** Could not run BONOBO test program, checking why..."
115           CFLAGS="$CFLAGS $BONOBO_CFLAGS"
116           LIBS="$LIBS $BONOBO_LIBS"
117           AC_TRY_LINK([
118 #include <stdio.h>
119 #include <bonobo/gnome-object.h>
120 ],      [ return 0; ],
121         [ echo "*** The test program compiled, but did not run. This usually means"
122           echo "*** that the run-time linker is not finding BONOBO or finding the wrong"
123           echo "*** version of BONOBO. If it is not finding BONOBO, you'll need to set your"
124           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
125           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
126           echo "*** is required on your system"
127           echo "***"
128           echo "*** If you have an old version installed, it is best to remove it, although"
129           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
130         [ echo "*** The test program failed to compile or link. See the file config.log for the"
131           echo "*** exact error that occured. This usually means BONOBO was incorrectly installed"
132           echo "*** or that you have moved BONOBO since it was installed. In the latter case, you"
133           echo "*** may want to edit the gnome-config script: $GNOME_CONFIG" ])
134           CFLAGS="$ac_save_CFLAGS"
135           LIBS="$ac_save_LIBS"
136        fi
137      fi
138      BONOBO_CFLAGS=""
139      BONOBO_LIBS=""
140      ifelse([$3], , :, [$3])
141   fi
142   AC_SUBST(BONOBO_CFLAGS)
143   AC_SUBST(BONOBO_LIBS)
144   rm -f conf.bonobotest
145 ])
146
147 AC_DEFUN([BONOBO_CHECK], [
148         AM_PATH_BONOBO(0.1.0,,[AC_MSG_ERROR(BONOBO not found)])
149 ])
150
151 AC_DEFUN([AM_BONOBO_USES_OAF],
152 [
153         AC_REQUIRE([AM_PATH_BONOBO])
154
155         AC_MSG_CHECKING(if Bonobo uses OAF)
156         if ( gnome-config --libs bonobo | grep oaf ) > /dev/null 2>&1 ; then
157           using_oaf="yes"
158           AC_DEFINE(BONOBO_USES_OAF)
159         else
160           using_oaf="no"
161         fi
162
163         AC_MSG_RESULT("$using_oaf")
164
165         AM_CONDITIONAL(BONOBO_USES_OAF, test x"using_oaf" = "xyes")
166 ])