1 |
# Configure paths for GTK+ |
2 |
# Owen Taylor 97-11-3 |
3 |
|
4 |
dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) |
5 |
dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS |
6 |
dnl |
7 |
AC_DEFUN(AM_PATH_GTK, |
8 |
[dnl |
9 |
dnl Get the cflags and libraries from the gtk-config script |
10 |
dnl |
11 |
AC_ARG_WITH(gtk-prefix,[ --with-gtk-prefix=PFX Prefix where GTK is installed (optional)], |
12 |
gtk_config_prefix="$withval", gtk_config_prefix="") |
13 |
AC_ARG_WITH(gtk-exec-prefix,[ --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)], |
14 |
gtk_config_exec_prefix="$withval", gtk_config_exec_prefix="") |
15 |
AC_ARG_ENABLE(gtktest, [ --disable-gtktest Do not try to compile and run a test GTK program], |
16 |
, enable_gtktest=yes) |
17 |
|
18 |
if test x$gtk_config_exec_prefix != x ; then |
19 |
gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix" |
20 |
if test x${GTK_CONFIG+set} != xset ; then |
21 |
GTK_CONFIG=$gtk_config_exec_prefix/bin/gtk-config |
22 |
fi |
23 |
fi |
24 |
if test x$gtk_config_prefix != x ; then |
25 |
gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix" |
26 |
if test x${GTK_CONFIG+set} != xset ; then |
27 |
GTK_CONFIG=$gtk_config_prefix/bin/gtk-config |
28 |
fi |
29 |
fi |
30 |
|
31 |
AC_PATH_PROG(GTK_CONFIG, gtk-config, no) |
32 |
min_gtk_version=ifelse([$1], ,0.99.7,$1) |
33 |
AC_MSG_CHECKING(for GTK - version >= $min_gtk_version) |
34 |
no_gtk="" |
35 |
if test "$GTK_CONFIG" = "no" ; then |
36 |
no_gtk=yes |
37 |
else |
38 |
GTK_CFLAGS=`$GTK_CONFIG $gtk_config_args --cflags` |
39 |
GTK_LIBS=`$GTK_CONFIG $gtk_config_args --libs` |
40 |
gtk_config_major_version=`$GTK_CONFIG $gtk_config_args --version | \ |
41 |
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` |
42 |
gtk_config_minor_version=`$GTK_CONFIG $gtk_config_args --version | \ |
43 |
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` |
44 |
gtk_config_micro_version=`$GTK_CONFIG $gtk_config_args --version | \ |
45 |
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` |
46 |
if test "x$enable_gtktest" = "xyes" ; then |
47 |
ac_save_CFLAGS="$CFLAGS" |
48 |
ac_save_LIBS="$LIBS" |
49 |
CFLAGS="$CFLAGS $GTK_CFLAGS" |
50 |
LIBS="$LIBS $GTK_LIBS" |
51 |
dnl |
52 |
dnl Now check if the installed GTK is sufficiently new. (Also sanity |
53 |
dnl checks the results of gtk-config to some extent |
54 |
dnl |
55 |
rm -f conf.gtktest |
56 |
AC_TRY_RUN([ |
57 |
#include <gtk/gtk.h> |
58 |
#include <stdio.h> |
59 |
|
60 |
int |
61 |
main () |
62 |
{ |
63 |
int major, minor, micro; |
64 |
|
65 |
system ("touch conf.gtktest"); |
66 |
|
67 |
if (sscanf("$min_gtk_version", "%d.%d.%d", &major, &minor, µ) != 3) { |
68 |
printf("%s, bad version string\n", "$min_gtk_version"); |
69 |
exit(1); |
70 |
} |
71 |
|
72 |
if ((gtk_major_version != $gtk_config_major_version) || |
73 |
(gtk_minor_version != $gtk_config_minor_version) || |
74 |
(gtk_micro_version != $gtk_config_micro_version)) |
75 |
{ |
76 |
printf("\n*** 'gtk-config --version' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n", |
77 |
$gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version, |
78 |
gtk_major_version, gtk_minor_version, gtk_micro_version); |
79 |
printf ("*** was found! If gtk-config was correct, then it is best\n"); |
80 |
printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n"); |
81 |
printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n"); |
82 |
printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n"); |
83 |
printf("*** required on your system.\n"); |
84 |
printf("*** If gtk-config was wrong, set the environment variable GTK_CONFIG\n"); |
85 |
printf("*** to point to the correct copy of gtk-config, and remove the file config.cache\n"); |
86 |
printf("*** before re-running configure\n"); |
87 |
} |
88 |
else |
89 |
{ |
90 |
if ((gtk_major_version > major) || |
91 |
((gtk_major_version == major) && (gtk_minor_version > minor)) || |
92 |
((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro))) |
93 |
{ |
94 |
return 0; |
95 |
} |
96 |
else |
97 |
{ |
98 |
printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n", |
99 |
gtk_major_version, gtk_minor_version, gtk_micro_version); |
100 |
printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n", |
101 |
major, minor, micro); |
102 |
printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n"); |
103 |
printf("***\n"); |
104 |
printf("*** If you have already installed a sufficiently new version, this error\n"); |
105 |
printf("*** probably means that the wrong copy of the gtk-config shell script is\n"); |
106 |
printf("*** being found. The easiest way to fix this is to remove the old version\n"); |
107 |
printf("*** of GTK+, but you can also set the GTK_CONFIG environment to point to the\n"); |
108 |
printf("*** correct copy of gtk-config. (In this case, you will have to\n"); |
109 |
printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n"); |
110 |
printf("*** so that the correct libraries are found at run-time))\n"); |
111 |
} |
112 |
} |
113 |
return 1; |
114 |
} |
115 |
],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) |
116 |
CFLAGS="$ac_save_CFLAGS" |
117 |
LIBS="$ac_save_LIBS" |
118 |
fi |
119 |
fi |
120 |
if test "x$no_gtk" = x ; then |
121 |
AC_MSG_RESULT(yes) |
122 |
ifelse([$2], , :, [$2]) |
123 |
else |
124 |
AC_MSG_RESULT(no) |
125 |
if test "$GTK_CONFIG" = "no" ; then |
126 |
echo "*** The gtk-config script installed by GTK could not be found" |
127 |
echo "*** If GTK was installed in PREFIX, make sure PREFIX/bin is in" |
128 |
echo "*** your path, or set the GTK_CONFIG environment variable to the" |
129 |
echo "*** full path to gtk-config." |
130 |
else |
131 |
if test -f conf.gtktest ; then |
132 |
: |
133 |
else |
134 |
echo "*** Could not run GTK test program, checking why..." |
135 |
CFLAGS="$CFLAGS $GTK_CFLAGS" |
136 |
LIBS="$LIBS $GTK_LIBS" |
137 |
AC_TRY_LINK([ |
138 |
#include <gtk/gtk.h> |
139 |
#include <stdio.h> |
140 |
], [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ], |
141 |
[ echo "*** The test program compiled, but did not run. This usually means" |
142 |
echo "*** that the run-time linker is not finding GTK or finding the wrong" |
143 |
echo "*** version of GTK. If it is not finding GTK, you'll need to set your" |
144 |
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" |
145 |
echo "*** to the installed location Also, make sure you have run ldconfig if that" |
146 |
echo "*** is required on your system" |
147 |
echo "***" |
148 |
echo "*** If you have an old version installed, it is best to remove it, although" |
149 |
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" |
150 |
echo "***" |
151 |
echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that" |
152 |
echo "*** came with the system with the command" |
153 |
echo "***" |
154 |
echo "*** rpm --erase --nodeps gtk gtk-devel" ], |
155 |
[ echo "*** The test program failed to compile or link. See the file config.log for the" |
156 |
echo "*** exact error that occured. This usually means GTK was incorrectly installed" |
157 |
echo "*** or that you have moved GTK since it was installed. In the latter case, you" |
158 |
echo "*** may want to edit the gtk-config script: $GTK_CONFIG" ]) |
159 |
CFLAGS="$ac_save_CFLAGS" |
160 |
LIBS="$ac_save_LIBS" |
161 |
fi |
162 |
fi |
163 |
GTK_CFLAGS="" |
164 |
GTK_LIBS="" |
165 |
ifelse([$3], , :, [$3]) |
166 |
fi |
167 |
AC_SUBST(GTK_CFLAGS) |
168 |
AC_SUBST(GTK_LIBS) |
169 |
rm -f conf.gtktest |
170 |
]) |
171 |
|
172 |
|
173 |
# Configure paths for ESD |
174 |
# Manish Singh 98-9-30 |
175 |
# stolen back from Frank Belew |
176 |
# stolen from Manish Singh |
177 |
# Shamelessly stolen from Owen Taylor |
178 |
|
179 |
dnl AM_PATH_ESD([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]]) |
180 |
dnl Test for ESD, and define ESD_CFLAGS and ESD_LIBS |
181 |
dnl |
182 |
AC_DEFUN(AM_PATH_ESD, |
183 |
[dnl |
184 |
dnl Get the cflags and libraries from the esd-config script |
185 |
dnl |
186 |
AC_ARG_WITH(esd-prefix,[ --with-esd-prefix=PFX Prefix where ESD is installed (optional)], |
187 |
esd_prefix="$withval", esd_prefix="") |
188 |
AC_ARG_WITH(esd-exec-prefix,[ --with-esd-exec-prefix=PFX Exec prefix where ESD is installed (optional)], |
189 |
esd_exec_prefix="$withval", esd_exec_prefix="") |
190 |
AC_ARG_ENABLE(esdtest, [ --disable-esdtest Do not try to compile and run a test ESD program], |
191 |
, enable_esdtest=yes) |
192 |
|
193 |
if test x$esd_exec_prefix != x ; then |
194 |
esd_args="$esd_args --exec-prefix=$esd_exec_prefix" |
195 |
if test x${ESD_CONFIG+set} != xset ; then |
196 |
ESD_CONFIG=$esd_exec_prefix/bin/esd-config |
197 |
fi |
198 |
fi |
199 |
if test x$esd_prefix != x ; then |
200 |
esd_args="$esd_args --prefix=$esd_prefix" |
201 |
if test x${ESD_CONFIG+set} != xset ; then |
202 |
ESD_CONFIG=$esd_prefix/bin/esd-config |
203 |
fi |
204 |
fi |
205 |
|
206 |
AC_PATH_PROG(ESD_CONFIG, esd-config, no) |
207 |
min_esd_version=ifelse([$1], ,0.2.7,$1) |
208 |
AC_MSG_CHECKING(for ESD - version >= $min_esd_version) |
209 |
no_esd="" |
210 |
if test "$ESD_CONFIG" = "no" ; then |
211 |
no_esd=yes |
212 |
else |
213 |
ESD_CFLAGS=`$ESD_CONFIG $esdconf_args --cflags` |
214 |
ESD_LIBS=`$ESD_CONFIG $esdconf_args --libs` |
215 |
|
216 |
esd_major_version=`$ESD_CONFIG $esd_args --version | \ |
217 |
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'` |
218 |
esd_minor_version=`$ESD_CONFIG $esd_args --version | \ |
219 |
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'` |
220 |
esd_micro_version=`$ESD_CONFIG $esd_config_args --version | \ |
221 |
sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'` |
222 |
if test "x$enable_esdtest" = "xyes" ; then |
223 |
ac_save_CFLAGS="$CFLAGS" |
224 |
ac_save_LIBS="$LIBS" |
225 |
CFLAGS="$CFLAGS $ESD_CFLAGS" |
226 |
LIBS="$LIBS $ESD_LIBS" |
227 |
dnl |
228 |
dnl Now check if the installed ESD is sufficiently new. (Also sanity |
229 |
dnl checks the results of esd-config to some extent |
230 |
dnl |
231 |
rm -f conf.esdtest |
232 |
AC_TRY_RUN([ |
233 |
#include <stdio.h> |
234 |
#include <stdlib.h> |
235 |
#include <string.h> |
236 |
#include <esd.h> |
237 |
|
238 |
char* |
239 |
my_strdup (char *str) |
240 |
{ |
241 |
char *new_str; |
242 |
|
243 |
if (str) |
244 |
{ |
245 |
new_str = malloc ((strlen (str) + 1) * sizeof(char)); |
246 |
strcpy (new_str, str); |
247 |
} |
248 |
else |
249 |
new_str = NULL; |
250 |
|
251 |
return new_str; |
252 |
} |
253 |
|
254 |
int main () |
255 |
{ |
256 |
int major, minor, micro; |
257 |
char *tmp_version; |
258 |
|
259 |
system ("touch conf.esdtest"); |
260 |
|
261 |
/* HP/UX 9 (%@#!) writes to sscanf strings */ |
262 |
tmp_version = my_strdup("$min_esd_version"); |
263 |
if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, µ) != 3) { |
264 |
printf("%s, bad version string\n", "$min_esd_version"); |
265 |
exit(1); |
266 |
} |
267 |
|
268 |
if (($esd_major_version > major) || |
269 |
(($esd_major_version == major) && ($esd_minor_version > minor)) || |
270 |
(($esd_major_version == major) && ($esd_minor_version == minor) && ($esd_micro_version >= micro))) |
271 |
{ |
272 |
return 0; |
273 |
} |
274 |
else |
275 |
{ |
276 |
printf("\n*** 'esd-config --version' returned %d.%d.%d, but the minimum version\n", $esd_major_version, $esd_minor_version, $esd_micro_version); |
277 |
printf("*** of ESD required is %d.%d.%d. If esd-config is correct, then it is\n", major, minor, micro); |
278 |
printf("*** best to upgrade to the required version.\n"); |
279 |
printf("*** If esd-config was wrong, set the environment variable ESD_CONFIG\n"); |
280 |
printf("*** to point to the correct copy of esd-config, and remove the file\n"); |
281 |
printf("*** config.cache before re-running configure\n"); |
282 |
return 1; |
283 |
} |
284 |
} |
285 |
|
286 |
],, no_esd=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"]) |
287 |
CFLAGS="$ac_save_CFLAGS" |
288 |
LIBS="$ac_save_LIBS" |
289 |
fi |
290 |
fi |
291 |
if test "x$no_esd" = x ; then |
292 |
AC_MSG_RESULT(yes) |
293 |
ifelse([$2], , :, [$2]) |
294 |
else |
295 |
AC_MSG_RESULT(no) |
296 |
if test "$ESD_CONFIG" = "no" ; then |
297 |
echo "*** The esd-config script installed by ESD could not be found" |
298 |
echo "*** If ESD was installed in PREFIX, make sure PREFIX/bin is in" |
299 |
echo "*** your path, or set the ESD_CONFIG environment variable to the" |
300 |
echo "*** full path to esd-config." |
301 |
else |
302 |
if test -f conf.esdtest ; then |
303 |
: |
304 |
else |
305 |
echo "*** Could not run ESD test program, checking why..." |
306 |
CFLAGS="$CFLAGS $ESD_CFLAGS" |
307 |
LIBS="$LIBS $ESD_LIBS" |
308 |
AC_TRY_LINK([ |
309 |
#include <stdio.h> |
310 |
#include <esd.h> |
311 |
], [ return 0; ], |
312 |
[ echo "*** The test program compiled, but did not run. This usually means" |
313 |
echo "*** that the run-time linker is not finding ESD or finding the wrong" |
314 |
echo "*** version of ESD. If it is not finding ESD, you'll need to set your" |
315 |
echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point" |
316 |
echo "*** to the installed location Also, make sure you have run ldconfig if that" |
317 |
echo "*** is required on your system" |
318 |
echo "***" |
319 |
echo "*** If you have an old version installed, it is best to remove it, although" |
320 |
echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"], |
321 |
[ echo "*** The test program failed to compile or link. See the file config.log for the" |
322 |
echo "*** exact error that occured. This usually means ESD was incorrectly installed" |
323 |
echo "*** or that you have moved ESD since it was installed. In the latter case, you" |
324 |
echo "*** may want to edit the esd-config script: $ESD_CONFIG" ]) |
325 |
CFLAGS="$ac_save_CFLAGS" |
326 |
LIBS="$ac_save_LIBS" |
327 |
fi |
328 |
fi |
329 |
ESD_CFLAGS="" |
330 |
ESD_LIBS="" |
331 |
ifelse([$3], , :, [$3]) |
332 |
fi |
333 |
AC_SUBST(ESD_CFLAGS) |
334 |
AC_SUBST(ESD_LIBS) |
335 |
rm -f conf.esdtest |
336 |
]) |