OSDN Git Service

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