1 # Configure paths for GLIB
2 # Owen Taylor 1997-2001
4 dnl AM_PATH_GLIB_2_0([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND [, MODULES]]]])
5 dnl Test for GLIB, and define GLIB_CFLAGS and GLIB_LIBS, if gmodule, gobject or
6 dnl gthread is specified in MODULES, pass to pkg-config
8 AC_DEFUN(AM_PATH_GLIB_2_0,
10 dnl Get the cflags and libraries from pkg-config
12 AC_ARG_ENABLE(glibtest, [ --disable-glibtest Do not try to compile and run a test GLIB program],
13 , enable_glibtest=yes)
15 pkg_config_args=glib-2.0
20 pkg_config_args="$pkg_config_args gmodule-2.0"
23 pkg_config_args="$pkg_config_args gobject-2.0"
26 pkg_config_args="$pkg_config_args gthread-2.0"
31 AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
33 min_glib_version=ifelse([$1], ,1.3.3,$1)
34 AC_MSG_CHECKING(for GLIB - version >= $min_glib_version)
38 if test x$PKG_CONFIG != xno ; then
39 if pkg-config --atleast-pkgconfig-version 0.5 ; then
42 echo *** pkg-config too old; version 0.5 or better required.
48 if test x"$no_glib" = x ; then
49 GLIB_CFLAGS=`$PKG_CONFIG --cflags $pkg_config_args`
50 GLIB_LIBS=`$PKG_CONFIG --libs $pkg_config_args`
51 glib_config_major_version=`$PKG_CONFIG --modversion glib-2.0 | \
52 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
53 glib_config_minor_version=`$PKG_CONFIG --modversion glib-2.0 | \
54 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
55 glib_config_micro_version=`$PKG_CONFIG --modversion glib-2.0 | \
56 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
57 if test "x$enable_glibtest" = "xyes" ; then
58 ac_save_CFLAGS="$CFLAGS"
60 CFLAGS="$CFLAGS $GLIB_CFLAGS"
61 LIBS="$GLIB_LIBS $LIBS"
63 dnl Now check if the installed GLIB is sufficiently new. (Also sanity
64 dnl checks the results of pkg-config to some extent)
75 int major, minor, micro;
78 system ("touch conf.glibtest");
80 /* HP/UX 9 (%@#!) writes to sscanf strings */
81 tmp_version = g_strdup("$min_glib_version");
82 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
83 printf("%s, bad version string\n", "$min_glib_version");
87 if ((glib_major_version != $glib_config_major_version) ||
88 (glib_minor_version != $glib_config_minor_version) ||
89 (glib_micro_version != $glib_config_micro_version))
91 printf("\n*** 'pkg-config --modversion glib-2.0' returned %d.%d.%d, but GLIB (%d.%d.%d)\n",
92 $glib_config_major_version, $glib_config_minor_version, $glib_config_micro_version,
93 glib_major_version, glib_minor_version, glib_micro_version);
94 printf ("*** was found! If pkg-config was correct, then it is best\n");
95 printf ("*** to remove the old version of GLib. You may also be able to fix the error\n");
96 printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
97 printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
98 printf("*** required on your system.\n");
99 printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
100 printf("*** to point to the correct configuration files\n");
102 else if ((glib_major_version != GLIB_MAJOR_VERSION) ||
103 (glib_minor_version != GLIB_MINOR_VERSION) ||
104 (glib_micro_version != GLIB_MICRO_VERSION))
106 printf("*** GLIB header files (version %d.%d.%d) do not match\n",
107 GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION);
108 printf("*** library (version %d.%d.%d)\n",
109 glib_major_version, glib_minor_version, glib_micro_version);
113 if ((glib_major_version > major) ||
114 ((glib_major_version == major) && (glib_minor_version > minor)) ||
115 ((glib_major_version == major) && (glib_minor_version == minor) && (glib_micro_version >= micro)))
121 printf("\n*** An old version of GLIB (%d.%d.%d) was found.\n",
122 glib_major_version, glib_minor_version, glib_micro_version);
123 printf("*** You need a version of GLIB newer than %d.%d.%d. The latest version of\n",
124 major, minor, micro);
125 printf("*** GLIB is always available from ftp://ftp.gtk.org.\n");
127 printf("*** If you have already installed a sufficiently new version, this error\n");
128 printf("*** probably means that the wrong copy of the pkg-config shell script is\n");
129 printf("*** being found. The easiest way to fix this is to remove the old version\n");
130 printf("*** of GLIB, but you can also set the PKG_CONFIG environment to point to the\n");
131 printf("*** correct copy of pkg-config. (In this case, you will have to\n");
132 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
133 printf("*** so that the correct libraries are found at run-time))\n");
138 ],, no_glib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
139 CFLAGS="$ac_save_CFLAGS"
143 if test "x$no_glib" = x ; then
144 AC_MSG_RESULT(yes (version $glib_config_major_version.$glib_config_minor_version.$glib_config_micro_version))
145 ifelse([$2], , :, [$2])
148 if test "$PKG_CONFIG" = "no" ; then
149 echo "*** A new enough version of pkg-config was not found."
150 echo "*** See http://pkgconfig.sourceforge.net"
152 if test -f conf.glibtest ; then
155 echo "*** Could not run GLIB test program, checking why..."
156 CFLAGS="$CFLAGS $GLIB_CFLAGS"
157 LIBS="$LIBS $GLIB_LIBS"
161 ], [ return ((glib_major_version) || (glib_minor_version) || (glib_micro_version)); ],
162 [ echo "*** The test program compiled, but did not run. This usually means"
163 echo "*** that the run-time linker is not finding GLIB or finding the wrong"
164 echo "*** version of GLIB. If it is not finding GLIB, you'll need to set your"
165 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
166 echo "*** to the installed location Also, make sure you have run ldconfig if that"
167 echo "*** is required on your system"
169 echo "*** If you have an old version installed, it is best to remove it, although"
170 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
171 [ echo "*** The test program failed to compile or link. See the file config.log for the"
172 echo "*** exact error that occured. This usually means GLIB was incorrectly installed"
173 echo "*** or that you have moved GLIB since it was installed. In the latter case, you"
174 echo "*** may want to edit the pkg-config script: $PKG_CONFIG" ])
175 CFLAGS="$ac_save_CFLAGS"
181 ifelse([$3], , :, [$3])
183 AC_SUBST(GLIB_CFLAGS)