77.3.6
by Monty Taylor
Added m4 macros for glib. |
1 |
# Configure paths for GLIB |
2 |
# Owen Taylor 1997-2001 |
|
3 |
||
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, |
|
6 |
dnl gthread, or gio is specified in MODULES, pass to pkg-config |
|
7 |
dnl
|
|
8 |
AC_DEFUN([AM_PATH_GLIB_2_0], |
|
9 |
[dnl |
|
10 |
dnl Get the cflags and libraries from pkg-config
|
|
11 |
dnl
|
|
12 |
AC_ARG_ENABLE(glibtest, [ --disable-glibtest do not try to compile and run a test GLIB program], |
|
13 |
, enable_glibtest=yes) |
|
14 |
||
15 |
pkg_config_args=glib-2.0 |
|
16 |
for module in . $4 |
|
17 |
do |
|
18 |
case "$module" in |
|
19 |
gmodule) |
|
20 |
pkg_config_args="$pkg_config_args gmodule-2.0" |
|
21 |
;; |
|
22 |
gmodule-no-export) |
|
23 |
pkg_config_args="$pkg_config_args gmodule-no-export-2.0" |
|
24 |
;; |
|
25 |
gobject) |
|
26 |
pkg_config_args="$pkg_config_args gobject-2.0" |
|
27 |
;; |
|
28 |
gthread) |
|
29 |
pkg_config_args="$pkg_config_args gthread-2.0" |
|
30 |
;; |
|
31 |
gio*) |
|
32 |
pkg_config_args="$pkg_config_args $module-2.0" |
|
33 |
;; |
|
34 |
esac |
|
35 |
done |
|
36 |
||
37 |
PKG_PROG_PKG_CONFIG([0.16]) |
|
38 |
||
39 |
no_glib="" |
|
40 |
||
41 |
if test "x$PKG_CONFIG" = x ; then |
|
42 |
no_glib=yes |
|
43 |
PKG_CONFIG=no |
|
44 |
fi |
|
45 |
||
46 |
min_glib_version=ifelse([$1], ,2.0.0,$1) |
|
47 |
AC_MSG_CHECKING(for GLIB - version >= $min_glib_version) |
|
48 |
||
49 |
if test x$PKG_CONFIG != xno ; then |
|
50 |
## don't try to run the test against uninstalled libtool libs |
|
51 |
if $PKG_CONFIG --uninstalled $pkg_config_args; then
|
|
52 |
echo "Will use uninstalled version of GLib found in PKG_CONFIG_PATH"
|
|
53 |
enable_glibtest=no
|
|
54 |
fi
|
|
55 |
||
56 |
if $PKG_CONFIG --atleast-version $min_glib_version $pkg_config_args; then
|
|
57 |
:
|
|
58 |
else
|
|
59 |
no_glib=yes
|
|
60 |
fi
|
|
61 |
fi
|
|
62 |
||
63 |
if test x"$no_glib" = x ; then
|
|
64 |
GLIB_GENMARSHAL=`$PKG_CONFIG --variable=glib_genmarshal glib-2.0`
|
|
65 |
GOBJECT_QUERY=`$PKG_CONFIG --variable=gobject_query glib-2.0`
|
|
66 |
GLIB_MKENUMS=`$PKG_CONFIG --variable=glib_mkenums glib-2.0`
|
|
67 |
||
68 |
GLIB_CFLAGS=`$PKG_CONFIG --cflags $pkg_config_args`
|
|
69 |
GLIB_LIBS=`$PKG_CONFIG --libs $pkg_config_args`
|
|
70 |
glib_config_major_version=`$PKG_CONFIG --modversion glib-2.0 | \
|
|
71 |
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` |
|
72 |
glib_config_minor_version=`$PKG_CONFIG --modversion glib-2.0 | \
|
|
73 |
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` |
|
74 |
glib_config_micro_version=`$PKG_CONFIG --modversion glib-2.0 | \
|
|
75 |
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` |
|
76 |
if test "x$enable_glibtest" = "xyes" ; then
|
|
77 |
ac_save_CFLAGS="$CFLAGS"
|
|
78 |
ac_save_LIBS="$LIBS"
|
|
79 |
CFLAGS="$CFLAGS $GLIB_CFLAGS"
|
|
80 |
LIBS="$GLIB_LIBS $LIBS"
|
|
81 |
dnl
|
|
82 |
dnl Now check if the installed GLIB is sufficiently new. (Also sanity
|
|
83 |
dnl checks the results of pkg-config to some extent)
|
|
84 |
dnl
|
|
85 |
rm -f conf.glibtest
|
|
86 |
AC_TRY_RUN([
|
|
87 |
#include <glib.h>
|
|
88 |
#include <stdio.h>
|
|
89 |
#include <stdlib.h>
|
|
90 |
||
91 |
int
|
|
92 |
main ()
|
|
93 |
{
|
|
94 |
int major, minor, micro;
|
|
95 |
char *tmp_version;
|
|
96 |
||
97 |
system ("touch conf.glibtest");
|
|
98 |
||
99 |
/* HP/UX 9 (%@#!) writes to sscanf strings */
|
|
100 |
tmp_version = g_strdup("$min_glib_version");
|
|
101 |
if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) {
|
|
102 |
printf("%s, bad version string\n", "$min_glib_version");
|
|
103 |
exit(1);
|
|
104 |
}
|
|
105 |
||
106 |
if ((glib_major_version != $glib_config_major_version) ||
|
|
107 |
(glib_minor_version != $glib_config_minor_version) ||
|
|
108 |
(glib_micro_version != $glib_config_micro_version))
|
|
109 |
{
|
|
110 |
printf("\n*** 'pkg-config --modversion glib-2.0' returned %d.%d.%d, but GLIB (%d.%d.%d)\n", |
|
111 |
$glib_config_major_version, $glib_config_minor_version, $glib_config_micro_version,
|
|
112 |
glib_major_version, glib_minor_version, glib_micro_version);
|
|
113 |
printf ("*** was found! If pkg-config was correct, then it is best\n");
|
|
114 |
printf ("*** to remove the old version of GLib. You may also be able to fix the error\n");
|
|
115 |
printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
|
|
116 |
printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
|
|
117 |
printf("*** required on your system.\n");
|
|
118 |
printf("*** If pkg-config was wrong, set the environment variable PKG_CONFIG_PATH\n");
|
|
119 |
printf("*** to point to the correct configuration files\n");
|
|
120 |
}
|
|
121 |
else if ((glib_major_version != GLIB_MAJOR_VERSION) ||
|
|
122 |
(glib_minor_version != GLIB_MINOR_VERSION) ||
|
|
123 |
(glib_micro_version != GLIB_MICRO_VERSION))
|
|
124 |
{
|
|
125 |
printf("*** GLIB header files (version %d.%d.%d) do not match\n",
|
|
126 |
GLIB_MAJOR_VERSION, GLIB_MINOR_VERSION, GLIB_MICRO_VERSION);
|
|
127 |
printf("*** library (version %d.%d.%d)\n",
|
|
128 |
glib_major_version, glib_minor_version, glib_micro_version);
|
|
129 |
}
|
|
130 |
else
|
|
131 |
{
|
|
132 |
if ((glib_major_version > major) ||
|
|
133 |
((glib_major_version == major) && (glib_minor_version > minor)) ||
|
|
134 |
((glib_major_version == major) && (glib_minor_version == minor) && (glib_micro_version >= micro)))
|
|
135 |
{
|
|
136 |
return 0;
|
|
137 |
}
|
|
138 |
else
|
|
139 |
{
|
|
140 |
printf("\n*** An old version of GLIB (%d.%d.%d) was found.\n",
|
|
141 |
glib_major_version, glib_minor_version, glib_micro_version);
|
|
142 |
printf("*** You need a version of GLIB newer than %d.%d.%d. The latest version of\n",
|
|
143 |
major, minor, micro);
|
|
144 |
printf("*** GLIB is always available from ftp://ftp.gtk.org.\n");
|
|
145 |
printf("***\n");
|
|
146 |
printf("*** If you have already installed a sufficiently new version, this error\n");
|
|
147 |
printf("*** probably means that the wrong copy of the pkg-config shell script is\n");
|
|
148 |
printf("*** being found. The easiest way to fix this is to remove the old version\n");
|
|
149 |
printf("*** of GLIB, but you can also set the PKG_CONFIG environment to point to the\n");
|
|
150 |
printf("*** correct copy of pkg-config. (In this case, you will have to\n");
|
|
151 |
printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
|
|
152 |
printf("*** so that the correct libraries are found at run-time))\n");
|
|
153 |
}
|
|
154 |
}
|
|
155 |
return 1;
|
|
156 |
}
|
|
157 |
],, no_glib=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
|
|
158 |
CFLAGS="$ac_save_CFLAGS"
|
|
159 |
LIBS="$ac_save_LIBS"
|
|
160 |
fi
|
|
161 |
fi
|
|
162 |
if test "x$no_glib" = x ; then
|
|
163 |
AC_MSG_RESULT(yes (version $glib_config_major_version.$glib_config_minor_version.$glib_config_micro_version))
|
|
164 |
ifelse([$2], , :, [$2])
|
|
165 |
else
|
|
166 |
AC_MSG_RESULT(no)
|
|
167 |
if test "$PKG_CONFIG" = "no" ; then
|
|
168 |
echo "*** A new enough version of pkg-config was not found."
|
|
169 |
echo "*** See http://www.freedesktop.org/software/pkgconfig/"
|
|
170 |
else
|
|
171 |
if test -f conf.glibtest ; then
|
|
172 |
:
|
|
173 |
else
|
|
174 |
echo "*** Could not run GLIB test program, checking why..."
|
|
175 |
ac_save_CFLAGS="$CFLAGS"
|
|
176 |
ac_save_LIBS="$LIBS"
|
|
177 |
CFLAGS="$CFLAGS $GLIB_CFLAGS"
|
|
178 |
LIBS="$LIBS $GLIB_LIBS"
|
|
179 |
AC_TRY_LINK([
|
|
180 |
#include <glib.h>
|
|
181 |
#include <stdio.h>
|
|
182 |
], [ return ((glib_major_version) || (glib_minor_version) || (glib_micro_version)); ],
|
|
183 |
[ echo "*** The test program compiled, but did not run. This usually means"
|
|
184 |
echo "*** that the run-time linker is not finding GLIB or finding the wrong"
|
|
185 |
echo "*** version of GLIB. If it is not finding GLIB, you'll need to set your" |
|
186 |
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" |
|
187 |
echo "*** to the installed location Also, make sure you have run ldconfig if that" |
|
188 |
echo "*** is required on your system" |
|
189 |
echo "***" |
|
190 |
echo "*** If you have an old version installed, it is best to remove it, although" |
|
191 |
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ], |
|
192 |
[ echo "*** The test program failed to compile or link. See the file config.log for the" |
|
193 |
echo "*** exact error that occured. This usually means GLIB is incorrectly installed."]) |
|
194 |
CFLAGS="$ac_save_CFLAGS" |
|
195 |
LIBS="$ac_save_LIBS" |
|
196 |
fi
|
|
197 |
fi
|
|
198 |
GLIB_CFLAGS=""
|
|
199 |
GLIB_LIBS=""
|
|
200 |
GLIB_GENMARSHAL=""
|
|
201 |
GOBJECT_QUERY=""
|
|
202 |
GLIB_MKENUMS="" |
|
203 |
ifelse([$3], , :, [$3]) |
|
204 |
fi |
|
205 |
AC_SUBST(GLIB_CFLAGS) |
|
206 |
AC_SUBST(GLIB_LIBS) |
|
207 |
AC_SUBST(GLIB_GENMARSHAL) |
|
208 |
AC_SUBST(GOBJECT_QUERY) |
|
209 |
AC_SUBST(GLIB_MKENUMS) |
|
210 |
rm -f conf.glibtest |
|
211 |
]) |