OSDN Git Service

TiMidity++-2.6.0-beta2
[timidity41/timidity41.git] / aclocal.m4
1 dnl aclocal.m4 generated automatically by aclocal 1.4
2
3 dnl Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
4 dnl This file 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   KEEP_LDFLAGS="$LDFLAGS"
92 dnl   LDFLAGS="$LDFLAGS $ALSA_LIBS"
93 dnl   AC_TRY_RUN([
94 dnl #include <sys/asoundlib.h>
95 dnl void main(void)
96 dnl {
97 dnl   snd_cards();
98 dnl   exit(0);
99 dnl }
100 dnl ],
101 dnl    [AC_MSG_RESULT("present")],
102 dnl    [AC_MSG_RESULT("not found. ")
103 dnl    AC_MSG_ERROR(Fatal error: Install alsa-lib package or use --with-alsa-prefix option...)],
104 dnl    [AC_MSG_RESULT(unsopported)
105 dnl     AC_MSG_ERROR(Cross-compiling isn't supported...)]
106 dnl  )
107 dnl   LDFLAGS="$KEEP_LDFLAGS"
108 dnl fi
109
110 dnl Check for a working version of libasound that is of the right version.
111 min_alsa_version=ifelse([$1], ,0.1.1,$1)
112 AC_MSG_CHECKING(for libasound headers version >= $min_alsa_version)
113 no_alsa=""
114     alsa_min_major_version=`echo $min_alsa_version | \
115            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
116     alsa_min_minor_version=`echo $min_alsa_version | \
117            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
118     alsa_min_micro_version=`echo $min_alsa_version | \
119            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
120
121 AC_TRY_COMPILE([
122 #include <sys/asoundlib.h>
123 ], [
124 /* ensure backward compatibility */
125 #if !defined(SND_LIB_MAJOR) && defined(SOUNDLIB_VERSION_MAJOR)
126 #define SND_LIB_MAJOR SOUNDLIB_VERSION_MAJOR
127 #endif
128 #if !defined(SND_LIB_MINOR) && defined(SOUNDLIB_VERSION_MINOR)
129 #define SND_LIB_MINOR SOUNDLIB_VERSION_MINOR
130 #endif
131 #if !defined(SND_LIB_SUBMINOR) && defined(SOUNDLIB_VERSION_SUBMINOR)
132 #define SND_LIB_SUBMINOR SOUNDLIB_VERSION_SUBMINOR
133 #endif
134
135 #  if(SND_LIB_MAJOR > $alsa_min_major_version)
136   exit(0);
137 #  else
138 #    if(SND_LIB_MAJOR < $alsa_min_major_version)
139 #       error not present
140 #    endif
141
142 #   if(SND_LIB_MINOR > $alsa_min_minor_version)
143   exit(0);
144 #   else
145 #     if(SND_LIB_MINOR < $alsa_min_minor_version)
146 #          error not present
147 #      endif
148
149 #      if(SND_LIB_SUBMINOR < $alsa_min_micro_version)
150 #        error not present
151 #      endif
152 #    endif
153 #  endif
154 exit(0);
155 ],
156   [AC_MSG_RESULT(found.)
157    have_alsa=yes],
158   [AC_MSG_RESULT(not present.)]
159 )
160
161 dnl Now that we know that we have the right version, let's see if we have the library and not just the headers.
162 AC_CHECK_LIB([asound], [snd_cards],,
163         [AC_MSG_RESULT(No linkable libasound was found.)]
164 )
165
166 dnl That should be it.  Now just export out symbols:
167 AC_SUBST(ALSA_CFLAGS)
168 AC_SUBST(ALSA_LIBS)
169 ])
170 dnl alsa.m4 ends here
171
172 # Configure paths for ESD
173 # Manish Singh    98-9-30
174 # stolen back from Frank Belew
175 # stolen from Manish Singh
176 # Shamelessly stolen from Owen Taylor
177
178 dnl AM_PATH_ESD([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
179 dnl Test for ESD, and define ESD_CFLAGS and ESD_LIBS
180 dnl
181 AC_DEFUN(AM_PATH_ESD,
182 [dnl 
183 dnl Get the cflags and libraries from the esd-config script
184 dnl
185 AC_ARG_WITH(esd-prefix,[  --with-esd-prefix=PFX   Prefix where ESD is installed (optional)],
186             esd_prefix="$withval", esd_prefix="")
187 AC_ARG_WITH(esd-exec-prefix,[  --with-esd-exec-prefix=PFX Exec prefix where ESD is installed (optional)],
188             esd_exec_prefix="$withval", esd_exec_prefix="")
189 AC_ARG_ENABLE(esdtest, [  --disable-esdtest       Do not try to compile and run a test ESD program],
190                     , enable_esdtest=yes)
191
192   if test x$esd_exec_prefix != x ; then
193      esd_args="$esd_args --exec-prefix=$esd_exec_prefix"
194      if test x${ESD_CONFIG+set} != xset ; then
195         ESD_CONFIG=$esd_exec_prefix/bin/esd-config
196      fi
197   fi
198   if test x$esd_prefix != x ; then
199      esd_args="$esd_args --prefix=$esd_prefix"
200      if test x${ESD_CONFIG+set} != xset ; then
201         ESD_CONFIG=$esd_prefix/bin/esd-config
202      fi
203   fi
204
205   AC_PATH_PROG(ESD_CONFIG, esd-config, no)
206   min_esd_version=ifelse([$1], ,0.2.7,$1)
207   AC_MSG_CHECKING(for ESD - version >= $min_esd_version)
208   no_esd=""
209   if test "$ESD_CONFIG" = "no" ; then
210     no_esd=yes
211   else
212     ESD_CFLAGS=`$ESD_CONFIG $esdconf_args --cflags`
213     ESD_LIBS=`$ESD_CONFIG $esdconf_args --libs`
214
215     esd_major_version=`$ESD_CONFIG $esd_args --version | \
216            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
217     esd_minor_version=`$ESD_CONFIG $esd_args --version | \
218            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
219     esd_micro_version=`$ESD_CONFIG $esd_config_args --version | \
220            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
221     if test "x$enable_esdtest" = "xyes" ; then
222       ac_save_CFLAGS="$CFLAGS"
223       ac_save_LIBS="$LIBS"
224       CFLAGS="$CFLAGS $ESD_CFLAGS"
225       LIBS="$LIBS $ESD_LIBS"
226 dnl
227 dnl Now check if the installed ESD is sufficiently new. (Also sanity
228 dnl checks the results of esd-config to some extent
229 dnl
230       rm -f conf.esdtest
231       AC_TRY_RUN([
232 #include <stdio.h>
233 #include <stdlib.h>
234 #include <string.h>
235 #include <esd.h>
236
237 char*
238 my_strdup (char *str)
239 {
240   char *new_str;
241   
242   if (str)
243     {
244       new_str = malloc ((strlen (str) + 1) * sizeof(char));
245       strcpy (new_str, str);
246     }
247   else
248     new_str = NULL;
249   
250   return new_str;
251 }
252
253 int main ()
254 {
255   int major, minor, micro;
256   char *tmp_version;
257
258   system ("touch conf.esdtest");
259
260   /* HP/UX 9 (%@#!) writes to sscanf strings */
261   tmp_version = my_strdup("$min_esd_version");
262   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
263      printf("%s, bad version string\n", "$min_esd_version");
264      exit(1);
265    }
266
267    if (($esd_major_version > major) ||
268       (($esd_major_version == major) && ($esd_minor_version > minor)) ||
269       (($esd_major_version == major) && ($esd_minor_version == minor) && ($esd_micro_version >= micro)))
270     {
271       return 0;
272     }
273   else
274     {
275       printf("\n*** 'esd-config --version' returned %d.%d.%d, but the minimum version\n", $esd_major_version, $esd_minor_version, $esd_micro_version);
276       printf("*** of ESD required is %d.%d.%d. If esd-config is correct, then it is\n", major, minor, micro);
277       printf("*** best to upgrade to the required version.\n");
278       printf("*** If esd-config was wrong, set the environment variable ESD_CONFIG\n");
279       printf("*** to point to the correct copy of esd-config, and remove the file\n");
280       printf("*** config.cache before re-running configure\n");
281       return 1;
282     }
283 }
284
285 ],, no_esd=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
286        CFLAGS="$ac_save_CFLAGS"
287        LIBS="$ac_save_LIBS"
288      fi
289   fi
290   if test "x$no_esd" = x ; then
291      AC_MSG_RESULT(yes)
292      ifelse([$2], , :, [$2])     
293   else
294      AC_MSG_RESULT(no)
295      if test "$ESD_CONFIG" = "no" ; then
296        echo "*** The esd-config script installed by ESD could not be found"
297        echo "*** If ESD was installed in PREFIX, make sure PREFIX/bin is in"
298        echo "*** your path, or set the ESD_CONFIG environment variable to the"
299        echo "*** full path to esd-config."
300      else
301        if test -f conf.esdtest ; then
302         :
303        else
304           echo "*** Could not run ESD test program, checking why..."
305           CFLAGS="$CFLAGS $ESD_CFLAGS"
306           LIBS="$LIBS $ESD_LIBS"
307           AC_TRY_LINK([
308 #include <stdio.h>
309 #include <esd.h>
310 ],      [ return 0; ],
311         [ echo "*** The test program compiled, but did not run. This usually means"
312           echo "*** that the run-time linker is not finding ESD or finding the wrong"
313           echo "*** version of ESD. If it is not finding ESD, you'll need to set your"
314           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
315           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
316           echo "*** is required on your system"
317           echo "***"
318           echo "*** If you have an old version installed, it is best to remove it, although"
319           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"],
320         [ echo "*** The test program failed to compile or link. See the file config.log for the"
321           echo "*** exact error that occured. This usually means ESD was incorrectly installed"
322           echo "*** or that you have moved ESD since it was installed. In the latter case, you"
323           echo "*** may want to edit the esd-config script: $ESD_CONFIG" ])
324           CFLAGS="$ac_save_CFLAGS"
325           LIBS="$ac_save_LIBS"
326        fi
327      fi
328      ESD_CFLAGS=""
329      ESD_LIBS=""
330      ifelse([$3], , :, [$3])
331   fi
332   AC_SUBST(ESD_CFLAGS)
333   AC_SUBST(ESD_LIBS)
334   rm -f conf.esdtest
335 ])
336
337 dnl CHECK_DLSYM_UNDERSCORE([ACTION-IF-NEED [, ACTION IF-NOT-NEED]])
338 dnl variable input:
339 dnl   CC CFLAGS CPPFLAGS LDFLAGS LIBS SHCFLAGS SHLD SHLDFLAGS
340 dnl   ac_cv_header_dlfcn_h lib_dl_opt so
341 AC_DEFUN(CHECK_DLSYM_UNDERSCORE,
342 [dnl Check if dlsym need a leading underscore
343 AC_MSG_CHECKING(whether your dlsym() needs a leading underscore)
344 AC_CACHE_VAL(timidity_cv_func_dlsym_underscore,
345 [case "$ac_cv_header_dlfcn_h" in
346 yes) i_dlfcn=define;;
347 *)   i_dlfcn=undef;;
348 esac
349 cat > dyna.c <<EOM
350 fred () { }
351 EOM
352
353 cat > fred.c <<EOM
354 #include <stdio.h>
355 #$i_dlfcn I_DLFCN
356 #ifdef I_DLFCN
357 #include <dlfcn.h>      /* the dynamic linker include file for Sunos/Solaris */
358 #else
359 #include <sys/types.h>
360 #include <nlist.h>
361 #include <link.h>
362 #endif
363
364 extern int fred() ;
365
366 main()
367 {
368     void * handle ;
369     void * symbol ;
370 #ifndef RTLD_LAZY
371     int mode = 1 ;
372 #else
373     int mode = RTLD_LAZY ;
374 #endif
375     handle = dlopen("./dyna.$so", mode) ;
376     if (handle == NULL) {
377         printf ("1\n") ;
378         fflush (stdout) ;
379         exit(0);
380     }
381     symbol = dlsym(handle, "fred") ;
382     if (symbol == NULL) {
383         /* try putting a leading underscore */
384         symbol = dlsym(handle, "_fred") ;
385         if (symbol == NULL) {
386             printf ("2\n") ;
387             fflush (stdout) ;
388             exit(0);
389         }
390         printf ("3\n") ;
391     }
392     else
393         printf ("4\n") ;
394     fflush (stdout) ;
395     exit(0);
396 }
397 EOM
398 : Call the object file tmp-dyna.o in case dlext=o.
399 if ${CC-cc} $CFLAGS $SHCFLAGS $CPPFLAGS -c dyna.c > /dev/null 2>&1 &&
400         mv dyna.o tmp-dyna.o > /dev/null 2>&1 &&
401         $SHLD $SHLDFLAGS -o dyna.$so tmp-dyna.o > /dev/null 2>&1 &&
402         ${CC-cc} -o fred $CFLAGS $CPPFLAGS $LDFLAGS fred.c $LIBS $lib_dl_opt > /dev/null 2>&1; then
403         xxx=`./fred`
404         case $xxx in
405         1)      AC_MSG_WARN(Test program failed using dlopen.  Perhaps you should not use dynamic loading.)
406                 ;;
407         2)      AC_MSG_WARN(Test program failed using dlsym.  Perhaps you should not use dynamic loading.)
408                 ;;
409         3)      timidity_cv_func_dlsym_underscore=yes
410                 ;;
411         4)      timidity_cv_func_dlsym_underscore=no
412                 ;;
413         esac
414 else
415         AC_MSG_WARN(I can't compile and run the test program.)
416 fi
417 rm -f dyna.c dyna.o dyna.$so tmp-dyna.o fred.c fred.o fred
418 ])
419 case "x$timidity_cv_func_dlsym_underscore" in
420 xyes)   [$1]
421         AC_MSG_RESULT(yes)
422         ;;
423 xno)    [$2]
424         AC_MSG_RESULT(no)
425         ;;
426 esac
427 ])
428
429
430 dnl contains program from perl5
431 dnl CONTAINS_INIT()
432 AC_DEFUN(CONTAINS_INIT,
433 [dnl Some greps do not return status, grrr.
434 AC_MSG_CHECKING(whether grep returns status)
435 echo "grimblepritz" >grimble
436 if grep blurfldyick grimble >/dev/null 2>&1 ; then
437         contains="./contains"
438 elif grep grimblepritz grimble >/dev/null 2>&1 ; then
439         contains=grep
440 else
441         contains="./contains"
442 fi
443 rm -f grimble
444 dnl the following should work in any shell
445 case "$contains" in
446 grep)   AC_MSG_RESULT(yes)
447         ;;
448 ./contains)
449         AC_MSG_RESULT(AGH!  Grep doesn't return a status.  Attempting remedial action.)
450         cat >./contains <<'EOSS'
451 grep "[$]1" "[$]2" >.greptmp && cat .greptmp && test -s .greptmp
452 EOSS
453         chmod +x "./contains"
454         ;;
455 esac
456 ])
457
458
459 dnl CONTAINS(word,filename,action-if-found,action-if-not-found)
460 AC_DEFUN(CONTAINS,
461 [if $contains "^[$1]"'[$]' $2 >/dev/null 2>&1; then
462   [$3]
463 else
464   [$4]
465 fi
466 ])
467
468
469 dnl SET_UNIQ_WORDS(shell-variable,words...)
470 AC_DEFUN(SET_UNIQ_WORDS,
471 [rm -f wordtmp >/dev/null 2>&1
472 val=''
473 for f in $2; do
474   CONTAINS([$f],wordtmp,:,[echo $f >>wordtmp; val="$val $f"])
475 done
476 $1="$val"
477 rm -f wordtmp >/dev/null 2>&1
478 ])
479
480
481 dnl WAPI_CHECK_FUNC(FUNCTION, INCLUDES, TEST-BODY,
482                     [ACTION-FI-FOUND [, ACTION-IF-NOT-FOUND]])
483 AC_DEFUN(WAPI_CHECK_FUNC,
484 [AC_MSG_CHECKING(for $1)
485 AC_CACHE_VAL(wapi_cv_func_$1,
486 [AC_TRY_LINK([#include <windows.h>
487 $2
488 ], [$3],
489 wapi_cv_func_$1=yes, wapi_cv_func_$1=no)])
490 if eval "test \"`echo '$wapi_cv_func_'$1`\" = yes"; then
491   AC_MSG_RESULT(yes)
492   ifelse([$4], , :, [$4])
493 else
494   AC_MSG_RESULT(no)
495 ifelse([$5], , , [$5
496 ])dnl
497 fi
498 ])
499
500
501 dnl WAPI_CHECK_LIB(LIBRARY, FUNCTION,
502 dnl             INCLUDES, TEST-BODY
503 dnl             [, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND
504 dnl             [, OTHER-LIBRARIES]]])
505 AC_DEFUN(WAPI_CHECK_LIB,
506 [AC_MSG_CHECKING([for $2 in -l$1])
507 ac_lib_var=`echo $1['_']$2 | sed 'y%./+-%__p_%'`
508 AC_CACHE_VAL(wapi_cv_lib_$ac_lib_var,
509 [ac_save_LIBS="$LIBS"
510 LIBS="-l$1 $7 $LIBS"
511 AC_TRY_LINK([#include <windows.h>
512 $3
513 ], [$4],
514 eval "wapi_cv_lib_$ac_lib_var=yes",
515 eval "wapi_cv_lib_$ac_lib_var=no")
516 LIBS="$ac_save_LIBS"
517 ])dnl
518 if eval "test \"`echo '$wapi_cv_lib_'$ac_lib_var`\" = yes"; then
519   AC_MSG_RESULT(yes)
520   ifelse([$5], ,LIBS="-l$1 $LIBS", [$5])
521 else
522   AC_MSG_RESULT(no)
523 ifelse([$6], , , [$6
524 ])dnl
525 fi
526 ])
527
528
529 dnl EXTRACT_CPPFLAGS(CPPFLAGS-to-append,others-to-append,FLAGS)
530 AC_DEFUN(EXTRACT_CPPFLAGS,
531 [for f in $3; do
532     case ".$f" in
533         .-I?*|.-D?*)    $1="[$]$1 $f" ;;
534         *)              $2="[$]$1 $f" ;;
535     esac
536 done
537 ])
538
539
540 dnl CHECK_COMPILER_OPTION(OPTIONS [, ACTION-IF-SUCCESS [, ACTION-IF-FAILED]])
541 AC_DEFUN(CHECK_COMPILER_OPTION,
542 [AC_MSG_CHECKING([whether -$1 option is recognized])
543 ac_ccoption=`echo $1 | sed 'y%./+-%__p_%'`
544 AC_CACHE_VAL(timidity_cv_ccoption_$ac_ccoption,
545 [cat > conftest.$ac_ext <<EOF
546 int main() {return 0;}
547 EOF
548 if ${CC-cc} $LDFLAGS $CFLAGS -o conftest${ac_exeext} -$1 conftest.$ac_ext > conftest.out 2>&1; then
549     if test -s conftest.out; then
550         eval "timidity_cv_ccoption_$ac_ccoption=no"
551     else
552         eval "timidity_cv_ccoption_$ac_ccoption=yes"
553     fi
554 else
555     eval "timidity_cv_ccoption_$ac_ccoption=no"
556 fi
557 ])
558 if eval "test \"`echo '$timidity_cv_ccoption_'$ac_ccoption`\" = yes"; then
559   AC_MSG_RESULT(yes)
560   ifelse([$2], , , [$2
561 ])
562 else
563   AC_MSG_RESULT(no)
564 ifelse([$3], , , [$3
565 ])
566 fi
567 ])
568
569 # Define a conditional.
570
571 AC_DEFUN(AM_CONDITIONAL,
572 [AC_SUBST($1_TRUE)
573 AC_SUBST($1_FALSE)
574 if $2; then
575   $1_TRUE=
576   $1_FALSE='#'
577 else
578   $1_TRUE='#'
579   $1_FALSE=
580 fi])
581
582 # Do all the work for Automake.  This macro actually does too much --
583 # some checks are only needed if your package does certain things.
584 # But this isn't really a big deal.
585
586 # serial 1
587
588 dnl Usage:
589 dnl AM_INIT_AUTOMAKE(package,version, [no-define])
590
591 AC_DEFUN(AM_INIT_AUTOMAKE,
592 [AC_REQUIRE([AC_PROG_INSTALL])
593 PACKAGE=[$1]
594 AC_SUBST(PACKAGE)
595 VERSION=[$2]
596 AC_SUBST(VERSION)
597 dnl test to see if srcdir already configured
598 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then
599   AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
600 fi
601 ifelse([$3],,
602 AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
603 AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package]))
604 AC_REQUIRE([AM_SANITY_CHECK])
605 AC_REQUIRE([AC_ARG_PROGRAM])
606 dnl FIXME This is truly gross.
607 missing_dir=`cd $ac_aux_dir && pwd`
608 AM_MISSING_PROG(ACLOCAL, aclocal, $missing_dir)
609 AM_MISSING_PROG(AUTOCONF, autoconf, $missing_dir)
610 AM_MISSING_PROG(AUTOMAKE, automake, $missing_dir)
611 AM_MISSING_PROG(AUTOHEADER, autoheader, $missing_dir)
612 AM_MISSING_PROG(MAKEINFO, makeinfo, $missing_dir)
613 AC_REQUIRE([AC_PROG_MAKE_SET])])
614
615 #
616 # Check to make sure that the build environment is sane.
617 #
618
619 AC_DEFUN(AM_SANITY_CHECK,
620 [AC_MSG_CHECKING([whether build environment is sane])
621 # Just in case
622 sleep 1
623 echo timestamp > conftestfile
624 # Do `set' in a subshell so we don't clobber the current shell's
625 # arguments.  Must try -L first in case configure is actually a
626 # symlink; some systems play weird games with the mod time of symlinks
627 # (eg FreeBSD returns the mod time of the symlink's containing
628 # directory).
629 if (
630    set X `ls -Lt $srcdir/configure conftestfile 2> /dev/null`
631    if test "[$]*" = "X"; then
632       # -L didn't work.
633       set X `ls -t $srcdir/configure conftestfile`
634    fi
635    if test "[$]*" != "X $srcdir/configure conftestfile" \
636       && test "[$]*" != "X conftestfile $srcdir/configure"; then
637
638       # If neither matched, then we have a broken ls.  This can happen
639       # if, for instance, CONFIG_SHELL is bash and it inherits a
640       # broken ls alias from the environment.  This has actually
641       # happened.  Such a system could not be considered "sane".
642       AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
643 alias in your environment])
644    fi
645
646    test "[$]2" = conftestfile
647    )
648 then
649    # Ok.
650    :
651 else
652    AC_MSG_ERROR([newly created file is older than distributed files!
653 Check your system clock])
654 fi
655 rm -f conftest*
656 AC_MSG_RESULT(yes)])
657
658 dnl AM_MISSING_PROG(NAME, PROGRAM, DIRECTORY)
659 dnl The program must properly implement --version.
660 AC_DEFUN(AM_MISSING_PROG,
661 [AC_MSG_CHECKING(for working $2)
662 # Run test in a subshell; some versions of sh will print an error if
663 # an executable is not found, even if stderr is redirected.
664 # Redirect stdin to placate older versions of autoconf.  Sigh.
665 if ($2 --version) < /dev/null > /dev/null 2>&1; then
666    $1=$2
667    AC_MSG_RESULT(found)
668 else
669    $1="$3/missing $2"
670    AC_MSG_RESULT(missing)
671 fi
672 AC_SUBST($1)])
673
674 # Like AC_CONFIG_HEADER, but automatically create stamp file.
675
676 AC_DEFUN(AM_CONFIG_HEADER,
677 [AC_PREREQ([2.12])
678 AC_CONFIG_HEADER([$1])
679 dnl When config.status generates a header, we must update the stamp-h file.
680 dnl This file resides in the same directory as the config header
681 dnl that is generated.  We must strip everything past the first ":",
682 dnl and everything past the last "/".
683 AC_OUTPUT_COMMANDS(changequote(<<,>>)dnl
684 ifelse(patsubst(<<$1>>, <<[^ ]>>, <<>>), <<>>,
685 <<test -z "<<$>>CONFIG_HEADERS" || echo timestamp > patsubst(<<$1>>, <<^\([^:]*/\)?.*>>, <<\1>>)stamp-h<<>>dnl>>,
686 <<am_indx=1
687 for am_file in <<$1>>; do
688   case " <<$>>CONFIG_HEADERS " in
689   *" <<$>>am_file "*<<)>>
690     echo timestamp > `echo <<$>>am_file | sed -e 's%:.*%%' -e 's%[^/]*$%%'`stamp-h$am_indx
691     ;;
692   esac
693   am_indx=`expr "<<$>>am_indx" + 1`
694 done<<>>dnl>>)
695 changequote([,]))])
696
697
698 # serial 1
699
700 AC_DEFUN(AM_PATH_LISPDIR,
701  [# If set to t, that means we are running in a shell under Emacs.
702   # If you have an Emacs named "t", then use the full path.
703   test "$EMACS" = t && EMACS=
704   AC_PATH_PROGS(EMACS, emacs xemacs, no)
705   if test $EMACS != "no"; then
706     AC_MSG_CHECKING([where .elc files should go])
707     dnl Set default value
708     lispdir="\$(datadir)/emacs/site-lisp"
709     emacs_flavor=`echo "$EMACS" | sed -e 's,^.*/,,'`
710     if test "x$prefix" = "xNONE"; then
711       if test -d $ac_default_prefix/share/$emacs_flavor/site-lisp; then
712         lispdir="\$(prefix)/share/$emacs_flavor/site-lisp"
713       else
714         if test -d $ac_default_prefix/lib/$emacs_flavor/site-lisp; then
715           lispdir="\$(prefix)/lib/$emacs_flavor/site-lisp"
716         fi
717       fi
718     else
719       if test -d $prefix/share/$emacs_flavor/site-lisp; then
720         lispdir="\$(prefix)/share/$emacs_flavor/site-lisp"
721       else
722         if test -d $prefix/lib/$emacs_flavor/site-lisp; then
723           lispdir="\$(prefix)/lib/$emacs_flavor/site-lisp"
724         fi
725       fi
726     fi
727     AC_MSG_RESULT($lispdir)
728   fi
729   AC_SUBST(lispdir)])
730
731 # Configure paths for GTK+
732 # Owen Taylor     97-11-3
733
734 dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
735 dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS
736 dnl
737 AC_DEFUN(AM_PATH_GTK,
738 [dnl 
739 dnl Get the cflags and libraries from the gtk-config script
740 dnl
741 AC_ARG_WITH(gtk-prefix,[  --with-gtk-prefix=PFX   Prefix where GTK is installed (optional)],
742             gtk_config_prefix="$withval", gtk_config_prefix="")
743 AC_ARG_WITH(gtk-exec-prefix,[  --with-gtk-exec-prefix=PFX Exec prefix where GTK is installed (optional)],
744             gtk_config_exec_prefix="$withval", gtk_config_exec_prefix="")
745 AC_ARG_ENABLE(gtktest, [  --disable-gtktest       Do not try to compile and run a test GTK program],
746                     , enable_gtktest=yes)
747
748   if test x$gtk_config_exec_prefix != x ; then
749      gtk_config_args="$gtk_config_args --exec-prefix=$gtk_config_exec_prefix"
750      if test x${GTK_CONFIG+set} != xset ; then
751         GTK_CONFIG=$gtk_config_exec_prefix/bin/gtk-config
752      fi
753   fi
754   if test x$gtk_config_prefix != x ; then
755      gtk_config_args="$gtk_config_args --prefix=$gtk_config_prefix"
756      if test x${GTK_CONFIG+set} != xset ; then
757         GTK_CONFIG=$gtk_config_prefix/bin/gtk-config
758      fi
759   fi
760
761   AC_PATH_PROG(GTK_CONFIG, gtk-config, no)
762   min_gtk_version=ifelse([$1], ,0.99.7,$1)
763   AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
764   no_gtk=""
765   if test "$GTK_CONFIG" = "no" ; then
766     no_gtk=yes
767   else
768     GTK_CFLAGS=`$GTK_CONFIG $gtk_config_args --cflags`
769     GTK_LIBS=`$GTK_CONFIG $gtk_config_args --libs`
770     gtk_config_major_version=`$GTK_CONFIG $gtk_config_args --version | \
771            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
772     gtk_config_minor_version=`$GTK_CONFIG $gtk_config_args --version | \
773            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
774     gtk_config_micro_version=`$GTK_CONFIG $gtk_config_args --version | \
775            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
776     if test "x$enable_gtktest" = "xyes" ; then
777       ac_save_CFLAGS="$CFLAGS"
778       ac_save_LIBS="$LIBS"
779       CFLAGS="$CFLAGS $GTK_CFLAGS"
780       LIBS="$LIBS $GTK_LIBS"
781 dnl
782 dnl Now check if the installed GTK is sufficiently new. (Also sanity
783 dnl checks the results of gtk-config to some extent
784 dnl
785       rm -f conf.gtktest
786       AC_TRY_RUN([
787 #include <gtk/gtk.h>
788 #include <stdio.h>
789
790 int 
791 main ()
792 {
793   int major, minor, micro;
794   char *tmp_version;
795
796   system ("touch conf.gtktest");
797
798   /* HP/UX 9 (%@#!) writes to sscanf strings */
799   tmp_version = g_strdup("$min_gtk_version");
800   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
801      printf("%s, bad version string\n", "$min_gtk_version");
802      exit(1);
803    }
804
805   if ((gtk_major_version != $gtk_config_major_version) ||
806       (gtk_minor_version != $gtk_config_minor_version) ||
807       (gtk_micro_version != $gtk_config_micro_version))
808     {
809       printf("\n*** 'gtk-config --version' returned %d.%d.%d, but GTK+ (%d.%d.%d)\n", 
810              $gtk_config_major_version, $gtk_config_minor_version, $gtk_config_micro_version,
811              gtk_major_version, gtk_minor_version, gtk_micro_version);
812       printf ("*** was found! If gtk-config was correct, then it is best\n");
813       printf ("*** to remove the old version of GTK+. You may also be able to fix the error\n");
814       printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
815       printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
816       printf("*** required on your system.\n");
817       printf("*** If gtk-config was wrong, set the environment variable GTK_CONFIG\n");
818       printf("*** to point to the correct copy of gtk-config, and remove the file config.cache\n");
819       printf("*** before re-running configure\n");
820     } 
821   else
822     {
823       if ((gtk_major_version > major) ||
824         ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
825         ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)))
826       {
827         return 0;
828        }
829      else
830       {
831         printf("\n*** An old version of GTK+ (%d.%d.%d) was found.\n",
832                gtk_major_version, gtk_minor_version, gtk_micro_version);
833         printf("*** You need a version of GTK+ newer than %d.%d.%d. The latest version of\n",
834                major, minor, micro);
835         printf("*** GTK+ is always available from ftp://ftp.gtk.org.\n");
836         printf("***\n");
837         printf("*** If you have already installed a sufficiently new version, this error\n");
838         printf("*** probably means that the wrong copy of the gtk-config shell script is\n");
839         printf("*** being found. The easiest way to fix this is to remove the old version\n");
840         printf("*** of GTK+, but you can also set the GTK_CONFIG environment to point to the\n");
841         printf("*** correct copy of gtk-config. (In this case, you will have to\n");
842         printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
843         printf("*** so that the correct libraries are found at run-time))\n");
844       }
845     }
846   return 1;
847 }
848 ],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
849        CFLAGS="$ac_save_CFLAGS"
850        LIBS="$ac_save_LIBS"
851      fi
852   fi
853   if test "x$no_gtk" = x ; then
854      AC_MSG_RESULT(yes)
855      ifelse([$2], , :, [$2])     
856   else
857      AC_MSG_RESULT(no)
858      if test "$GTK_CONFIG" = "no" ; then
859        echo "*** The gtk-config script installed by GTK could not be found"
860        echo "*** If GTK was installed in PREFIX, make sure PREFIX/bin is in"
861        echo "*** your path, or set the GTK_CONFIG environment variable to the"
862        echo "*** full path to gtk-config."
863      else
864        if test -f conf.gtktest ; then
865         :
866        else
867           echo "*** Could not run GTK test program, checking why..."
868           CFLAGS="$CFLAGS $GTK_CFLAGS"
869           LIBS="$LIBS $GTK_LIBS"
870           AC_TRY_LINK([
871 #include <gtk/gtk.h>
872 #include <stdio.h>
873 ],      [ return ((gtk_major_version) || (gtk_minor_version) || (gtk_micro_version)); ],
874         [ echo "*** The test program compiled, but did not run. This usually means"
875           echo "*** that the run-time linker is not finding GTK or finding the wrong"
876           echo "*** version of GTK. If it is not finding GTK, you'll need to set your"
877           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
878           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
879           echo "*** is required on your system"
880           echo "***"
881           echo "*** If you have an old version installed, it is best to remove it, although"
882           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH"
883           echo "***"
884           echo "*** If you have a RedHat 5.0 system, you should remove the GTK package that"
885           echo "*** came with the system with the command"
886           echo "***"
887           echo "***    rpm --erase --nodeps gtk gtk-devel" ],
888         [ echo "*** The test program failed to compile or link. See the file config.log for the"
889           echo "*** exact error that occured. This usually means GTK was incorrectly installed"
890           echo "*** or that you have moved GTK since it was installed. In the latter case, you"
891           echo "*** may want to edit the gtk-config script: $GTK_CONFIG" ])
892           CFLAGS="$ac_save_CFLAGS"
893           LIBS="$ac_save_LIBS"
894        fi
895      fi
896      GTK_CFLAGS=""
897      GTK_LIBS=""
898      ifelse([$3], , :, [$3])
899   fi
900   AC_SUBST(GTK_CFLAGS)
901   AC_SUBST(GTK_LIBS)
902   rm -f conf.gtktest
903 ])
904