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 GTK2_CFLAGS and GTK2_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],
13 AS_HELP_STRING([--disable-gtktest], [do not try to compile and run a test GTK+ program]),
14 [], [enable_gtktest=yes])
16 pkg_config_args=gtk+-2.0
21 pkg_config_args="$pkg_config_args gthread-2.0"
28 AC_REQUIRE([PKG_PROG_PKG_CONFIG])
29 PKG_PROG_PKG_CONFIG([0.7])
31 min_gtk_version=ifelse([$1], ,2.0.0,$1)
32 AC_MSG_CHECKING(for GTK+ - version >= $min_gtk_version)
34 if test x$PKG_CONFIG != xno ; then
35 ## don't try to run the test against uninstalled libtool libs
36 if $PKG_CONFIG --uninstalled $pkg_config_args; then
37 echo "Will use uninstalled version of GTK+ found in PKG_CONFIG_PATH"
41 if $PKG_CONFIG --atleast-version $min_gtk_version $pkg_config_args; then
48 if test x"$no_gtk" = x ; then
49 GTK2_CFLAGS=`$PKG_CONFIG $pkg_config_args --cflags`
50 GTK2_CFLAGS="$GTK2_CFLAGS -DGDK_VERSION_MIN_REQUIRED=GDK_VERSION_2_12 -DGDK_VERSION_MAX_ALLOWED=GDK_VERSION_2_12"
51 GTK2_CFLAGS="$GTK2_CFLAGS -DGLIB_DISABLE_DEPRECATION_WARNINGS"
52 GTK2_LIBS=`$PKG_CONFIG $pkg_config_args --libs`
53 gtk_config_major_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
54 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
55 gtk_config_minor_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
56 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
57 gtk_config_micro_version=`$PKG_CONFIG --modversion gtk+-2.0 | \
58 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
59 if test "x$enable_gtktest" = "xyes" ; then
60 ac_save_CFLAGS="$CFLAGS"
62 CFLAGS="$CFLAGS $GTK2_CFLAGS"
63 LIBS="$GTK2_LIBS $LIBS"
65 dnl Now check if the installed GTK+ is sufficiently new. (Also sanity
66 dnl checks the results of pkg-config to some extent)
69 AC_RUN_IFELSE([AC_LANG_SOURCE([[
77 int major, minor, micro;
80 fclose (fopen ("conf.gtktest", "w"));
82 /* HP/UX 9 (%@#!) writes to sscanf strings */
83 tmp_version = g_strdup("$min_gtk_version");
84 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
85 printf("%s, bad version string\n", "$min_gtk_version");
89 if ((gtk_major_version != $gtk_config_major_version) ||
90 (gtk_minor_version != $gtk_config_minor_version) ||
91 (gtk_micro_version != $gtk_config_micro_version))
93 printf("\n*** 'pkg-config --modversion gtk+-2.0' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n",
94 $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
95 gtk_major_version, gtk_minor_version, gtk_micro_version);
96 printf ("*** was found! If pkg-config was correct, then it is best\n");
97 printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
98 printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
99 printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
100 printf("*** required on your system.\n");
101 printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
102 printf("*** to point to the correct configuration files\n");
104 else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
105 (gtk_minor_version != GTK_MINOR_VERSION) ||
106 (gtk_micro_version != GTK_MICRO_VERSION))
108 printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
109 GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
110 printf("*** library (version %d.%d.%d)\n",
111 gtk_major_version, gtk_minor_version, gtk_micro_version);
115 if ((gtk_major_version > major) ||
116 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
117 ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
123 printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
124 gtk_major_version, gtk_minor_version, gtk_micro_version);
125 printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
126 major, minor, micro);
127 printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
129 printf("*** If you have already installed a sufficiently new version, this error\n");
130 printf("*** probably means that the wrong copy of the pkg-config shell script is\n");
131 printf("*** being found. The easiest way to fix this is to remove the old version\n");
132 printf("*** of GTK+, but you can also set the PKG_CONFIG environment to point to the\n");
133 printf("*** correct copy of pkg-config. (In this case, you will have to\n");
134 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
135 printf("*** so that the correct libraries are found at run-time))\n");
140 ]])],[],[no_gtk=yes],[echo $ac_n "cross compiling; assumed OK... $ac_c"])
141 CFLAGS="$ac_save_CFLAGS"
145 if test "x$no_gtk" = x ; then
146 AC_MSG_RESULT(yes (version $gtk_config_major_version.$gtk_config_minor_version.$gtk_config_micro_version))
147 ifelse([$2], , :, [$2])
150 if test "$PKG_CONFIG" = "no" ; then
151 echo "*** A new enough version of pkg-config was not found."
152 echo "*** See http://pkgconfig.sourceforge.net"
154 if test -f conf.gtktest ; then
157 echo "*** Could not run GTK+ test program, checking why..."
158 ac_save_CFLAGS="$CFLAGS"
160 CFLAGS="$CFLAGS $GTK2_CFLAGS"
161 LIBS="$LIBS $GTK_LIBS"
162 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
165 ]], [[ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ]])],[ echo "*** The test program compiled, but did not run. This usually means"
166 echo "*** that the run-time linker is not finding GTK+ or finding the wrong"
167 echo "*** version of GTK+. If it is not finding GTK+, you'll need to set your"
168 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
169 echo "*** to the installed location Also, make sure you have run ldconfig if that"
170 echo "*** is required on your system"
172 echo "*** If you have an old version installed, it is best to remove it, although"
173 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],[ echo "*** The test program failed to compile or link. See the file config.log for the"
174 echo "*** exact error that occurred. This usually means GTK+ is incorrectly installed."])
175 CFLAGS="$ac_save_CFLAGS"
181 ifelse([$3], , :, [$3])
183 AC_SUBST(GTK2_CFLAGS)