Added SILC Thread Queue API
[crypto.git] / apps / irssi / glib-2.0.m4_
1 # Configure paths for GLIB
2 # Owen Taylor     1997-2001
3
4 dnl AM_PATH_GLIB_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
5 dnl Test for GLIB, and define GLIB_CFLAGS and GLIB_LIBS, if gmodule, gobject or 
6 dnl gthread is specified in MODULES, pass to pkg-config
7 dnl
8 AC_DEFUN([AM_PATH_GLIB_2_0],
9 [dnl 
10 dnl Get the cflags and libraries from pkg-config
11 dnl
12 AC_ARG_ENABLE(glibtest, [  --disable-glibtest      do not try to compile and run a test GLIB program],
13                     , enable_glibtest=yes)
14
15   pkg_config_args=glib-2.0
16   for module in . $4
17   do
18       case "$module" in
19          gmodule) 
20              pkg_config_args="$pkg_config_args gmodule-2.0"
21          ;;
22          gmodule-no-export) 
23              pkg_config_args="$pkg_config_args gmodule-no-export-2.0"
24          ;;
25          gobject) 
26              pkg_config_args="$pkg_config_args gobject-2.0"
27          ;;
28          gthread) 
29              pkg_config_args="$pkg_config_args gthread-2.0"
30          ;;
31       esac
32   done
33
34   AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
35
36   no_glib=""
37
38   if test x$PKG_CONFIG != xno ; then
39     if $PKG_CONFIG --atleast-pkgconfig-version 0.7 ; then
40       :
41     else
42       echo *** pkg-config too old; version 0.7 or better required.
43       no_glib=yes
44       PKG_CONFIG=no
45     fi
46   else
47     no_glib=yes
48   fi
49
50   min_glib_version=ifelse([$1], ,2.0.0,$1)
51   AC_MSG_CHECKING(for GLIB - version >= $min_glib_version)
52
53   if test x$PKG_CONFIG != xno ; then
54     ## don't try to run the test against uninstalled libtool libs
55     if $PKG_CONFIG --uninstalled $pkg_config_args; then
56           echo "Will use uninstalled version of GLib found in PKG_CONFIG_PATH"
57           enable_glibtest=no
58     fi
59
60     if $PKG_CONFIG --atleast-version $min_glib_version $pkg_config_args; then
61           :
62     else
63           no_glib=yes
64     fi
65   fi
66
67   if test x"$no_glib" = x ; then
68     GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0`
69     GOBJECT_QUERY=`$PKG_CONFIG --variable=gobject_query glib-2.0`
70     GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0`
71
72     GLIB_CFLAGS=`$PKG_CONFIG --cflags $pkg_config_args`
73     GLIB_LIBS=`$PKG_CONFIG --libs $pkg_config_args`
74     glib_config_major_version=`$PKG_CONFIG --modversion glib-2.0 | \
75            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
76     glib_config_minor_version=`$PKG_CONFIG --modversion glib-2.0 | \
77            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
78     glib_config_micro_version=`$PKG_CONFIG --modversion glib-2.0 | \
79            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
80     if test "x$enable_glibtest" = "xyes" ; then
81       ac_save_CFLAGS="$CFLAGS"
82       ac_save_LIBS="$LIBS"
83       CFLAGS="$CFLAGS $GLIB_CFLAGS"
84       LIBS="$GLIB_LIBS $LIBS"
85 dnl
86 dnl Now check if the installed GLIB is sufficiently new. (Also sanity
87 dnl checks the results of pkg-config to some extent)
88 dnl
89       rm -f conf.glibtest
90       AC_TRY_RUN([
91 #include <glib.h>
92 #include <stdio.h>
93 #include <stdlib.h>
94
95 int 
96 main ()
97 {
98   int major, minor, micro;
99   char *tmp_version;
100
101   system ("touch conf.glibtest");
102
103   /* HP/UX 9 (%@#!) writes to sscanf strings */
104   tmp_version = g_strdup("$min_glib_version");
105   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
106      printf("%s, bad version string\n", "$min_glib_version");
107      exit(1);
108    }
109
110   if ((glib_major_version != $glib_config_major_version) ||
111       (glib_minor_version != $glib_config_minor_version) ||
112       (glib_micro_version != $glib_config_micro_version))
113     {
114       printf("\n*** 'pkg-config --modversion glib-2.0' returned %d.%d.%d, but GLIB (%d.%d.%d)\n", 
115              $glib_config_major_version, $glib_config_minor_version, $glib_config_micro_version,
116              glib_major_version, glib_minor_version, glib_micro_version);
117       printf ("*** was found! If pkg-config was correct, then it is best\n");
118       printf ("*** to remove the old version of GLib. You may also be able to fix the error\n");
119       printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
120       printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
121       printf("*** required on your system.\n");
122       printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
123       printf("*** to point to the correct configuration files\n");
124     } 
125   else if ((glib_major_version != GLIB_MAJOR_VERSION) ||
126            (glib_minor_version != GLIB_MINOR_VERSION) ||
127            (glib_micro_version != GLIB_MICRO_VERSION))
128     {
129       printf("*** GLIB header files (version %d.%d.%d) do not match\n",
130              GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION);
131       printf("*** library (version %d.%d.%d)\n",
132              glib_major_version, glib_minor_version, glib_micro_version);
133     }
134   else
135     {
136       if ((glib_major_version > major) ||
137         ((glib_major_version == major) && (glib_minor_version > minor)) ||
138         ((glib_major_version == major) && (glib_minor_version == minor) && (glib_micro_version >= micro)))
139       {
140         return 0;
141        }
142      else
143       {
144         printf("\n*** An old version of GLIB (%d.%d.%d) was found.\n",
145                glib_major_version, glib_minor_version, glib_micro_version);
146         printf("*** You need a version of GLIB newer than %d.%d.%d. The latest version of\n",
147                major, minor, micro);
148         printf("*** GLIB is always available from ftp://ftp.gtk.org.\n");
149         printf("***\n");
150         printf("*** If you have already installed a sufficiently new version, this error\n");
151         printf("*** probably means that the wrong copy of the pkg-config shell script is\n");
152         printf("*** being found. The easiest way to fix this is to remove the old version\n");
153         printf("*** of GLIB, but you can also set the PKG_CONFIG environment to point to the\n");
154         printf("*** correct copy of pkg-config. (In this case, you will have to\n");
155         printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
156         printf("*** so that the correct libraries are found at run-time))\n");
157       }
158     }
159   return 1;
160 }
161 ],, no_glib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
162        CFLAGS="$ac_save_CFLAGS"
163        LIBS="$ac_save_LIBS"
164      fi
165   fi
166   if test "x$no_glib" = x ; then
167      AC_MSG_RESULT(yes (version $glib_config_major_version.$glib_config_minor_version.$glib_config_micro_version))
168      ifelse([$2], , :, [$2])     
169   else
170      AC_MSG_RESULT(no)
171      if test "$PKG_CONFIG" = "no" ; then
172        echo "*** A new enough version of pkg-config was not found."
173        echo "*** See http://www.freedesktop.org/software/pkgconfig/"
174      else
175        if test -f conf.glibtest ; then
176         :
177        else
178           echo "*** Could not run GLIB test program, checking why..."
179           ac_save_CFLAGS="$CFLAGS"
180           ac_save_LIBS="$LIBS"
181           CFLAGS="$CFLAGS $GLIB_CFLAGS"
182           LIBS="$LIBS $GLIB_LIBS"
183           AC_TRY_LINK([
184 #include <glib.h>
185 #include <stdio.h>
186 ],      [ return ((glib_major_version) || (glib_minor_version) || (glib_micro_version)); ],
187         [ echo "*** The test program compiled, but did not run. This usually means"
188           echo "*** that the run-time linker is not finding GLIB or finding the wrong"
189           echo "*** version of GLIB. If it is not finding GLIB, you'll need to set your"
190           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
191           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
192           echo "*** is required on your system"
193           echo "***"
194           echo "*** If you have an old version installed, it is best to remove it, although"
195           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
196         [ echo "*** The test program failed to compile or link. See the file config.log for the"
197           echo "*** exact error that occured. This usually means GLIB is incorrectly installed."])
198           CFLAGS="$ac_save_CFLAGS"
199           LIBS="$ac_save_LIBS"
200        fi
201      fi
202      GLIB_CFLAGS=""
203      GLIB_LIBS=""
204      GLIB_GENMARSHAL=""
205      GOBJECT_QUERY=""
206      GLIB_MKENUMS=""
207      ifelse([$3], , :, [$3])
208   fi
209   AC_SUBST(GLIB_CFLAGS)
210   AC_SUBST(GLIB_LIBS)
211   AC_SUBST(GLIB_GENMARSHAL)
212   AC_SUBST(GOBJECT_QUERY)
213   AC_SUBST(GLIB_MKENUMS)
214   rm -f conf.glibtest
215 ])