1AC_DEFUN(CY_AC_PATH_TCLCONFIG, [
2#
3# Ok, lets find the tcl configuration
4# First, look for one uninstalled.
5# the alternative search directory is invoked by --with-tclconfig
6#
7
8if test x"${no_tcl}" = x ; then
9  # we reset no_tcl in case something fails here
10  no_tcl=true
11  AC_ARG_WITH(tclconfig, [  --with-tclconfig=DIR    Directory containing tcl configuration (tclConfig.sh)],
12         with_tclconfig=${withval})
13  AC_MSG_CHECKING([for Tcl configuration])
14  AC_CACHE_VAL(ac_cv_c_tclconfig,[
15
16  # First check to see if --with-tclconfig was specified.
17  if test x"${with_tclconfig}" != x ; then
18    if test -f "${with_tclconfig}/tclConfig.sh" ; then
19      ac_cv_c_tclconfig=`(cd ${with_tclconfig}; pwd)`
20    else
21      AC_MSG_ERROR([${with_tclconfig} directory doesn't contain tclConfig.sh])
22    fi
23  fi
24
25  # then check for a private Tcl installation
26  if test x"${ac_cv_c_tclconfig}" = x ; then
27    for i in \
28		./tcl \
29		../tcl \
30		`ls -dr ../tcl[[7-9]]* 2>/dev/null` \
31		../../tcl \
32		`ls -dr ../../tcl[[7-9]]* 2>/dev/null` \
33		../../../tcl \
34		`ls -dr ../../../tcl[[7-9]]* 2>/dev/null` ; do
35      if test -f "$i/${configdir}/tclConfig.sh" ; then
36        ac_cv_c_tclconfig=`(cd $i/${configdir}; pwd)`
37	break
38      fi
39    done
40  fi
41  # check in a few common install locations
42  if test x"${ac_cv_c_tclconfig}" = x ; then
43    tcl_probe_dirs="${prefix}/lib /usr/lib /usr/local/lib /mingw/lib"
44    for i in `ls -d ${tcl_probe_dirs} 2>/dev/null` ; do
45      if test -f "$i/tclConfig.sh" ; then
46        ac_cv_c_tclconfig=`(cd $i; pwd)`
47	break
48      fi
49    done
50  fi
51  # check in some other known public install locations
52  # NOTE: This could possibly pick up wrong version if more than one
53  #  Tcl/Tk version is installed in this form.
54  if test x"${ac_cv_c_tclconfig}" = x ; then
55    for i in \
56        `ls -d ${prefix}/lib/tcl[[7-9]]* /usr/lib/tcl[[7-9]]* 2>/dev/null` ; do
57      if test -f "$i/tclConfig.sh" ; then
58        ac_cv_c_tclconfig=`(cd $i; pwd)`
59        break
60      fi
61    done
62  fi
63  # check in a few other private locations
64  if test x"${ac_cv_c_tclconfig}" = x ; then
65    for i in \
66        ${srcdir}/../tcl \
67	`ls -dr ${srcdir}/../tcl[[7-9]]* 2>/dev/null` ; do
68      if test -f "$i/${configdir}/tclConfig.sh" ; then
69        ac_cv_c_tclconfig=`(cd $i/${configdir}; pwd)`
70	break
71      fi
72    done
73  fi
74  ])
75  if test x"${ac_cv_c_tclconfig}" = x ; then
76    TCLCONFIG="# no Tcl configs found"
77    AC_MSG_WARN(Can't find Tcl configuration definitions)
78  else
79    no_tcl=
80    TCLCONFIG=${ac_cv_c_tclconfig}/tclConfig.sh
81    AC_MSG_RESULT(found $TCLCONFIG)
82  fi
83fi
84])
85
86AC_DEFUN(CY_AC_LOAD_TCLCONFIG, [
87    . $TCLCONFIG
88
89    AC_SUBST(TCL_VERSION)
90    AC_SUBST(TCL_MAJOR_VERSION)
91    AC_SUBST(TCL_MINOR_VERSION)
92    AC_SUBST(TCL_CC)
93    AC_SUBST(TCL_DEFS)
94    AC_SUBST(TCL_UNSHARED_LIB_SUFFIX)
95    AC_SUBST(TCL_EXTRA_CFLAGS)
96
97
98dnl ## On some versions of Cygwin, the 'TCL_INCLUDE_SPEC' is incorrectly
99dnl ##  indicated to be '/nonexistent/include'. We must be on the look out
100dnl ##  for this, and doubt it if we see it.
101    if test "x${TCL_INCLUDE_SPEC}" = "x-I/nonexistent/include" \
102	    -a ! -d /nonexistent/include ;
103    then
104	TCL_INCLUDE_SPEC=""
105    fi
106dnl ## If TCL_INCLUDE_SPEC is not defined, then we might be on a Debian
107dnl ##  system, and should try to synthesize it.
108    if test "x${TCL_INCLUDE_SPEC}" = "x" ;
109    then
110      if test "x${TCL_INC_DIR}" != "x" ;
111      then
112        if test -d ${TCL_INC_DIR} ;
113        then
114          TCL_INCLUDE_SPEC="-I${TCL_INC_DIR}"
115	fi
116      fi
117    fi
118dnl ## If neither TCL_INCLUDE_SPEC nor TCL_INC_DIR are defined, we still
119dnl ##  might be on a Debian system. Try another synthesis.
120    if test "x${TCL_INCLUDE_SPEC}" = "x" ;
121    then
122      if test "x${TCL_VERSION}" != "x" -a "x${TCL_PREFIX}" != "x" ;
123      then
124	if test -d ${TCL_PREFIX}/include/tcl${TCL_VERSION} ;
125	then
126          TCL_INCLUDE_SPEC="-I${TCL_PREFIX}/include/tcl${TCL_VERSION}"
127	fi
128      fi
129    fi
130dnl ## Filter out common include paths to prevent <> vs. "" conflicts.
131    TCL_INCLUDE_SPEC=`echo ${TCL_INCLUDE_SPEC} | grep -v '/usr/include$'`
132    AC_SUBST(TCL_INCLUDE_SPEC)
133
134    if test "x${TCL_LDFLAGS}" = "x" ; then
135      TCL_LDFLAGS=${TCL_LIB_SPEC}
136    fi
137dnl ## Fairly crude hack to find the lib under certain conditions.
138    if test "x${TCL_LDFLAGS}" = "x" ; then
139      tcl_libs=`ls ./tcl[[7-9]]*.lib ./libtcl[[7-9]]*.a 2>/dev/null`
140      if test "x${tcl_libs}" != "x" ; then
141        TCL_LDFLAGS="../${tcl_libs}"
142      fi
143    fi
144    if test "x${TCL_LDFLAGS}" = "x" ; then
145      tcl_libs=`ls tcltk/tcl[[7-9]]*.lib tcltk/libtcl[[7-9]]*.a 2>/dev/null`
146      if test "x${tcl_libs}" != "x" ; then
147	TCL_LDFLAGS="../${tcl_libs}"
148      fi
149    fi
150    if test "x${TCL_LDFLAGS}" = "x" ; then
151      tcl_libs=`ls tcl/tcl[[7-9]]*.lib tcl/libtcl[[7-9]]*.a 2>/dev/null`
152      if test "x${tcl_libs}" != "x" ; then
153	TCL_LDFLAGS="../${tcl_libs}"
154      fi
155    fi
156dnl ## Another attempt to salvage a usable lib.
157    if test "x${TCL_LDFLAGS}" = "x" ; then
158      if test "x${TCL_LIB_FILE}" != "x" ; then
159        TCL_LDFLAGS="`dirname ${TCLCONFIG}`/${TCL_LIB_FILE}"
160      fi
161    fi
162    dnl Tack on extra goodies that may be needed.
163dnl Let the TK_LIBS do the talking. At worst, TCL_LIBS is a redundant
164dnl  subset of TK_LIBS; at best, it is nothing.
165dnl    if test "x${TCL_LIBS}" != "x" ; then
166dnl      TCL_LDFLAGS="${TCL_LDFLAGS} ${TCL_LIBS}"
167dnl    fi
168
169dnl not used, don't export to save symbols
170dnl    AC_SUBST(TCL_LIB_FILE)
171
172dnl don't export, not used outside of configure
173dnl     AC_SUBST(TCL_LIBS)
174dnl not used, don't export to save symbols
175dnl    AC_SUBST(TCL_PREFIX)
176
177dnl not used, don't export to save symbols
178dnl    AC_SUBST(TCL_EXEC_PREFIX)
179
180    AC_SUBST(TCL_SHLIB_CFLAGS)
181    AC_SUBST(TCL_SHLIB_LD)
182dnl don't export, not used outside of configure
183    AC_SUBST(TCL_SHLIB_LD_LIBS)
184    AC_SUBST(TCL_SHLIB_SUFFIX)
185dnl not used, don't export to save symbols
186    AC_SUBST(TCL_DL_LIBS)
187    AC_SUBST(TCL_LD_FLAGS)
188dnl don't export, not used outside of configure
189    AC_SUBST(TCL_LD_SEARCH_FLAGS)
190    AC_SUBST(TCL_COMPAT_OBJS)
191    AC_SUBST(TCL_RANLIB)
192    AC_SUBST(TCL_BUILD_LIB_SPEC)
193    AC_SUBST(TCL_LIB_SPEC)
194    AC_SUBST(TCL_LIB_VERSIONS_OK)
195
196dnl not used, don't export to save symbols
197dnl    AC_SUBST(TCL_SHARED_LIB_SUFFIX)
198
199dnl not used, don't export to save symbols
200dnl    AC_SUBST(TCL_UNSHARED_LIB_SUFFIX)
201
202	AC_SUBST(TCL_LDFLAGS)
203])
204
205AC_DEFUN(CY_AC_PATH_TKCONFIG, [
206#
207# Ok, lets find the tk configuration
208# First, look for one uninstalled.
209# the alternative search directory is invoked by --with-tkconfig
210#
211
212if test x"${no_tk}" = x ; then
213  # we reset no_tk in case something fails here
214  no_tk=true
215  AC_ARG_WITH(tkconfig, [  --with-tkconfig=DIR     Directory containing tk configuration (tkConfig.sh)],
216         with_tkconfig=${withval})
217  AC_MSG_CHECKING([for Tk configuration])
218  AC_CACHE_VAL(ac_cv_c_tkconfig,[
219
220  # First check to see if --with-tkconfig was specified.
221  if test x"${with_tkconfig}" != x ; then
222    if test -f "${with_tkconfig}/tkConfig.sh" ; then
223      ac_cv_c_tkconfig=`(cd ${with_tkconfig}; pwd)`
224    else
225      AC_MSG_ERROR([${with_tkconfig} directory doesn't contain tkConfig.sh])
226    fi
227  fi
228
229  # then check for a private Tk library
230  if test x"${ac_cv_c_tkconfig}" = x ; then
231    for i in \
232		./tk \
233		../tk \
234		`ls -dr ../tk[[4-9]]* 2>/dev/null` \
235		../../tk \
236		`ls -dr ../../tk[[4-9]]* 2>/dev/null` \
237		../../../tk \
238		`ls -dr ../../../tk[[4-9]]* 2>/dev/null` ; do
239      if test -f "$i/${configdir}/tkConfig.sh" ; then
240        ac_cv_c_tkconfig=`(cd $i/${configdir}; pwd)`
241	break
242      fi
243    done
244  fi
245  # check in a few common install locations
246  if test x"${ac_cv_c_tkconfig}" = x ; then
247    tk_probe_dirs="${prefix}/lib /usr/lib /usr/local/lib /mingw/lib"
248    for i in `ls -d ${tk_probe_dirs} 2>/dev/null` ; do
249      if test -f "$i/tkConfig.sh" ; then
250        ac_cv_c_tkconfig=`(cd $i; pwd)`
251	break
252      fi
253    done
254  fi
255  # check in some other known public install locations
256  # NOTE: This could possibly pick up wrong version if more than one
257  #  Tcl/Tk version is installed in this form.
258  if test x"${ac_cv_c_tkconfig}" = x ; then
259    for i in \
260        `ls -d ${prefix}/lib/tk[[7-9]]* /usr/lib/tk[[7-9]]* 2>/dev/null` ; do
261      if test -f "$i/tkConfig.sh" ; then
262        ac_cv_c_tkconfig=`(cd $i; pwd)`
263        break
264      fi
265    done
266  fi
267  # check in a few other private locations
268  if test x"${ac_cv_c_tkconfig}" = x ; then
269    for i in \
270		${srcdir}/../tk \
271		`ls -dr ${srcdir}/../tk[[4-9]]* 2>/dev/null` ; do
272      if test -f "$i/${configdir}/tkConfig.sh" ; then
273        ac_cv_c_tkconfig=`(cd $i/${configdir}; pwd)`
274	break
275      fi
276    done
277  fi
278  ])
279  if test x"${ac_cv_c_tkconfig}" = x ; then
280    TKCONFIG="# no Tk configs found"
281    AC_MSG_WARN(Can't find Tk configuration definitions)
282  else
283    no_tk=
284    TKCONFIG=${ac_cv_c_tkconfig}/tkConfig.sh
285    AC_MSG_RESULT(found $TKCONFIG)
286  fi
287fi
288
289])
290
291AC_DEFUN(CY_AC_LOAD_TKCONFIG, [
292    if test -f "$TKCONFIG" ; then
293      . $TKCONFIG
294    fi
295
296dnl ## If TK_INCLUDE_SPEC is not defined, then we might be on a Debian
297dnl ##  system and have need of it, and should try to synthesize it.
298dnl ## On most other systems the TCL_INCLUDE_SPEC is enough to pick up
299dnl ##  Tk headers.
300    if test "x${TK_INCLUDE_SPEC}" = "x" ;
301    then
302      if test "x${TK_INC_DIR}" != "x" ;
303      then
304	if test -d ${TK_INC_DIR} ;
305	then
306          TK_INCLUDE_SPEC="-I${TK_INC_DIR}"
307	fi
308      fi
309    fi
310dnl ## If neither TK_INCLUDE_SPEC nor TK_INC_DIR are defined, we still
311dnl ##  might be on a Debian system. Try another synthesis.
312    if test "x${TK_INCLUDE_SPEC}" = "x" ;
313    then
314      if test "x${TK_VERSION}" != "x" -a "x${TK_PREFIX}" != "x" ;
315      then
316	if test -d ${TK_PREFIX}/include/tk${TK_VERSION} ;
317	then
318          TK_INCLUDE_SPEC="-I${TK_PREFIX}/include/tk${TK_VERSION}"
319	fi
320      fi
321    fi
322dnl ## Filter out common include paths to prevent <> vs. "" conflicts.
323    TK_INCLUDE_SPEC=`echo ${TK_INCLUDE_SPEC} | grep -v '/usr/include$'`
324    AC_SUBST(TK_INCLUDE_SPEC)
325
326    if test "x${TK_LDFLAGS}" = "x" ; then
327      TK_LDFLAGS=${TK_LIB_SPEC}
328    fi
329dnl ## Fairly crude hack to find the lib under certain conditions.
330    if test "x${TK_LDFLAGS}" = "x" ; then
331      tk_libs=`ls ./tk[[7-9]]*.lib ./libtk[[7-9]]*.a 2>/dev/null`
332      if test "x${tk_libs}" != "x" ; then
333	TK_LDFLAGS="../${tk_libs}"
334      fi
335    fi
336    if test "x${TK_LDFLAGS}" = "x" ; then
337      tk_libs=`ls tcltk/tk[[7-9]]*.lib tcltk/libtk[[7-9]]*.a 2>/dev/null`
338      if test "x${tk_libs}" != "x" ; then
339	TK_LDFLAGS="../${tk_libs}"
340      fi
341    fi
342    if test "x${TK_LDFLAGS}" = "x" ; then
343      tk_libs=`ls tk/tk[[7-9]]*.lib tk/libtk[[7-9]]*.a 2>/dev/null`
344      if test "x${tk_libs}" != "x" ; then
345	TK_LDFLAGS="../${tk_libs}"
346      fi
347    fi
348dnl ## Another attempt to salvage a usable lib.
349    if test "x${TK_LDFLAGS}" = "x" ; then
350      if test "x${TK_LIB_FILE}" != "x" ; then
351        TK_LDFLAGS="`dirname ${TKCONFIG}`/${TK_LIB_FILE}"
352      fi
353    fi
354dnl ## Tack on extra goodies that may be needed.
355dnl ## But filter off any directly named static libs.
356    if test "x${TK_LIBS}" != "x" ; then
357      liblist=""
358      for libitem in ${TK_LIBS} ; do
359	tmplibitem=`echo "$libitem" | grep -v '\.lib$' | grep -v '\.a$'`
360	liblist="$liblist $tmplibitem"
361      done
362      TK_LDFLAGS="${TK_LDFLAGS} $liblist"
363    fi
364
365    AC_SUBST(TK_VERSION)
366dnl not actually used, don't export to save symbols
367dnl    AC_SUBST(TK_MAJOR_VERSION)
368dnl    AC_SUBST(TK_MINOR_VERSION)
369    AC_SUBST(TK_DEFS)
370
371dnl not used, don't export to save symbols
372dnl    AC_SUBST(TK_LIB_FILE)
373
374dnl not used outside of configure
375dnl    AC_SUBST(TK_LIBS)
376dnl not used, don't export to save symbols
377dnl    AC_SUBST(TK_PREFIX)
378
379dnl not used, don't export to save symbols
380dnl    AC_SUBST(TK_EXEC_PREFIX)
381
382    AC_SUBST(TK_BUILD_INCLUDES)
383    AC_SUBST(TK_XINCLUDES)
384    AC_SUBST(TK_XLIBSW)
385    AC_SUBST(TK_BUILD_LIB_SPEC)
386    AC_SUBST(TK_LIB_SPEC)
387
388	AC_SUBST(TK_LDFLAGS)
389])
390
391# Configure paths for SDL
392# Sam Lantinga 9/21/99
393# stolen from Manish Singh
394# stolen back from Frank Belew
395# stolen from Manish Singh
396# Shamelessly stolen from Owen Taylor
397
398dnl AM_PATH_SDL([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
399dnl Test for SDL, and define SDL_CFLAGS and SDL_LIBS
400dnl
401AC_DEFUN(AM_PATH_SDL,
402[dnl
403dnl Get the cflags and libraries from the sdl-config script
404dnl
405AC_ARG_WITH(sdl-prefix,[  --with-sdl-prefix=PFX   Prefix where SDL is installed (optional)],
406            sdl_prefix="$withval", sdl_prefix="")
407AC_ARG_WITH(sdl-exec-prefix,[  --with-sdl-exec-prefix=PFX Exec prefix where SDL is installed (optional)],
408            sdl_exec_prefix="$withval", sdl_exec_prefix="")
409AC_ARG_ENABLE(sdltest, [  --disable-sdltest       Do not try to compile and run a test SDL program],
410		    , enable_sdltest=yes)
411
412  if test x$sdl_exec_prefix != x ; then
413     sdl_args="$sdl_args --exec-prefix=$sdl_exec_prefix"
414     if test x${SDL_CONFIG+set} != xset ; then
415        SDL_CONFIG=$sdl_exec_prefix/bin/sdl-config
416     fi
417  fi
418  if test x$sdl_prefix != x ; then
419     sdl_args="$sdl_args --prefix=$sdl_prefix"
420     if test x${SDL_CONFIG+set} != xset ; then
421        SDL_CONFIG=$sdl_prefix/bin/sdl-config
422     fi
423  fi
424
425  AC_REQUIRE([AC_CANONICAL_TARGET])
426  PATH="$prefix/bin:$prefix/usr/bin:$PATH"
427  AC_PATH_PROG(SDL_CONFIG, sdl-config, no, [$PATH])
428  min_sdl_version=ifelse([$1], ,0.11.0,$1)
429  AC_MSG_CHECKING(for SDL - version >= $min_sdl_version)
430  no_sdl=""
431  if test "$SDL_CONFIG" = "no" ; then
432    no_sdl=yes
433  else
434    SDL_CFLAGS=`$SDL_CONFIG $sdlconf_args --cflags`
435    SDL_LIBS=`$SDL_CONFIG $sdlconf_args --libs`
436
437    sdl_major_version=`$SDL_CONFIG $sdl_args --version | \
438           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
439    sdl_minor_version=`$SDL_CONFIG $sdl_args --version | \
440           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
441    sdl_micro_version=`$SDL_CONFIG $sdl_config_args --version | \
442           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
443    if test "x$enable_sdltest" = "xyes" ; then
444      ac_save_CFLAGS="$CFLAGS"
445      ac_save_CXXFLAGS="$CXXFLAGS"
446      ac_save_LIBS="$LIBS"
447      CFLAGS="$CFLAGS $SDL_CFLAGS"
448      CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
449      LIBS="$LIBS $SDL_LIBS"
450dnl
451dnl Now check if the installed SDL is sufficiently new. (Also sanity
452dnl checks the results of sdl-config to some extent
453dnl
454      rm -f conf.sdltest
455      AC_TRY_RUN([
456#include <stdio.h>
457#include <stdlib.h>
458#include <string.h>
459#include "SDL.h"
460
461char*
462my_strdup (char *str)
463{
464  char *new_str;
465
466  if (str)
467    {
468      new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
469      strcpy (new_str, str);
470    }
471  else
472    new_str = NULL;
473
474  return new_str;
475}
476
477int main (int argc, char *argv[])
478{
479  int major, minor, micro;
480  char *tmp_version;
481
482  /* This hangs on some systems (?)
483  system ("touch conf.sdltest");
484  */
485  { FILE *fp = fopen("conf.sdltest", "a"); if ( fp ) fclose(fp); }
486
487  /* HP/UX 9 (%@#!) writes to sscanf strings */
488  tmp_version = my_strdup("$min_sdl_version");
489  if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
490     printf("%s, bad version string\n", "$min_sdl_version");
491     exit(1);
492   }
493
494   if (($sdl_major_version > major) ||
495      (($sdl_major_version == major) && ($sdl_minor_version > minor)) ||
496      (($sdl_major_version == major) && ($sdl_minor_version == minor) && ($sdl_micro_version >= micro)))
497    {
498      return 0;
499    }
500  else
501    {
502      printf("\n*** 'sdl-config --version' returned %d.%d.%d, but the minimum version\n", $sdl_major_version, $sdl_minor_version, $sdl_micro_version);
503      printf("*** of SDL required is %d.%d.%d. If sdl-config is correct, then it is\n", major, minor, micro);
504      printf("*** best to upgrade to the required version.\n");
505      printf("*** If sdl-config was wrong, set the environment variable SDL_CONFIG\n");
506      printf("*** to point to the correct copy of sdl-config, and remove the file\n");
507      printf("*** config.cache before re-running configure\n");
508      return 1;
509    }
510}
511
512],, no_sdl=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
513       CFLAGS="$ac_save_CFLAGS"
514       CXXFLAGS="$ac_save_CXXFLAGS"
515       LIBS="$ac_save_LIBS"
516     fi
517  fi
518  if test "x$no_sdl" = x ; then
519     AC_MSG_RESULT(yes)
520     ifelse([$2], , :, [$2])
521  else
522     AC_MSG_RESULT(no)
523     if test "$SDL_CONFIG" = "no" ; then
524       echo "*** The sdl-config script installed by SDL could not be found"
525       echo "*** If SDL was installed in PREFIX, make sure PREFIX/bin is in"
526       echo "*** your path, or set the SDL_CONFIG environment variable to the"
527       echo "*** full path to sdl-config."
528     else
529       if test -f conf.sdltest ; then
530        :
531       else
532          echo "*** Could not run SDL test program, checking why..."
533          CFLAGS="$CFLAGS $SDL_CFLAGS"
534          CXXFLAGS="$CXXFLAGS $SDL_CFLAGS"
535          LIBS="$LIBS $SDL_LIBS"
536          AC_TRY_LINK([
537#include <stdio.h>
538#include "SDL.h"
539
540int main(int argc, char *argv[])
541{ return 0; }
542#undef  main
543#define main K_and_R_C_main
544],      [ return 0; ],
545        [ echo "*** The test program compiled, but did not run. This usually means"
546          echo "*** that the run-time linker is not finding SDL or finding the wrong"
547          echo "*** version of SDL. If it is not finding SDL, you'll need to set your"
548          echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
549          echo "*** to the installed location  Also, make sure you have run ldconfig if that"
550          echo "*** is required on your system"
551	  echo "***"
552          echo "*** If you have an old version installed, it is best to remove it, although"
553          echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
554        [ echo "*** The test program failed to compile or link. See the file config.log for the"
555          echo "*** exact error that occured. This usually means SDL was incorrectly installed"
556          echo "*** or that you have moved SDL since it was installed. In the latter case, you"
557          echo "*** may want to edit the sdl-config script: $SDL_CONFIG" ])
558          CFLAGS="$ac_save_CFLAGS"
559          CXXFLAGS="$ac_save_CXXFLAGS"
560          LIBS="$ac_save_LIBS"
561       fi
562     fi
563     SDL_CFLAGS=""
564     SDL_LIBS=""
565     ifelse([$3], , :, [$3])
566  fi
567  AC_SUBST(SDL_CFLAGS)
568  AC_SUBST(SDL_LIBS)
569  rm -f conf.sdltest
570])
571
572# Configure paths for FreeType2
573# Marcelo Magallon 2001-10-26, based on gtk.m4 by Owen Taylor
574
575dnl AC_CHECK_FT2([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
576dnl Test for FreeType2, and define FT2_CFLAGS and FT2_LIBS
577dnl
578AC_DEFUN(AC_CHECK_FT2,
579[dnl
580dnl Get the cflags and libraries from the freetype-config script
581dnl
582AC_ARG_WITH(ft-prefix,
583[  --with-ft-prefix=PREFIX
584                          Prefix where FreeType is installed (optional)],
585            ft_config_prefix="$withval", ft_config_prefix="")
586AC_ARG_WITH(ft-exec-prefix,
587[  --with-ft-exec-prefix=PREFIX
588                          Exec prefix where FreeType is installed (optional)],
589            ft_config_exec_prefix="$withval", ft_config_exec_prefix="")
590AC_ARG_ENABLE(freetypetest,
591[  --disable-freetypetest  Do not try to compile and run
592                          a test FreeType program],
593[case "${enableval}" in
594yes) enable_fttest=yes ;;
595no) enable_fttest=no ;;
596*) AC_MSG_ERROR(bad value ${enableval} for freetypetest option) ;;
597esac], enable_fttest=yes)
598
599if test x$ft_config_exec_prefix != x ; then
600  ft_config_args="$ft_config_args --exec-prefix=$ft_config_exec_prefix"
601  if test x${FT2_CONFIG+set} != xset ; then
602    FT2_CONFIG=$ft_config_exec_prefix/bin/freetype-config
603  fi
604fi
605if test x$ft_config_prefix != x ; then
606  ft_config_args="$ft_config_args --prefix=$ft_config_prefix"
607  if test x${FT2_CONFIG+set} != xset ; then
608    FT2_CONFIG=$ft_config_prefix/bin/freetype-config
609  fi
610fi
611AC_PATH_PROG(FT2_CONFIG, freetype-config, no)
612
613min_ft_version=ifelse([$1], ,6.1.0,$1)
614AC_MSG_CHECKING(for FreeType - version >= $min_ft_version)
615no_ft=""
616if test "$FT2_CONFIG" = "no" ; then
617  no_ft=yes
618else
619  FT2_CFLAGS=`$FT2_CONFIG $ft_config_args --cflags`
620  FT2_LIBS=`$FT2_CONFIG $ft_config_args --libs`
621  ft_config_major_version=`$FT2_CONFIG $ft_config_args --version | \
622         sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
623  ft_config_minor_version=`$FT2_CONFIG $ft_config_args --version | \
624         sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
625  ft_config_micro_version=`$FT2_CONFIG $ft_config_args --version | \
626         sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
627  ft_min_major_version=`echo $min_ft_version | \
628         sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
629  ft_min_minor_version=`echo $min_ft_version | \
630         sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
631  ft_min_micro_version=`echo $min_ft_version | \
632         sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
633  if test x$enable_fttest = xyes ; then
634    ft_config_is_lt=""
635    if test $ft_config_major_version -lt $ft_min_major_version ; then
636      ft_config_is_lt=yes
637    else
638      if test $ft_config_major_version -eq $ft_min_major_version ; then
639        if test $ft_config_minor_version -lt $ft_min_minor_version ; then
640          ft_config_is_lt=yes
641        else
642          if test $ft_config_minor_version -eq $ft_min_minor_version ; then
643            if test $ft_config_micro_version -lt $ft_min_micro_version ; then
644              ft_config_is_lt=yes
645            fi
646          fi
647        fi
648      fi
649    fi
650    if test x$ft_config_is_lt = xyes ; then
651      no_ft=yes
652    else
653      ac_save_CFLAGS="$CFLAGS"
654      ac_save_LIBS="$LIBS"
655      CFLAGS="$CFLAGS $FT2_CFLAGS"
656      LIBS="$FT2_LIBS $LIBS"
657dnl
658dnl Sanity checks for the results of freetype-config to some extent
659dnl
660      AC_TRY_RUN([
661#include <ft2build.h>
662#include FT_FREETYPE_H
663#include <stdio.h>
664#include <stdlib.h>
665
666int
667main()
668{
669  FT_Library library;
670  FT_Error error;
671
672  error = FT_Init_FreeType(&library);
673
674  if (error)
675    return 1;
676  else
677  {
678    FT_Done_FreeType(library);
679    return 0;
680  }
681}
682],, no_ft=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
683      CFLAGS="$ac_save_CFLAGS"
684      LIBS="$ac_save_LIBS"
685    fi             # test $ft_config_version -lt $ft_min_version
686  fi               # test x$enable_fttest = xyes
687fi                 # test "$FT2_CONFIG" = "no"
688if test x$no_ft = x ; then
689   AC_MSG_RESULT(yes)
690   ifelse([$2], , :, [$2])
691else
692   AC_MSG_RESULT(no)
693   if test "$FT2_CONFIG" = "no" ; then
694     echo "*** The freetype-config script installed by FreeType 2 could not be found."
695     echo "*** If FreeType 2 was installed in PREFIX, make sure PREFIX/bin is in"
696     echo "*** your path, or set the FT2_CONFIG environment variable to the"
697     echo "*** full path to freetype-config."
698   else
699     if test x$ft_config_is_lt = xyes ; then
700       echo "*** Your installed version of the FreeType 2 library is too old."
701       echo "*** If you have different versions of FreeType 2, make sure that"
702       echo "*** correct values for --with-ft-prefix or --with-ft-exec-prefix"
703       echo "*** are used, or set the FT2_CONFIG environment variable to the"
704       echo "*** full path to freetype-config."
705     else
706       echo "*** The FreeType test program failed to run.  If your system uses"
707       echo "*** shared libraries and they are installed outside the normal"
708       echo "*** system library path, make sure the variable LD_LIBRARY_PATH"
709       echo "*** (or whatever is appropiate for your system) is correctly set."
710     fi
711   fi
712   FT2_CFLAGS=""
713   FT2_LIBS=""
714   ifelse([$3], , :, [$3])
715fi
716AC_SUBST(FT2_CFLAGS)
717AC_SUBST(FT2_LIBS)
718])
719
720# Configure paths for ParaGUI
721# Alexander Pipelka 17.05.2000
722# stolen from Sam Lantinga
723# stolen from Manish Singh
724# stolen back from Frank Belew
725# stolen from Manish Singh
726# Shamelessly stolen from Owen Taylor
727
728dnl AM_PATH_PARAGUI([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
729dnl Test for PARAGUI, and define PARAGUI_CFLAGS and PARAGUI_LIBS
730dnl
731AC_DEFUN(AM_PATH_PARAGUI,
732[dnl
733dnl Get the cflags and libraries from the paragui-config script
734dnl
735AC_ARG_WITH(paragui-prefix,[  --with-paragui-prefix=PFX   Prefix where PARAGUI is installed (optional)],
736            paragui_prefix="$withval", paragui_prefix="")
737AC_ARG_WITH(paragui-exec-prefix,[  --with-paragui-exec-prefix=PFX Exec prefix where PARAGUI is installed (optional)],
738            paragui_exec_prefix="$withval", paragui_exec_prefix="")
739AC_ARG_ENABLE(paraguitest, [  --disable-paraguitest       Do not try to compile and run a test PARAGUI program],
740[case "${enableval}" in
741yes) enable_paraguitest=yes ;;
742no) enable_paraguitest=no ;;
743*) AC_MSG_ERROR(bad value ${enableval} for paraguitest option) ;;
744esac], enable_paraguitest=yes)
745
746  if test x$paragui_exec_prefix != x ; then
747     paragui_args="$paragui_args --exec-prefix=$paragui_exec_prefix"
748     if test x${PARAGUI_CONFIG+set} != xset ; then
749        PARAGUI_CONFIG=$paragui_exec_prefix/bin/paragui-config
750     fi
751  fi
752  if test x$paragui_prefix != x ; then
753     paragui_args="$paragui_args --prefix=$paragui_prefix"
754     if test x${PARAGUI_CONFIG+set} != xset ; then
755        PARAGUI_CONFIG=$paragui_prefix/bin/paragui-config
756     fi
757  fi
758
759  AC_PATH_PROG(PARAGUI_CONFIG, paragui-config, no, [$prefix/usr/bin:$prefix/bin:$PATH])
760  min_paragui_version=ifelse([$1], ,0.11.0,$1)
761  AC_MSG_CHECKING(for PARAGUI - version >= $min_paragui_version)
762  no_paragui=""
763  if test "$PARAGUI_CONFIG" = "no" ; then
764    no_paragui=yes
765  else
766    PARAGUI_CFLAGS=`$PARAGUI_CONFIG $paraguiconf_args --cflags`
767    PARAGUI_LIBS=`$PARAGUI_CONFIG $paraguiconf_args --libs`
768
769    paragui_major_version=`$PARAGUI_CONFIG $paragui_args --version | \
770           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
771    paragui_minor_version=`$PARAGUI_CONFIG $paragui_args --version | \
772           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
773    paragui_micro_version=`$PARAGUI_CONFIG $paragui_config_args --version | \
774           sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
775    if test "x$enable_paraguitest" = "xyes" ; then
776      ac_save_CXXFLAGS="$CXXFLAGS"
777      ac_save_LIBS="$LIBS"
778      CXXFLAGS="$CXXFLAGS $PARAGUI_CFLAGS"
779      LIBS="$LIBS $PARAGUI_LIBS"
780dnl
781dnl Now check if the installed PARAGUI is sufficiently new. (Also sanity
782dnl checks the results of paragui-config to some extent
783dnl
784      rm -f conf.paraguitest
785      AC_LANG_CPLUSPLUS
786      AC_TRY_RUN([
787#include "paragui.h"
788#include "pgapplication.h"
789#include <stdio.h>
790#include <stdlib.h>
791#include <string.h>
792
793char*
794my_strdup (char *str)
795{
796  char *new_str;
797
798  if (str)
799    {
800      new_str = (char *)malloc ((strlen (str) + 1) * sizeof(char));
801      strcpy (new_str, str);
802    }
803  else
804    new_str = NULL;
805
806  return new_str;
807}
808
809int main (int argc, char *argv[])
810{
811  int major, minor, micro;
812  char *tmp_version;
813
814  PG_Application app;
815
816  /* This hangs on some systems (?)
817  system ("touch conf.paraguitest");
818  */
819  { FILE *fp = fopen("conf.paraguitest", "a"); if ( fp ) fclose(fp); }
820
821  /* HP/UX 9 (%@#!) writes to sscanf strings */
822  tmp_version = my_strdup("$min_paragui_version");
823  if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
824     printf("%s, bad version string\n", "$min_paragui_version");
825     exit(1);
826   }
827
828   if (($paragui_major_version > major) ||
829      (($paragui_major_version == major) && ($paragui_minor_version > minor)) ||
830      (($paragui_major_version == major) && ($paragui_minor_version == minor) && ($paragui_micro_version >= micro)))
831    {
832      return 0;
833    }
834  else
835    {
836      printf("\n*** 'paragui-config --version' returned %d.%d.%d, but the minimum version\n", $paragui_major_version, $paragui_minor_version, $paragui_micro_version);
837      printf("*** of PARAGUI required is %d.%d.%d. If paragui-config is correct, then it is\n", major, minor, micro);
838      printf("*** best to upgrade to the required version.\n");
839      printf("*** If paragui-config was wrong, set the environment variable PARAGUI_CONFIG\n");
840      printf("*** to point to the correct copy of paragui-config, and remove the file\n");
841      printf("*** config.cache before re-running configure\n");
842      return 1;
843    }
844}
845
846],, no_paragui=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
847       CXXFLAGS="$ac_save_CXXFLAGS"
848       LIBS="$ac_save_LIBS"
849     fi
850  fi
851  if test "x$no_paragui" = x ; then
852     AC_MSG_RESULT(yes)
853     ifelse([$2], , :, [$2])
854  else
855     AC_MSG_RESULT(no)
856     if test "$PARAGUI_CONFIG" = "no" ; then
857       echo "*** The paragui-config script installed by PARAGUI could not be found"
858       echo "*** If PARAGUI was installed in PREFIX, make sure PREFIX/bin is in"
859       echo "*** your path, or set the PARAGUI_CONFIG environment variable to the"
860       echo "*** full path to paragui-config."
861     else
862       if test -f conf.paraguitest ; then
863        :
864       else
865          echo "*** Could not run PARAGUI test program, checking why..."
866          CXXFLAGS="$CXXFLAGS $PARAGUI_CFLAGS"
867          LIBS="$LIBS $PARAGUI_LIBS"
868          AC_TRY_LINK([
869#include "paragui.h"
870#include <stdio.h>
871],      [ return 0; ],
872        [ echo "*** The test program compiled, but did not run. This usually means"
873          echo "*** that the run-time linker is not finding PARAGUI or finding the wrong"
874          echo "*** version of PARAGUI. If it is not finding PARAGUI, you'll need to set your"
875          echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
876          echo "*** to the installed location  Also, make sure you have run ldconfig if that"
877          echo "*** is required on your system"
878	  echo "***"
879          echo "*** If you have an old version installed, it is best to remove it, although"
880          echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
881        [ echo "*** The test program failed to compile or link. See the file config.log for the"
882          echo "*** exact error that occured. This usually means PARAGUI was incorrectly installed"
883          echo "*** or that you have moved PARAGUI since it was installed. In the latter case, you"
884          echo "*** may want to edit the paragui-config script: $PARAGUI_CONFIG" ])
885          CXXFLAGS="$ac_save_CXXFLAGS"
886          LIBS="$ac_save_LIBS"
887       fi
888     fi
889     PARAGUI_CFLAGS=""
890     PARAGUI_LIBS=""
891     ifelse([$3], , :, [$3])
892  fi
893  AC_SUBST(PARAGUI_CFLAGS)
894  AC_SUBST(PARAGUI_LIBS)
895  rm -f conf.paraguitest
896])
897