OSDN Git Service

TiMidity++-1.3.2
[timidity41/timidity41.git] / aclocal.m4
1 dnl aclocal.m4 generated automatically by aclocal 1.3
2
3 dnl Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
4 dnl This Makefile.in is free software; the Free Software Foundation
5 dnl gives unlimited permission to copy and/or distribute it,
6 dnl with or without modifications, as long as this notice is preserved.
7
8 dnl This program is distributed in the hope that it will be useful,
9 dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
10 dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11 dnl PARTICULAR PURPOSE.
12
13 dnl MY_DEFINE(VARIABLE)
14 AC_DEFUN(MY_DEFINE,
15 [cat >> confdefs.h <<EOF
16 [#define] $1 1
17 EOF
18 ])
19
20 dnl CONFIG_INTERFACE(package,macro_name,interface_id,help
21 dnl                  $1      $2         $3           $4
22 dnl                  action-if-yes-or-dynamic,
23 dnl                  $5
24 dnl                  action-if-yes,action-if-dynamic,action-if-no)
25 dnl                  $6            $7                $8
26 AC_DEFUN(CONFIG_INTERFACE,
27 [AC_ARG_ENABLE($1,[$4],
28 [case "x$enable_$1" in xyes|xdynamic) $5 ;; esac])
29 case "x$enable_$1" in
30 xyes)
31   MY_DEFINE(IA_$2)
32   AM_CONDITIONAL(ENABLE_$2, true)
33   $6
34   ;;
35 xdynamic)
36   dynamic_targets="$dynamic_targets interface_$3.\$(so)"
37   $7
38   ;;
39 *)
40   $8
41   ;;
42 esac
43 AC_SUBST($3_so_libs)
44 ])
45
46
47 dnl alsa.m4 starts form here
48 dnl Configure Paths for Alsa
49 dnl Christopher Lansdown (lansdoct@cs.alfred.edu)
50 dnl 29/10/1998
51 dnl modified for TiMidity++ by Isaku Yamahata(yamahata@kusm.kyoto-u.ac.jp)
52 dnl 16/12/1998
53 dnl AM_PATH_ALSA_LOCAL(MINIMUM-VERSION)
54 dnl Test for libasound, and define ALSA_CFLAGS and ALSA_LIBS as appropriate.
55 dnl if there exit ALSA, define have_alsa=yes, otherwise no.
56 dnl enables arguments --with-alsa-prefix= --with-alsa-enc-prefix= --disable-alsatest
57 dnl
58 AC_DEFUN(AM_PATH_ALSA_LOCAL,
59 [dnl
60 dnl Get the clfags and libraries for alsa
61 dnl
62 have_alsa=no
63 AC_ARG_WITH(alsa-prefix,[  --with-alsa-prefix=PFX  Prefix where Alsa library is installed(optional)],
64         [alsa_prefix="$withval"], [alsa_prefix=""])
65 AC_ARG_WITH(alsa-inc-prefix, [  --with-alsa-inc-prefix=PFX  Prefix where include libraries are (optional)],
66         [alsa_inc_prefix="$withval"], [alsa_inc_prefix=""])
67 AC_ARG_ENABLE(alsatest, [  --disable-alsatest      Do not try to compile and run a test Alsa program], [enable_alsatest=no], [enable_alsatest=yes])
68
69 dnl Add any special include directories
70 AC_MSG_CHECKING(for ALSA CFLAGS)
71 if test "$alsa_inc_prefix" != "" ; then
72         ALSA_CFLAGS="$ALSA_CFLAGS -I$alsa_inc_prefix"
73         CFLAGS="$CFLAGS -I$alsa_inc_prefix"
74 fi
75 AC_MSG_RESULT($ALSA_CFLAGS)
76
77 dnl add any special lib dirs
78 AC_MSG_CHECKING(for ALSA LDFLAGS)
79 if test "$alsa_prefix" != "" ; then
80         ALSA_LIBS="$ALSA_LIBS -L$alsa_prefix"
81         LIBS="-L$alsa_prefix"
82 fi
83
84 dnl add the alsa library
85 ALSA_LIBS="$ALSA_LIBS -lasound"
86 AC_MSG_RESULT($ALSA_LIBS)
87
88 dnl Check for the presence of the library
89 dnl if test $enable_alsatest = yes; then
90 dnl   AC_MSG_CHECKING(for working libasound)
91 dnl   AC_TRY_RUN([
92 dnl #include <sys/asoundlib.h>
93 dnl void main(void)
94 dnl {
95 dnl   snd_cards();
96 dnl   exit(0);
97 dnl }
98 dnl ],
99 dnl    [AC_MSG_RESULT("present")],
100 dnl    [AC_MSG_RESULT("not found. ")
101 dnl    AC_MSG_ERROR(Fatal error: Install alsa-lib package or use --with-alsa-prefix option...)],
102 dnl    [AC_MSG_RESULT(unsopported)
103 dnl     AC_MSG_ERROR(Cross-compiling isn't supported...)]
104 dnl  )
105 dnl fi
106
107 dnl Check for a working version of libasound that is of the right version.
108 min_alsa_version=ifelse([$1], ,0.1.1,$1)
109 AC_MSG_CHECKING(for libasound headers version >= $min_alsa_version)
110 no_alsa=""
111     alsa_min_major_version=`echo $min_alsa_version | \
112            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
113     alsa_min_minor_version=`echo $min_alsa_version | \
114            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
115     alsa_min_micro_version=`echo $min_alsa_version | \
116            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
117
118 AC_TRY_COMPILE([
119 #include <sys/asoundlib.h>
120 ], [
121 /* ensure backward compatibility */
122 #if !defined(SND_LIB_MAJOR) && defined(SOUNDLIB_VERSION_MAJOR)
123 #define SND_LIB_MAJOR SOUNDLIB_VERSION_MAJOR
124 #endif
125 #if !defined(SND_LIB_MINOR) && defined(SOUNDLIB_VERSION_MINOR)
126 #define SND_LIB_MINOR SOUNDLIB_VERSION_MINOR
127 #endif
128 #if !defined(SND_LIB_SUBMINOR) && defined(SOUNDLIB_VERSION_SUBMINOR)
129 #define SND_LIB_SUBMINOR SOUNDLIB_VERSION_SUBMINOR
130 #endif
131
132 #  if(SND_LIB_MAJOR > $alsa_min_major_version)
133   exit(0);
134 #  else
135 #    if(SND_LIB_MAJOR < $alsa_min_major_version)
136 #       error not present
137 #    endif
138
139 #   if(SND_LIB_MINOR > $alsa_min_minor_version)
140   exit(0);
141 #   else
142 #     if(SND_LIB_MINOR < $alsa_min_minor_version)
143 #          error not present
144 #      endif
145
146 #      if(SND_LIB_SUBMINOR < $alsa_min_micro_version)
147 #        error not present
148 #      endif
149 #    endif
150 #  endif
151 exit(0);
152 ],
153   [AC_MSG_RESULT(found.)
154    have_alsa=yes],
155   [AC_MSG_RESULT(not present.)]
156 )
157
158 dnl Now that we know that we have the right version, let's see if we have the library and not just the headers.
159 AC_CHECK_LIB([asound], [snd_cards],,
160         [AC_MSG_RESULT(No linkable libasound was found.)]
161 )
162
163 dnl That should be it.  Now just export out symbols:
164 AC_SUBST(ALSA_CFLAGS)
165 AC_SUBST(ALSA_LIBS)
166 ])
167 dnl alsa.m4 ends here
168
169
170 dnl CHECK_DLSYM_UNDERSCORE([ACTION-IF-NEED [, ACTION IF-NOT-NEED]])
171 dnl variable input:
172 dnl   CC CFLAGS CPPFLAGS LDFLAGS LIBS SHCFLAGS SHLD SHLDFLAGS
173 dnl   ac_cv_header_dlfcn_h lib_dl_opt so
174 AC_DEFUN(CHECK_DLSYM_UNDERSCORE,
175 [dnl Check if dlsym need a leading underscore
176 AC_MSG_CHECKING(whether your dlsym() needs a leading underscore)
177 AC_CACHE_VAL(timidity_cv_func_dlsym_underscore,
178 [case "$ac_cv_header_dlfcn_h" in
179 yes) i_dlfcn=define;;
180 *)   i_dlfcn=undef;;
181 esac
182 cat > dyna.c <<EOM
183 fred () { }
184 EOM
185
186 cat > fred.c <<EOM
187 #include <stdio.h>
188 #$i_dlfcn I_DLFCN
189 #ifdef I_DLFCN
190 #include <dlfcn.h>      /* the dynamic linker include file for Sunos/Solaris */
191 #else
192 #include <sys/types.h>
193 #include <nlist.h>
194 #include <link.h>
195 #endif
196
197 extern int fred() ;
198
199 main()
200 {
201     void * handle ;
202     void * symbol ;
203 #ifndef RTLD_LAZY
204     int mode = 1 ;
205 #else
206     int mode = RTLD_LAZY ;
207 #endif
208     handle = dlopen("./dyna.$so", mode) ;
209     if (handle == NULL) {
210         printf ("1\n") ;
211         fflush (stdout) ;
212         exit(0);
213     }
214     symbol = dlsym(handle, "fred") ;
215     if (symbol == NULL) {
216         /* try putting a leading underscore */
217         symbol = dlsym(handle, "_fred") ;
218         if (symbol == NULL) {
219             printf ("2\n") ;
220             fflush (stdout) ;
221             exit(0);
222         }
223         printf ("3\n") ;
224     }
225     else
226         printf ("4\n") ;
227     fflush (stdout) ;
228     exit(0);
229 }
230 EOM
231 : Call the object file tmp-dyna.o in case dlext=o.
232 if ${CC-cc} $CFLAGS $SHCFLAGS $CPPFLAGS -c dyna.c > /dev/null 2>&1 &&
233         mv dyna.o tmp-dyna.o > /dev/null 2>&1 && 
234         $SHLD $SHLDFLAGS -o dyna.$so tmp-dyna.o > /dev/null 2>&1 && 
235         ${CC-cc} -o fred $CFLAGS $CPPFLAGS $LDFLAGS fred.c $LIBS $lib_dl_opt > /dev/null 2>&1; then
236         xxx=`./fred`
237         case $xxx in
238         1)      AC_MSG_WARN(Test program failed using dlopen.  Perhaps you should not use dynamic loading.)
239                 ;;
240         2)      AC_MSG_WARN(Test program failed using dlsym.  Perhaps you should not use dynamic loading.)
241                 ;;
242         3)      timidity_cv_func_dlsym_underscore=yes
243                 ;;
244         4)      timidity_cv_func_dlsym_underscore=no
245                 ;;
246         esac
247 else
248         AC_MSG_WARN(I can't compile and run the test program.)
249 fi
250 rm -f dyna.c dyna.o dyna.$so tmp-dyna.o fred.c fred.o fred
251 ])
252 case "x$timidity_cv_func_dlsym_underscore" in
253 xyes)   [$1]
254         AC_MSG_RESULT(yes)
255         ;;
256 xno)    [$2]
257         AC_MSG_RESULT(no)
258         ;;
259 esac
260 ])
261
262
263 dnl contains program from perl5
264 dnl CONTAINS_INIT()
265 AC_DEFUN(CONTAINS_INIT,
266 [dnl Some greps do not return status, grrr.
267 AC_MSG_CHECKING(whether grep returns status)
268 echo "grimblepritz" >grimble
269 if grep blurfldyick grimble >/dev/null 2>&1 ; then
270         contains="./contains"
271 elif grep grimblepritz grimble >/dev/null 2>&1 ; then
272         contains=grep
273 else
274         contains="./contains"
275 fi
276 rm -f grimble
277 dnl the following should work in any shell
278 case "$contains" in
279 grep)   AC_MSG_RESULT(yes)
280         ;;
281 ./contains)
282         AC_MSG_RESULT(AGH!  Grep doesn't return a status.  Attempting remedial action.)
283         cat >./contains <<'EOSS'
284 grep "[$]1" "[$]2" >.greptmp && cat .greptmp && test -s .greptmp
285 EOSS
286         chmod +x "./contains"
287         ;;
288 esac
289 ])
290
291
292 dnl CONTAINS(word,filename,action-if-found,action-if-not-found)
293 AC_DEFUN(CONTAINS,
294 [if $contains "^[$1]"'[$]' $2 >/dev/null 2>&1; then
295   [$3]
296 else
297   [$4]
298 fi
299 ])
300
301
302 dnl SET_UNIQ_WORDS(shell-variable,words...)
303 AC_DEFUN(SET_UNIQ_WORDS,
304 [rm -f wordtmp >/dev/null 2>&1
305 val=''
306 for f in $2; do
307   CONTAINS([$f],wordtmp,:,[echo $f >>wordtmp; val="$val $f"])
308 done
309 $1="$val"
310 rm -f wordtmp >/dev/null 2>&1
311 ])
312
313
314 dnl WAPI_CHECK_FUNC(FUNCTION, INCLUDES, TEST-BODY,
315                     [ACTION-FI-FOUND [, ACTION-IF-NOT-FOUND]])
316 AC_DEFUN(WAPI_CHECK_FUNC,
317 [AC_MSG_CHECKING(for $1)
318 AC_CACHE_VAL(wapi_cv_func_$1,
319 [AC_TRY_LINK([#include <windows.h>
320 $2
321 ], [$3],
322 wapi_cv_func_$1=yes, wapi_cv_func_$1=no)])
323 if eval "test \"`echo '$wapi_cv_func_'$1`\" = yes"; then
324   AC_MSG_RESULT(yes)
325   ifelse([$4], , :, [$4])
326 else
327   AC_MSG_RESULT(no)
328 ifelse([$5], , , [$5
329 ])dnl
330 fi
331 ])
332
333
334 dnl WAPI_CHECK_LIB(LIBRARY, FUNCTION,
335 dnl             INCLUDES, TEST-BODY
336 dnl             [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
337 dnl             [, OTHER-LIBRARIES]]])
338 AC_DEFUN(WAPI_CHECK_LIB,
339 [AC_MSG_CHECKING([for $2 in -l$1])
340 ac_lib_var=`echo $1['_']$2 | sed 'y%./+-%__p_%'`
341 AC_CACHE_VAL(wapi_cv_lib_$ac_lib_var,
342 [ac_save_LIBS="$LIBS"
343 LIBS="-l$1 $7 $LIBS"
344 AC_TRY_LINK([#include <windows.h>
345 $3
346 ], [$4],
347 eval "wapi_cv_lib_$ac_lib_var=yes",
348 eval "wapi_cv_lib_$ac_lib_var=no")
349 LIBS="$ac_save_LIBS"
350 ])dnl
351 if eval "test \"`echo '$wapi_cv_lib_'$ac_lib_var`\" = yes"; then
352   AC_MSG_RESULT(yes)
353   ifelse([$5], ,LIBS="-l$1 $LIBS", [$5])
354 else
355   AC_MSG_RESULT(no)
356 ifelse([$6], , , [$6
357 ])dnl
358 fi
359 ])
360
361
362 dnl EXTRACT_CPPFLAGS(CPPFLAGS-to-append,others-to-append,FLAGS)
363 AC_DEFUN(EXTRACT_CPPFLAGS,
364 [for f in $3; do
365     case ".$f" in
366         .-I?*|.-D?*)    $1="[$]$1 $f" ;;
367         *)              $2="[$]$1 $f" ;;
368     esac
369 done
370 ])
371
372 # Define a conditional.
373
374 AC_DEFUN(AM_CONDITIONAL,
375 [AC_SUBST($1_TRUE)
376 AC_SUBST($1_FALSE)
377 if $2; then
378   $1_TRUE=
379   $1_FALSE='#'
380 else
381   $1_TRUE='#'
382   $1_FALSE=
383 fi])
384
385 # Do all the work for Automake.  This macro actually does too much --
386 # some checks are only needed if your package does certain things.
387 # But this isn't really a big deal.
388
389 # serial 1
390
391 dnl Usage:
392 dnl AM_INIT_AUTOMAKE(package,version, [no-define])
393
394 AC_DEFUN(AM_INIT_AUTOMAKE,
395 [AC_REQUIRE([AM_PROG_INSTALL])
396 PACKAGE=[$1]
397 AC_SUBST(PACKAGE)
398 VERSION=[$2]
399 AC_SUBST(VERSION)
400 dnl test to see if srcdir already configured
401 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
402   AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
403 fi
404 ifelse([$3],,
405 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
406 AC_DEFINE_UNQUOTED(VERSION, "$VERSION"))
407 AC_REQUIRE([AM_SANITY_CHECK])
408 AC_REQUIRE([AC_ARG_PROGRAM])
409 dnl FIXME This is truly gross.
410 missing_dir=`cd $ac_aux_dir && pwd`
411 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
412 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
413 AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
414 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
415 AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
416 AC_REQUIRE([AC_PROG_MAKE_SET])])
417
418
419 # serial 1
420
421 AC_DEFUN(AM_PROG_INSTALL,
422 [AC_REQUIRE([AC_PROG_INSTALL])
423 test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
424 AC_SUBST(INSTALL_SCRIPT)dnl
425 ])
426
427 #
428 # Check to make sure that the build environment is sane.
429 #
430
431 AC_DEFUN(AM_SANITY_CHECK,
432 [AC_MSG_CHECKING([whether build environment is sane])
433 # Just in case
434 sleep 1
435 echo timestamp > conftestfile
436 # Do `set' in a subshell so we don't clobber the current shell's
437 # arguments.  Must try -L first in case configure is actually a
438 # symlink; some systems play weird games with the mod time of symlinks
439 # (eg FreeBSD returns the mod time of the symlink's containing
440 # directory).
441 if (
442    set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
443    if test "[$]*" = "X"; then
444       # -L didn't work.
445       set X `ls -t $srcdir/configure conftestfile`
446    fi
447    if test "[$]*" != "X $srcdir/configure conftestfile" \
448       && test "[$]*" != "X conftestfile $srcdir/configure"; then
449
450       # If neither matched, then we have a broken ls.  This can happen
451       # if, for instance, CONFIG_SHELL is bash and it inherits a
452       # broken ls alias from the environment.  This has actually
453       # happened.  Such a system could not be considered "sane".
454       AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
455 alias in your environment])
456    fi
457
458    test "[$]2" = conftestfile
459    )
460 then
461    # Ok.
462    :
463 else
464    AC_MSG_ERROR([newly created file is older than distributed files!
465 Check your system clock])
466 fi
467 rm -f conftest*
468 AC_MSG_RESULT(yes)])
469
470 dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
471 dnl The program must properly implement --version.
472 AC_DEFUN(AM_MISSING_PROG,
473 [AC_MSG_CHECKING(for working $2)
474 # Run test in a subshell; some versions of sh will print an error if
475 # an executable is not found, even if stderr is redirected.
476 # Redirect stdin to placate older versions of autoconf.  Sigh.
477 if ($2 --version) < /dev/null > /dev/null 2>&1; then
478    $1=$2
479    AC_MSG_RESULT(found)
480 else
481    $1="$3/missing $2"
482    AC_MSG_RESULT(missing)
483 fi
484 AC_SUBST($1)])
485
486 # Like AC_CONFIG_HEADER, but automatically create stamp file.
487
488 AC_DEFUN(AM_CONFIG_HEADER,
489 [AC_PREREQ([2.12])
490 AC_CONFIG_HEADER([$1])
491 dnl When config.status generates a header, we must update the stamp-h file.
492 dnl This file resides in the same directory as the config header
493 dnl that is generated.  We must strip everything past the first ":",
494 dnl and everything past the last "/".
495 AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
496 ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
497 <<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
498 <<am_indx=1
499 for am_file in <<$1>>; do
500   case " <<$>>CONFIG_HEADERS " in
501   *" <<$>>am_file "*<<)>>
502     echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
503     ;;
504   esac
505   am_indx=`expr "<<$>>am_indx" + 1`
506 done<<>>dnl>>)
507 changequote([,]))])
508
509
510 # serial 1
511
512 AC_DEFUN(AM_PATH_LISPDIR,
513  [# If set to t, that means we are running in a shell under Emacs.
514   # If you have an Emacs named "t", then use the full path.
515   test "$EMACS" = t && EMACS=
516   AC_PATH_PROG(EMACS, emacs xemacs, no)
517   if test $EMACS != "no"; then
518     AC_MSG_CHECKING([where .elc files should go])
519     dnl Set default value
520     lispdir="\$(datadir)/emacs/site-lisp"
521     if test "x$prefix" = "xNONE"; then
522       if test -d $ac_default_prefix/share/emacs/site-lisp; then
523         lispdir="\$(prefix)/share/emacs/site-lisp"
524       else
525         if test -d $ac_default_prefix/lib/emacs/site-lisp; then
526           lispdir="\$(prefix)/lib/emacs/site-lisp"
527         fi
528       fi
529     else
530       if test -d $prefix/share/emacs/site-lisp; then
531         lispdir="\$(prefix)/share/emacs/site-lisp"
532       else
533         if test -d $prefix/lib/emacs/site-lisp; then
534           lispdir="\$(prefix)/lib/emacs/site-lisp"
535         fi
536       fi
537     fi
538     AC_MSG_RESULT($lispdir)
539   fi
540   AC_SUBST(lispdir)])
541
542 # Configure paths for GTK+
543 # Owen Taylor     97-11-3
544
545 dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
546 dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS
547 dnl
548 AC_DEFUN(AM_PATH_GTK,
549 [dnl 
550 dnl Get the cflags and libraries from the gtk-config script
551 dnl
552 AC_ARG_WITH(gtk-prefix,[  --with-gtk-prefix=PFX   Prefix where GTK is installed (optional)],
553             gtk_config_prefix="$withval", gtk_config_prefix="")
554 AC_ARG_WITH(gtk-exec-prefix,[  --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)],
555             gtk_config_exec_prefix="$withval", gtk_config_exec_prefix="")
556 AC_ARG_ENABLE(gtktest, [  --disable-gtktest       Do not try to compile and run a test GTK program],
557                     , enable_gtktest=yes)
558
559   if test x$gtk_config_exec_prefix != x ; then
560      gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix"
561      if test x${GTK_CONFIG+set} != xset ; then
562         GTK_CONFIG=$gtk_config_exec_prefix/bin/gtk-config
563      fi
564   fi
565   if test x$gtk_config_prefix != x ; then
566      gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix"
567      if test x${GTK_CONFIG+set} != xset ; then
568         GTK_CONFIG=$gtk_config_prefix/bin/gtk-config
569      fi
570   fi
571
572   AC_PATH_PROG(GTK_CONFIG, gtk-config, no)
573   min_gtk_version=ifelse([$1], ,0.99.7,$1)
574   AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
575   no_gtk=""
576   if test "$GTK_CONFIG" = "no" ; then
577     no_gtk=yes
578   else
579     GTK_CFLAGS=`$GTK_CONFIG $gtk_config_args --cflags`
580     GTK_LIBS=`$GTK_CONFIG $gtk_config_args --libs`
581     gtk_config_major_version=`$GTK_CONFIG $gtk_config_args --version | \
582            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
583     gtk_config_minor_version=`$GTK_CONFIG $gtk_config_args --version | \
584            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
585     gtk_config_micro_version=`$GTK_CONFIG $gtk_config_args --version | \
586            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
587     if test "x$enable_gtktest" = "xyes" ; then
588       ac_save_CFLAGS="$CFLAGS"
589       ac_save_LIBS="$LIBS"
590       CFLAGS="$CFLAGS $GTK_CFLAGS"
591       LIBS="$LIBS $GTK_LIBS"
592 dnl
593 dnl Now check if the installed GTK is sufficiently new. (Also sanity
594 dnl checks the results of gtk-config to some extent
595 dnl
596       rm -f conf.gtktest
597       AC_TRY_RUN([
598 #include <gtk/gtk.h>
599 #include <stdio.h>
600
601 int 
602 main ()
603 {
604   int major, minor, micro;
605   char *tmp_version;
606
607   system ("touch conf.gtktest");
608
609   /* HP/UX 9 (%@#!) writes to sscanf strings */
610   tmp_version = g_strdup("$min_gtk_version");
611   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
612      printf("%s, bad version string\n", "$min_gtk_version");
613      exit(1);
614    }
615
616   if ((gtk_major_version != $gtk_config_major_version) ||
617       (gtk_minor_version != $gtk_config_minor_version) ||
618       (gtk_micro_version != $gtk_config_micro_version))
619     {
620       printf("\n*** 'gtk-config --version' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n", 
621              $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
622              gtk_major_version, gtk_minor_version, gtk_micro_version);
623       printf ("*** was found! If gtk-config was correct, then it is best\n");
624       printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
625       printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
626       printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
627       printf("*** required on your system.\n");
628       printf("*** If gtk-config was wrong, set the environment variable GTK_CONFIG\n");
629       printf("*** to point to the correct copy of gtk-config, and remove the file config.cache\n");
630       printf("*** before re-running configure\n");
631     } 
632   else
633     {
634       if ((gtk_major_version > major) ||
635         ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
636         ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
637       {
638         return 0;
639        }
640      else
641       {
642         printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
643                gtk_major_version, gtk_minor_version, gtk_micro_version);
644         printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
645                major, minor, micro);
646         printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
647         printf("***\n");
648         printf("*** If you have already installed a sufficiently new version, this error\n");
649         printf("*** probably means that the wrong copy of the gtk-config shell script is\n");
650         printf("*** being found. The easiest way to fix this is to remove the old version\n");
651         printf("*** of GTK+, but you can also set the GTK_CONFIG environment to point to the\n");
652         printf("*** correct copy of gtk-config. (In this case, you will have to\n");
653         printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
654         printf("*** so that the correct libraries are found at run-time))\n");
655       }
656     }
657   return 1;
658 }
659 ],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
660        CFLAGS="$ac_save_CFLAGS"
661        LIBS="$ac_save_LIBS"
662      fi
663   fi
664   if test "x$no_gtk" = x ; then
665      AC_MSG_RESULT(yes)
666      ifelse([$2], , :, [$2])     
667   else
668      AC_MSG_RESULT(no)
669      if test "$GTK_CONFIG" = "no" ; then
670        echo "*** The gtk-config script installed by GTK could not be found"
671        echo "*** If GTK was installed in PREFIX, make sure PREFIX/bin is in"
672        echo "*** your path, or set the GTK_CONFIG environment variable to the"
673        echo "*** full path to gtk-config."
674      else
675        if test -f conf.gtktest ; then
676         :
677        else
678           echo "*** Could not run GTK test program, checking why..."
679           CFLAGS="$CFLAGS $GTK_CFLAGS"
680           LIBS="$LIBS $GTK_LIBS"
681           AC_TRY_LINK([
682 #include <gtk/gtk.h>
683 #include <stdio.h>
684 ],      [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
685         [ echo "*** The test program compiled, but did not run. This usually means"
686           echo "*** that the run-time linker is not finding GTK or finding the wrong"
687           echo "*** version of GTK. If it is not finding GTK, you'll need to set your"
688           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
689           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
690           echo "*** is required on your system"
691           echo "***"
692           echo "*** If you have an old version installed, it is best to remove it, although"
693           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
694           echo "***"
695           echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that"
696           echo "*** came with the system with the command"
697           echo "***"
698           echo "***    rpm --erase --nodeps gtk gtk-devel" ],
699         [ echo "*** The test program failed to compile or link. See the file config.log for the"
700           echo "*** exact error that occured. This usually means GTK was incorrectly installed"
701           echo "*** or that you have moved GTK since it was installed. In the latter case, you"
702           echo "*** may want to edit the gtk-config script: $GTK_CONFIG" ])
703           CFLAGS="$ac_save_CFLAGS"
704           LIBS="$ac_save_LIBS"
705        fi
706      fi
707      GTK_CFLAGS=""
708      GTK_LIBS=""
709      ifelse([$3], , :, [$3])
710   fi
711   AC_SUBST(GTK_CFLAGS)
712   AC_SUBST(GTK_LIBS)
713   rm -f conf.gtktest
714 ])
715