OSDN Git Service

Concerning compilaton with vcc or bcc in Msys or cygwin environment.
[timidity41/timidity41.git] / configure.in
1 dnl TiMidity++ -- MIDI to WAVE converter and player
2 dnl Copyright (C) 1999-2002 Masanao Izumo <mo@goice.co.jp>
3 dnl Copyright (C) 1995 Tuukka Toivonen <tt@cgs.fi>
4 dnl
5 dnl This program is free software; you can redistribute it and/or modify
6 dnl it under the terms of the GNU General Public License as published by
7 dnl the Free Software Foundation; either version 2 of the License, or
8 dnl (at your option) any later version.
9 dnl
10 dnl This program is distributed in the hope that it will be useful,
11 dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
12 dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 dnl GNU General Public License for more details.
14 dnl
15 dnl You should have received a copy of the GNU General Public License
16 dnl along with this program; if not, write to the Free Software
17 dnl Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18
19 dnl configure.in created from configure.scan
20 dnl by URABE, Shyouhei <root@mput.dip.jp> on 2002.07.06
21
22 dnl variable note:
23 dnl CFLAGS      - Flags for compile.
24 dnl CPPFLAGS    - Flags for cpp
25 dnl LDFLAGS     - Flags for linker
26 dnl             ac_cpp:     $CPP $CPPFLAGS
27 dnl             ac_compile: ${CC-cc} -c $CFLAGS $CPPFLAGS
28 dnl             ac_link:    ${CC-cc} -o * $CFLAGS $CPPFLAGS $LDFLAGS *.c $LIBS
29 dnl EXTRACFLAGS - Extra flags to compile.  Adds to CFLAGS.
30 dnl EXTRADEFS   - Extra define macros.  Adds to CPPFLAGS.
31 dnl EXTRALIBS   - Extra libraries  Adds to LIBS.
32 dnl SYSEXTRAS   - Additional source codes to compile.
33 dnl lib_*_opt   - Optional libraries. Adds to LIBS.
34 dnl LIBRARY_PATH
35 dnl             - add to -L LDFLAGS
36 dnl C_INCLUDE_PATH
37 dnl             - add to -I CPPFLAGS
38 dnl CYGNUS      - `yes' if cygnus windows environment.
39 dnl MSYS        - `yes' if Mingw windows environment.
40 dnl WISH        - wish
41 dnl LN_S        - ln -s
42 dnl tcltk_dep   - make dependencies for tcl/tk interface
43 dnl
44 dnl so          - File extension of shared object library.
45 dnl SHLD        - Linker to make shared object library.
46 dnl SHLDFLAGS   - Link flags to link shared object library.
47 dnl SHCFLAGS    - Additional flags to compile shared object library.
48 dnl               (such as -fPIC)
49
50 # This is a autoscan-generated configure.scan.
51 # AC_PREREQ(2.56)
52
53 # "AC_INIT(timidity/timidity.c)" is obsolate yet.
54 AC_INIT([TiMidity++],[current],[root@mput.dip.jp],[TiMidity++])
55 AC_CONFIG_AUX_DIR([autoconf])
56 AC_CANONICAL_TARGET
57 AM_INIT_AUTOMAKE([gnu dist-bzip2])
58 AC_CONFIG_SRCDIR([timidity/timidity.c])
59 AC_CONFIG_HEADERS([config.h interface.h])
60 AM_MAINTAINER_MODE
61
62 SHELL=${CONFIG_SHELL-"/bin/sh"}
63 WISH=${WISH-"wish"}
64
65 dnl to use contains() macro (see autoconf/acinclude.m4)
66 CONTAINS_INIT
67
68 # Check for compiler options -- such as debug flags.
69
70 dnl "--enable-debug" turnes -g on.
71 AC_MSG_CHECKING(if --enable-debug option specified)
72 AC_ARG_ENABLE(debug,
73   [  --enable-debug          Build a debugging version.],
74   [timidity_cv_debug="yes"], [timidity_cv_debug="no"])
75 if test "x$timidity_cv_debug" = "xyes"; then
76   AC_DEFINE(DEBUG,1,Define to 1 if you are in debug mode)
77   CFLAGS=${CFLAGS-"-g"}
78 fi
79 if test "x$timidity_cv_debug" = "xno"; then
80   AC_DEFINE(NDEBUG,1,Define to 1 if you are NOT in debug mode)
81 fi
82 AC_MSG_RESULT($timidity_cv_debug)
83
84 CFLAGS=${CFLAGS-"-O2"}
85
86 dnl --with-x turns on if `--with-x' is NOT specified.
87 if test "x$with_x" = x; then
88   with_x=yes
89 else
90   x_config_flag=yes
91 fi
92
93 # Checking gcc environment
94 for i in `echo $LIBRARY_PATH|sed -e 's,:, ,g'`; do
95   LDFLAGS="$LDFLAGS -L${i}"
96 done
97 for i in `echo $C_INCLUDE_PATH|sed -e 's,:, ,g'`; do
98   CPPFLAGS="$CPPFLAGS -I${i}"
99 done
100
101 # add $prefix if specified.
102 if test "x$prefix" != xNONE -a "x$prefix" != "x$ac_default_prefix" -a "x$prefix" != "x/usr"; then
103   LDFLAGS="-L$prefix/lib $LDFLAGS"
104   SHLDFLAGS="-L$prefix/lib $SHLDFLAGS"
105   CPPFLAGS="-I$prefix/include $CPPFLAGS"
106 fi
107
108 dnl add --with-includes, --with-libraries
109 AC_ARG_WITH(includes,
110   [  --with-includes=DIR     Specify include directories (colon separated)],
111   [ j=' '
112     for i in `echo "$withval"|sed -e 's,:, ,g'`; do
113       j="${j}-I${i} "
114     done
115     CPPFLAGS="$j$CPPFLAGS"
116   ])
117
118 AC_ARG_WITH(libraries,
119   [  --with-libraries=DIR    Specify library directories (colon separated)],
120   [ j=' '
121     for i in `echo "$withval"|sed -e 's,:, ,g'`; do
122       j="${j}-L${i} "
123     done
124     LDFLAGS="$j$LDFLAGS"
125   ])
126
127
128 dnl a bit hairly yet.(20020718:mput)
129 dnl CPPFLAGS="$CPPFLAGS \$(DEF_PKGDATADIR) \$(DEF_PKGLIBDIR) \$(DEF_DEFAULT_PATH)"
130 AC_ARG_WITH(default-path,
131   [  --with-default-path=DIR Where timidity.cfg is  (PREFIX/share/timidity)],
132   [pkgdatadir=$withval],
133   [
134    if test "x$prefix" != "xNONE"; then
135       pkgdatadir='${prefix}/share/timidity'
136    else
137       pkgdatadir='/usr/local/share/timidity'
138    fi
139   ])
140 tmpdefpath="`eval \"echo ${pkgdatadir}\"`"
141 AC_DEFINE_UNQUOTED(DEFAULT_PATH,"$tmpdefpath",place to install patches)
142 AC_DEFINE(PKGDATADIR,DEFAULT_PATH,a compatibility matter. ignore it.)
143
144 AC_ARG_WITH(module-dir,
145   [  --with-module-dir=DIR   Where to install interfaces (PREFIX/lib/timidity)],
146   [pkglibdir=$withval],
147   [
148    if test "x$prefix" != "xNONE"; then
149       pkglibdir='${prefix}/lib/timidity'
150    else
151       pkglibdir='/usr/local/lib/timidity'
152    fi
153   ])
154 tmplibdir="`eval \"echo ${pkglibdir}\"`"
155 AC_DEFINE_UNQUOTED(PKGLIBDIR,"$tmplibdir",place to install modules)
156
157
158 # Checks for programs.
159 AM_PATH_LISPDIR
160 AC_PROG_CC
161 AC_PROG_GCC_TRADITIONAL
162 AC_PROG_INSTALL
163 AC_PROG_AWK
164 AC_PROG_RANLIB
165 AC_PROG_LN_S
166 CHECK_COMPILER_OPTION(rdynamic)
167
168 # Checks for target dependencies
169
170 AC_ARG_WITH(elf,
171   [  --with-elf              create ELF shared object instead of AOUT ],
172   [ ELFFORMAT=$withval ], [ ELFFORMAT="yes" ])
173
174 # AC_ARG_WITH(simd,
175 #  [  --with-simd             create SIMD friendly binary (default is no) ],
176 #  [ SIMD=$withval ], [ SIMD="no" ])
177
178 case "$target" in
179   *-*-hpux*)
180     EXTRADEFS="-DHPUX"
181     test -n "$SHLD" || SHLD="ld -b"
182     so="sl"
183     ;;
184   *-sgi-irix*)
185     dnl IRIX cc needs -signed option
186     case ".$CC" in .cc*) EXTRACFLAGS="-signed";; esac
187     test -n "$SHLD" || SHLD="cc -shared -all"
188     so="so"
189     ;;
190   *-*-netbsd*)
191     test -n "$SHLD" || SHLD="$CC -shared -nostartfiles"
192     so="so"
193     ;;
194
195   *-*-freebsd2*)
196     dnl EXTRALIBS="$EXTRALIBS -lxpg4"
197     test -n "$SHLD" || SHLD="ld -Bshareable"
198     so="so"
199     ;;
200   *-*-freebsd*)
201     if test "$ELFFORMAT" = yes; then
202         test -n "$SHLD" || SHLD="ld -Bshareable"
203     else
204         SHCFLAGS=-aou
205         SHLDFLAGS="-L/usr/X11R6/lib/aout $SHLDFLAGS"
206         test -n "$SHLD" || SHLD="env OBJFORMAT=aout ld -shared"
207     fi
208     dnl EXTRALIBS="$EXTRALIBS -lxpg4"
209     so="so"
210     ;;
211
212 #  *-*-freebsd*)
213 #    EXTRALIBS="$EXTRALIBS -lxpg4"
214 #    test -n "$SHLD" || SHLD="ld -Bshareable"
215 #    so="so"
216 #  ;;
217
218   *-*-cygwin*)
219     EXTRADEFS="-D__W32__"
220     # ??
221     case "x${CC} " in
222       "xbcc32 "*) 
223 #        test -n "$SHLD" || SHLD="tlink32 -Tpd"
224         test -n "$SHLD" || SHLD="BCC32 -WD"
225         BORLANDC=yes
226         BORLANDC_LDFLAGS="kernel32.lib winspool.lib comdlg32.lib advapi32.lib oleaut32.lib uuid.lib odbc32.lib wsock32.lib user32.lib shell32.lib cw32mt.lib"
227                 BORLANDC_START='C0X32.OBJ'
228         CFLAGS="$CFLAGS  -tWM -VM"
229         EXTRADEFS="$EXTRADEFS -D_WINDOWS -DWIN32"
230         ;;
231       "xcl "*)
232          test -n "$SHLD" || SHLD="link -dll" 
233          VCPP_LDFLAGS="-nologo -incremental:no  -nodefaultlib:libc.lib -nodefaultlib:msvcrt.lib kernel32.lib winspool.lib comdlg32.lib advapi32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib user32.lib shell32.lib libcmt.lib"
234          CFLAGS="$CFLAGS -nologo -Zp16 -MT -W3 -GX  -Ob2"
235          EXTRADEFS="$EXTRADEFS -DNDEBUG -D_WINDOWS -DWIN32 -DMBCS -D_MT -YX  -FD -c"
236          VCPP=yes
237          ;;
238       "xgcc"*) test -n "$SHLD" || SHLD="gcc -mdll" ;;
239       *) test -n "$SHLD" || SHLD="unknown" ;;
240     esac
241     so="dll"
242     CYGNUS=yes
243     lib_user32_test=-luser32
244     ;;
245   *-*-mingw*)
246     EXTRADEFS="-D__W32__"
247     # ??
248     case "x${CC} " in
249       "xbcc32 "*) 
250 #        test -n "$SHLD" || SHLD="tlink32 -Tpd"
251         test -n "$SHLD" || SHLD="BCC32 -WD"
252         BORLANDC=yes
253         BORLANDC_LDFLAGS="kernel32.lib winspool.lib comdlg32.lib advapi32.lib oleaut32.lib uuid.lib odbc32.lib wsock32.lib user32.lib shell32.lib cw32mt.lib"
254         BORLANDC_START='C0X32.OBJ'
255         CFLAGS="$CFLAGS  -tWM -VM"
256         EXTRADEFS="$EXTRADEFS -D_WINDOWS -DWIN32"
257         ;;
258       "xcl "*) 
259          test -n "$SHLD" || SHLD="link -dll"
260          VCPP=yes
261          VCPP_LDFLAGS="-nologo -incremental:no  -nodefaultlib:libc.lib -nodefaultlib:msvcrt.lib kernel32.lib winspool.lib comdlg32.lib advapi32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib user32.lib shell32.lib libcmt.lib"
262          CFLAGS="$CFLAGS -nologo -Zp16 -MT -W3 -GX  -Ob2"
263          EXTRADEFS="$EXTRADEFS -DNDEBUG -D_WINDOWS -DWIN32 -DMBCS -D_MT -YX  -FD -c"
264          ;;
265       "xgcc"*) test -n "$SHLD" || SHLD="gcc -mdll" ;;
266       *) test -n "$SHLD" || SHLD="unknown" ;;
267     esac
268     so="dll"
269     MSYS=yes
270     lib_user32_test=-luser32
271     ;;
272   *-dec-*)
273     EXTRADEFS="-DDEC"
274     test -n "$SHLD" || SHLD="ld -Bdynamic -G"
275     so="so"
276     ;;
277   *-*-solaris*)
278     EXTRADEFS="-DSOLARIS"
279     test -n "$SHLD" || SHLD="/usr/ccs/bin/ld -G"
280     so="so"
281     ;;
282   *-*-nextstep*)
283     test -n "$SHLD" || SHLD="/usr/ccs/bin/ld -G"
284     so="so"
285     ;;
286   *-*-darwin*)
287     if test "x$SIMD" = "xyes"; then
288        AC_DEFINE(USE_ALTIVEC,1,Define to 1 if you use altivec)
289        # EXTRACFLAGS="$EXTRACFLAGS -faltivec -mabi=altivec -maltivec" # for GCC3.
290        EXTRACFLAGS="$EXTRACFLAGS -faltivec"
291     else
292        AC_DEFINE(USE_ALTIVEC,0,Define to 1 if you use altivec)
293     fi
294     CPPFLAGS="$CPPFLAGS -no-cpp-precomp"
295     LDOPTS="-dynamic -undefined suppress -flat_namespace $LDOPTS"
296     test -n "$SHLD" || SHLD="$CC -dynamic -bundle -undefined suppress -flat_namespace $LDFLAGS"
297     so="bundle"
298     ;;
299   *)
300     test -n "$SHLD" || \
301       if test "x$GCC" = xyes; then
302         SHLD="$CC -shared"
303       else
304         SHLD="ld -Bdynamic -G"
305       fi
306     so="so"
307     ;;
308 esac
309
310 dnl For .exe
311 dnl AC_EXEEX # obsolate
312
313 # Checks for libraries.
314 AC_CHECK_LIB(m,sqrt)
315 AC_CHECK_LIB(socket,socket)
316 AC_CHECK_LIB(dl,dlopen,lib_dl_opt=-ldl)
317 AC_CHECK_LIB(objc,NSLinkModule,lib_dl_opt=-lobjc) # Mac OS X need this.
318 if test "x$VCPP" != "xyes" && test "x$BORLANDC" != "xyes"; then
319 AC_CHECK_LIB(xpg4,setlocale) # Mac OS X (and maybe NetBSD) need this.
320 fi
321 AC_CHECK_FUNCS(gethostbyname,,[ AC_CHECK_LIB(nsl,gethostbyname) ])
322 AC_PATH_XTRA
323
324 # Checks for X
325 if test "x$with_x" = xyes; then
326   if test "x$have_x" = xno; then
327     if test "x$x_config_flag" = xyes; then
328       AC_MSG_ERROR(Could not configure X)
329     else
330       AC_MSG_WARN(Could not configure X)
331     fi
332   fi
333 fi
334 if test "x$with_x" = xyes -a "x$have_x" = xyes; then
335   if test "x$x_libraries" != x; then
336     ldflags_x_opt="-L$x_libraries"
337     LDFLAGS="$LDFLAGS $ldflags_x_opt"
338     SHLDFLAGS="$SHLDFLAGS $ldflags_x_opt"
339   else
340     ldflags_x_opt=
341   fi
342   if test "x$x_includes" != x; then
343     CPPFLAGS="$CPPFLAGS -I$x_includes"
344   fi
345
346   AC_CHECK_LIB(X11,XOpenDisplay)
347   AC_MSG_CHECKING(X11 version 6)
348   AC_CACHE_VAL(timidity_cv_x11_version_6,
349     AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>]], [[
350 #if XlibSpecificationRelease < 6
351 fail;
352 #endif
353 ]])],[timidity_cv_x11_version_6=yes],[timidity_cv_x11_version_6=no]))
354   if test "$timidity_cv_x11_version_6" = "yes"; then
355     AC_MSG_RESULT(6 or newer)
356     dnl AC_DEFINE(HAVE_X11R6)
357   else
358     AC_MSG_RESULT(before 6)
359   fi
360
361   dnl checking order required
362   KEEPLIBS=$LIBS
363   AC_CHECK_LIB(Xext,XShapeCombineMask,have_xext=yes; LIBS="-lXext $LIBS",have_xext=no)
364   AC_CHECK_LIB(ICE,IceConnectionNumber)
365   AC_CHECK_LIB(SM,SmcOpenConnection,have_xprelibs=yes; LIBS="-lSM $LIBS",have_xprelibs=no)
366   AC_CHECK_LIB(Xt,XtVaAppInitialize,have_xt=yes; LIBS="-lXt $LIBS",have_xt=no)
367   AC_CHECK_LIB(Xmu,XmuInternAtom,LIBS="-lXmu $LIBS")
368   AC_CHECK_FUNCS(XmuRegisterExternalAgent)
369   AC_CHECK_LIB(Xaw3d,XawInitializeWidgetSet,have_xaw=3d,
370    [ AC_CHECK_LIB(Xaw,XawInitializeWidgetSet,have_xaw=yes,have_xaw=no) ])
371   AC_CHECK_LIB(Xm,XmCreateForm,have_xm=yes,have_xm=no)
372   AC_CHECK_FUNCS(XShmCreatePixmap)
373   LIBS=$KEEPLIBS
374 fi
375 dnl End of X configure
376
377 # Checks for header files.
378 AC_HEADER_STDC
379 AC_HEADER_STDBOOL
380 AC_HEADER_SYS_WAIT
381 AC_HEADER_TIME
382 AC_HEADER_DIRENT
383 AC_CHECK_HEADERS( \
384   [arpa/inet.h \
385   errno.h \
386   getopt.h \
387   glob.h \
388   dlfcn.h \
389   fcntl.h \
390   inttypes.h \
391   limits.h \
392   machine/endian.h \
393   memory.h \
394   netdb.h \
395   netinet/in.h \
396   nlist.h \
397   stddef.h \
398   stdlib.h \
399   stdint.h \
400   string.h \
401   strings.h \
402   stropts.h \
403   soundcard.h \
404   alsa/asoundlib.h \
405   sys/asoundlib.h \
406   sys/audioio.h \
407   sys/awe_voice.h\
408   sys/ioctl.h \
409   sys/ipc.h \
410   sys/param.h \
411   sys/shm.h \
412   sys/socket.h \
413   sys/soundcard.h \
414   sys/param.h \
415   sys/time.h \
416   sys/types.h \
417   sys/sysctl.h \
418   termios.h \
419   unistd.h \
420   X11/Xlib.h])
421 AC_CHECK_HEADERS(\
422   [X11/extensions/XShm.h X11/Xmu/ExtAgent.h],[],[],[
423 #ifdef HAVE_X11_XLIB_H
424 #include <X11/Xlib.h>
425 #endif
426   ])
427 AC_CHECK_HEADER(string.h,, [ AC_DEFINE(NO_STRING_H,1,Define to 1 if you do not have <string.h>.)])
428 if test "x$VCPP" != xyes && test "x$BORLANDC" != xyes; then
429 AC_CHECK_HEADERS([malloc.h])
430 fi
431
432 # Checks for typedefs, structures, and compiler characteristics.
433 AC_C_BIGENDIAN
434 AC_C_CHAR_UNSIGNED
435 AC_C_CONST
436 AC_C_INLINE
437 AC_C_VOLATILE
438 AC_C_STRINGIZE
439 AC_C_PROTOTYPES
440 AC_STRUCT_TM
441 AC_TYPE_SIZE_T
442 AC_TYPE_OFF_T
443 AC_TYPE_PID_T
444
445 dnl keyword "volatile" check
446 AC_CACHE_CHECK(volatile declaration,timidity_cv_type_volatile,
447   AC_COMPILE_IFELSE([AC_LANG_PROGRAM(, [[volatile int x]])],[timidity_cv_type_volatile=yes],[timidity_cv_type_volatile=no]))
448 if test $timidity_cv_type_volatile = no; then
449   AC_DEFINE(NO_VOLATILE,1,Define to 1 if you cannot use volatile keyword)
450 fi
451
452 dnl union usenum check
453 AC_CACHE_CHECK(union semun declaration,timidity_cv_type_union_semun,
454   AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
455 #include <sys/types.h>
456 #include <sys/ipc.h>
457 #include <sys/sem.h>
458 ]], [[union semun x]])],[timidity_cv_type_union_semun=yes],[timidity_cv_type_union_semun=no]))
459 if test $timidity_cv_type_union_semun = yes; then
460   AC_DEFINE(HAVE_UNION_SEMUN,1,Define to 1 if you use semun keyword)
461 fi
462
463 dnl Cygnus and Mingw memory struct optiontest
464 if test "x$CYGNUS" = xyes || test "x$MSYS" = xyes; then
465         case "x${CC}" in
466         "xgcc"*) 
467                 msnative_struct=''
468             AC_MSG_CHECKING([how to get MSVC-compatible struct packing])
469             if test -z "$ac_cv_prog_CC"; then
470                         our_gcc="$CC"
471                 else
472                         our_gcc="$ac_cv_prog_CC"
473                 fi
474                 case `$our_gcc --version | sed -e 's,\..*,.,' -e q` in
475                         2.)
476                 if $our_gcc -v --help 2>/dev/null | grep fnative-struct >/dev/null; then
477                         msnative_struct='-fnative-struct'
478                 fi
479                 ;;
480                         *)
481                 if $our_gcc -v --help 2>/dev/null | grep ms-bitfields >/dev/null; then
482                         msnative_struct='-mms-bitfields'
483                 fi
484                 ;;
485                 esac
486                 if test x"$msnative_struct" = x ; then
487                         AC_MSG_RESULT([no way])
488                         AC_MSG_WARN([produced binary will be incompatible with windows' GUI ])
489                 else
490                         CFLAGS="$CFLAGS $msnative_struct"
491                         CPPFLAGS="$CPPFLAGS $msnative_struct"
492                         AC_MSG_RESULT([${msnative_struct}])
493                 fi
494                 ;;
495         *) 
496                 ;;
497         esac
498 fi
499 dnl Cygnus Mingw32 mmsystem check
500 if test "x$CYGNUS" = xyes || test "x$MSYS" = xyes; then
501   AC_CACHE_CHECK(Cygwin new mmsystem,timidity_cv_header_new_mmsystem,
502     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
503 #include <windows.h>
504 #include <mmsystem.h>
505 ]], [[return WOM_OPEN != 0x3BB]])],[timidity_cv_header_new_mmsystem=yes],[timidity_cv_header_new_mmsystem=no]))
506   if test $timidity_cv_header_new_mmsystem = yes; then
507     AC_DEFINE(HAVE_NEW_MMSYSTEM,1,Define to 1 if you have <mmsystem.h> file)
508   fi
509 fi
510
511 # Checks for library functions.
512 AC_FUNC_ERROR_AT_LINE
513 AC_FUNC_FORK
514 AC_FUNC_MEMCMP
515 AC_FUNC_MMAP
516 AC_FUNC_SETVBUF_REVERSED
517 AC_TYPE_SIGNAL
518 if test "x$VCPP" != xyes && test "x$BORLANDC" != xyes; then
519 AC_FUNC_VPRINTF
520 fi
521 AC_CHECK_FUNCS( \
522   [alarm \
523   dup2 \
524   floor \
525   getcwd \
526   getopt \
527   gethostbyname \
528   gettimeofday \
529   getwd \
530   isatty \
531   memchr \
532   memmove \
533   memset \
534   modf \
535   munmap \
536   popen \
537   pow \
538   select \
539   signal \
540   socket \
541   sleep \
542   vsnprintf \
543   snprintf \
544   sqrt \
545   strchr \
546   strdup \
547   strstr \
548   strerror \
549   strcasecmp \
550   strncasecmp \
551   strrchr \
552   strstr \
553   strtol \
554   usleep])
555 if test "x$VCPP" = xyes || test "x$BORLANDC" = xyes; then
556   AC_DEFINE(RETSIGTYPE,int)
557   AC_DEFINE(HAVE_GETCWD,int)
558   AC_DEFINE(HAVE_GETHOSTBYNAME,1)
559   AC_DEFINE(HAVE_POPEN,1)
560   AC_DEFINE(popen,_popen,[for VC])
561   AC_DEFINE(pclose,_pclose,[for VC])
562   AC_DEFINE(HAVE_SELECT,1)
563   AC_DEFINE(HAVE_SNPRINTF,1)
564   AC_DEFINE(HAVE_STRDUP,1)
565   AC_DEFINE(HAVE_STRERROR,1)
566   AC_DEFINE(HAVE_STRNCASECMP,1)
567   AC_DEFINE(HAVE_STRSTR,1)
568   AC_DEFINE(snprintf,_snprintf,[for VC])
569   AC_DEFINE(HAVE_SOCKET,1)
570   AC_DEFINE(HAVE_VSNPRINTF,1)
571   AC_DEFINE(vsnprintf,_vsnprintf,[for VC])
572   AC_DEFINE(TIMID_VERSION,[$(PACKAGE_VERSION)],[for windows gui])
573   AC_DEFINE(DEFAULT_PATH,[".\\"],[for windows])
574 fi
575
576 AC_CHECK_FUNC(getopt_long,
577          AC_DEFINE([HAVE_GETOPT_LONG],1,[Define to 1 if you have `getopt_long function'])
578          tm_cv_needgetopt="no",
579          tm_cv_needgetopt="yes")
580 AM_CONDITIONAL([NEEDGETOPT], test "x$tm_cv_needgetopt" = "xyes")
581
582 # Checks on cygnus and MYSYS
583 if test "x$CYGNUS" = xyes || test "x$MSYS" = xyes; then
584   case "$ac_cv_header_dirent_dirent_h$ac_cv_header_dirent_sys_ndir_h$ac_cv_header_dirent_sys_dir_h$ac_cv_header_dirent_ndir_h" in
585   *yes*)
586     AC_CHECK_FUNC(opendir,,
587   [ EXTRADEFS="$EXTRADEFS -D__W32READDIR__"
588     W32READDIR=yes ])
589     ;;
590   *)EXTRADEFS="$EXTRADEFS -D__W32READDIR__"
591     W32READDIR=yes
592     ;;
593   esac
594   if test "x$enable_network" = "xyes"; then
595         if test "x$VCPP" = xyes || test "x$BORLANDC" = xyes; then
596       EXTRALIBS="$EXTRALIBS  wsock32.lib"
597       EXTRADEFS="$EXTRADEFS -DWINSOCK" 
598     else
599       AC_CHECK_FUNC(socket,,
600        WAPI_CHECK_LIB(wsock32,WSAStartup,
601              [#include <winsock.h>],
602              [WSAStartup(0,0);],
603          [ EXTRALIBS="$EXTRALIBS -lwsock32"
604           EXTRADEFS="$EXTRADEFS -DWINSOCK" ]
605        )
606       )
607     fi
608   fi
609 fi
610
611 # Checks on extra paths
612
613 dnl tcltk paths
614 AC_ARG_WITH(tcl-includes,
615   [  --with-tcl-includes=DIR Tcl include file path ],
616   [ if test ! -d $withval; then
617       AC_MSG_WARN($withval is not found.)
618     fi
619     tcl_include_dir="-I$withval"
620   ])
621 AC_ARG_WITH(tcl-libs,
622   [  --with-tcl-libs=DIR     Tcl library file path ],
623   [ if test ! -d $withval; then
624       AC_MSG_WARN($withval is not found.)
625     fi
626     tcl_libdir="-L$withval" ])
627 AC_ARG_WITH(tk-includes,
628   [  --with-tk-includes=DIR  Tk include file path ],
629   [ if test ! -d $withval; then
630       AC_MSG_WARN($withval is not found.)
631     fi
632     tk_includes="-I$withval" ])
633 AC_ARG_WITH(tk-libs,
634   [  --with-tk-libs=DIR      Tk library file path ],
635   [ if test ! -d $withval; then
636       AC_MSG_WARN($withval is not found.)
637     fi
638     tk_libdir="-L$withval" ])
639
640 dnl offix paths
641 AC_ARG_WITH(offix-includes,
642   [  --with-offix-includes=DIR Offix include file path ],
643   [ if test ! -d $withval; then
644       AC_MSG_WARN($withval is not found.)
645     fi
646     offix_include_dir="-I$withval" ])
647 AC_ARG_WITH(offix-libs,
648   [  --with-offix-libs=DIR   Offix include file path ],
649   [ if test ! -d $withval; then
650       AC_MSG_WARN($withval is not found.)
651     fi
652     offix_lib_dir="-L$withval" ])
653
654
655 #
656 # audio section
657 #
658 dnl default(d): auto selection
659 dnl oss(d):     OSS /dev/dsp
660 dnl alsa(d):    ALSA pcm device
661 dnl sun(d):     SunOS /dev/audio
662 dnl hpux(d):    HPUX /dev/audio
663 dnl irix(d):    IRIX audio
664 dnl mme(d):     OSF/1 MME
665 dnl sb_dsp(d):  BSD/OS 2.0 /dev/sb_dsp
666 dnl w32(d):     Windows MMS
667 dnl darwin(d):  Mac OS X pcm device
668 dnl alsa(s):    ALSA pcm device
669 dnl alib(A):    HPUX network audio (Alib)
670 dnl nas(n):     Network Audio System
671 dnl arts(R):    aRts
672 dnl esd(e):     EsounD
673 dnl portaudio(p) PortAudio
674 dnl vorbis(v):  Ogg Vorbis
675 dnl flac(F):    FLAC / OggFLAC
676 dnl speex(S):   Ogg Speex
677 dnl gogo(g):    MP3 GOGO
678 dnl jack(j):    JACK
679 dnl ao(O):      Libao
680
681 audio_targets='default oss alsa sun hpux irix mme sb_dsp w32 alib nas arts esd vorbis flac gogo portaudio jack ao'
682
683 AC_ARG_WITH(nas-library,
684   [  --with-nas-library=library NAS absolute library path(Don't use -laudio)])
685 AC_ARG_WITH(nas-includes,
686   [  --with-nas-includes=DIR NAS include files are in dir])
687
688
689 AC_ARG_ENABLE(audio,
690   [  --enable-audio[=mode_list] Enable audio (Specify comma separated mode list):
691                               default:   Automatically select audio device.
692                               oss:       OSS /dev/dsp
693                               sun:       SunOS /dev/audio
694                               hpux:      HPUX /dev/audio
695                               irix:      IRIX audio library
696                               mme:       OSF/1 MME
697                               sb_dsp:    BSD/OS 2.0 /dev/sb_dsp
698                               w32:       Windows MMS
699                               darwin:    Darwin CoreAudio
700                               alsa:      ALSA pcm device
701                               alib:      HPUX network audio (Alib)
702                               nas:       NAS - Network Audio System
703                               arts:      aRts
704                               esd:       EsounD - Enlightened Sound Daemon
705                               portaudio: PortAudio
706                               jack:      JACK
707                               ao:        Libao
708                               vorbis:    Ogg Vorbis
709                               flac:      FLAC / OggFLAC
710                               speex:     Ogg Speex
711                               gogo:      MP3 GOGO (Only Windows is supported)],
712   [ enable_audio=$enableval
713     have_audio_opt=yes ],
714   [ enable_audio=yes
715     have_audio_opt=no ])
716
717 dnl yes -> default
718 test "x$enable_audio" = xyes && enable_audio=default
719
720 if test "x$enable_audio" != xno; then
721   for i in `echo $enable_audio | sed 's/,/ /g'`; do
722     eval "au_enable_$i=yes"
723   done
724 fi
725
726 dnl Turn on default output mode
727 DEFAULT_PLAYMODE=
728 AC_ARG_WITH(default-output,
729   [  --with-default-output=<mode>  Specify default output mode (optional):
730                                 (default|alsa|alib|arts|nas|
731                                 esd|wav|au|aiff|list|vorbis|flac|speex|
732                                 gogo|portaudio|jack|ao)],
733   [ if test "$enable_audio" != no; then
734     DEFAULT_PLAYMODE=$withval
735     eval "au_enable_$DEFAULT_PLAYMODE=yes"
736   else
737     AC_MSG_WARN(--with-default-output=$withval: audio is not enabled)
738   fi])
739
740 dnl compatibility matters.
741 dnl AC_ARG_ENABLE(esd,
742 dnl   [  --enable-esd         EsounD (Obsoleted.  Use --enable-audio=esd)],
743 dnl   [ au_enable_esd=$enableval ])
744 dnl AC_ARG_ENABLE(nas,
745 dnl   [  --enable-nas         NAS  (Obsoleted.  Use --enable-audio=nas)],
746 dnl   [ au_enable_nas=$enableval ])
747 dnl AC_ARG_ENABLE(alsa,
748 dnl   [  --enable-alsa        ALSA   (Obsoleted.  Use --enable-audio=alsa)],
749 dnl   [ au_enable_alsa=$enableval ])
750
751 dnl target-specific defaults
752 if test "x$au_enable_default" = xyes; then
753   case "$target" in
754   *-*-linux*|*-*-freebsd*)
755     au_enable_oss=yes
756     ;;
757   *-*-bsdi2.0)
758     au_enable_sb_dsp=yes
759     ;;
760   *-*-bsdi2.1|*-*-bsdi3.?|*-*-bsdi4.?)
761     au_enable_oss=yes
762     ;;
763   *-*-hpux*)
764     au_enable_hpux=yes
765     ;;
766   *-dec-*)
767     au_enable_mme=yes
768     ;;
769   *irix*)
770     au_enable_irix=yes
771     ;;
772   *-*-sunos4*)
773     au_enable_sun=yes
774     ;;
775   *-*-solaris*)
776     au_enable_sun=yes
777     ;;
778   *-*-netbsd*)
779     au_enable_sun=yes
780     ;;
781   *-*-cygwin*)
782     au_enable_w32=yes
783     ;;
784   *-*-mingw*)
785     au_enable_w32=yes
786     ;;
787   *-*-darwin*)
788     au_enable_darwin=yes
789     ;;
790   *)
791     AC_MSG_WARN(No --enable-audio=default audio for $target)
792     ;;
793   esac
794 fi
795
796
797 # Each audio mode's configurations
798 dnl oss
799 AC_MSG_CHECKING(enable_audio=oss)
800 if test "x$au_enable_oss" = xyes; then
801   EXTRADEFS="$EXTRADEFS -DAU_OSS"
802   SYSEXTRAS="$SYSEXTRAS oss_a.c"
803   if test "x$ac_cv_header_sys_soundcard_h" = xyes; then
804     AC_MSG_RESULT(yes - <sys/soundcard.h>)
805   else
806     case "$target" in
807       *linux*|*freebsd*)
808         dnl <linux/soundcard.h> or <machine/soundcard.h>
809         AC_MSG_RESULT(yes)
810         ;;
811       *)
812         if test "x$ac_cv_header_soundcard_h" = xyes; then
813           AC_MSG_RESULT(yes - <soundcard.h>)
814         else
815           AC_MSG_WARN(<sys/soundcard.h> is not found)
816         fi
817         ;;
818     esac
819   fi
820   AC_CHECK_LIB(ossaudio,open)
821
822   dnl Why OpenBSD use /dev/audio instead of /dev/dsp for OSS
823   case "$target" in
824     *openbsd*)
825       if test ! -e "/dev/dsp"; then
826         oss_device=/dev/audio
827       fi
828       ;;
829   esac
830 else
831   AC_MSG_RESULT(no)
832 fi
833
834 dnl SunOS's
835 AC_MSG_CHECKING(enable_audio=sun)
836 if test "x$au_enable_sun" = xyes; then
837   case "$target" in
838     *-*-sunos4*)
839       if test -f /usr/demo/SOUND/libaudio.a; then
840         EXTRALIBS="$EXTRALIBS /usr/demo/SOUND/libaudio.a"
841         AC_MSG_RESULT(yes)
842       else
843         AC_MSG_RESULT(Notice: libaudio.a is not found [(ignore)])
844       fi
845       ;;
846     *-*-solaris*)
847       if test -f /usr/demo/SOUND/lib/libaudio.a; then
848         EXTRALIBS="$EXTRALIBS /usr/demo/SOUND/lib/libaudio.a"
849         AC_MSG_RESULT(yes)
850       else
851         AC_MSG_RESULT(Notice: libaudio.a is not found [(ignore)])
852       fi
853       ;;
854     *)   AC_MSG_RESULT(yes)
855       ;;
856   esac
857   EXTRADEFS="$EXTRADEFS -DAU_SUN"
858   SYSEXTRAS="$SYSEXTRAS sun_a.c"
859 else
860   AC_MSG_RESULT(no)
861 fi
862
863 dnl HP-UX's
864 AC_MSG_CHECKING(enable_audio=hpux)
865 if test "x$au_enable_hpux" = xyes; then
866   case "$target" in
867     *-*-hpux*) AC_MSG_RESULT(yes) ;;
868     *) AC_MSG_WARN(may not work on $target) ;;
869   esac
870   EXTRADEFS="$EXTRADEFS -DAU_HPUX_AUDIO"
871   SYSEXTRAS="$SYSEXTRAS hpux_d_a.c"
872 else
873   AC_MSG_RESULT(no)
874 fi
875
876 dnl Irix's
877 AC_MSG_CHECKING(enable_audio=irix)
878 if test "x$au_enable_irix" = xyes; then
879   case "$target" in
880     *-sgi-irix5*|*-sgi-irix6.2)
881       EXTRADEFS="$EXTRADEFS -DAU_AUDRIV -DSGI_OLDAL"
882       AC_MSG_RESULT(yes)
883       ;;
884     *-sgi-irix6*)
885       EXTRADEFS="$EXTRADEFS -DAU_AUDRIV -DSGI_NEWAL"
886       AC_MSG_RESULT(yes)
887       ;;
888     *) AC_MSG_WARN(may not work on $target) ;;
889   esac
890   SYSEXTRAS="$SYSEXTRAS audriv_a.c audriv_al.c"
891   EXTRALIBS="$EXTRASLIBS -laudio"
892 else
893   AC_MSG_RESULT(no)
894 fi
895
896 dnl OSF/1 MME
897 AC_MSG_CHECKING(enable_audio=mme)
898 if test "x$au_enable_mme" = xyes; then
899   case "$target" in
900     *-dec-*) AC_MSG_RESULT(yes) ;;
901     *) AC_MSG_WARN(may not work on $target) ;;
902   esac
903   EXTRADEFS="$EXTRADEFS -DAU_DEC -DAU_AUDRIV"
904   SYSEXTRAS="$SYSEXTRAS audriv_a.c audriv_mme.c"
905   CPPFLAGS="$CPPFLAGS -I/usr/opt/MME210/include"
906   EXTRALIBS="$EXTRALIBS /usr/opt/MME220/lib/libmme.a"
907 else
908   AC_MSG_RESULT(no)
909 fi
910
911 dnl BSD/OS's sb_dsp
912 AC_MSG_CHECKING(enable_audio=sb_dsp)
913 if test "x$au_enable_sb_dsp" = xyes; then
914   case "$target" in
915     *-*-bsdi2.0) AC_MSG_RESULT(yes) ;;
916     *) AC_MSG_WARN(may not work on $target) ;;
917   esac
918   EXTRADEFS="$EXTRADEFS -DAU_BSDI -DDEFAULT_RATE=22500"
919   SYSEXTRAS="$SYSEXTRAS bsd20_a.c"
920 else
921   AC_MSG_RESULT(no)
922 fi
923
924 dnl Windows' MME
925 AC_MSG_CHECKING(enable_audio=w32)
926 if test "x$au_enable_w32" = xyes; then
927   case "$target" in
928     *-*-cygwin*)
929      AC_MSG_RESULT(yes)
930      ;;
931     *-*-mingw32)
932      AC_MSG_RESULT(yes)
933      ;;
934     *)
935      AC_MSG_WARN(may not work on $target)
936      ;;
937   esac
938   SYSEXTRAS="$SYSEXTRAS w32_a.c"
939   if test "x$VCPP" = xyes || test "x$BORLANDC" = xyes; then
940         EXTRALIBS="$EXTRALIBS winmm.lib"
941   else
942     EXTRALIBS="$EXTRALIBS -lwinmm"
943   fi
944   EXTRADEFS="$EXTRADEFS -DAU_W32"
945 else
946   AC_MSG_RESULT(no)
947 fi
948
949 dnl Mac OS X / darwin-x86
950 AC_MSG_CHECKING(enable_audio=darwin)
951 if test "x$au_enable_darwin" = xyes; then
952   EXTRADEFS="$EXTRADEFS -DAU_DARWIN"
953   SYSEXTRAS="$SYSEXTRAS darwin_a.c"
954   EXTRALIBS="$EXTRALIBS -framework CoreAudio"
955   dnl just say yes or no :-P
956   case "$target" in
957     *-*-darwin*)
958      AC_MSG_RESULT(yes);;
959    *)
960      AC_MSG_WARN(may not work on $target)
961      ;;
962   esac
963 else
964   AC_MSG_RESULT(no)
965 fi
966
967
968 dnl alsa - Advanced Linux Sound Architecture
969 AC_MSG_CHECKING(enable_audio=alsa)
970 if test "x$au_enable_alsa" = xyes; then
971   AC_MSG_RESULT([yes, configuring alsa])
972   KEEPCFLAGS=$CFLAGS
973   KEEPLIBS=$LIBS
974   KEEPLDFLAGS=$LDFLAGS
975   AM_PATH_ALSA()
976   if test "x$alsa_found" = "xyes" ; then
977     dnl AC_MSG_RESULT(yes)
978     EXTRADEFS="$EXTRADEFS -DAU_ALSA"
979     SYSEXTRAS="$SYSEXTRAS alsa_a.c"
980     EXTRACT_CPPFLAGS(CPPFLAGS,CFLAGS,$ALSA_CFLAGS)
981     LIBS="$LIBS $ALSA_LIBS"
982     AC_CHECK_FUNCS(snd_seq_port_info_set_timestamping)
983   else
984     AC_MSG_WARN(Couldn't configure alsa.)
985     CFLAGS=$KEEPCFLAGS
986     LIBS=$KEEPLIBS
987     LDFLAGS=$KEEPLDFLAGS
988   fi
989 else
990   AC_MSG_RESULT(no)
991 fi
992
993 dnl HP-UX Alib
994 AC_MSG_CHECKING(enable_audio=alib)
995 if test "x$au_enable_alib" = xyes; then
996   case "$target" in
997     *-*-hpux*) AC_MSG_RESULT(yes) ;;
998     *) AC_MSG_WARN(may not work on $target) ;;
999   esac
1000   SYSEXTRAS="$SYSEXTRAS hpux_a.c"
1001   EXTRADEFS="$EXTRADEFS -DAU_HPUX_ALIB"
1002   if test -d /opt/audio/include; then
1003     CPPFLAGS="$CPPFLAGS -I/opt/audio/include"
1004   fi
1005   if test -d /opt/audio/lib; then
1006     EXTRALIBS="$EXTRALIBS -L/opt/audio/lib"
1007   fi
1008   EXTRALIBS="$EXTRALIBS -lAlib"
1009 else
1010   AC_MSG_RESULT(no)
1011 fi
1012
1013 dnl nas
1014 AC_MSG_CHECKING(enable_audio=nas)
1015 if test "x$au_enable_nas" = xyes; then
1016   if test "x$with_x" != xyes; then
1017     AC_MSG_ERROR(nas: --with-x option must be specified)
1018   fi
1019   EXTRADEFS="$EXTRADEFS -DAU_NAS"
1020   SYSEXTRAS="$SYSEXTRAS nas_a.c"
1021
1022   dnl -laudio conflicts another audio library,
1023   dnl so I specify NAS library with absolete path.
1024
1025   if test "x$with_nas_library" != x; then
1026     AC_MSG_RESULT($with_nas_library);
1027     EXTRALIBS="$EXTRALIBS $with_nas_library"
1028   else
1029     AC_MSG_RESULT()
1030     MY_SEARCH_LIBS(AuOpenServer,
1031         [$x_libraries/libaudio.a \
1032          /usr/lib/libaudio.so \
1033          /usr/lib/libaudio.a ],
1034         [ AC_MSG_RESULT(NAS: $timidity_cv_search_AuOpenServer)
1035           EXTRALIBS="$EXTRALIBS $timidity_cv_search_AuOpenServer"],
1036         [AC_MSG_WARN(NAS library is not found.)])
1037   fi
1038   test "x$with_nas_includes" != x && CPPFLAGS="$CPPFLAGS -I$with_nas_includes"
1039   lib_xt_opt=-lXt
1040   if test "x$have_xext" = xyes; then
1041     lib_xext_opt=-lXext
1042   fi
1043   if test "x$have_xprelibs" = xyes; then
1044     lib_xprelibs_opt='-lSM -lICE'
1045   fi
1046 else
1047   AC_MSG_RESULT(no)
1048 fi
1049
1050 dnl aRts of KDE
1051 AC_MSG_CHECKING(enable_audio=arts)
1052 if test "x$au_enable_arts" = xyes; then
1053   AC_MSG_RESULT([yes, configuring aRts])
1054   KEEPCFLAGS=$CFLAGS
1055   KEEPLIBS=$LIBS
1056   KEEPLDFLAGS=$LDFLAGS
1057   AM_PATH_ARTS()
1058   CFLAGS=$KEEPCFLAGS
1059   LIBS=$KEEPLIBS
1060   LDFLAGS=$KEEPLDFLAGS
1061   if test "x$no_arts" = x; then
1062     dnl AC_MSG_RESULT(aRts: Enabled)
1063     EXTRADEFS="$EXTRADEFS -DAU_ARTS"
1064     SYSEXTRAS="$SYSEXTRAS aRts_a.c"
1065     EXTRACT_CPPFLAGS(CPPFLAGS,CFLAGS,$ARTS_CFLAGS)
1066     LIBS="$LIBS $ARTS_LIBS"
1067   else
1068     AC_MSG_WARN(aRts: Couldn't configure)
1069   fi
1070 else
1071   AC_MSG_RESULT(no)
1072 fi
1073
1074 dnl EsounD
1075 AC_MSG_CHECKING(enable_audio=esd)
1076 if test "x$au_enable_esd" = xyes; then
1077   AC_MSG_RESULT([yes, configuring esd])
1078   KEEPCFLAGS=$CFLAGS
1079   KEEPLIBS=$LIBS
1080   KEEPLDFLAGS=$LDFLAGS
1081   AM_PATH_ESD()
1082   CFLAGS=$KEEPCFLAGS
1083   LIBS=$KEEPLIBS
1084   LDFLAGS=$KEEPLDFLAGS
1085   if test "x$no_esd" = x; then
1086     dnl AC_MSG_RESULT(EsounD: Enabled)
1087     EXTRADEFS="$EXTRADEFS -DAU_ESD"
1088     SYSEXTRAS="$SYSEXTRAS esd_a.c"
1089     EXTRACT_CPPFLAGS(CPPFLAGS,CFLAGS,$ESD_CFLAGS)
1090     LIBS="$LIBS $ESD_LIBS"
1091   else
1092     AC_MSG_WARN(EsounD: Couldn't configure)
1093   fi
1094 else
1095   AC_MSG_RESULT(no)
1096 fi
1097
1098 dnl portaudio E
1099 AC_MSG_CHECKING(enable_audio=portaudio)
1100 if test "x$au_enable_portaudio" = xyes; then
1101   AC_MSG_RESULT(yes)
1102   if test "x$CYGNUS" = xyes ||test "x$MSYS" = xyes; then
1103         SYSEXTRAS="$SYSEXTRAS portaudio_a.c w32_portaudio_dll.c"
1104         EXTRALIBS="$EXTRALIBS -lportaudio"
1105         EXTRADEFS="$EXTRADEFS -DAU_PORTAUDIO -DAU_PORTAUDIO_DLL"
1106   else
1107         SYSEXTRAS="$SYSEXTRAS portaudio_a.c"
1108         EXTRALIBS="$EXTRALIBS -lportaudio"
1109         EXTRADEFS="$EXTRADEFS -DAU_PORTAUDIO"
1110   fi
1111 else
1112   AC_MSG_RESULT(no)
1113 fi
1114
1115 dnl JACK
1116 AC_MSG_CHECKING(enable_audio=jack)
1117 if test "x$au_enable_jack" = xyes; then
1118   AC_MSG_RESULT(yes)
1119   SYSEXTRAS="$SYSEXTRAS jack_a.c"
1120   EXTRALIBS="$EXTRALIBS $(pkg-config --libs jack)"
1121   EXTRADEFS="$EXTRADEFS -DAU_JACK $(pkg-config --cflags jack)"
1122 else
1123   AC_MSG_RESULT(no)
1124 fi
1125
1126 dnl AO
1127 AC_MSG_CHECKING(enable_audio=ao)
1128 if test "x$au_enable_ao" = xyes; then
1129   AC_MSG_RESULT([yes, configuring ao])
1130   XIPH_PATH_AO()
1131   if test "x$no_ao" = "x" ; then
1132     AC_MSG_RESULT(yes)
1133     EXTRADEFS="$EXTRADEFS -DAU_AO"
1134     SYSEXTRAS="$SYSEXTRAS ao_a.c"
1135     EXTRACT_CPPFLAGS(CPPFLAGS,CFLAGS,$AO_CFLAGS)
1136     LIBS="$LIBS $AO_LIBS"
1137   else
1138     AC_MSG_WARN(Couldn't configure libao.)
1139   fi
1140 else
1141   AC_MSG_RESULT(no)
1142 fi
1143
1144 dnl ogg's vorbis
1145 AC_MSG_CHECKING(enable_audio=vorbis)
1146 if test "x$au_enable_vorbis" = xyes; then
1147   AC_MSG_RESULT([yes, configuring vorbis])
1148   AM_PATH_OGG([
1149     AM_PATH_VORBIS([
1150       have_vorbis=yes
1151       SYSEXTRAS="$SYSEXTRAS vorbis_a.c"
1152       EXTRADEFS="$EXTRADEFS -DAU_VORBIS $OGG_CFLAGS $VORBIS_CFLAGS"
1153       EXTRALIBS="$EXTRALIBS $VORBIS_LIBS $VORBISENC_LIBS $OGG_LIBS"
1154       if test "x$CYGNUS" = "xyes"; then
1155       EXTRADEFS="-DAU_VORBIS_DLL $EXTRADEFS"
1156           SYSEXTRAS="$SYSEXTRAS w32g_vorbisenc_dll.c w32g_vorbis_dll.c w32g_ogg_dll.c"
1157       fi
1158       if test "x$MSYS" = "xyes"; then
1159       EXTRADEFS="-DAU_VORBIS_DLL $EXTRADEFS"
1160           SYSEXTRAS="$SYSEXTRAS w32g_vorbisenc_dll.c w32g_vorbis_dll.c w32g_ogg_dll.c"
1161       fi
1162     ],[
1163       AC_MSG_WARN([Unable to configure vorbis, but ogg is there (???)])
1164     ])
1165   ],[
1166     AC_MSG_WARN(Unable to configure vorbis!)
1167     have_vorbis=no
1168   ])
1169 else
1170   AC_MSG_RESULT(no)
1171 fi
1172
1173 dnl libFLAC - Free Lossless Audio Codec
1174 if test "x$CYGNUS" = xyes || test "x$MSYS" = xyes ; then
1175   AC_MSG_CHECKING(enable_audio=flac)
1176   if test "x$au_enable_flac" = xyes; then
1177     AC_MSG_RESULT([yes, configuring flac])
1178     SYSEXTRAS="$SYSEXTRAS flac_a.c w32_libFLAC_dll.c w32_libOggFLAC_dll.c"
1179     AM_PATH_LIBFLAC([
1180       EXTRADEFS="$EXTRADEFS -DAU_FLAC -DAU_FLAC_DLL"
1181       EXTRACT_CPPFLAGS(CPPFLAGS,CFLAGS,$LIBFLAC_CFLAGS)
1182       LIBS="$LIBS $LIBFLAC_LIBS"
1183     ])
1184     AM_PATH_LIBOGGFLAC([
1185       EXTRADEFS="$EXTRADEFS -DAU_OGGFLAC -DAU_OGGFLAC_DLL"
1186       EXTRACT_CPPFLAGS(CPPFLAGS,CFLAGS,$LIBOGGFLAC_CFLAGS)
1187       LIBS="$LIBS $LIBOGGFLAC_LIBS"
1188     ])
1189   else
1190     AC_MSG_RESULT(no)
1191   fi
1192 else
1193   AC_MSG_CHECKING(enable_audio=flac)
1194   if test "x$au_enable_flac" = xyes; then
1195     AC_MSG_RESULT([yes, configuring flac])
1196     SYSEXTRAS="$SYSEXTRAS flac_a.c"
1197     AM_PATH_LIBFLAC([
1198       EXTRADEFS="$EXTRADEFS -DAU_FLAC"
1199       EXTRACT_CPPFLAGS(CPPFLAGS,CFLAGS,$LIBFLAC_CFLAGS)
1200       LIBS="$LIBS $LIBFLAC_LIBS"
1201     ])
1202     AM_PATH_LIBOGGFLAC([
1203       EXTRADEFS="$EXTRADEFS -DAU_OGGFLAC"
1204       EXTRACT_CPPFLAGS(CPPFLAGS,CFLAGS,$LIBOGGFLAC_CFLAGS)
1205       LIBS="$LIBS $LIBOGGFLAC_LIBS"
1206     ])
1207   else
1208     AC_MSG_RESULT(no)
1209   fi
1210 fi
1211 dnl ogg's speex
1212 AC_MSG_CHECKING(enable_audio=speex)
1213 if test "x$au_enable_speex" = xyes; then
1214   AC_CACHE_VAL(have_speex,
1215   [AC_TRY_LINK([
1216   #include <speex.h>
1217   #include <ogg/ogg.h>
1218   ],
1219   [
1220     SpeexBits *dummy;
1221   ],
1222   [have_speex=yes], [have_speex=no])])
1223   AC_MSG_RESULT($have_speex)
1224   if test "x$have_speex" = xyes; then
1225     SYSEXTRAS="$SYSEXTRAS speex_a.c"
1226     EXTRALIBS="$EXTRALIBS -lspeex -logg"
1227     EXTRADEFS="$EXTRADEFS -DAU_SPEEX"
1228   fi
1229 else
1230   AC_MSG_RESULT(no)
1231 fi
1232
1233 dnl Win32 Gogo-no-coder
1234 AC_MSG_CHECKING(enable_audio=gogo)
1235 if test "x$au_enable_gogo" = xyes; then
1236   if test "x$CYGNUS" = "xyes"; then
1237     AC_MSG_RESULT(yes, configuring gogo)
1238   else
1239     if test "x$MSYS" = "xyes"; then
1240     AC_MSG_RESULT(yes, configuring gogo)
1241     else
1242       AC_MSG_WARN(May be gogo is not supported.  You need hack the gogo_a.c)
1243     fi
1244   fi
1245   have_gogo=yes
1246   SYSEXTRAS="$SYSEXTRAS gogo_a.c w32_gogo.c"
1247   EXTRADEFS="$EXTRADEFS -DAU_GOGO -DAU_GOGO_DLL"
1248   EXTRALIBS="$EXTRALIBS -lgogo"
1249 else
1250   AC_MSG_RESULT(no)
1251 fi
1252
1253 dnl Pseudo audio device (Undocumented).
1254 if test "x$au_enable_none" = xyes; then
1255     EXTRADEFS="$EXTRADEFS -DAU_NONE -DAU_AUDRIV"
1256     SYSEXTRAS="$SYSEXTRAS audriv_a.c audriv_none.c"
1257 fi
1258 dnl
1259 dnl TIMIDITY_OUTPUT_ID
1260 dnl
1261 AC_MSG_CHECKING(default output mode)
1262 if test "x$DEFAULT_PLAYMODE" = x; then
1263   DEFAULT_PLAYMODE=`echo $enable_audio | sed 's/,.*//'`
1264 fi
1265 case ".$DEFAULT_PLAYMODE" in
1266   .default)  TIMIDITY_OUTPUT_ID=d ;;
1267   .oss)      TIMIDITY_OUTPUT_ID=d ;;
1268   .alsa)     TIMIDITY_OUTPUT_ID=s ;;
1269   .sun)      TIMIDITY_OUTPUT_ID=d ;;
1270   .hpux)     TIMIDITY_OUTPUT_ID=d ;;
1271   .irix)     TIMIDITY_OUTPUT_ID=d ;;
1272   .mme)      TIMIDITY_OUTPUT_ID=d ;;
1273   .sb_dsp)   TIMIDITY_OUTPUT_ID=d ;;
1274   .darwin)   TIMIDITY_OUTPUT_ID=d ;;
1275   .w32)      TIMIDITY_OUTPUT_ID=d ;;
1276   .alib)     TIMIDITY_OUTPUT_ID=A ;;
1277   .nas)      TIMIDITY_OUTPUT_ID=n ;;
1278   .arts)     TIMIDITY_OUTPUT_ID=R ;;
1279   .esd)      TIMIDITY_OUTPUT_ID=e ;;
1280   .portaudio)      TIMIDITY_OUTPUT_ID=p ;;  
1281   .wav)      TIMIDITY_OUTPUT_ID=w ;;
1282   .au)       TIMIDITY_OUTPUT_ID=u ;;
1283   .aiff)     TIMIDITY_OUTPUT_ID=a ;;
1284   .list)     TIMIDITY_OUTPUT_ID=l ;;
1285   .vorbis)   TIMIDITY_OUTPUT_ID=v ;;
1286   .flac)     TIMIDITY_OUTPUT_ID=F ;;
1287   .speex)    TIMIDITY_OUTPUT_ID=S ;;
1288   .gogo)     TIMIDITY_OUTPUT_ID=g ;;
1289   .jack)     TIMIDITY_OUTPUT_ID=j ;;
1290   *)         TIMIDITY_OUTPUT_ID= ;;
1291 esac
1292 AC_MSG_RESULT($DEFAULT_PLAYMODE/$TIMIDITY_OUTPUT_ID)
1293
1294 #
1295 # Interface Section
1296 #
1297
1298 interface_targets='dynamic ncurses slang motif tcltk emacs vt100 xaw xskin gtk alsaseq winsyn winsyng portmidisyng'
1299
1300 AC_ARG_ENABLE(interface,
1301   [  --enable-interface=[interface_list]
1302                           Comma separated interface list ],
1303   [ for i in `echo $enableval | sed 's/,/ /g'`; do
1304       eval "enable_$i=yes"
1305     done ])
1306
1307 #  Dynamic link configuration
1308 AC_ARG_ENABLE(dynamic,
1309   [  --enable-dynamic        Enable dynamic link interface   (default is no)
1310   --enable-dynamic=dynamic_list
1311                           Comma separated dynamic interface list],
1312   [ dnl --enable-dynamic=yes to --enable-dynamic=dynamic
1313     if test "x$enable_dynamic" = xyes; then
1314       enable_dynamic=dynamic
1315     elif test "x$enable_dynamic" != xno; then
1316       for i in `echo $enableval | sed 's/,/ /g'`; do
1317         eval "enable_$i=dynamic"
1318       done
1319     fi])
1320
1321 join_targets=
1322 for i in $interface_targets; do
1323   eval "join_targets=$join_targets\$enable_$i"
1324 done
1325
1326 case ".$join_targets" in
1327 .*dynamic*) NEEDDLOPEN=yes;;
1328 *)          NEEDDLOPEN=no;;
1329 esac
1330
1331 dnl check -fpic option for gcc
1332 if test "x$GCC" = xyes; then SHCFLAGS="$SHCFLAGS -fPIC"; fi
1333 case "x$enable_ump" in xyes|xdynamic) EXTRACFLAGS="$EXTRACFLAGS -DXP_UNIX $SHCFLAGS";; esac
1334
1335 dnl Which type of dynamic loader?
1336 if test "$NEEDDLOPEN" = "yes"; then
1337   have_dl=no
1338
1339   WAPI_CHECK_FUNC(LoadLibrary,,[LoadLibrary(0);],have_dl=w32)
1340   test $wapi_cv_func_LoadLibrary = yes && have_dl=w32
1341
1342   if test "$have_dl" = "no"; then
1343     AC_CHECK_FUNC(shl_load,have_dl=hpux)
1344   fi
1345   if test "$have_dl" = "no"; then
1346     dnl darwin has both dyld and libdl: in case user installed dlcompat.
1347     dnl dyld is recommended because libdl is a wrapper for dyld.
1348     AC_CHECK_FUNC(NSLinkModule,have_dl=dyld)
1349   fi
1350   if test "$have_dl" = "no" -a "x$ac_cv_lib_dl_dlopen" = xyes; then
1351     have_dl=dlopen
1352   fi
1353   if test "$have_dl" = "no"; then
1354     AC_CHECK_FUNC(dlopen,have_dl=dlopen)
1355   fi
1356   if test "$have_dl" = "no"; then
1357     AC_CHECK_FUNC(dld_init,have_dl=dld)
1358   fi
1359   if test "$have_dl" = "no"; then
1360     AC_CHECK_LIB(dld,dld_init,have_dl=dld;lib_dl_opt=-ldld)
1361   fi
1362
1363   AC_MSG_CHECKING(dynamic link method)
1364   case "$have_dl" in
1365     dlopen)
1366       AC_MSG_RESULT(use dl_dlopen.c)
1367       SYSEXTRAS="$SYSEXTRAS dl_dlopen.c"
1368       CHECK_DLSYM_UNDERSCORE(AC_DEFINE(DLSYM_NEEDS_UNDERSCORE,1,Define to 1 if you have to add "_" to every identifiers.))
1369       ;;
1370     dld)
1371       AC_MSG_RESULT(use dl_dld.c)
1372       SYSEXTRAS="$SYSEXTRAS dl_dld.c"
1373       ;;
1374     hpux)
1375       AC_MSG_RESULT(use dl_hpux.c)
1376       SYSEXTRAS="$SYSEXTRAS dl_hpux.c"
1377       LDFLAGS="$LDFLAGS -Wl,-E $LDFLAGS"
1378       ;;
1379     w32)
1380       AC_MSG_RESULT(use dl_w32.c)
1381       SYSEXTRAS="$SYSEXTRAS dl_w32.c"
1382       ;;
1383     dyld)
1384       AC_MSG_RESULT(use dl_dyld.c)
1385       SYSEXTRAS="$SYSEXTRAS dl_dyld.c"
1386       ;;
1387     *)
1388       NEEDDLOPEN="no"
1389       AC_MSG_WARN(no method to open a shared object)
1390       ;;
1391   esac
1392 fi
1393
1394 if test "$NEEDDLOPEN" = "yes"; then
1395   MY_DEFINE(IA_DYNAMIC)
1396   AC_DEFINE_UNQUOTED(SHARED_LIB_EXT,".$so", shared library extention)
1397   dnl needless?
1398   dnl EXTRADEFS="$EXTRADEFS \$(DEF_SHLIB_DIR)"
1399   test "x$GCC" = xyes -a "x$timidity_cv_ccoption_rdynamic" = xyes  && timidity_LDFLAGS="-rdynamic"
1400 fi
1401
1402 AM_CONDITIONAL(NEEDDLOPEN, test "$NEEDDLOPEN" = "yes")
1403
1404 dnl
1405 dnl Each interface section
1406 dnl
1407
1408 dnl ncurses
1409 AM_CONDITIONAL(ENABLE_NCURSES, false)
1410 CONFIG_INTERFACE(ncurses,NCURSES,n,
1411   [  --enable-ncurses        Enable ncurses interface        (default is no)],
1412   [ AC_CHECK_HEADERS(ncurses.h ncurses/curses.h curses.h)
1413
1414 dnl #include <ncurses/curses.h> is failure on Plamo Linux 1.3/ncurses 1.9.9e
1415 dnl because <ncurses/curses.h> includes <unctrl.h>:
1416 dnl /usr/include/ncurses/curses.h:34: unctrl.h: No such file or directory
1417 dnl But surely there is unctl.h at /usr/include/ncurses/unctrl.h.
1418 dnl configure must check ncurses header with -I/usr/include/ncurses option.
1419
1420   case "$ac_cv_header_curses_h$ac_cv_header_ncurses_curses_h$ac_cv_header_ncurses_h" in
1421     *yes*);;
1422     *)  for i in /usr/include /usr/local/include; do
1423           if test -f "$i/ncurses/curses.h" -a -f "$i/ncurses/unctrl.h"; then
1424             AC_MSG_WARN(ncurses test is failure.  Please check config.h and common.makefile later)
1425             CPPFLAGS="$CPPFLAGS -I$i/ncurses"
1426             break
1427           fi
1428         done
1429         ;;
1430     esac
1431
1432     AC_CHECK_LIB(ncurses,initscr,lib_curses_opt=-lncurses,
1433       [ dnl checking pdcurses
1434         AC_CHECK_LIB(curses,PDC_set_ctrl_break,
1435           [ lib_curses_opt=-lcurses
1436             AC_DEFINE(USE_PDCURSES,1,Define to 1 if you use PDcurses)
1437             lib_user32_opt="$lib_user32_test"
1438           ],
1439           [ dnl checking libpdcurses
1440             AC_CHECK_LIB(pdcurses,PDC_set_ctrl_break,
1441             [ lib_curses_opt=-lpdcurses
1442               AC_DEFINE(USE_PDCURSES,1,Define to 1 if you use PDcurses)
1443               lib_user32_opt="$lib_user32_test"
1444             ],
1445             [ dnl OpenBSD use -lcurses instead of -lncurses.
1446               case "$target" in
1447                 *openbsd*)
1448                   AC_CHECK_LIB(curses,initscr,lib_curses_opt=-lcurses,
1449                     [ AC_MSG_WARN(ncurses interface is not enabled)
1450                       enable_ncurses=no ])
1451                   ;;
1452                 *)
1453                   if test "x$VCPP" = xyes || test "x$BORLANDC" = xyes; then
1454                     lib_curses_opt=libpdcurses.lib
1455                     AC_DEFINE(USE_PDCURSES,1,Define to 1 if you use PDcurses)
1456                   else
1457                     AC_MSG_WARN(ncurses interface is not enabled)
1458                     enable_ncurses=no
1459                   fi
1460                   ;;
1461               esac
1462             ])
1463         ],
1464         $lib_user32_test)
1465       ])
1466   ],
1467   [ LIBS="$LIBS $lib_curses_opt"
1468     case "$target" in
1469        *-*-freebsd[123]*)
1470          EXTRALIBS="$EXTRALIBS -lmytinfo"
1471          ;;
1472      esac
1473     INTERFACE_SRCS="$INTERFACE_SRCS ncurs_c.c"
1474   ],
1475   [ n_so_libs="$lib_curses_opt"
1476     case "$target" in
1477        *-*-freebsd[123]*)
1478          EXTRALIBS="$EXTRALIBS -lmytinfo"
1479          ;;
1480      esac])
1481
1482 dnl slang
1483 AM_CONDITIONAL(ENABLE_SLANG, false)
1484 CONFIG_INTERFACE(slang,SLANG,s,
1485   [  --enable-slang          Enable slang interface          (default is no)],
1486   [ AC_CHECK_LIB(slang,SLang_init_tty,:,
1487     [ enable_slang=no
1488       AC_MSG_WARN(slang interface is not enabled)
1489     ])
1490     AC_CHECK_HEADERS(slang/slang.h slang.h)
1491   ],
1492   [ LIBS="$LIBS -lslang"
1493     INTERFACE_SRCS="$INTERFACE_SRCS slang_c.c"
1494   ],
1495   [ s_so_libs="-lslang"
1496     AC_CHECK_LIB(termcap,initscr,s_so_libs="$s_so_libs -ltermcap")
1497   ])
1498
1499 dnl Motif
1500 AM_CONDITIONAL(ENABLE_MOTIF, false)
1501 CONFIG_INTERFACE(motif,MOTIF,m,
1502   [  --enable-motif          Enable motif interface          (default is no)],
1503   [ if test "x$with_x" != xyes; then
1504         AC_MSG_ERROR(motif: --with-x option must be specified)
1505     fi
1506     if test "x$have_xm" != xyes; then
1507       AC_MSG_WARN(Motif library is not found.)
1508       enable_motif=no
1509     fi
1510   ],
1511   [ lib_xm_opt=-lXm
1512     lib_xt_opt=-lXt
1513     lib_xext_opt=-lXext
1514     if test "x$have_xprelibs" = xyes; then
1515         lib_xprelibs_opt='-lSM -lICE'
1516     fi
1517     INTERFACE_SRCS="$INTERFACE_SRCS motif_c.c motif_i.c motif_p.c"
1518   ],
1519   [ if test x$have_xprelibs = xyes; then
1520       m_so_libs="-lXext -lSM -lICE"
1521     fi
1522     m_so_libs="$ldflags_x_opt -lXm -lXt $m_so_libs -lX11"
1523   ])
1524
1525 dnl Tcl/Tk
1526 AM_CONDITIONAL(ENABLE_TCLTK, false)
1527 CONFIG_INTERFACE(tcltk,TCLTK,k,
1528   [  --enable-tcltk          Enable tcltk interface          (default is no)],
1529   [ if test "x$with_x" != xyes; then
1530         AC_MSG_ERROR(tcltk: --with-x option must be specified)
1531     fi
1532
1533     dnl save flags
1534     KEEPCPPFLAGS=$CPPFLAGS
1535     KEEPLDFLAGS=$LDFLAGS
1536     KEEPLIBS=$LIBS
1537
1538     CPPFLAGS="$tcl_include_dir $tk_includes $CPPFLAGS"
1539     LDFLAGS="$tcl_libdir $tk_libdir $LDFLAGS"
1540     LIBS="$LIBS $lib_dl_opt"
1541
1542     tcl_lib=
1543     tk_lib=
1544     for l in tcl tcl8.4 tcl8.3 tcl8.0jp tcl7.6jp tcl80jp tcl76jp tcl8.0 tcl7.6 tcl80 tcl76; do
1545       case "x$tcl_lib" in x) AC_CHECK_LIB($l,Tcl_Init,tcl_lib=-l$l);; esac
1546     done
1547     LIBS="$LIBS $tcl_lib"
1548     for l in tk tk8.4 tk8.3 tk8.0jp tk4.2jp tk80jp tk42jp tk8.0 tk4.2 tk80 tk42; do
1549       case "x$tk_lib" in x) AC_CHECK_LIB($l,Tk_Init,tk_lib=-l$l);; esac
1550     done
1551
1552     LIBS=$KEEPLIBS
1553     if test "x$tcl_lib" = x -o "x$tk_lib" = x; then
1554       CPPFLAGS=$KEEPCPPFLAGS
1555       LDFLAGS=$KEEPLDFLAGS
1556       enable_tcltk=no
1557       AC_MSG_WARN(tcl/tk is not enable)
1558     else
1559       tcltk_dep='tclIndex'
1560     fi
1561   ],
1562   [ LIBS=`echo $LIBS | sed "s/-lX11/$tk_lib $tcl_lib -lX11/"`
1563     case "$target" in
1564       *-*-bsdi*)
1565         EXTRALIBS="$EXTRALIBS -lipc"
1566         ;;
1567     esac
1568     INTERFACE_SRCS="$INTERFACE_SRCS tk_c.c"
1569   ],
1570   [ k_so_libs="$tcl_libdir $tk_libdir $tcl_lib $tk_lib $lib_dl_opt"
1571     case "$target" in
1572       *-*-bsdi*)
1573         k_so_libs="$k_so_libs -lipc"
1574         ;;
1575     esac
1576     k_so_libs="$k_so_libs -lX11 -lm"
1577   ])
1578 AM_CONDITIONAL(ENABLE_DYNAMIC_TCLTK, test "x$enable_tcltk" = "xdynamic")
1579
1580 dnl Emacs
1581 AM_CONDITIONAL(ENABLE_EMACS, false)
1582 CONFIG_INTERFACE(emacs,EMACS,e,
1583   [  --enable-emacs          Enable emacs interface          (default is no)],
1584   ,
1585   [ ELFILES="$ELFILES timidity.el"
1586     INTERFACE_SRCS="$INTERFACE_SRCS emacs_c.c"
1587   ],
1588   [ ELFILES="$ELFILES timidity.el" ])
1589
1590 dnl VT100
1591 AM_CONDITIONAL(ENABLE_VT100, false)
1592 CONFIG_INTERFACE(vt100,VT100,T,
1593   [  --enable-vt100          Enable VT100 interface          (default is no)],
1594   ,
1595   [ INTERFACE_SRCS="$INTERFACE_SRCS vt100_c.c vt100.c" ])
1596
1597 dnl X Athena Widget
1598 AM_CONDITIONAL(ENABLE_XAW, false)
1599 CONFIG_INTERFACE(xaw,XAW,a,
1600   [  --enable-xaw            Enable athena interface         (default is no)],
1601   [ if test "x$with_x" != xyes; then
1602         AC_MSG_ERROR(xaw: --with-x option must be specified)
1603     fi
1604     if test "x$have_xaw" != "xyes" -a "x$have_xaw" != "x3d"; then
1605       AC_MSG_WARN(X Athena Widget library is not found.)
1606       enable_xaw=no
1607     fi ],
1608   [ dnl Add -lXext -lSM -lICE -lXmu -lXt {-lXaw|-lXaw3d}
1609     if test "x$have_xext" = xyes; then
1610       lib_xext_opt=-lXext
1611     fi
1612     if test "x$have_xprelibs" = xyes; then
1613       lib_xprelibs_opt='-lSM -lICE'
1614     fi
1615     lib_xmu_opt=-lXmu
1616     lib_xt_opt=-lXt
1617     if test "x$have_xaw" = x3d; then
1618       AC_DEFINE(XAW3D,1,Define to 1 if you have libXaw3d.)
1619       lib_xaw_opt=-lXaw3d
1620     else
1621       lib_xaw_opt=-lXaw
1622     fi
1623     INTERFACE_SRCS="$INTERFACE_SRCS xaw_c.c xaw_i.c"
1624   ],
1625   [ if test "x$have_xext" = xyes; then
1626       a_so_libs="-lXext -lX11"
1627     else
1628       a_so_libs="-lX11"
1629     fi
1630     case "$target" in
1631       *darwin*)
1632         a_so_libs="$a_so_libs -lcc_dynamic"
1633         ;;
1634     esac
1635     if test "x$have_xprelibs" = xyes; then
1636       a_so_libs="-lSM -lICE $a_so_libs"
1637     fi
1638     if test "x$have_xaw" = xyes; then
1639       a_so_libs="-lXaw -lXmu -lXt $a_so_libs"
1640     elif test "x$have_xaw" = x3d; then
1641       AC_DEFINE(XAW3D,1,Define to 1 if you have libXaw3d.)
1642       a_so_libs="-lXaw3d -lXmu -lXt $a_so_libs"
1643     fi
1644     a_so_libs="$ldflags_x_opt $a_so_libs"
1645   ])
1646 AM_CONDITIONAL(ENABLE_DYNAMIC_XAW, test "x$enable_xaw" = "xdynamic")
1647
1648 dnl X skin
1649 AM_CONDITIONAL(ENABLE_XSKIN, false)
1650 CONFIG_INTERFACE(xskin,XSKIN,i,
1651   [  --enable-xskin          Enable X skin interface         (default is no)],
1652   [ if test "x$with_x" != xyes; then
1653         AC_MSG_ERROR(xskin: --with-x option must be specified)
1654     fi
1655   ],
1656   [ INTERFACE_SRCS="$INTERFACE_SRCS xskin_c.c xskin_i.c xskin_loadBMP.c xskin_spectrum.c" ],
1657   [ i_so_libs="$ldflags_x_opt -lX11" ])
1658
1659 dnl GTK+
1660 AM_CONDITIONAL(ENABLE_GTK, false)
1661 CONFIG_INTERFACE(gtk, GTK, g,
1662   [  --enable-gtk            Enable GTK+ interface           (default is no)],
1663   [ AM_PATH_GTK(1.1.3,,enable_gtk=no) ],
1664   [ LIBS="$LIBS $GTK_LIBS"
1665     EXTRACT_CPPFLAGS(CPPFLAGS,CFLAGS,$GTK_CFLAGS)
1666     INTERFACE_SRCS="$INTERFACE_SRCS gtk_c.c gtk_i.c gtk_p.c"
1667   ],
1668   [ if test "x$GCC" = xyes; then
1669         dnl Do not include -rdynamic option in $g_so_libs.
1670         for i in $GTK_LIBS; do
1671             case "x$i" in
1672                 x-rdynamic) ;;
1673                 *) g_so_libs="$g_so_libs $i" ;;
1674             esac
1675         done
1676     else
1677         g_so_libs="$GTK_LIBS"
1678     fi
1679     EXTRACT_CPPFLAGS(CPPFLAGS,CFLAGS,$GTK_CFLAGS) ])
1680
1681 dnl TiMidity Network MIDI Server
1682 AM_CONDITIONAL(ENABLE_SERVER, false)
1683 CONFIG_INTERFACE(server,SERVER,r,
1684   [  --enable-server         Enable server interface         (default is no)],
1685   ,
1686   [ INTERFACE_SRCS="$INTERFACE_SRCS server_c.c"
1687     AC_CHECK_HEADERS(sys/soundcard.h)
1688   ])
1689
1690 dnl TiMidity ALSA sequencer server
1691 AM_CONDITIONAL(ENABLE_ALSASEQ, false)
1692 CONFIG_INTERFACE(alsaseq,ALSASEQ,A,
1693   [  --enable-alsaseq        Enable ALSA sequencer server interface
1694                                                           (default is no)],
1695   ,
1696   [ INTERFACE_SRCS="$INTERFACE_SRCS alsaseq_c.c"
1697     AM_PATH_ALSA
1698   ])
1699
1700 dnl TiMidity Windows synthesizer server
1701 AM_CONDITIONAL(ENABLE_WINSYN, false)
1702 CONFIG_INTERFACE(winsyn,WINSYN,W,
1703   [  --enable-winsyn        Enable Windows Synthesizer interface
1704                                                           (default is no)],
1705   ,
1706   [ INTERFACE_SRCS="$INTERFACE_SRCS winsyn_c.c rtsyn_common.c rtsyn_winmm.c" ])
1707
1708 dnl TiMidity PortMIDI synthesizer server
1709 AM_CONDITIONAL(ENABLE_PORTMIDISYN, false)
1710 CONFIG_INTERFACE(portmidisyn,PORTMIDISYN,P,
1711   [  --enable-portmidisyn        Enable PortMIDI Synthesizer interface
1712                                                           (default is no)],
1713   ,
1714   [ INTERFACE_SRCS="$INTERFACE_SRCS portmidisyn_c.c rtsyn_common.c rtsyn_portmidi.c" ])
1715
1716 dnl TiMidity Windows GUI synthesizer server
1717 AM_CONDITIONAL(ENABLE_W32G_SYN, false)
1718 CONFIG_INTERFACE(winsyng,W32G_SYN,W,
1719   [  --enable-winsyng        Enable Windows GUI Synthesizer interface
1720                                                           (default is no)],
1721   ,
1722   [ 
1723   if test "x$VCPP" = xyes || test "x$BORLANDC" = xyes; then
1724     INTERFACE_SRCS="$INTERFACE_SRCS w32g_ini.c w32g_pref.c w32g_syn.c w32g_utl.c winsyn_c.c rtsyn_common.c rtsyn_winmm.c"
1725     lib_w32gui_opt='gdi32.lib comctl32.lib comdlg32.lib ole32.lib'
1726     lib_user32_opt='user32.lib'
1727     if test "x$VCPP" = xyes; then
1728       VCPP_LDFLAGS="$VCPP_LDFLAGS -subsystem:windows "
1729     else
1730           BORLANDC_START='C0W32.OBJ'
1731       CFLAGS="$CFLAGS -tW"
1732       lib_w32gui_opt="-aa $lib_w32gui_opt"
1733     fi
1734   else
1735         lib_w32gui_opt='-lgdi32 -lcomctl32 -lcomdlg32 -lole32'
1736     lib_user32_opt='-luser32'
1737     LDFLAGS="-mwindows $LDFLAGS"
1738     INTERFACE_SRCS="$INTERFACE_SRCS w32g_ini.c w32g_pref.c w32g_syn_escaped.c w32g_utl.c winsyn_c.c rtsyn_common.c rtsyn_winmm.c"
1739   fi
1740   ])
1741
1742
1743 dnl Windows GUI
1744 AM_CONDITIONAL(ENABLE_W32GUI, false)
1745 CONFIG_INTERFACE(w32gui, W32GUI, w,
1746   [  --enable-w32gui         Enable Windows GUI interface    (default is no)],
1747   ,
1748   [ 
1749   if test "x$VCPP" = xyes || test "x$BORLANDC" = xyes; then
1750         INTERFACE_SRCS="$INTERFACE_SRCS w32g_c.c w32g_ini.c w32g_i.c w32g_playlist.c w32g_utl.c w32g_pref.c w32g_subwin.c w32g_subwin2.c w32g_subwin3.c w32g_ut2.c w32g_dib.c  wrdt_w32g.c w32g_mag.c"
1751     lib_w32gui_opt='gdi32.lib comctl32.lib comdlg32.lib ole32.lib'
1752     lib_user32_opt='user32.lib'
1753     if test "x$VCPP" = xyes; then
1754           VCPP_LDFLAGS="$VCPP_LDFLAGS -subsystem:windows "
1755         else
1756           BORLANDC_START='C0W32.OBJ'
1757           CFLAGS="$CFLAGS -tW"
1758           lib_w32gui_opt="-aa $lib_w32gui_opt"
1759         fi
1760   else
1761     lib_w32gui_opt='-lgdi32 -lcomctl32 -lcomdlg32 -lole32'
1762     lib_user32_opt='-luser32'
1763     LDFLAGS="-mwindows $LDFLAGS"
1764     INTERFACE_SRCS="$INTERFACE_SRCS w32g_c.c w32g_ini.c w32g_i.c w32g_playlist.c w32g_utl.c w32g_pref.c w32g_subwin_escaped.c w32g_subwin2.c w32g_subwin3.c w32g_ut2.c w32g_dib.c  wrdt_w32g.c w32g_mag.c"
1765   fi
1766   ])
1767
1768 dnl UMP configuration
1769 AM_CONDITIONAL(ENABLE_PLUGIN, false)
1770 CONFIG_INTERFACE(ump, PLUGIN, p,
1771   [  --enable-ump            UMP configuration               (default is no)],
1772   [ if test ! -d ump; then
1773         AC_MSG_ERROR(UMP Package is not exists.  Can't configure it.)
1774     fi
1775     AC_CHECK_HEADER(X11/xpm.h,,AC_MSG_ERROR([UMP Package needs xpm.h[,] but could not find it.]))
1776     AC_CHECK_LIB(Xpm,XpmCreatePixmapFromData,:,AC_MSG_ERROR([UMP Package needs libXpm.a[,] but could not find it.]))
1777     if test "x$have_xext" = xyes; then
1778       lib_xext_opt=-lXext
1779     fi
1780     if test "x$have_xprelibs" = xyes; then
1781       lib_xprelibs_opt='-lSM -lICE'
1782     fi
1783     lib_xmu_opt=-lXmu
1784     lib_xt_opt=-lXt
1785   ])
1786
1787
1788 dnl Offix support
1789 dnl this rely on  CFLAGS and LIBS
1790 AC_ARG_ENABLE(offix,
1791   [  --enable-offix          Enable offix support            (default is no)],
1792   [ if test "$enableval" = "yes"; then
1793       KEEPCPPFLAGS=$CPPFLAGS
1794       KEEPLIBS=$LIBS
1795       KEEPLDFLAGS=$LDFLAGS
1796       CPPFLAGS="$CPPFLAGS $offix_include_dir"
1797       LDFLAGS="$LDFLAGS $offix_lib_dir"
1798       LIBS="$LIBS $lib_xmu_opt $lib_xt_opt $lib_xprelibs_opt $lib_xext_opt -lX11"
1799       AC_CHECK_LIB(Dnd,DndInitialize,[
1800         LIBS=$KEEPLIBS
1801         lib_offix_opt="-lDnd"
1802         AC_DEFINE(OFFIX,1,Define to 1 if you need offix support)
1803       ],
1804       [ LDFLAGS=$KEEPLDFLAGS
1805         CPPFLAGS=$KEEPCPPFLAGS
1806         LIBS=$KEEPLIBS
1807       ])
1808     fi
1809   ])
1810
1811 dnl Network section
1812 AC_ARG_ENABLE(network,
1813   [  --enable-network        Enable network support          (default is no)],
1814   [ if test "$enableval" = "yes"; then
1815       AC_DEFINE(SUPPORT_SOCKET,1,Define to 1 if you need network support)
1816     fi ])
1817 AM_CONDITIONAL(ENABLE_NETWORK, test "x$enable_network" = "xyes")
1818
1819 dnl Sound Spectrogram Viewer
1820 AC_ARG_ENABLE(spectrogram,
1821   [  --enable-spectrogram    Enable Sound Spectrogram Viewer (default is no)],
1822   [ if test "$enableval" = "yes"; then
1823       if test "x$with_x" != xyes; then
1824         AC_MSG_ERROR(spectrogram: --with-x option must be specified)
1825       fi
1826       AC_DEFINE(SUPPORT_SOUNDSPEC,1,Define to 1 if you need spectrogram vewer.)
1827     fi ])
1828 AM_CONDITIONAL(ENABLE_SOUND_SPEC, test "x$enable_spectrogram" = "xyes")
1829
1830 dnl Wave Spline Interpolations
1831 AC_ARG_ENABLE(spline,
1832   [  --enable-spline=[method]  Specify spline method.
1833                                   one of no,linear,cubic,lagrange,newton,gauss
1834                                                           (default is linear)],
1835   [ case "x$enableval" in
1836       xlinear)
1837         AC_DEFINE(DEFAULT_RESAMPLATION,resample_linear,Define resampler.)
1838         ;;
1839       xcubic)
1840         AC_DEFINE(DEFAULT_RESAMPLATION,resample_cspline,Define resampler.)
1841         ;;
1842       xlagrange)
1843         AC_DEFINE(DEFAULT_RESAMPLATION,resample_lagrange,Define resampler.)
1844         ;;
1845       xnewton)
1846         AC_DEFINE(DEFAULT_RESAMPLATION,resample_newton,Define resampler.)
1847         ;;
1848       xgauss)
1849         AC_DEFINE(DEFAULT_RESAMPLATION,resample_gauss,Define resampler.)
1850         ;;
1851       xno)
1852         AC_DEFINE(DEFAULT_RESAMPLATION,resample_none,Define resampler.)
1853         ;;
1854       *)
1855         AC_MSG_ERROR(Invalid method of --enable-spline)
1856         ;;
1857     esac ])
1858
1859 dnl WRD interface
1860 AC_ARG_ENABLE(wrd,
1861   [  --enable-wrd            Enable WRD interface for X      (default is no)],
1862   [ if test "$enableval" = "yes"; then
1863       if test "x$with_x" != xyes; then
1864         AC_MSG_ERROR(wrd: --with-x option must be specified)
1865       fi
1866       AC_DEFINE(WRDT_X,1,Define to 1 if you need wrd support for X.)
1867       enable_sherry_wrd=yes
1868       AC_CHECK_LIB(z,zlibVersion,:,enable_sherry_wrd=no)
1869       AC_CHECK_HEADER(png.h,,enable_sherry_wrd=no)
1870       AC_CHECK_LIB(png,png_init_io,:,enable_sherry_wrd=no,-lz)
1871       if test "$enable_sherry_wrd" = yes; then
1872         AC_DEFINE(ENABLE_SHERRY,1,Define to 1 if you enable Sherry WRD)
1873         lib_zip_opt=-lz
1874         lib_png_opt=-lpng
1875       else
1876          AC_MSG_WARN([Sherry WRD is disabled: png.h, libpng.a, libz.a are required])
1877       fi
1878       if test "x$have_xext" = xyes; then
1879         lib_xext_opt=-lXext
1880       fi
1881     fi ])
1882
1883 dnl end of interfaces
1884
1885
1886 #
1887 # Finish up
1888 #
1889
1890 AM_CONDITIONAL(ENABLE_WRD, test "x$enable_wrd" = "xyes")
1891 AM_CONDITIONAL(CYGNUS, test "x$CYGNUS" = xyes)
1892 AM_CONDITIONAL(MSYS, test "x$MSYS" = xyes)
1893 AM_CONDITIONAL(VCPP, test "x$VCPP" = xyes)
1894 AM_CONDITIONAL(BORLANDC, test "x$BORLANDC" = xyes)
1895
1896 AM_CONDITIONAL(W32READDIR, test "x$W32READDIR" = "xyes")
1897
1898 SET_UNIQ_WORDS(LDFLAGS,$LDFLAGS)
1899 SET_UNIQ_WORDS(SHLDFLAGS,$SHLDFLAGS)
1900 SET_UNIQ_WORDS(CFLAGS,$EXTRACFLAGS $CFLAGS)
1901 SET_UNIQ_WORDS(CPPFLAGS,$CPPFLAGS $EXTRADEFS)
1902
1903 if test "x$oss_device" != x; then
1904   AC_DEFINE_UNQUOTED(OSS_DEVICE,"$oss_device", oss device name)
1905 fi
1906
1907 if test "x$TIMIDITY_OUTPUT_ID" != x; then
1908   AC_DEFINE_UNQUOTED(TIMIDITY_OUTPUT_ID,"$TIMIDITY_OUTPUT_ID", the output specification)
1909 fi
1910
1911 if test "x$with_x" = xyes; then
1912   dnl Order of X-library is: -lXm -lXaw -lXmu -lXt -lSM -lICE -lXext -lX11
1913   LIBS=`echo $LIBS | sed "s/-lX11/$lib_offix_opt $lib_xm_opt $lib_xaw_opt $lib_xmu_opt $lib_xt_opt $lib_xprelibs_opt $lib_xext_opt -lX11/"`
1914 fi
1915 LIBS="$LIBS $lib_dl_opt $lib_png_opt $lib_zip_opt $lib_user32_opt $lib_w32gui_opt $EXTRALIBS"
1916 SHLD="$SHLD $SHLDFLAGS"
1917
1918 AC_SUBST(BORLANDC_START)
1919 AC_SUBST(BORLANDC_LDFLAGS)
1920 AC_SUBST(SHELL)
1921 AC_SUBST(timidity_LDFLAGS)
1922 AC_SUBST(VCPP_LDFLAGS)
1923 AC_SUBST(SYSEXTRAS)
1924 AC_SUBST(EXTRALIBS)
1925 AC_SUBST(NETSRCS)
1926 AC_SUBST(ELFILES)
1927 AC_SUBST(SHLD)
1928 AC_SUBST(SHCFLAGS)
1929 AC_SUBST(dynamic_targets)
1930 AC_SUBST(so)
1931 AC_SUBST(LN_S)
1932 AC_SUBST(WISH)
1933 AC_SUBST(tcltk_dep)
1934 AC_SUBST(program_transform_name)
1935 AC_SUBST(INTERFACE_SRCS)
1936 AC_SUBST(pkgdatadir)
1937 AC_SUBST(pkglibdir)
1938
1939 AC_CONFIG_FILES([
1940   Makefile
1941   autoconf/Makefile
1942   common.makefile
1943   configs/Makefile
1944   doc/Makefile
1945   doc/C/Makefile
1946   doc/ja_JP.eucJP/Makefile
1947   interface/Makefile
1948   interface/motif_bitmaps/Makefile
1949   interface/bitmaps/Makefile
1950   interface/pixmaps/Makefile
1951   libarc/Makefile
1952   libunimod/Makefile
1953   timidity/Makefile
1954   utils/Makefile
1955   script/Makefile
1956   TiMidity.ad
1957   TiMidity-uj.ad
1958 ])
1959 AC_OUTPUT