1 # Configure paths for GTK+
2 # Owen Taylor 1997-2001
4 dnl AM_PATH_GTK_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
5 dnl Test for GTK+, and define GTK_CFLAGS and GTK_LIBS, if gthread is specified in MODULES,
8 AC_DEFUN(AM_PATH_GTK_2_0,
10 dnl Get the cflags and libraries from pkg-config
12 AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK+ program],
15 pkg_config_args=gtk+-2.0
20 pkg_config_args="$pkg_config_args gthread-2.0"
25 min_gtk_version=ifelse([$1], ,1.3.3,$1)
26 AC_MSG_CHECKING(for GTK+ - version >= $min_gtk_version)
30 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
32 if test x$PKG_CONFIG != xno ; then
33 if pkg-config --atleast-pkgconfig-version 0.5 ; then
36 echo *** pkg-config too old; version 0.5 or better required.
42 if test x"$no_gtk" = x ; then
43 GTK_CFLAGS=`$PKG_CONFIG $pkg_config_args --cflags`
44 GTK_LIBS=`$PKG_CONFIG $pkg_config_args --libs`
45 gtk_config_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
46 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
47 gtk_config_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
48 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
49 gtk_config_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
50 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
51 if test "x$enable_gtktest" = "xyes" ; then
52 ac_save_CFLAGS="$CFLAGS"
54 CFLAGS="$CFLAGS $GTK_CFLAGS"
55 LIBS="$GTK_LIBS $LIBS"
57 dnl Now check if the installed GTK+ is sufficiently new. (Also sanity
58 dnl checks the results of pkg-config to some extent)
69 int major, minor, micro;
72 system ("touch conf.gtktest");
74 /* HP/UX 9 (%@#!) writes to sscanf strings */
75 tmp_version = g_strdup("$min_gtk_version");
76 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
77 printf("%s, bad version string\n", "$min_gtk_version");
81 if ((gtk_major_version != $gtk_config_major_version) ||
82 (gtk_minor_version != $gtk_config_minor_version) ||
83 (gtk_micro_version != $gtk_config_micro_version))
85 printf("\n*** 'pkg-config --modversion gtk+-2.0' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n",
86 $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
87 gtk_major_version, gtk_minor_version, gtk_micro_version);
88 printf ("*** was found! If pkg-config was correct, then it is best\n");
89 printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
90 printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
91 printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
92 printf("*** required on your system.\n");
93 printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
94 printf("*** to point to the correct configuration files\n");
96 else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
97 (gtk_minor_version != GTK_MINOR_VERSION) ||
98 (gtk_micro_version != GTK_MICRO_VERSION))
100 printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
101 GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
102 printf("*** library (version %d.%d.%d)\n",
103 gtk_major_version, gtk_minor_version, gtk_micro_version);
107 if ((gtk_major_version > major) ||
108 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
109 ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
115 printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
116 gtk_major_version, gtk_minor_version, gtk_micro_version);
117 printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
118 major, minor, micro);
119 printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
121 printf("*** If you have already installed a sufficiently new version, this error\n");
122 printf("*** probably means that the wrong copy of the pkg-config shell script is\n");
123 printf("*** being found. The easiest way to fix this is to remove the old version\n");
124 printf("*** of GTK+, but you can also set the PKG_CONFIG environment to point to the\n");
125 printf("*** correct copy of pkg-config. (In this case, you will have to\n");
126 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
127 printf("*** so that the correct libraries are found at run-time))\n");
132 ],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
133 CFLAGS="$ac_save_CFLAGS"
137 if test "x$no_gtk" = x ; then
138 AC_MSG_RESULT(yes (version $gtk_config_major_version.$gtk_config_minor_version.$gtk_config_micro_version))
139 ifelse([$2], , :, [$2])
142 if test "$PKG_CONFIG" = "no" ; then
143 echo "*** A new enough version of pkg-config was not found."
144 echo "*** See http://pkgconfig.sourceforge.net"
146 if test -f conf.gtktest ; then
149 echo "*** Could not run GTK+ test program, checking why..."
150 CFLAGS="$CFLAGS $GTK_CFLAGS"
151 LIBS="$LIBS $GTK_LIBS"
155 ], [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
156 [ echo "*** The test program compiled, but did not run. This usually means"
157 echo "*** that the run-time linker is not finding GTK+ or finding the wrong"
158 echo "*** version of GTK+. If it is not finding GTK+, you'll need to set your"
159 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
160 echo "*** to the installed location Also, make sure you have run ldconfig if that"
161 echo "*** is required on your system"
163 echo "*** If you have an old version installed, it is best to remove it, although"
164 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
165 [ echo "*** The test program failed to compile or link. See the file config.log for the"
166 echo "*** exact error that occured. This usually means GTK+ was incorrectly installed"
167 echo "*** or that you have moved GTK+ since it was installed. In the latter case, you"
168 echo "*** may want to edit the pkg-config script: $PKG_CONFIG" ])
169 CFLAGS="$ac_save_CFLAGS"
175 ifelse([$3], , :, [$3])