1 # Configure paths for GTK+
2 # Owen Taylor 1997-2001
4 dnl AM_PATH_GTK_3_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_3_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_gtk_version=gtk+-3.0
16 pkg_config_args=$pkg_gtk_version
21 pkg_gthread_version=gthread-2.0
22 pkg_config_args="$pkg_config_args $pkg_gthread_version"
29 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
31 if test x$PKG_CONFIG != xno ; then
32 if $PKG_CONFIG --atleast-pkgconfig-version 0.7 ; then
35 echo "*** pkg-config too old; version 0.7 or better required."
43 min_gtk_version=ifelse([$1], ,3.0.0,$1)
44 AC_MSG_CHECKING(for GTK+ - version >= $min_gtk_version)
46 if test x$PKG_CONFIG != xno ; then
47 ## don't try to run the test against uninstalled libtool libs
48 if $PKG_CONFIG --uninstalled $pkg_config_args; then
49 echo "Will use uninstalled version of GTK+ found in PKG_CONFIG_PATH"
52 if $PKG_CONFIG --atleast-version $min_gtk_version $pkg_gtk_version ; then
59 if test x"$no_gtk" = x ; then
60 GTK_CFLAGS=`$PKG_CONFIG $pkg_config_args --cflags`
61 GTK_LIBS=`$PKG_CONFIG $pkg_config_args --libs`
62 gtk_config_major_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
63 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
64 gtk_config_minor_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
65 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
66 gtk_config_micro_version=`$PKG_CONFIG --modversion gtk+-3.0 | \
67 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
68 if test "x$enable_gtktest" = "xyes" ; then
69 ac_save_CFLAGS="$CFLAGS"
71 CFLAGS="$CFLAGS $GTK_CFLAGS"
72 LIBS="$GTK_LIBS $LIBS"
74 dnl Now check if the installed GTK+ is sufficiently new. (Also sanity
75 dnl checks the results of pkg-config to some extent)
86 int major, minor, micro;
89 fclose (fopen ("conf.gtktest", "w"));
91 /* HP/UX 9 (%@#!) writes to sscanf strings */
92 tmp_version = g_strdup("$min_gtk_version");
93 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
94 printf("%s, bad version string\n", "$min_gtk_version");
98 if ((gtk_major_version != $gtk_config_major_version) ||
99 (gtk_minor_version != $gtk_config_minor_version) ||
100 (gtk_micro_version != $gtk_config_micro_version))
102 printf("\n*** 'pkg-config --modversion gtk+-3.0' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n",
103 $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
104 gtk_major_version, gtk_minor_version, gtk_micro_version);
105 printf ("*** was found! If pkg-config was correct, then it is best\n");
106 printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
107 printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
108 printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
109 printf("*** required on your system.\n");
110 printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
111 printf("*** to point to the correct configuration files\n");
113 else if ((gtk_major_version != GTK_MAJOR_VERSION) ||
114 (gtk_minor_version != GTK_MINOR_VERSION) ||
115 (gtk_micro_version != GTK_MICRO_VERSION))
117 printf("*** GTK+ header files (version %d.%d.%d) do not match\n",
118 GTK_MAJOR_VERSION, GTK_MINOR_VERSION, GTK_MICRO_VERSION);
119 printf("*** library (version %d.%d.%d)\n",
120 gtk_major_version, gtk_minor_version, gtk_micro_version);
124 if ((gtk_major_version > major) ||
125 ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
126 ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
132 printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
133 gtk_major_version, gtk_minor_version, gtk_micro_version);
134 printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
135 major, minor, micro);
136 printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
138 printf("*** If you have already installed a sufficiently new version, this error\n");
139 printf("*** probably means that the wrong copy of the pkg-config shell script is\n");
140 printf("*** being found. The easiest way to fix this is to remove the old version\n");
141 printf("*** of GTK+, but you can also set the PKG_CONFIG environment to point to the\n");
142 printf("*** correct copy of pkg-config. (In this case, you will have to\n");
143 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
144 printf("*** so that the correct libraries are found at run-time))\n");
149 ],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
150 CFLAGS="$ac_save_CFLAGS"
154 if test "x$no_gtk" = x ; then
155 AC_MSG_RESULT(yes (version $gtk_config_major_version.$gtk_config_minor_version.$gtk_config_micro_version))
156 ifelse([$2], , :, [$2])
159 if test "$PKG_CONFIG" = "no" ; then
160 echo "*** A new enough version of pkg-config was not found."
161 echo "*** See http://pkgconfig.sourceforge.net"
163 if test -f conf.gtktest ; then
166 echo "*** Could not run GTK+ test program, checking why..."
167 ac_save_CFLAGS="$CFLAGS"
169 CFLAGS="$CFLAGS $GTK_CFLAGS"
170 LIBS="$LIBS $GTK_LIBS"
174 ], [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
175 [ echo "*** The test program compiled, but did not run. This usually means"
176 echo "*** that the run-time linker is not finding GTK+ or finding the wrong"
177 echo "*** version of GTK+. If it is not finding GTK+, you'll need to set your"
178 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
179 echo "*** to the installed location Also, make sure you have run ldconfig if that"
180 echo "*** is required on your system"
182 echo "*** If you have an old version installed, it is best to remove it, although"
183 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
184 [ echo "*** The test program failed to compile or link. See the file config.log for the"
185 echo "*** exact error that occured. This usually means GTK+ is incorrectly installed."])
186 CFLAGS="$ac_save_CFLAGS"
192 ifelse([$3], , :, [$3])
199 dnl GTK_CHECK_BACKEND(BACKEND-NAME [, MINIMUM-VERSION [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
200 dnl Tests for BACKEND-NAME in the GTK targets list
202 AC_DEFUN([GTK_CHECK_BACKEND],
204 pkg_config_args=ifelse([$1],,gtk+-3.0, gtk+-$1-3.0)
205 min_gtk_version=ifelse([$2],,3.0.0,$2)
207 AC_PATH_PROG(PKG_CONFIG, [pkg-config], [AC_MSG_ERROR([No pkg-config found])])
209 if $PKG_CONFIG --atleast-version $min_gtk_version $pkg_gtk_version ; then
215 if test "x$target_found" = "xno"; then
216 ifelse([$4],,[AC_MSG_ERROR([Backend $backend not found.])],[$4])
218 ifelse([$3],,[:],[$3])