comparison acinclude.m4 @ 68:0b53ace8b875

Initial add.
author Ryan C. Gordon <icculus@icculus.org>
date Tue, 25 Sep 2001 15:46:48 +0000
parents
children 72b51548aeca
comparison
equal deleted inserted replaced
67:78da63951b29 68:0b53ace8b875
1 # Configure paths for SDL
2 # Sam Lantinga 9/21/99
3 # stolen from Manish Singh
4 # stolen back from Frank Belew
5 # stolen from Manish Singh
6 # Shamelessly stolen from Owen Taylor
7
8 dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
9 dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
10 dnl
11 AC_DEFUN(AM_PATH_SDL,
12 [dnl
13 dnl Get the cflags and libraries from the sdl-config script
14 dnl
15 AC_ARG_WITH(sdl-prefix,[ --with-sdl-prefix=PFX Prefix where SDL is installed (optional)],
16 sdl_prefix="$withval", sdl_prefix="")
17 AC_ARG_WITH(sdl-exec-prefix,[ --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
18 sdl_exec_prefix="$withval", sdl_exec_prefix="")
19 AC_ARG_ENABLE(sdltest, [ --disable-sdltest Do not try to compile and run a test SDL program],
20 , enable_sdltest=yes)
21
22 if test x$sdl_exec_prefix != x ; then
23 sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix"
24 if test x${SDL_CONFIG+set} != xset ; then
25 SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config
26 fi
27 fi
28 if test x$sdl_prefix != x ; then
29 sdl_args="$sdl_args --prefix=$sdl_prefix"
30 if test x${SDL_CONFIG+set} != xset ; then
31 SDL_CONFIG=$sdl_prefix/bin/sdl-config
32 fi
33 fi
34
35 AC_PATH_PROG(SDL_CONFIG, sdl-config, no)
36 min_sdl_version=ifelse([$1], ,0.11.0,$1)
37 AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
38 no_sdl=""
39 if test "$SDL_CONFIG" = "no" ; then
40 no_sdl=yes
41 else
42 SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags`
43 SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs`
44
45 sdl_major_version=`$SDL_CONFIG $sdl_args --version | \
46 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
47 sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \
48 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
49 sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \
50 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
51 if test "x$enable_sdltest" = "xyes" ; then
52 ac_save_CFLAGS="$CFLAGS"
53 ac_save_LIBS="$LIBS"
54 CFLAGS="$CFLAGS $SDL_CFLAGS"
55 LIBS="$LIBS $SDL_LIBS"
56 dnl
57 dnl Now check if the installed SDL is sufficiently new. (Also sanity
58 dnl checks the results of sdl-config to some extent
59 dnl
60 rm -f conf.sdltest
61 AC_TRY_RUN([
62 #include <stdio.h>
63 #include <stdlib.h>
64 #include <string.h>
65 #include "SDL.h"
66
67 char*
68 my_strdup (char *str)
69 {
70 char *new_str;
71
72 if (str)
73 {
74 new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
75 strcpy (new_str, str);
76 }
77 else
78 new_str = NULL;
79
80 return new_str;
81 }
82
83 int main (int argc, char *argv[])
84 {
85 int major, minor, micro;
86 char *tmp_version;
87
88 /* This hangs on some systems (?)
89 system ("touch conf.sdltest");
90 */
91 { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }
92
93 /* HP/UX 9 (%@#!) writes to sscanf strings */
94 tmp_version = my_strdup("$min_sdl_version");
95 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
96 printf("%s, bad version string\n", "$min_sdl_version");
97 exit(1);
98 }
99
100 if (($sdl_major_version > major) ||
101 (($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
102 (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
103 {
104 return 0;
105 }
106 else
107 {
108 printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
109 printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro);
110 printf("*** best to upgrade to the required version.\n");
111 printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n");
112 printf("*** to point to the correct copy of sdl-config, and remove the file\n");
113 printf("*** config.cache before re-running configure\n");
114 return 1;
115 }
116 }
117
118 ],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
119 CFLAGS="$ac_save_CFLAGS"
120 LIBS="$ac_save_LIBS"
121 fi
122 fi
123 if test "x$no_sdl" = x ; then
124 AC_MSG_RESULT(yes)
125 ifelse([$2], , :, [$2])
126 else
127 AC_MSG_RESULT(no)
128 if test "$SDL_CONFIG" = "no" ; then
129 echo "*** The sdl-config script installed by SDL could not be found"
130 echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
131 echo "*** your path, or set the SDL_CONFIG environment variable to the"
132 echo "*** full path to sdl-config."
133 else
134 if test -f conf.sdltest ; then
135 :
136 else
137 echo "*** Could not run SDL test program, checking why..."
138 CFLAGS="$CFLAGS $SDL_CFLAGS"
139 LIBS="$LIBS $SDL_LIBS"
140 AC_TRY_LINK([
141 #include <stdio.h>
142 #include "SDL.h"
143
144 int main(int argc, char *argv[])
145 { return 0; }
146 #undef main
147 #define main K_and_R_C_main
148 ], [ return 0; ],
149 [ echo "*** The test program compiled, but did not run. This usually means"
150 echo "*** that the run-time linker is not finding SDL or finding the wrong"
151 echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
152 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
153 echo "*** to the installed location Also, make sure you have run ldconfig if that"
154 echo "*** is required on your system"
155 echo "***"
156 echo "*** If you have an old version installed, it is best to remove it, although"
157 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
158 [ echo "*** The test program failed to compile or link. See the file config.log for the"
159 echo "*** exact error that occured. This usually means SDL was incorrectly installed"
160 echo "*** or that you have moved SDL since it was installed. In the latter case, you"
161 echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ])
162 CFLAGS="$ac_save_CFLAGS"
163 LIBS="$ac_save_LIBS"
164 fi
165 fi
166 SDL_CFLAGS=""
167 SDL_LIBS=""
168 ifelse([$3], , :, [$3])
169 fi
170 AC_SUBST(SDL_CFLAGS)
171 AC_SUBST(SDL_LIBS)
172 rm -f conf.sdltest
173 ])
174 # Configure paths for libmikmod
175 #
176 # Derived from glib.m4 (Owen Taylor 97-11-3)
177 # Improved by Chris Butler
178 #
179
180 dnl AM_PATH_LIBMIKMOD([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND ]]])
181 dnl Test for libmikmod, and define LIBMIKMOD_CFLAGS, LIBMIKMOD_LIBS and
182 dnl LIBMIKMOD_LDADD
183 dnl
184 AC_DEFUN(AM_PATH_LIBMIKMOD,
185 [dnl
186 dnl Get the cflags and libraries from the libmikmod-config script
187 dnl
188 AC_ARG_WITH(libmikmod-prefix,[ --with-libmikmod-prefix=PFX Prefix where libmikmod is installed (optional)],
189 libmikmod_config_prefix="$withval", libmikmod_config_prefix="")
190 AC_ARG_WITH(libmikmod-exec-prefix,[ --with-libmikmod-exec-prefix=PFX Exec prefix where libmikmod is installed (optional)],
191 libmikmod_config_exec_prefix="$withval", libmikmod_config_exec_prefix="")
192 AC_ARG_ENABLE(libmikmodtest, [ --disable-libmikmodtest Do not try to compile and run a test libmikmod program],
193 , enable_libmikmodtest=yes)
194
195 if test x$libmikmod_config_exec_prefix != x ; then
196 libmikmod_config_args="$libmikmod_config_args --exec-prefix=$libmikmod_config_exec_prefix"
197 if test x${LIBMIKMOD_CONFIG+set} != xset ; then
198 LIBMIKMOD_CONFIG=$libmikmod_config_exec_prefix/bin/libmikmod-config
199 fi
200 fi
201 if test x$libmikmod_config_prefix != x ; then
202 libmikmod_config_args="$libmikmod_config_args --prefix=$libmikmod_config_prefix"
203 if test x${LIBMIKMOD_CONFIG+set} != xset ; then
204 LIBMIKMOD_CONFIG=$libmikmod_config_prefix/bin/libmikmod-config
205 fi
206 fi
207
208 AC_PATH_PROG(LIBMIKMOD_CONFIG, libmikmod-config, no)
209 min_libmikmod_version=ifelse([$1], ,3.1.5,$1)
210 AC_MSG_CHECKING(for libmikmod - version >= $min_libmikmod_version)
211 no_libmikmod=""
212 if test "$LIBMIKMOD_CONFIG" = "no" ; then
213 no_libmikmod=yes
214 else
215 LIBMIKMOD_CFLAGS=`$LIBMIKMOD_CONFIG $libmikmod_config_args --cflags`
216 LIBMIKMOD_LIBS=`$LIBMIKMOD_CONFIG $libmikmod_config_args --libs`
217 LIBMIKMOD_LDADD=`$LIBMIKMOD_CONFIG $libmikmod_config_args --ldadd`
218 libmikmod_config_major_version=`$LIBMIKMOD_CONFIG $libmikmod_config_args --version | \
219 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\).*/\1/'`
220 libmikmod_config_minor_version=`$LIBMIKMOD_CONFIG $libmikmod_config_args --version | \
221 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\).*/\2/'`
222 libmikmod_config_micro_version=`$LIBMIKMOD_CONFIG $libmikmod_config_args --version | \
223 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\).*/\3/'`
224 if test "x$enable_libmikmodtest" = "xyes" ; then
225 ac_save_CFLAGS="$CFLAGS"
226 ac_save_LIBS="$LIBS"
227 AC_LANG_SAVE
228 AC_LANG_C
229 CFLAGS="$CFLAGS $LIBMIKMOD_CFLAGS $LIBMIKMOD_LDADD"
230 LIBS="$LIBMIKMOD_LIBS $LIBS"
231 dnl
232 dnl Now check if the installed libmikmod is sufficiently new. (Also sanity
233 dnl checks the results of libmikmod-config to some extent
234 dnl
235 rm -f conf.mikmodtest
236 AC_TRY_RUN([
237 #include <mikmod.h>
238 #include <stdio.h>
239 #include <stdlib.h>
240
241 char* my_strdup (char *str)
242 {
243 char *new_str;
244
245 if (str) {
246 new_str = malloc ((strlen (str) + 1) * sizeof(char));
247 strcpy (new_str, str);
248 } else
249 new_str = NULL;
250
251 return new_str;
252 }
253
254 int main()
255 {
256 int major,minor,micro;
257 int libmikmod_major_version,libmikmod_minor_version,libmikmod_micro_version;
258 char *tmp_version;
259
260 system("touch conf.mikmodtest");
261
262 /* HP/UX 9 (%@#!) writes to sscanf strings */
263 tmp_version = my_strdup("$min_libmikmod_version");
264 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
265 printf("%s, bad version string\n", "$min_libmikmod_version");
266 exit(1);
267 }
268
269 libmikmod_major_version=(MikMod_GetVersion() >> 16) & 255;
270 libmikmod_minor_version=(MikMod_GetVersion() >> 8) & 255;
271 libmikmod_micro_version=(MikMod_GetVersion() ) & 255;
272
273 if ((libmikmod_major_version != $libmikmod_config_major_version) ||
274 (libmikmod_minor_version != $libmikmod_config_minor_version) ||
275 (libmikmod_micro_version != $libmikmod_config_micro_version))
276 {
277 printf("\n*** 'libmikmod-config --version' returned %d.%d.%d, but libmikmod (%d.%d.%d)\n",
278 $libmikmod_config_major_version, $libmikmod_config_minor_version, $libmikmod_config_micro_version,
279 libmikmod_major_version, libmikmod_minor_version, libmikmod_micro_version);
280 printf ("*** was found! If libmikmod-config was correct, then it is best\n");
281 printf ("*** to remove the old version of libmikmod. You may also be able to fix the error\n");
282 printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
283 printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
284 printf("*** required on your system.\n");
285 printf("*** If libmikmod-config was wrong, set the environment variable LIBMIKMOD_CONFIG\n");
286 printf("*** to point to the correct copy of libmikmod-config, and remove the file config.cache\n");
287 printf("*** before re-running configure\n");
288 }
289 else if ((libmikmod_major_version != LIBMIKMOD_VERSION_MAJOR) ||
290 (libmikmod_minor_version != LIBMIKMOD_VERSION_MINOR) ||
291 (libmikmod_micro_version != LIBMIKMOD_REVISION))
292 {
293 printf("*** libmikmod header files (version %d.%d.%d) do not match\n",
294 LIBMIKMOD_VERSION_MAJOR, LIBMIKMOD_VERSION_MINOR, LIBMIKMOD_REVISION);
295 printf("*** library (version %d.%d.%d)\n",
296 libmikmod_major_version, libmikmod_minor_version, libmikmod_micro_version);
297 }
298 else
299 {
300 if ((libmikmod_major_version > major) ||
301 ((libmikmod_major_version == major) && (libmikmod_minor_version > minor)) ||
302 ((libmikmod_major_version == major) && (libmikmod_minor_version == minor) && (libmikmod_micro_version >= micro)))
303 {
304 return 0;
305 }
306 else
307 {
308 printf("\n*** An old version of libmikmod (%d.%d.%d) was found.\n",
309 libmikmod_major_version, libmikmod_minor_version, libmikmod_micro_version);
310 printf("*** You need a version of libmikmod newer than %d.%d.%d.\n",
311 major, minor, micro);
312 printf("***\n");
313 printf("*** If you have already installed a sufficiently new version, this error\n");
314 printf("*** probably means that the wrong copy of the libmikmod-config shell script is\n");
315 printf("*** being found. The easiest way to fix this is to remove the old version\n");
316 printf("*** of libmikmod, but you can also set the LIBMIKMOD_CONFIG environment to point to the\n");
317 printf("*** correct copy of libmikmod-config. (In this case, you will have to\n");
318 printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
319 printf("*** so that the correct libraries are found at run-time))\n");
320 }
321 }
322 return 1;
323 }
324 ],, no_libmikmod=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
325 CFLAGS="$ac_save_CFLAGS"
326 LIBS="$ac_save_LIBS"
327 AC_LANG_RESTORE
328 fi
329 fi
330 if test "x$no_libmikmod" = x ; then
331 AC_MSG_RESULT([yes, `$LIBMIKMOD_CONFIG --version`])
332 ifelse([$2], , :, [$2])
333 else
334 AC_MSG_RESULT(no)
335 if test "$LIBMIKMOD_CONFIG" = "no" ; then
336 echo "*** The libmikmod-config script installed by libmikmod could not be found"
337 echo "*** If libmikmod was installed in PREFIX, make sure PREFIX/bin is in"
338 echo "*** your path, or set the LIBMIKMOD_CONFIG environment variable to the"
339 echo "*** full path to libmikmod-config."
340 else
341 if test -f conf.mikmodtest ; then
342 :
343 else
344 echo "*** Could not run libmikmod test program, checking why..."
345 CFLAGS="$CFLAGS $LIBMIKMOD_CFLAGS"
346 LIBS="$LIBS $LIBMIKMOD_LIBS"
347 AC_LANG_SAVE
348 AC_LANG_C
349 AC_TRY_LINK([
350 #include <mikmod.h>
351 #include <stdio.h>
352 ], [ return (MikMod_GetVersion()!=0); ],
353 [ echo "*** The test program compiled, but did not run. This usually means"
354 echo "*** that the run-time linker is not finding libmikmod or finding the wrong"
355 echo "*** version of libmikmod. If it is not finding libmikmod, you'll need to set your"
356 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
357 echo "*** to the installed location. Also, make sure you have run ldconfig if that"
358 echo "*** is required on your system."
359 echo "***"
360 echo "*** If you have an old version installed, it is best to remove it, although"
361 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
362 [ echo "*** The test program failed to compile or link. See the file config.log for the"
363 echo "*** exact error that occured. This usually means libmikmod was incorrectly installed"
364 echo "*** or that you have moved libmikmod since it was installed. In the latter case, you"
365 echo "*** may want to edit the libmikmod-config script: $LIBMIKMOD_CONFIG" ])
366 CFLAGS="$ac_save_CFLAGS"
367 LIBS="$ac_save_LIBS"
368 AC_LANG_RESTORE
369 fi
370 fi
371 LIBMIKMOD_CFLAGS=""
372 LIBMIKMOD_LIBS=""
373 LIBMIKMOD_LDADD=""
374 ifelse([$3], , :, [$3])
375 fi
376 AC_SUBST(LIBMIKMOD_CFLAGS)
377 AC_SUBST(LIBMIKMOD_LIBS)
378 AC_SUBST(LIBMIKMOD_LDADD)
379 rm -f conf.mikmodtest
380 ])
381 # Configure paths for libvorbis
382 # Jack Moffitt <jack@icecast.org> 10-21-2000
383 # Shamelessly stolen from Owen Taylor and Manish Singh
384
385 dnl AM_PATH_VORBIS([ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]])
386 dnl Test for libvorbis, and define VORBIS_CFLAGS and VORBIS_LIBS
387 dnl
388 AC_DEFUN(AM_PATH_VORBIS,
389 [dnl
390 dnl Get the cflags and libraries
391 dnl
392 AC_ARG_WITH(vorbis-prefix,[ --with-vorbis-prefix=PFX Prefix where libvorbis is installed (optional)], vorbis_prefix="$withval", vorbis_prefix="")
393 AC_ARG_ENABLE(vorbistest, [ --disable-vorbistest Do not try to compile and run a test Vorbis program],, enable_vorbistest=yes)
394
395 if test x$vorbis_prefix != x ; then
396 vorbis_args="$vorbis_args --prefix=$vorbis_prefix"
397 VORBIS_CFLAGS="-I$vorbis_prefix/include"
398 VORBIS_LIBDIR="-L$vorbis_prefix/lib"
399 fi
400
401 VORBIS_LIBS="$VORBIS_LIBDIR -lvorbis -lm"
402 VORBISFILE_LIBS="-lvorbisfile"
403 VORBISENC_LIBS="-lvorbisenc"
404
405 AC_MSG_CHECKING(for Vorbis)
406 no_vorbis=""
407
408
409 if test "x$enable_vorbistest" = "xyes" ; then
410 ac_save_CFLAGS="$CFLAGS"
411 ac_save_LIBS="$LIBS"
412 CFLAGS="$CFLAGS $VORBIS_CFLAGS"
413 LIBS="$LIBS $VORBIS_LIBS $OGG_LIBS"
414 dnl
415 dnl Now check if the installed Vorbis is sufficiently new.
416 dnl
417 rm -f conf.vorbistest
418 AC_TRY_RUN([
419 #include <stdio.h>
420 #include <stdlib.h>
421 #include <string.h>
422 #include <vorbis/codec.h>
423
424 int main ()
425 {
426 system("touch conf.vorbistest");
427 return 0;
428 }
429
430 ],, no_vorbis=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
431 CFLAGS="$ac_save_CFLAGS"
432 LIBS="$ac_save_LIBS"
433 fi
434
435 if test "x$no_vorbis" = x ; then
436 AC_MSG_RESULT(yes)
437 ifelse([$1], , :, [$1])
438 else
439 AC_MSG_RESULT(no)
440 if test -f conf.vorbistest ; then
441 :
442 else
443 echo "*** Could not run Vorbis test program, checking why..."
444 CFLAGS="$CFLAGS $VORBIS_CFLAGS"
445 LIBS="$LIBS $VORBIS_LIBS $OGG_LIBS"
446 AC_TRY_LINK([
447 #include <stdio.h>
448 #include <vorbis/codec.h>
449 ], [ return 0; ],
450 [ echo "*** The test program compiled, but did not run. This usually means"
451 echo "*** that the run-time linker is not finding Vorbis or finding the wrong"
452 echo "*** version of Vorbis. If it is not finding Vorbis, you'll need to set your"
453 echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
454 echo "*** to the installed location Also, make sure you have run ldconfig if that"
455 echo "*** is required on your system"
456 echo "***"
457 echo "*** If you have an old version installed, it is best to remove it, although"
458 echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
459 [ echo "*** The test program failed to compile or link. See the file config.log for the"
460 echo "*** exact error that occured. This usually means Vorbis was incorrectly installed"
461 echo "*** or that you have moved Vorbis since it was installed." ])
462 CFLAGS="$ac_save_CFLAGS"
463 LIBS="$ac_save_LIBS"
464 fi
465 VORBIS_CFLAGS=""
466 VORBIS_LIBS=""
467 VORBISFILE_LIBS=""
468 VORBISENC_LIBS=""
469 ifelse([$2], , :, [$2])
470 fi
471 AC_SUBST(VORBIS_CFLAGS)
472 AC_SUBST(VORBIS_LIBS)
473 AC_SUBST(VORBISFILE_LIBS)
474 AC_SUBST(VORBISENC_LIBS)
475 rm -f conf.vorbistest
476 ])
477 # Configure paths for SMPEG
478 # Nicolas Vignal 11/19/2000
479 # stolen from Sam Lantinga
480 # stolen from Manish Singh
481 # stolen back from Frank Belew
482 # stolen from Manish Singh
483 # Shamelessly stolen from Owen Taylor
484
485 dnl AM_PATH_SMPEG([MINIMUM-VERSION, [ACTION-IF-FOUND [,
486 ACTION-IF-NOT-FOUND]]])
487 dnl Test for SMPEG, and define SMPEG_CFLAGS and SMPEG_LIBS
488 dnl
489 AC_DEFUN(AM_PATH_SMPEG,
490 [dnl
491 dnl Get the cflags and libraries from the smpeg-config script
492 dnl
493 AC_ARG_WITH(smpeg-prefix,[ --with-smpeg-prefix=PFX Prefix where SMPEG is
494 installed (optional)],
495 smpeg_prefix="$withval", smpeg_prefix="")
496 AC_ARG_WITH(smpeg-exec-prefix,[ --with-smpeg-exec-prefix=PFX Exec prefix
497 where SMPEG is installed (optional)],
498 smpeg_exec_prefix="$withval", smpeg_exec_prefix="")
499 AC_ARG_ENABLE(smpegtest, [ --disable-smpegtest Do not try to compile
500 and run a test SMPEG program],
501 , enable_smpegtest=yes)
502
503 if test x$smpeg_exec_prefix != x ; then
504 smpeg_args="$smpeg_args --exec-prefix=$smpeg_exec_prefix"
505 if test x${SMPEG_CONFIG+set} != xset ; then
506 SMPEG_CONFIG=$smpeg_exec_prefix/bin/smpeg-config
507 fi
508 fi
509 if test x$smpeg_prefix != x ; then
510 smpeg_args="$smpeg_args --prefix=$smpeg_prefix"
511 if test x${SMPEG_CONFIG+set} != xset ; then
512 SMPEG_CONFIG=$smpeg_prefix/bin/smpeg-config
513 fi
514 fi
515
516 AC_PATH_PROG(SMPEG_CONFIG, smpeg-config, no)
517 min_smpeg_version=ifelse([$1], ,0.2.7,$1)
518 AC_MSG_CHECKING(for SMPEG - version >= $min_smpeg_version)
519 no_smpeg=""
520 if test "$SMPEG_CONFIG" = "no" ; then
521 no_smpeg=yes
522 else
523 SMPEG_CFLAGS=`$SMPEG_CONFIG $smpegconf_args --cflags`
524 SMPEG_LIBS=`$SMPEG_CONFIG $smpegconf_args --libs`
525
526 smpeg_major_version=`$SMPEG_CONFIG $smpeg_args --version | \
527 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
528 smpeg_minor_version=`$SMPEG_CONFIG $smpeg_args --version | \
529 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
530 smpeg_micro_version=`$SMPEG_CONFIG $smpeg_config_args --version | \
531 sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
532 if test "x$enable_smpegtest" = "xyes" ; then
533 ac_save_CFLAGS="$CFLAGS"
534 ac_save_LIBS="$LIBS"
535 CFLAGS="$CFLAGS $SMPEG_CFLAGS $SDL_CFLAGS"
536 LIBS="$LIBS $SMPEG_LIBS $SDL_LIBS"
537 dnl
538 dnl Now check if the installed SMPEG is sufficiently new. (Also sanity
539 dnl checks the results of smpeg-config to some extent
540 dnl
541 rm -f conf.smpegtest
542 AC_TRY_RUN([
543 #include <stdio.h>
544 #include <stdlib.h>
545 #include <string.h>
546 #include "smpeg.h"
547
548 char*
549 my_strdup (char *str)
550 {
551 char *new_str;
552
553 if (str)
554 {
555 new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
556 strcpy (new_str, str);
557 }
558 else
559 new_str = NULL;
560
561 return new_str;
562 }
563
564 int main (int argc, char *argv[])
565 {
566 int major, minor, micro;
567 char *tmp_version;
568
569 /* This hangs on some systems (?)
570 system ("touch conf.smpegtest");
571 */
572 { FILE *fp = fopen("conf.smpegtest", "a"); if ( fp ) fclose(fp); }
573
574 /* HP/UX 9 (%@#!) writes to sscanf strings */
575 tmp_version = my_strdup("$min_smpeg_version");
576 if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
577 printf("%s, bad version string\n", "$min_smpeg_version");
578 exit(1);
579 }
580
581 if (($smpeg_major_version > major) ||
582 (($smpeg_major_version == major) && ($smpeg_minor_version > minor)) ||
583 (($smpeg_major_version == major) && ($smpeg_minor_version == minor)
584 && ($smpeg_micro_version >= micro)))
585 {
586 return 0;
587 }
588 else
589 {
590 printf("\n*** 'smpeg-config --version' returned %d.%d.%d, but the
591 minimum version\n", $smpeg_major_version, $smpeg_minor_version,
592 $smpeg_micro_version);
593 printf("*** of SMPEG required is %d.%d.%d. If smpeg-config is
594 correct, then it is\n", major, minor, micro);
595 printf("*** best to upgrade to the required version.\n");
596 printf("*** If smpeg-config was wrong, set the environment variable
597 SMPEG_CONFIG\n");
598 printf("*** to point to the correct copy of smpeg-config, and remove
599 the file\n");
600 printf("*** config.cache before re-running configure\n");
601 return 1;
602 }
603 }
604
605 ],, no_smpeg=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
606 CFLAGS="$ac_save_CFLAGS"
607 LIBS="$ac_save_LIBS"
608 fi
609 fi
610 if test "x$no_smpeg" = x ; then
611 AC_MSG_RESULT(yes)
612 ifelse([$2], , :, [$2])
613 else
614 AC_MSG_RESULT(no)
615 if test "$SMPEG_CONFIG" = "no" ; then
616 echo "*** The smpeg-config script installed by SMPEG could not be
617 found"
618 echo "*** If SMPEG was installed in PREFIX, make sure PREFIX/bin is
619 in"
620 echo "*** your path, or set the SMPEG_CONFIG environment variable to
621 the"
622 echo "*** full path to smpeg-config."
623 else
624 if test -f conf.smpegtest ; then
625 :
626 else
627 echo "*** Could not run SMPEG test program, checking why..."
628 CFLAGS="$CFLAGS $SMPEG_CFLAGS $SDL_CFLAGS"
629 LIBS="$LIBS $SMPEG_LIBS $SDL_LIBS"
630 AC_TRY_LINK([
631 #include <stdio.h>
632 #include "smpeg.h"
633 ], [ return 0; ],
634 [ echo "*** The test program compiled, but did not run. This
635 usually means"
636 echo "*** that the run-time linker is not finding SMPEG or
637 finding the wrong"
638 echo "*** version of SMPEG. If it is not finding SMPEG, you'll
639 need to set your"
640 echo "*** LD_LIBRARY_PATH environment variable, or edit
641 /etc/ld.so.conf to point"
642 echo "*** to the installed location Also, make sure you have run
643 ldconfig if that"
644 echo "*** is required on your system"
645 echo "***"
646 echo "*** If you have an old version installed, it is best to
647 remove it, although"
648 echo "*** you may also be able to get things to work by modifying
649 LD_LIBRARY_PATH"],
650 [ echo "*** The test program failed to compile or link. See the
651 file config.log for the"
652 echo "*** exact error that occured. This usually means SMPEG was
653 incorrectly installed"
654 echo "*** or that you have moved SMPEG since it was installed. In
655 the latter case, you"
656 echo "*** may want to edit the smpeg-config script:
657 $SMPEG_CONFIG" ])
658 CFLAGS="$ac_save_CFLAGS"
659 LIBS="$ac_save_LIBS"
660 fi
661 fi
662 SMPEG_CFLAGS=""
663 SMPEG_LIBS=""
664 ifelse([$3], , :, [$3])
665 fi
666 AC_SUBST(SMPEG_CFLAGS)
667 AC_SUBST(SMPEG_LIBS)
668 rm -f conf.smpegtest
669 ])