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