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