OSDN Git Service

Remove support for Intel C++ Compiler Classic
[timidity41/timidity41.git] / configure.in
index 8831a83..2ffc327 100644 (file)
@@ -20,47 +20,49 @@ dnl configure.in created from configure.scan
 dnl by URABE, Shyouhei <root@mput.dip.jp> on 2002.07.06
 
 dnl variable note:
-dnl CFLAGS     - Flags for compile.
-dnl CPPFLAGS   - Flags for cpp
-dnl LDFLAGS    - Flags for linker
-dnl            ac_cpp:     $CPP $CPPFLAGS
-dnl            ac_compile: ${CC-cc} -c $CFLAGS $CPPFLAGS
-dnl            ac_link:    ${CC-cc} -o * $CFLAGS $CPPFLAGS $LDFLAGS *.c $LIBS
+dnl CFLAGS      - Flags for compile.
+dnl CPPFLAGS    - Flags for cpp
+dnl LDFLAGS     - Flags for linker
+dnl             ac_cpp:     $CPP $CPPFLAGS
+dnl             ac_compile: ${CC-cc} -c $CFLAGS $CPPFLAGS
+dnl             ac_link:    ${CC-cc} -o * $CFLAGS $CPPFLAGS $LDFLAGS *.c $LIBS
 dnl EXTRACFLAGS - Extra flags to compile.  Adds to CFLAGS.
-dnl EXTRADEFS  - Extra define macros.  Adds to CPPFLAGS.
-dnl EXTRALIBS  - Extra libraries  Adds to LIBS.
-dnl SYSEXTRAS  - Additional source codes to compile.
-dnl lib_*_opt  - Optional libraries. Adds to LIBS.
+dnl EXTRADEFS   - Extra define macros. Adds to CPPFLAGS.
+dnl EXTRALIBS   - Extra libraries  Adds to LIBS.
+dnl SYSEXTRAS   - Additional source codes to compile.
+dnl lib_*_opt   - Optional libraries. Adds to LIBS.
 dnl LIBRARY_PATH
-dnl            - add to -L LDFLAGS
+dnl             - add to -L LDFLAGS
 dnl C_INCLUDE_PATH
-dnl            - add to -I CPPFLAGS
-dnl MSYS       - `yes' if cygnus or Mingw windows environment.
+dnl             - add to -I CPPFLAGS
+dnl CYGNUS     - `yes' if cygnus windows environment.
+dnl MSYS       - `yes' if Mingw windows environment.
 dnl WISH       - wish
-dnl LN_S       - ln -s
-dnl tcltk_dep  - make dependencies for tcl/tk interface
+dnl TCLSH       - tclsh
+dnl LN_S        - ln -s
+dnl tcltk_dep   - make dependencies for tcl/tk interface
 dnl
-dnl so         - File extension of shared object library.
-dnl SHLD       - Linker to make shared object library.
-dnl SHLDFLAGS  - Link flags to link shared object library.
-dnl SHCFLAGS   - Additional flags to compile shared object library.
-dnl              (such as -fPIC)
+dnl so          - File extension of shared object library.
+dnl SHLD        - Linker to make shared object library.
+dnl SHLDFLAGS   - Link flags to link shared object library.
+dnl SHCFLAGS    - Additional flags to compile shared object library.
+dnl               (such as -fPIC)
 
 # This is a autoscan-generated configure.scan.
 # AC_PREREQ(2.56)
 
 # "AC_INIT(timidity/timidity.c)" is obsolate yet.
-AC_INIT([TiMidity++],[2.13.2],[root@mput.dip.jp],[TiMidity++])
+AC_INIT([TiMidity++],[2.15.0],[timidity-talk@lists.sourceforge.net],[TiMidity++])
 AC_CONFIG_AUX_DIR([autoconf])
 AC_CANONICAL_TARGET
 AM_INIT_AUTOMAKE([gnu dist-bzip2])
 AC_CONFIG_SRCDIR([timidity/timidity.c])
 AC_CONFIG_HEADERS([config.h interface.h])
 AM_MAINTAINER_MODE
-AC_PROG_CXX
 
 SHELL=${CONFIG_SHELL-"/bin/sh"}
 WISH=${WISH-"wish"}
+TCLSH=${TCLSH-"tclsh"}
 
 dnl to use contains() macro (see autoconf/acinclude.m4)
 CONTAINS_INIT
@@ -70,9 +72,9 @@ CONTAINS_INIT
 dnl "--enable-debug" turnes -g on.
 AC_MSG_CHECKING(if --enable-debug option specified)
 AC_ARG_ENABLE(debug,
-  [  --enable-debug          Build a debugging version.],
-  [timidity_cv_debug="yes"], [timidity_cv_debug="no"])
-if test "x$timidity_cv_debug" = "xyes"; then
+              AS_HELP_STRING([--enable-debug], [Build a debugging version.]),
+              [timidity_cv_debug="yes"], [timidity_cv_debug="no"])
+if test "x$timidity_cv_debug" = xyes; then
   AC_DEFINE(DEBUG,1,Define to 1 if you are in debug mode)
   CFLAGS=${CFLAGS-"-g"}
 fi
@@ -86,7 +88,7 @@ if test "x$CFLAGS" = "x"; then
 fi
 
 dnl --with-x turns on if `--with-x' is NOT specified.
-if test "x$with_x" = x; then
+if test "x$with_x" = "x"; then
   with_x=yes
 else
   x_config_flag=yes
@@ -109,7 +111,7 @@ fi
 
 dnl add --with-includes, --with-libraries
 AC_ARG_WITH(includes,
-  [  --with-includes=DIR     Specify include directories (colon separated)],
+  AS_HELP_STRING([--with-includes=DIR], [Specify include directories (colon separated)]),
   [ j=' '
     for i in `echo "$withval"|sed -e 's,:, ,g'`; do
       j="${j}-I${i} "
@@ -118,7 +120,7 @@ AC_ARG_WITH(includes,
   ])
 
 AC_ARG_WITH(libraries,
-  [  --with-libraries=DIR    Specify library directories (colon separated)],
+  AS_HELP_STRING([--with-libraries=DIR], [Specify library directories (colon separated)]),
   [ j=' '
     for i in `echo "$withval"|sed -e 's,:, ,g'`; do
       j="${j}-L${i} "
@@ -130,7 +132,7 @@ AC_ARG_WITH(libraries,
 dnl a bit hairly yet.(20020718:mput)
 dnl CPPFLAGS="$CPPFLAGS \$(DEF_PKGDATADIR) \$(DEF_PKGLIBDIR) \$(DEF_DEFAULT_PATH)"
 AC_ARG_WITH(default-path,
-  [  --with-default-path=DIR Where timidity.cfg is  (PREFIX/share/timidity)],
+  AS_HELP_STRING([--with-default-path=DIR], [Where timidity.cfg is  (PREFIX/share/timidity)]),
   [pkgdatadir=$withval],
   [
    if test "x$prefix" != "xNONE"; then
@@ -144,7 +146,7 @@ AC_DEFINE_UNQUOTED(DEFAULT_PATH,"$tmpdefpath",place to install patches)
 AC_DEFINE(PKGDATADIR,DEFAULT_PATH,a compatibility matter. ignore it.)
 
 AC_ARG_WITH(module-dir,
-  [  --with-module-dir=DIR   Where to install interfaces (PREFIX/lib/timidity)],
+  AS_HELP_STRING([--with-module-dir=DIR], [Where to install interfaces (PREFIX/lib/timidity)]),
   [pkglibdir=$withval],
   [
    if test "x$prefix" != "xNONE"; then
@@ -156,6 +158,11 @@ AC_ARG_WITH(module-dir,
 tmplibdir="`eval \"echo ${pkglibdir}\"`"
 AC_DEFINE_UNQUOTED(PKGLIBDIR,"$tmplibdir",place to install modules)
 
+AC_ARG_WITH(xaw-resource-prefix,
+  AS_HELP_STRING([--with-xaw-resource-prefix=DIR], [What prefix to install X resource files to (optional, used by Xaw/Motif interfaces)]),
+  [xawresdir=$withval], [])
+AM_CONDITIONAL(XAW_INSTALL_RESOURCE_FILES, test "x$xawresdir" != "x")
+AC_SUBST(xawresdir)
 
 # Checks for programs.
 AM_PATH_LISPDIR
@@ -163,12 +170,14 @@ AC_PROG_CC
 AC_PROG_GCC_TRADITIONAL
 AC_PROG_INSTALL
 AC_PROG_AWK
+AC_CHECK_PROG([AR], [${ac_tool_prefix}ar], [${ac_tool_prefix}ar])
 AC_PROG_RANLIB
 AC_PROG_LN_S
+AC_CHECK_PROG([WINDRES], [${ac_tool_prefix}windres], [${ac_tool_prefix}windres])
 CHECK_COMPILER_OPTION(rdynamic)
 
-if test "x$NOCFLAGS" = "xyes"; then
-  if test "x$GCC" = "xyes"; then
+if test "x$NOCFLAGS" = xyes; then
+  if test "x$GCC" = xyes; then
     CFLAGS="-O2"
   else
     CFLAGS=""
@@ -178,11 +187,11 @@ fi
 # Checks for target dependencies
 
 AC_ARG_WITH(elf,
-  [  --with-elf              create ELF shared object instead of AOUT ],
+  AS_HELP_STRING([--with-elf], [create ELF shared object instead of AOUT]),
   [ ELFFORMAT=$withval ], [ ELFFORMAT="yes" ])
 
 # AC_ARG_WITH(simd,
-#  [  --with-simd             create SIMD friendly binary (default is no) ],
+#  AS_HELP_STRING([--with-simd], [create SIMD friendly binary (default is no) ]),
 #  [ SIMD=$withval ], [ SIMD="no" ])
 
 case "$target" in
@@ -209,11 +218,11 @@ case "$target" in
     ;;
   *-*-freebsd*)
     if test "$ELFFORMAT" = yes; then
-       test -n "$SHLD" || SHLD="ld -Bshareable"
+        test -n "$SHLD" || SHLD="ld -Bshareable"
     else
-       SHCFLAGS=-aou
-       SHLDFLAGS="-L/usr/X11R6/lib/aout $SHLDFLAGS"
-       test -n "$SHLD" || SHLD="env OBJFORMAT=aout ld -shared"
+        SHCFLAGS=-aou
+        SHLDFLAGS="-L/usr/X11R6/lib/aout $SHLDFLAGS"
+        test -n "$SHLD" || SHLD="env OBJFORMAT=aout ld -shared"
     fi
     dnl EXTRALIBS="$EXTRALIBS -lxpg4"
     so="so"
@@ -226,34 +235,72 @@ case "$target" in
 #  ;;
 
   *-*-cygwin*|*-*-mingw*)
+    case "$target" in
+      *-*-cygwin*)
+        CYGNUS=yes
+        ;;
+      *-*-mingw*)
+        MSYS=yes
+        ;;
+    esac
+    WIN32=yes
     EXTRADEFS="-D__W32__"
+    EXTRAINCS="$EXTRAINCS -I\${top_srcdir}"
+    EXTRAINCS="$EXTRAINCS -I\${top_srcdir}/speex"
+    EXTRAINCS="$EXTRAINCS -I\${top_srcdir}/rcpcv"
+    EXTRAINCS="$EXTRAINCS -I\${top_srcdir}/portaudio/pa_common"
+    EXTRAINCS="$EXTRAINCS -I\${top_srcdir}/portmidi/pm_common"
+    EXTRAINCS="$EXTRAINCS -I\${top_srcdir}/portmidi/porttime"
+    EXTRAINCS="$EXTRAINCS -I\${top_srcdir}/libao"
+    EXTRAINCS="$EXTRAINCS -I\${top_srcdir}/libmpg123/include"
+    EXTRAINCS="$EXTRAINCS -I\${top_srcdir}/opus"
+    EXTRAINCS="$EXTRAINCS -I\${top_srcdir}/pdcurses"
+    EXTRAINCS="$EXTRAINCS -I\${top_srcdir}/ogg"
+    EXTRAINCS="$EXTRAINCS -I\${top_srcdir}/vorbis"
+    EXTRAINCS="$EXTRAINCS -I\${top_srcdir}/OggFLAC"
+    EXTRAINCS="$EXTRAINCS -I\${top_srcdir}/FLAC"
+    EXTRAINCS="$EXTRAINCS -I\${top_srcdir}/gogo"
+    EXTRAINCS="$EXTRAINCS -I\${top_srcdir}/Winamp"
+    CPPFLAGS="$CPPFLAGS -I. -I../cygwin/"
     # ??
     case "x${CC} " in
-      "xbcc32 "*) 
+      "xbcc32 "*|xbcc32
 #        test -n "$SHLD" || SHLD="tlink32 -Tpd"
         test -n "$SHLD" || SHLD="BCC32 -WD"
         BORLANDC=yes
-        BORLANDC_LDFLAGS="kernel32.lib winspool.lib comdlg32.lib advapi32.lib oleaut32.lib uuid.lib odbc32.lib wsock32.lib user32.lib shell32.lib cw32mt.lib"
+        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"
         BORLANDC_START='C0X32.OBJ'
         CFLAGS="$CFLAGS  -tWM -VM"
         EXTRADEFS="$EXTRADEFS -D_WINDOWS -DWIN32"
         ;;
-      "xdmc "*) 
+      "xcc "*|xcc) 
+        test -n "$SHLD" || SHLD="polink -DLL"
+        POCC=yes
+         case " $CFLAGS " in
+           *" -MT "*)  NODEF="-nodefaultlib:pocrt.lib -nodefaultlib:crt.lib -defaultlib:crtmt.lib"  ;;
+           *" -MD "*)  NODEF="-nodefaultlib:crtmt.lib -nodefaultlib:crt.lib -defaultlib:pocrt.lib"  ;;
+           *) CFLAGS="$CFLAGS -MT"; NODEF="-nodefaultlib:pocrt.lib -nodefaultlib:crtmt.lib -defaultlib:crt.lib" ;;
+         esac
+        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"
+        CFLAGS="$CFLAGS -Ze -D__POCC__OLDNAMES"
+        EXTRADEFS="$EXTRADEFS -D_WINDOWS -DWIN32"
+        ;;
+      "xdmc "*|xdmc) 
         test -n "$SHLD" || SHLD="dmc -WD"
         DMC=yes
-        DMC_LDFLAGS="winmm.lib wsock32.lib user32.lib kernel32.lib shell32.lib gdi32.lib comctl32.lib comdlg32.lib ole32.lib advapi32.lib"
+        DMC_LDFLAGS="winmm.lib ws2_32.lib user32.lib kernel32.lib shell32.lib gdi32.lib comctl32.lib comdlg32.lib ole32.lib advapi32.lib"
         CFLAGS="$CFLAGS  -mn -j0"
         DLLFLAG=" "
         EXTRADEFS="$EXTRADEFS -D_WINDOWS -DWIN32"
         ;;
-      "xwcc386_w.sh "*)
+      "xwcc386_w.sh "*|xwcc386)
          WATCOM_C=yes
          CFLAGS="$CFLAGS -br -bm -5s -zk0 -zp=16 -w=4 -D_WINDOWS -DWIN32 -DINCLUDE_WINDOWS_H"
          DLLFLAG=" "
          WATCOM_LDFLAGS=
-         EXTRALIBS="$EXTRALIBS kernel32.lib winspool.lib comdlg32.lib advapi32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib user32.lib shell32.lib"
+         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"
          ;;
-      "xcl "*) 
+      "xcl "*|xcl
          test -n "$SHLD" || SHLD="link -dll"
          VCPP=yes
          case " $CFLAGS " in
@@ -263,11 +310,11 @@ case "$target" in
            *" -MDd "*) NODEF="-nodefaultlib:libcmt.lib -nodefaultlib:libcmtd.lib -nodefaultlib:msvcrt.lib -nodefaultlib:libc.lib -nodefaultlib:libcd.lib"  ;;
            *) CFLAGS="$CFLAGS -MT"; NODEF="-nodefaultlib:msvcrt.lib -nodefaultlib:msvcrtd.lib -nodefaultlib:libcmtd.lib -nodefaultlib:libc.lib -nodefaultlib:libcd.lib"  ;;
          esac
-         VCPP_LDFLAGS="-nologo -incremental:no  $NODEF kernel32.lib winspool.lib comdlg32.lib advapi32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib user32.lib shell32.lib"
+         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"
          CFLAGS="$CFLAGS -nologo -Zp16 -W3 -GX  -Ob2"
          EXTRADEFS="$EXTRADEFS -DNDEBUG -D_WINDOWS -DWIN32 -DMBCS -D_MT -YX  -FD -c"
          ;;
-      "xgcc"*) test -n "$SHLD" || SHLD="gcc -mdll"; MINGWGCC=yes ;;
+      x*gcc*) test -n "$SHLD" || SHLD="gcc -mdll"; MINGWGCC=yes ;;
       *) test -n "$SHLD" || SHLD="unknown" ;;
     esac
     so="dll"
@@ -289,7 +336,7 @@ case "$target" in
     so="so"
     ;;
   *-*-darwin*)
-    if test "x$SIMD" = "xyes"; then
+    if test "x$SIMD" = xyes; then
        AC_DEFINE(USE_ALTIVEC,1,Define to 1 if you use altivec)
        # EXTRACFLAGS="$EXTRACFLAGS -faltivec -mabi=altivec -maltivec" # for GCC3.
        EXTRACFLAGS="$EXTRACFLAGS -faltivec"
@@ -304,9 +351,9 @@ case "$target" in
   *)
     test -n "$SHLD" || \
       if test "x$GCC" = xyes; then
-       SHLD="$CC -shared"
+        SHLD="$CC -shared"
       else
-       SHLD="ld -Bdynamic -G"
+        SHLD="ld -Bdynamic -G"
       fi
     so="so"
     ;;
@@ -320,15 +367,29 @@ AC_CHECK_LIB(m,sqrt)
 AC_CHECK_LIB(socket,socket)
 AC_CHECK_LIB(dl,dlopen,lib_dl_opt=-ldl)
 AC_CHECK_LIB(objc,NSLinkModule,lib_dl_opt=-lobjc) # Mac OS X need this.
-if test "x$VCPP" != "xyes" && test "x$BORLANDC" != "xyes" && test "x$WATCOM_C" != "xyes"; then
+if test "x$VCPP" != xyes && test "x$BORLANDC" != xyes && test "x$WATCOM_C" != xyes && test "x$POCC" != xyes; then
 AC_CHECK_LIB(xpg4,setlocale) # Mac OS X (and maybe NetBSD) need this.
 fi
 AC_CHECK_FUNCS(gethostbyname,,[ AC_CHECK_LIB(nsl,gethostbyname) ])
 AC_PATH_XTRA
 
+dnl Xft for trace window
+AC_ARG_ENABLE(xft,
+  AS_HELP_STRING([--enable-xft], [Enable use of Xft in X trace mode]))
+
+AC_ARG_WITH(xawlib,
+  [  --with-xawlib=lib     Try to link to these xaw widget libraries by the
+                           order specified by the comma separated value list:
+                             xaw: libXaw
+                             xaw3d: Xaw3d
+                             neXtaw: neXtaw
+                             XawPlus: XawPlus
+                             default is --with-xawlib=xaw3d,xaw],
+  [ with_xawlib="$withval" ], [ with_xawlib="xaw3d,xaw" ])
+
 # Checks for X
 if test "x$with_x" = xyes; then
-  if test "x$have_x" = xno; then
+  if test "x$have_x" = "xno"; then
     if test "x$x_config_flag" = xyes; then
       AC_MSG_ERROR(Could not configure X)
     else
@@ -337,18 +398,19 @@ if test "x$with_x" = xyes; then
   fi
 fi
 if test "x$with_x" = xyes -a "x$have_x" = xyes; then
-  if test "x$x_libraries" != x; then
+  if test "x$x_libraries" != "x"; then
     ldflags_x_opt="-L$x_libraries"
     LDFLAGS="$LDFLAGS $ldflags_x_opt"
     SHLDFLAGS="$SHLDFLAGS $ldflags_x_opt"
   else
     ldflags_x_opt=
   fi
-  if test "x$x_includes" != x; then
+  if test "x$x_includes" != "x"; then
     CPPFLAGS="$CPPFLAGS -I$x_includes"
   fi
 
-  AC_CHECK_LIB(X11,XOpenDisplay)
+  AC_CHECK_LIB(X11,XOpenDisplay,
+  AC_DEFINE(HAVE_LIBX11,1,Define to 1 if you have the `X11' library (-lX11).))
   AC_MSG_CHECKING(X11 version 6)
   AC_CACHE_VAL(timidity_cv_x11_version_6,
     AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <X11/Xlib.h>]], [[
@@ -371,8 +433,39 @@ fail;
   AC_CHECK_LIB(Xt,XtVaAppInitialize,have_xt=yes; LIBS="-lXt $LIBS",have_xt=no)
   AC_CHECK_LIB(Xmu,XmuInternAtom,LIBS="-lXmu $LIBS")
   AC_CHECK_FUNCS(XmuRegisterExternalAgent)
-  AC_CHECK_LIB(Xaw3d,XawInitializeWidgetSet,have_xaw=3d,
-   [ AC_CHECK_LIB(Xaw,XawInitializeWidgetSet,have_xaw=yes,have_xaw=no) ])
+  if test "x$enable_xft" = xyes; then
+    AC_CHECK_LIB(Xft,XftInit,
+                 AC_DEFINE(HAVE_LIBXFT,1,Define to 1 if you have the 'Xft' library.),
+                 enable_xft=no)
+  fi
+  for i in `echo $with_xawlib | sed 's/,/ /g'`; do
+  case "$i" in
+  "xaw")
+    AC_CHECK_LIB(Xaw,XawInitializeWidgetSet,have_xaw=yes,have_xaw=no)
+    ;;
+  "xaw3d") 
+    AC_CHECK_LIB(Xaw3d,XawInitializeWidgetSet,
+      [ have_xaw=3d;
+          AC_CHECK_HEADER(X11/Xaw3d/Tip.h,
+          AC_DEFINE(HAVE_XAW3D_TIP,1,Define to 1 if you have the <X11/Xaw3d/Tip.h> header file.),
+          )
+      ],
+      have_xaw=no
+    )
+    ;;
+  "neXtaw")
+    AC_CHECK_LIB(neXtaw,XawInitializeWidgetSet,have_xaw=next,have_xaw=no)
+    ;;
+  "XawPlus")
+    AC_CHECK_LIB(Xpm,XpmCreatePixmapFromData)
+    AC_CHECK_LIB(XawPlus,XawInitializeWidgetSet,have_xaw=plus,have_xaw=no)
+    ;;
+  *)
+    have_xaw=no
+    ;;
+  esac
+  if test "x$have_xaw" != "xno"; then break; fi
+  done
   AC_CHECK_LIB(Xm,XmCreateForm,have_xm=yes,have_xm=no)
   AC_CHECK_FUNCS(XShmCreatePixmap)
   LIBS=$KEEPLIBS
@@ -393,6 +486,7 @@ AC_CHECK_HEADERS( \
   getopt.h \
   glob.h \
   dlfcn.h \
+  dld.h \
   fcntl.h \
   inttypes.h \
   limits.h \
@@ -402,6 +496,8 @@ AC_CHECK_HEADERS( \
   netdb.h \
   netinet/in.h \
   nlist.h \
+  pthread.h \
+  pthreads.h \
   stddef.h \
   stdlib.h \
   stdint.h \
@@ -422,10 +518,17 @@ AC_CHECK_HEADERS( \
   sys/param.h \
   sys/time.h \
   sys/types.h \
+  sys/stat.h \
   sys/sysctl.h \
   termios.h \
-  unistd.h \
   X11/Xlib.h])
+
+if test "x$DMC" != xyes ; then
+AC_CHECK_HEADERS([ \
+  unistd.h \
+  ])
+fi
+
 AC_CHECK_HEADERS(\
   [X11/extensions/XShm.h X11/Xmu/ExtAgent.h],[],[],[
 #ifdef HAVE_X11_XLIB_H
@@ -445,9 +548,29 @@ AC_C_VOLATILE
 AC_C_STRINGIZE
 AC_C_PROTOTYPES
 AC_STRUCT_TM
+if test "x$DMC" != xyes ; then
 AC_TYPE_SIZE_T
+fi
+if test "x$POCC" != xyes ; then
 AC_TYPE_OFF_T
 AC_TYPE_PID_T
+fi
+
+# Older versions of MinGW do not define ssize_t in sys/types
+AC_MSG_CHECKING([for ssize_t])
+AC_CACHE_VAL(ac_cv_type_$1,
+[AC_EGREP_CPP([ssize_t@<:@^a-zA-Z_0-9@:>@],
+[#include <sys/types.h>
+#if STDC_HEADERS
+#include <stdlib.h>
+#include <stddef.h>
+#endif], [ac_cv_type_ssize_t=yes], [ac_cv_type_ssize_t=no])])
+
+AC_MSG_RESULT([$ac_cv_type_ssize_t])
+if test $ac_cv_type_ssize_t = yes; then
+  AC_DEFINE(HAVE_SSIZE_T, 1,
+    [Define to 1 if the system has the type `ssize_t'.])
+fi
 
 dnl keyword "volatile" check
 AC_CACHE_CHECK(volatile declaration,timidity_cv_type_volatile,
@@ -468,45 +591,46 @@ if test $timidity_cv_type_union_semun = yes; then
 fi
 
 dnl Cygnus and Mingw memory struct optiontest
-if test "x$MSYS" = xyes ; then
-       case "x${CC}" in
-       "xgcc"*) 
-               msnative_struct=''
-           AC_MSG_CHECKING([how to get MSVC-compatible struct packing])
-           if test -z "$ac_cv_prog_CC"; then
-                       our_gcc="$CC"
-               else
-                       our_gcc="$ac_cv_prog_CC"
-               fi
-               case `$our_gcc --version | sed -e 's,\..*,.,' -e q` in
-                       2.)
-               if $our_gcc -v --help 2>/dev/null | grep fnative-struct >/dev/null; then
-                       msnative_struct='-fnative-struct'
-               fi
-               ;;
-                       *)
-               if $our_gcc -v --help 2>/dev/null | grep ms-bitfields >/dev/null; then
-                       msnative_struct='-mms-bitfields'
-               fi
-               ;;
-               esac
-               if test x"$msnative_struct" = x ; then
-                       AC_MSG_RESULT([no way])
-                       AC_MSG_WARN([produced binary will be incompatible with windows' GUI ])
-               else
-                       CFLAGS="$CFLAGS $msnative_struct"
-                       CPPFLAGS="$CPPFLAGS $msnative_struct"
-                       AC_MSG_RESULT([${msnative_struct}])
-               fi
-               ;;
-       *) 
-               ;;
-       esac
+if test "x$CYGNUS" = xyes || test "x$MSYS" = xyes; then
+        case "x${CC}" in
+        "xgcc"*) 
+            msnative_struct=''
+            AC_MSG_CHECKING([how to get MSVC-compatible struct packing])
+            if test -z "$ac_cv_prog_CC"; then
+                        our_gcc="$CC"
+                else
+                        our_gcc="$ac_cv_prog_CC"
+                fi
+                case `$our_gcc --version | sed -e 's,\..*,.,' -e q` in
+                        2.)
+                if $our_gcc -v --help 2>/dev/null | grep fnative-struct >/dev/null; then
+                        msnative_struct='-fnative-struct'
+                fi
+                ;;
+                        *)
+                if $our_gcc -v --help 2>/dev/null | grep ms-bitfields >/dev/null; then
+                        msnative_struct='-mms-bitfields'
+                fi
+                ;;
+                esac
+                if test x"$msnative_struct" = "x"; then
+                        AC_MSG_RESULT([no way])
+                        AC_MSG_WARN([produced binary will be incompatible with windows' GUI ])
+                else
+                        CFLAGS="$CFLAGS $msnative_struct"
+                        CPPFLAGS="$CPPFLAGS $msnative_struct"
+                        AC_MSG_RESULT([${msnative_struct}])
+                fi
+                ;;
+        *) 
+                ;;
+        esac
 fi
 dnl Cygnus Mingw32 mmsystem check
-if test "x$MSYS" = xyes ; then
+if test "x$CYGNUS" = xyes || test "x$MSYS" = xyes; then
   AC_CACHE_CHECK(Cygwin new mmsystem,timidity_cv_header_new_mmsystem,
     AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#define _WIN32_WINDOWS 0x0400
 #include <windows.h>
 #include <mmsystem.h>
 ]], [[return WOM_OPEN != 0x3BB]])],[timidity_cv_header_new_mmsystem=yes],[timidity_cv_header_new_mmsystem=no]))
@@ -517,21 +641,31 @@ fi
 
 # Checks for library functions.
 AC_FUNC_ERROR_AT_LINE
+if test "x$DMC" != xyes ; then
 AC_FUNC_FORK
+fi
 AC_FUNC_MEMCMP
+if test "x$DMC" != xyes ; then
 AC_FUNC_MMAP
+fi
 AC_FUNC_SETVBUF_REVERSED
 AC_TYPE_SIGNAL
-if test "x$VCPP" != xyes && test "x$BORLANDC" != xyes && test "x$WATCOM_C" != "xyes"; then
+if test "x$GCC" == xyes; then
+AC_DEFINE(VOID_SIGHANDLER)
+fi
+if test "x$VCPP" != xyes && test "x$BORLANDC" != xyes && test "x$WATCOM_C" != xyes && test "x$POCC" != xyes; then
 AC_FUNC_VPRINTF
 fi
+AC_CHECK_LIB(pthread, pthread_create, [AC_DEFINE(HAVE_PTHREAD_CREATE,1,[Define to 1 if you have the `pthread_create' function.])])
 AC_CHECK_FUNCS( \
   [alarm \
   dup2 \
   floor \
+  fseeko \
+  ftello \
   getcwd \
-  getopt \
   gethostbyname \
+  getopt \
   gettimeofday \
   getwd \
   isatty \
@@ -564,7 +698,22 @@ AC_CHECK_FUNCS( \
   usleep])
 if test "x$VCPP" = xyes; then
   AC_DEFINE(RETSIGTYPE,int)
-  AC_DEFINE(HAVE_GETCWD,int)
+  AC_DEFINE(HAVE_GETCWD,1)
+fi
+if test "x$POCC" = xyes; then
+  AC_DEFINE(HAVE_GETCWD,1)
+  AC_DEFINE(HAVE_GETHOSTBYNAME,1)
+  AC_DEFINE(HAVE_POPEN,1)
+  AC_DEFINE(HAVE_SELECT,1)
+  AC_DEFINE(HAVE_SNPRINTF,1)
+  AC_DEFINE(HAVE_STRDUP,1)
+  AC_DEFINE(HAVE_STRERROR,1)
+  AC_DEFINE(HAVE_STRCASECMP,1)
+  AC_DEFINE(HAVE_STRSTR,1)
+  AC_DEFINE(HAVE_SOCKET,1)
+  AC_DEFINE(HAVE_VSNPRINTF,1)
+  AC_DEFINE(HAVE_GETOPT,1)
+  AC_DEFINE(TIMID_VERSION,[$(PACKAGE_VERSION)],[for windows gui])
 fi
 if test "x$VCPP" = xyes || test "x$BORLANDC" = xyes || test "x$WATCOM_C" = xyes; then
   AC_DEFINE(HAVE_GETHOSTBYNAME,1)
@@ -580,18 +729,101 @@ if test "x$VCPP" = xyes || test "x$BORLANDC" = xyes || test "x$WATCOM_C" = xyes;
   AC_DEFINE(snprintf,_snprintf,[for VC])
   AC_DEFINE(HAVE_SOCKET,1)
   AC_DEFINE(HAVE_VSNPRINTF,1)
-  AC_DEFINE(vsnprintf,_vsnprintf,[for VC])
+dnl  AC_DEFINE(vsnprintf,_vsnprintf,[for VC])
   AC_DEFINE(TIMID_VERSION,[$(PACKAGE_VERSION)],[for windows gui])
 fi
 
 AC_CHECK_FUNC(getopt_long,
-        AC_DEFINE([HAVE_GETOPT_LONG],1,[Define to 1 if you have `getopt_long function'])
-        tm_cv_needgetopt="no",
-        tm_cv_needgetopt="yes")
-AM_CONDITIONAL([NEEDGETOPT], test "x$tm_cv_needgetopt" = "xyes")
+         AC_DEFINE([HAVE_GETOPT_LONG],1,[Define to 1 if you have `getopt_long' function])
+         tm_cv_needgetopt="no",
+         tm_cv_needgetopt="yes")
+AM_CONDITIONAL([NEEDGETOPT], test "x$tm_cv_needgetopt" = xyes)
+
+AC_CHECK_FUNC(open_memstream, [
+         AC_DEFINE([HAVE_OPEN_MEMSTREAM],1,[Define to 1 if you have `open_memstream' function])
+         ])
+
+dnl ***
+dnl *** va_copy checks (from GLIB)
+dnl ***
+
+AC_CACHE_CHECK([for an implementation of va_copy()],lib_cv_va_copy,[
+        AC_RUN_IFELSE([AC_LANG_SOURCE([[
+        #include <stdarg.h>
+        void f (int i, ...) {
+        va_list args1, args2;
+        va_start (args1, i);
+        va_copy (args2, args1);
+        if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
+          exit (1);
+        va_end (args1); va_end (args2);
+        }
+        int main() {
+          f (0, 42);
+          return 0;
+        }]])],
+        [lib_cv_va_copy=yes],
+        [lib_cv_va_copy=no],
+        [lib_cv_va_copy=no])
+])
+
+AC_CACHE_CHECK([for an implementation of __va_copy()],lib_cv___va_copy,[
+        AC_RUN_IFELSE([AC_LANG_SOURCE([[
+        #include <stdarg.h>
+        void f (int i, ...) {
+        va_list args1, args2;
+        va_start (args1, i);
+        __va_copy (args2, args1);
+        if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
+          exit (1);
+        va_end (args1); va_end (args2);
+        }
+        int main() {
+          f (0, 42);
+          return 0;
+        }]])],
+        [lib_cv___va_copy=yes],
+        [lib_cv___va_copy=no],
+        [lib_cv___va_copy=no])
+])
+
+if test "x$lib_cv_va_copy" = xyes; then
+  va_copy_func=va_copy
+else if test "x$lib_cv___va_copy" = xyes; then
+  va_copy_func=__va_copy
+fi
+fi
+
+if test -n "$va_copy_func"; then
+  AC_DEFINE_UNQUOTED(VA_COPY,$va_copy_func,[A 'va_copy' style function])
+fi
+
+AC_CACHE_CHECK([whether va_lists can be copied by value],lib_cv_va_val_copy,[
+        AC_RUN_IFELSE([AC_LANG_SOURCE([[
+        #include <stdarg.h>
+        void f (int i, ...) {
+        va_list args1, args2;
+        va_start (args1, i);
+        args2 = args1;
+        if (va_arg (args2, int) != 42 || va_arg (args1, int) != 42)
+          exit (1);
+        va_end (args1); va_end (args2);
+        }
+        int main() {
+          f (0, 42);
+          return 0;
+        }]])],
+        [lib_cv_va_val_copy=yes],
+        [lib_cv_va_val_copy=no],
+        [lib_cv_va_val_copy=no])
+])
+
+if test "x$lib_cv_va_val_copy" = "xno"; then
+  AC_DEFINE(VA_COPY_AS_ARRAY,1, ['va_lists' cannot be copies as values])
+fi
 
 # Checks on cygnus and MYSYS
-if test "x$MSYS" = xyes ; then
+if test "x$CYGNUS" = xyes || test "x$MSYS" = xyes; then
   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
   *yes*)
     AC_CHECK_FUNC(opendir,,
@@ -603,15 +835,15 @@ if test "x$MSYS" = xyes ; then
     ;;
   esac
   if test "x$enable_network" = "xyes"; then
-       if test "x$VCPP" = xyes || test "x$BORLANDC" = xyes || test "x$WATCOM_C" = xyes || test "x$DMC" = xyes; then
-      EXTRALIBS="$EXTRALIBS  wsock32.lib"
+    if test "x$VCPP" = xyes || test "x$BORLANDC" = xyes || test "x$WATCOM_C" = xyes || test "x$DMC" = xyes || test "x$POCC" = xyes; then
+      EXTRALIBS="$EXTRALIBS  ws2_32.lib"
       EXTRADEFS="$EXTRADEFS -DWINSOCK" 
     else
       AC_CHECK_FUNC(socket,,
-       WAPI_CHECK_LIB(wsock32,WSAStartup,
-            [#include <winsock.h>],
-            [WSAStartup(0,0);],
-         [ EXTRALIBS="$EXTRALIBS -lwsock32"
+       WAPI_CHECK_LIB(ws2_32,WSAStartup,
+         [#include <winsock.h>],
+         [WSAStartup(0,0);],
+         [ EXTRALIBS="$EXTRALIBS -lws2_32"
           EXTRADEFS="$EXTRADEFS -DWINSOCK" ]
        )
       )
@@ -623,26 +855,26 @@ fi
 
 dnl tcltk paths
 AC_ARG_WITH(tcl-includes,
-  [  --with-tcl-includes=DIR Tcl include file path ],
+  AS_HELP_STRING([--with-tcl-includes=DIR], [Tcl include file path]),
   [ if test ! -d $withval; then
       AC_MSG_WARN($withval is not found.)
     fi
     tcl_include_dir="-I$withval"
   ])
 AC_ARG_WITH(tcl-libs,
-  [  --with-tcl-libs=DIR     Tcl library file path ],
+  AS_HELP_STRING([--with-tcl-libs=DIR], [Tcl library file path]),
   [ if test ! -d $withval; then
       AC_MSG_WARN($withval is not found.)
     fi
     tcl_libdir="-L$withval" ])
 AC_ARG_WITH(tk-includes,
-  [  --with-tk-includes=DIR  Tk include file path ],
+  AS_HELP_STRING([--with-tk-includes=DIR], [Tk include file path]),
   [ if test ! -d $withval; then
       AC_MSG_WARN($withval is not found.)
     fi
     tk_includes="-I$withval" ])
 AC_ARG_WITH(tk-libs,
-  [  --with-tk-libs=DIR      Tk library file path ],
+  AS_HELP_STRING([--with-tk-libs=DIR], [Tk library file path]),
   [ if test ! -d $withval; then
       AC_MSG_WARN($withval is not found.)
     fi
@@ -650,51 +882,144 @@ AC_ARG_WITH(tk-libs,
 
 dnl offix paths
 AC_ARG_WITH(offix-includes,
-  [  --with-offix-includes=DIR Offix include file path ],
+  AS_HELP_STRING([--with-offix-includes=DIR], [Offix include file path]),
   [ if test ! -d $withval; then
       AC_MSG_WARN($withval is not found.)
     fi
     offix_include_dir="-I$withval" ])
 AC_ARG_WITH(offix-libs,
-  [  --with-offix-libs=DIR   Offix include file path ],
+  AS_HELP_STRING([--with-offix-libs=DIR], [Offix include file path]),
   [ if test ! -d $withval; then
       AC_MSG_WARN($withval is not found.)
     fi
     offix_lib_dir="-L$withval" ])
 
+# audio encoder/decoder libraries
+
+dnl ogg's vorbis
+if test "x$CYGNUS" = xyes || test "x$MSYS" = xyes; then
+  have_ogg=yes
+  have_vorbis=yes
+  AC_DEFINE(HAVE_OGG,1, [Define to 1 if you have the <ogg/ogg.h> header file.])
+  AC_DEFINE(HAVE_LIBVORBIS,1, [Define to 1 if you have the <vorbis/codec.h> header file.])
+else
+  XIPH_PATH_OGG([
+    have_ogg=yes
+    AC_DEFINE(HAVE_OGG,1, [Define to 1 if you have the <ogg/ogg.h> header file.])
+    XIPH_PATH_VORBIS([
+      have_vorbis=yes
+      AC_DEFINE(HAVE_LIBVORBIS,1, [Define to 1 if you have the <vorbis/codec.h> header file.])
+    ],[
+      have_vorbis=no
+    ])
+  ],[
+    have_ogg=no
+  ])
+fi
+
+dnl FLAC
+if test "x$CYGNUS" = xyes || test "x$MSYS" = xyes; then
+  have_flac=yes
+  AC_DEFINE(HAVE_LIBFLAC,1, [Define to 1 if you have the <FLAC/all.h> header file.])
+else
+  AC_CHECK_HEADER(FLAC/all.h, [ 
+    have_flac=yes
+    AC_DEFINE(HAVE_LIBFLAC,1, [Define to 1 if you have the <FLAC/all.h> header file.])
+  ],[
+    have_flac=no
+  ])
+fi
+
+dnl OggFLAC
+dnl if test "x$CYGNUS" = xyes || test "x$MSYS" = xyes; then
+dnl   have_oggflac=yes
+dnl   AC_DEFINE(HAVE_LIBOGGFLAC,1, [Define to 1 if you have the <OggFLAC/all.h> header file.])
+dnl else
+dnl   AC_CHECK_HEADER(OggFLAC/all.h, [ 
+dnl     have_oggflac=yes
+dnl     AC_DEFINE(HAVE_LIBOGGFLAC,1, [Define to 1 if you have the <OggFLAC/all.h> header file.])
+dnl   ],[
+dnl    have_oggflac=no
+dnl  ])
+dnl fi
+
+dnl GoGo-No-Coda
+if test "x$CYGNUS" = xyes || test "x$MSYS" = xyes; then
+  have_libgogo=yes
+  AC_DEFINE(HAVE_LIBGOGO,1, [Define to 1 if you have the <gogo/gogo.h> header file.])
+else
+  AC_CHECK_HEADER(gogo/gogo.h, [ 
+    have_libgogo=yes
+    AC_DEFINE(HAVE_LIBGOGO,1, [Define to 1 if you have the <gogo/gogo.h> header file.])
+  ],[
+    have_libgogo=no
+  ])
+fi
+
+dnl mpg123
+if test "x$CYGNUS" = xyes || test "x$MSYS" = xyes; then
+  have_mpg123=yes
+  AC_DEFINE(HAVE_LIBMPG123,1, [Define to 1 if you have the <mpg123.h> header file.])
+else
+  AC_CHECK_HEADER(mpg123.h, [ 
+    have_mpg123=yes
+    AC_DEFINE(HAVE_LIBMPG123,1, [Define to 1 if you have the <mpg123.h> header file.])
+    EXTRALIBS="$EXTRALIBS -lmpg123"
+  ],[
+    have_mpg123=no
+  ])
+fi
+
 
 #
 # audio section
 #
-dnl default(d): auto selection
-dnl oss(d):     OSS /dev/dsp
-dnl alsa(d):    ALSA pcm device
-dnl sun(d):     SunOS /dev/audio
-dnl hpux(d):    HPUX /dev/audio
-dnl irix(d):    IRIX audio
-dnl mme(d):     OSF/1 MME
-dnl sb_dsp(d):  BSD/OS 2.0 /dev/sb_dsp
-dnl w32(d):     Windows MMS
-dnl darwin(d):  Mac OS X pcm device
-dnl alsa(s):    ALSA pcm device
-dnl alib(A):    HPUX network audio (Alib)
-dnl nas(n):     Network Audio System
-dnl arts(R):   aRts
-dnl esd(e):     EsounD
+dnl default(d):  auto selection
+dnl oss(d):      OSS /dev/dsp
+dnl alsa(d):     ALSA pcm device
+dnl sun(d):      SunOS /dev/audio
+dnl hpux(d):     HPUX /dev/audio
+dnl irix(d):     IRIX audio
+dnl mme(d):      OSF/1 MME
+dnl sb_dsp(d):   BSD/OS 2.0 /dev/sb_dsp
+dnl w32(d):      Windows MMS
+dnl darwin(d):   Mac OS X pcm device
+dnl alsa(s):     ALSA pcm device
+dnl alib(A):     HPUX network audio (Alib)
+dnl nas(n):      Network Audio System
+dnl arts(R):     aRts
+dnl esd(e):      EsounD
 dnl portaudio(p) PortAudio
-dnl vorbis(v):  Ogg Vorbis
-dnl flac(F):    FLAC / OggFLAC
-dnl speex(S):   Ogg Speex
-dnl gogo(g):    MP3 GOGO
-dnl jack(j):    JACK
-dnl ao(O):      Libao
-
-audio_targets='default oss alsa sun hpux irix mme sb_dsp w32 alib nas arts esd vorbis flac gogo portaudio jack ao'
+dnl portaudio(O) PortAudio (w32; DirectSound)
+dnl portaudio(P) PortAudio (w32; WDM KernelStreaming)
+dnl portaudio(K) PortAudio (w32; WDM KernelStreaming)
+dnl portaudio(W) PortAudio (w32; WASAPI)
+dnl w32ks(k):    Windows WDM KernelStreaming
+dnl w32wasapi(x) Windows WASAPI
+dnl npipe(N):    Windows named pipe
+dnl vorbis(v):   Ogg Vorbis
+dnl flac(F):     FLAC / OggFLAC
+dnl opus(U):     Ogg Opus
+dnl speex(S):    Ogg Speex
+dnl gogo(g):     MP3 GOGO
+dnl lame(L):     LAME
+dnl jack(j):     JACK
+dnl ao(O):       Libao
+dnl benchmark(b) Benchmark
+dnl macintosh(m) Macintosh pcm device
+dnl macqt(q):    Macintosh QuickTime pcm device
+dnl aiff(a):     output AIFF audio file
+dnl sun(u):      output Sun audio file
+dnl raw(r):      output raw sound data
+dnl volumecalc(V) output analyze text
+dnl wave(w):     output RIFF WAVE sound data
+
+audio_targets='default oss alsa sun hpux irix mme sb_dsp w32 w32ks w32wasapi alib nas arts esd vorbis flac opus lame gogo portaudio npipe jack ao'
 
 AC_ARG_WITH(nas-library,
-  [  --with-nas-library=library NAS absolute library path(Don't use -laudio)])
+  AS_HELP_STRING([--with-nas-library=library], [NAS absolute library path(Don't use -laudio)]))
 AC_ARG_WITH(nas-includes,
-  [  --with-nas-includes=DIR NAS include files are in dir])
+  AS_HELP_STRING([--with-nas-includes=DIR], [NAS include files are in dir]))
 
 
 AC_ARG_ENABLE(audio,
@@ -707,6 +1032,8 @@ AC_ARG_ENABLE(audio,
                               mme:       OSF/1 MME
                               sb_dsp:    BSD/OS 2.0 /dev/sb_dsp
                               w32:       Windows MMS
+                              w32ks:     Windows WDM KernelStreaming
+                              w32wasapi: Windows WASAPI
                               darwin:    Darwin CoreAudio
                               alsa:      ALSA pcm device
                               alib:      HPUX network audio (Alib)
@@ -714,12 +1041,17 @@ AC_ARG_ENABLE(audio,
                               arts:      aRts
                               esd:       EsounD - Enlightened Sound Daemon
                               portaudio: PortAudio
+                              npipe:     Named Pipe(windows)
                               jack:      JACK
                               ao:        Libao
                               vorbis:    Ogg Vorbis
                               flac:      FLAC / OggFLAC
+                              opus:      Ogg Opus
                               speex:     Ogg Speex
-                              gogo:      MP3 GOGO (Only Windows is supported)],
+                              gogo:      MP3 GOGO (Only Windows is supported)
+                              lame:      LAME (Only Windows is supported)
+                              benchmark: Benchmark
+],
   [ enable_audio=$enableval
     have_audio_opt=yes ],
   [ enable_audio=yes
@@ -728,7 +1060,7 @@ AC_ARG_ENABLE(audio,
 dnl yes -> default
 test "x$enable_audio" = xyes && enable_audio=default
 
-if test "x$enable_audio" != xno; then
+if test "x$enable_audio" != "xno"; then
   for i in `echo $enable_audio | sed 's/,/ /g'`; do
     eval "au_enable_$i=yes"
   done
@@ -737,15 +1069,16 @@ fi
 dnl Turn on default output mode
 DEFAULT_PLAYMODE=
 AC_ARG_WITH(default-output,
-  [  --with-default-output=<mode>  Specify default output mode (optional):
+  AS_HELP_STRING([--with-default-output=<mode>],
+  [Specify default output mode (optional):
                                 (default|alsa|alib|arts|nas|
-                                esd|wav|au|aiff|list|vorbis|flac|speex|
-                                gogo|portaudio|jack|ao)],
+                                esd|wav|au|aiff|list|vorbis|flac|opus|speex|
+                                lame|gogo|portaudio|npipe|jack|ao)]),
   [ if test "$enable_audio" != no; then
     DEFAULT_PLAYMODE=$withval
     eval "au_enable_$DEFAULT_PLAYMODE=yes"
   else
-    AC_MSG_WARN(--with-default-output=$withval: audio is not enabled)
+    AC_MSG_WARN([--with-default-output=$withval: audio is not enabled])
   fi])
 
 dnl compatibility matters.
@@ -762,7 +1095,13 @@ dnl   [ au_enable_alsa=$enableval ])
 dnl target-specific defaults
 if test "x$au_enable_default" = xyes; then
   case "$target" in
-  *-*-linux*|*-*-freebsd*)
+  *-*-linux*)
+    au_enable_alsa=yes
+    if test "x$DEFAULT_PLAYMODE" = "x"; then
+      DEFAULT_PLAYMODE="alsa"
+    fi
+    ;;
+  *-*-freebsd*)
     au_enable_oss=yes
     ;;
   *-*-bsdi2.0)
@@ -789,6 +1128,9 @@ if test "x$au_enable_default" = xyes; then
   *-*-netbsd*)
     au_enable_sun=yes
     ;;
+  *-*-openbsd*)
+    au_enable_sun=yes
+    ;;
   *-*-cygwin*)
     au_enable_w32=yes
     ;;
@@ -825,7 +1167,7 @@ if test "x$au_enable_oss" = xyes; then
         else
           AC_MSG_WARN(<sys/soundcard.h> is not found)
         fi
-       ;;
+        ;;
     esac
   fi
   AC_CHECK_LIB(ossaudio,open)
@@ -849,15 +1191,15 @@ if test "x$au_enable_sun" = xyes; then
     *-*-sunos4*)
       if test -f /usr/demo/SOUND/libaudio.a; then
         EXTRALIBS="$EXTRALIBS /usr/demo/SOUND/libaudio.a"
-       AC_MSG_RESULT(yes)
+        AC_MSG_RESULT(yes)
       else
-       AC_MSG_RESULT(Notice: libaudio.a is not found [(ignore)])
+        AC_MSG_RESULT(Notice: libaudio.a is not found [(ignore)])
       fi
       ;;
     *-*-solaris*)
       if test -f /usr/demo/SOUND/lib/libaudio.a; then
         EXTRALIBS="$EXTRALIBS /usr/demo/SOUND/lib/libaudio.a"
-       AC_MSG_RESULT(yes)
+        AC_MSG_RESULT(yes)
       else
         AC_MSG_RESULT(Notice: libaudio.a is not found [(ignore)])
       fi
@@ -939,7 +1281,7 @@ if test "x$au_enable_w32" = xyes; then
     *-*-cygwin*)
      AC_MSG_RESULT(yes)
      ;;
-    *-*-mingw32)
+    *-*-mingw*)
      AC_MSG_RESULT(yes)
      ;;
     *)
@@ -947,8 +1289,8 @@ if test "x$au_enable_w32" = xyes; then
      ;;
   esac
   SYSEXTRAS="$SYSEXTRAS w32_a.c"
-  if test "x$VCPP" = xyes || test "x$BORLANDC" = xyes || test "x$WATCOM_C" = xyes || test "x$DMC" = xyes; then
-       EXTRALIBS="$EXTRALIBS winmm.lib"
+  if test "x$VCPP" = xyes || test "x$BORLANDC" = xyes || test "x$WATCOM_C" = xyes || test "x$DMC" = xyes || test "x$POCC" = xyes; then
+    EXTRALIBS="$EXTRALIBS winmm.lib"
   else
     EXTRALIBS="$EXTRALIBS -lwinmm"
   fi
@@ -984,7 +1326,7 @@ if test "x$au_enable_alsa" = xyes; then
   KEEPLIBS=$LIBS
   KEEPLDFLAGS=$LDFLAGS
   AM_PATH_ALSA()
-  if test "x$alsa_found" = "xyes" ; then
+  if test "x$alsa_found" = xyes ; then
     dnl AC_MSG_RESULT(yes)
     EXTRADEFS="$EXTRADEFS -DAU_ALSA"
     SYSEXTRAS="$SYSEXTRAS alsa_a.c"
@@ -1033,20 +1375,20 @@ if test "x$au_enable_nas" = xyes; then
   dnl -laudio conflicts another audio library,
   dnl so I specify NAS library with absolete path.
 
-  if test "x$with_nas_library" != x; then
+  if test "x$with_nas_library" != "x"; then
     AC_MSG_RESULT($with_nas_library);
     EXTRALIBS="$EXTRALIBS $with_nas_library"
   else
     AC_MSG_RESULT()
     MY_SEARCH_LIBS(AuOpenServer,
-       [$x_libraries/libaudio.a \
-        /usr/lib/libaudio.so \
-        /usr/lib/libaudio.a ],
-       [ AC_MSG_RESULT(NAS: $timidity_cv_search_AuOpenServer)
-         EXTRALIBS="$EXTRALIBS $timidity_cv_search_AuOpenServer"],
-       [AC_MSG_WARN(NAS library is not found.)])
+        [$x_libraries/libaudio.a \
+         /usr/lib/libaudio.so \
+         /usr/lib/libaudio.a ],
+        [ AC_MSG_RESULT(NAS: $timidity_cv_search_AuOpenServer)
+          EXTRALIBS="$EXTRALIBS $timidity_cv_search_AuOpenServer"],
+        [AC_MSG_WARN(NAS library is not found.)])
   fi
-  test "x$with_nas_includes" != x && CPPFLAGS="$CPPFLAGS -I$with_nas_includes"
+  test "x$with_nas_includes" != "x" && CPPFLAGS="$CPPFLAGS -I$with_nas_includes"
   lib_xt_opt=-lXt
   if test "x$have_xext" = xyes; then
     lib_xext_opt=-lXext
@@ -1062,19 +1404,35 @@ dnl aRts of KDE
 AC_MSG_CHECKING(enable_audio=arts)
 if test "x$au_enable_arts" = xyes; then
   AC_MSG_RESULT([yes, configuring aRts])
-  KEEPCFLAGS=$CFLAGS
-  KEEPLIBS=$LIBS
-  KEEPLDFLAGS=$LDFLAGS
-  AM_PATH_ARTS()
-  CFLAGS=$KEEPCFLAGS
-  LIBS=$KEEPLIBS
-  LDFLAGS=$KEEPLDFLAGS
-  if test "x$no_arts" = x; then
+  dnl **** Check for aRts Sound Server ****
+  AC_PATH_PROG(ARTSCCONFIG, artsc-config)
+  if test x$ARTSCCONFIG != "x" -a x$ARTSCCONFIG != x'"$ARTSCCONFIG"';
+  then
+    ARTSC_CFLAGS=""
+    for i in `$ARTSCCONFIG --cflags`
+    do
+      case "$i" in
+        -I*) ARTSC_CFLAGS="$ARTSC_CFLAGS $i";;
+      esac
+    done
+    ARTSC_LIBS=`$ARTSCCONFIG --libs`
+    save_CFLAGS="$CFLAGS"
+    CFLAGS="$CFLAGS $ARTSC_CFLAGS"
+    AC_TRY_COMPILE([#include <artsc.h>],[arts_stream_t stream;],
+        [AC_SUBST(ARTSLIBS, $ARTSC_LIBS)
+         AC_SUBST(ARTSINCL, $ARTSC_CFLAGS)
+         AC_DEFINE(HAVE_ARTS, 1, [Define if you have ARTS sound server])
+           have_arts="yes"
+         ])
+    CFLAGS="$save_CFLAGS"
+  fi
+
+  if test "$have_arts" = "yes"; then
     dnl AC_MSG_RESULT(aRts: Enabled)
     EXTRADEFS="$EXTRADEFS -DAU_ARTS"
     SYSEXTRAS="$SYSEXTRAS aRts_a.c"
-    EXTRACT_CPPFLAGS(CPPFLAGS,CFLAGS,$ARTS_CFLAGS)
-    LIBS="$LIBS $ARTS_LIBS"
+    EXTRACT_CPPFLAGS(CPPFLAGS,CFLAGS,$ARTSC_CFLAGS)
+    LIBS="$LIBS $ARTSC_LIBS"
   else
     AC_MSG_WARN(aRts: Couldn't configure)
   fi
@@ -1093,7 +1451,7 @@ if test "x$au_enable_esd" = xyes; then
   CFLAGS=$KEEPCFLAGS
   LIBS=$KEEPLIBS
   LDFLAGS=$KEEPLDFLAGS
-  if test "x$no_esd" = x; then
+  if test "x$no_esd" = "x"; then
     dnl AC_MSG_RESULT(EsounD: Enabled)
     EXTRADEFS="$EXTRADEFS -DAU_ESD"
     SYSEXTRAS="$SYSEXTRAS esd_a.c"
@@ -1106,23 +1464,48 @@ else
   AC_MSG_RESULT(no)
 fi
 
-dnl portaudio E
+dnl portaudio
 AC_MSG_CHECKING(enable_audio=portaudio)
 if test "x$au_enable_portaudio" = xyes; then
   AC_MSG_RESULT(yes)
-  if test "x$MSYS" = xyes ; then
-       SYSEXTRAS="$SYSEXTRAS portaudio_a.c w32_portaudio_dll.c"
-       EXTRALIBS="$EXTRALIBS -lportaudio"
-       EXTRADEFS="$EXTRADEFS -DAU_PORTAUDIO -DAU_PORTAUDIO_DLL"
+  if test "x$CYGNUS" = xyes ||test "x$MSYS" = xyes; then
+    AC_ARG_ENABLE(dynamic-portaudio,
+                AS_HELP_STRING([--dynamic-portaudio], [Dynamic Link PortAudio.]),
+                [timidity_cv_dynamic_portaudio="yes"], [timidity_cv_dynamic_portaudio="no"])
+    if test "x$timidity_cv_dynamic_portaudio" = xyes; then
+        SYSEXTRAS="$SYSEXTRAS portaudio_a.c w32_portaudio_dll.c"
+dnl     EXTRALIBS="$EXTRALIBS -lportaudio"
+        CPPFLAGS="$CPPFLAGS -I../portaudio/pa_common/"
+        EXTRADEFS="$EXTRADEFS -DAU_PORTAUDIO -DAU_PORTAUDIO_DLL -DPORTAUDIO_V19"
+    else
+dnl     SYSEXTRAS="$SYSEXTRAS portaudio_a.c"
+        SYSEXTRAS="$SYSEXTRAS portaudio_a.c w32_portaudio_dll.c"
+dnl     EXTRALIBS="$EXTRALIBS -lportaudio"
+        CPPFLAGS="$CPPFLAGS -I../portaudio/pa_common/"
+dnl     EXTRADEFS="$EXTRADEFS -DAU_PORTAUDIO -DPORTAUDIO_V19"
+        EXTRADEFS="$EXTRADEFS -DAU_PORTAUDIO -DAU_PORTAUDIO_DLL -DPORTAUDIO_V19"
+    fi
   else
-       SYSEXTRAS="$SYSEXTRAS portaudio_a.c"
-       EXTRALIBS="$EXTRALIBS -lportaudio"
-       EXTRADEFS="$EXTRADEFS -DAU_PORTAUDIO"
+        SYSEXTRAS="$SYSEXTRAS portaudio_a.c"
+        EXTRALIBS="$EXTRALIBS -lportaudio"
+        EXTRADEFS="$EXTRADEFS -DAU_PORTAUDIO"
   fi
 else
   AC_MSG_RESULT(no)
 fi
 
+dnl npipe (windows named pipe)
+if test "x$CYGNUS" = xyes ||test "x$MSYS" = xyes; then
+  AC_MSG_CHECKING(enable_audio=npipe)
+  if test "x$au_enable_npipe" = xyes; then
+    AC_MSG_RESULT(yes)
+      SYSEXTRAS="$SYSEXTRAS npipe_a.c"
+      EXTRADEFS="$EXTRADEFS -DAU_NPIPE"
+  else
+    AC_MSG_RESULT(no)
+  fi
+fi
+
 dnl JACK
 AC_MSG_CHECKING(enable_audio=jack)
 if test "x$au_enable_jack" = xyes; then
@@ -1156,43 +1539,68 @@ dnl ogg's vorbis
 AC_MSG_CHECKING(enable_audio=vorbis)
 if test "x$au_enable_vorbis" = xyes; then
   AC_MSG_RESULT([yes, configuring vorbis])
-  AM_PATH_OGG([
-    AM_PATH_VORBIS([
+  if test "x$CYGNUS" = xyes || test "x$MSYS" = xyes; then
+    AC_ARG_ENABLE(dynamic-vorbis,
+                AS_HELP_STRING([--dynamic-vorbis], [Dynamic Link OggVorbis.]),
+                [timidity_cv_dynamic_vorbis="yes"], [timidity_cv_dynamic_vorbis="no"])
+    if test "x$timidity_cv_dynamic_vorbis" = xyes; then
       have_vorbis=yes
-      SYSEXTRAS="$SYSEXTRAS vorbis_a.c"
-      EXTRADEFS="$EXTRADEFS -DAU_VORBIS $OGG_CFLAGS $VORBIS_CFLAGS"
-      EXTRALIBS="$EXTRALIBS $VORBIS_LIBS $VORBISENC_LIBS $OGG_LIBS"
-      if test "x$MSYS" = "xyes"; then
-      EXTRADEFS="-DAU_VORBIS_DLL $EXTRADEFS"
-         SYSEXTRAS="$SYSEXTRAS w32g_vorbisenc_dll.c w32g_vorbis_dll.c w32g_ogg_dll.c"
-      fi
+      EXTRADEFS="$EXTRADEFS -DAU_VORBIS -DAU_VORBIS_DLL"
+      SYSEXTRAS="$SYSEXTRAS vorbis_a.c w32g_vorbisenc_dll.c w32g_vorbis_dll.c w32g_ogg_dll.c"
+    else
+      AC_CHECK_HEADER(vorbis/vorbisenc.h,, [ 
+        have_vorbis=yes
+        EXTRADEFS="$EXTRADEFS -DAU_VORBIS"
+        SYSEXTRAS="$SYSEXTRAS vorbis_a.c"
+      ])
+    fi
+  else
+    XIPH_PATH_OGG([
+      XIPH_PATH_VORBIS([
+        have_vorbis=yes
+        SYSEXTRAS="$SYSEXTRAS vorbis_a.c"
+        EXTRADEFS="$EXTRADEFS -DAU_VORBIS $OGG_CFLAGS $VORBIS_CFLAGS"
+        EXTRALIBS="$EXTRALIBS $VORBIS_LIBS $VORBISENC_LIBS $VORBISFILE_LIBS $OGG_LIBS"
+        if test "x$MINGWGCC" = xyes ; then
+          EXTRADEFS="-DAU_VORBIS_DLL $EXTRADEFS"
+          SYSEXTRAS="$SYSEXTRAS w32g_vorbisenc_dll.c w32g_vorbis_dll.c w32g_ogg_dll.c"
+        fi
+      ],[
+        AC_MSG_WARN([Unable to configure vorbis, but ogg is there (???)])
+      ])
     ],[
-      AC_MSG_WARN([Unable to configure vorbis, but ogg is there (???)])
+      AC_MSG_WARN(Unable to configure vorbis!)
+      have_vorbis=no
     ])
-  ],[
-    AC_MSG_WARN(Unable to configure vorbis!)
-    have_vorbis=no
-  ])
+  fi
 else
   AC_MSG_RESULT(no)
 fi
 
 dnl libFLAC - Free Lossless Audio Codec
-if test "x$MSYS" = xyes ; then
+if test "x$CYGNUS" = xyes || test "x$MSYS" = xyes ; then
   AC_MSG_CHECKING(enable_audio=flac)
   if test "x$au_enable_flac" = xyes; then
     AC_MSG_RESULT([yes, configuring flac])
+    have_flac=yes
     SYSEXTRAS="$SYSEXTRAS flac_a.c w32_libFLAC_dll.c w32_libOggFLAC_dll.c"
-    AM_PATH_LIBFLAC([
-      EXTRADEFS="$EXTRADEFS -DAU_FLAC -DAU_FLAC_DLL"
-      EXTRACT_CPPFLAGS(CPPFLAGS,CFLAGS,$LIBFLAC_CFLAGS)
-      LIBS="$LIBS $LIBFLAC_LIBS"
-    ])
-    AM_PATH_LIBOGGFLAC([
-      EXTRADEFS="$EXTRADEFS -DAU_OGGFLAC -DAU_OGGFLAC_DLL"
-      EXTRACT_CPPFLAGS(CPPFLAGS,CFLAGS,$LIBOGGFLAC_CFLAGS)
-      LIBS="$LIBS $LIBOGGFLAC_LIBS"
-    ])
+    EXTRADEFS="$EXTRADEFS -DAU_FLAC -DAU_FLAC_DLL -DAU_OGGFLAC"
+dnl    AC_CHECK_HEADER(FLAC/all.h, [ 
+dnl      EXTRADEFS="$EXTRADEFS -DAU_FLAC -DAU_FLAC_DLL"
+dnl    ])
+dnl    AC_CHECK_HEADER(OggFLAC/all.h, [ 
+dnl      EXTRADEFS="$EXTRADEFS -DAU_OGGFLAC -DAU_OGGFLAC_DLL"
+dnl    ])
+dnl    AM_PATH_LIBFLAC([
+dnl      EXTRADEFS="$EXTRADEFS -DAU_FLAC -DAU_FLAC_DLL"
+dnl      EXTRACT_CPPFLAGS(CPPFLAGS,CFLAGS,$LIBFLAC_CFLAGS)
+dnl      LIBS="$LIBS $LIBFLAC_LIBS"
+dnl    ])
+dnl    AM_PATH_LIBOGGFLAC([
+dnl      EXTRADEFS="$EXTRADEFS -DAU_OGGFLAC -DAU_OGGFLAC_DLL"
+dnl      EXTRACT_CPPFLAGS(CPPFLAGS,CFLAGS,$LIBOGGFLAC_CFLAGS)
+dnl      LIBS="$LIBS $LIBOGGFLAC_LIBS"
+dnl    ])
   else
     AC_MSG_RESULT(no)
   fi
@@ -1202,11 +1610,13 @@ else
     AC_MSG_RESULT([yes, configuring flac])
     SYSEXTRAS="$SYSEXTRAS flac_a.c"
     AM_PATH_LIBFLAC([
+      have_flac=yes
       EXTRADEFS="$EXTRADEFS -DAU_FLAC"
       EXTRACT_CPPFLAGS(CPPFLAGS,CFLAGS,$LIBFLAC_CFLAGS)
       LIBS="$LIBS $LIBFLAC_LIBS"
     ])
     AM_PATH_LIBOGGFLAC([
+      have_oggflac=yes
       EXTRADEFS="$EXTRADEFS -DAU_OGGFLAC"
       EXTRACT_CPPFLAGS(CPPFLAGS,CFLAGS,$LIBOGGFLAC_CFLAGS)
       LIBS="$LIBS $LIBOGGFLAC_LIBS"
@@ -1215,23 +1625,78 @@ else
     AC_MSG_RESULT(no)
   fi
 fi
+
+dnl ogg's opus
+AC_MSG_CHECKING(enable_audio=opus)
+if test "x$au_enable_opus" = xyes; then
+  AC_MSG_RESULT([yes, configuring opus])
+  if test "x$CYGNUS" = xyes || test "x$MSYS" = xyes; then
+    AC_ARG_ENABLE(dynamic-opus,
+                AS_HELP_STRING([--dynamic-opus], [Dynamic Link Opus.]),
+                [timidity_cv_dynamic_opus="yes"], [timidity_cv_dynamic_opus="no"])
+    if test "x$timidity_cv_dynamic_opus" = xyes; then
+      AC_CHECK_HEADER(opus/opus.h,, [ 
+        have_opus=yes
+        EXTRADEFS="-DAU_OPUS -DAU_OPUS_DLL $EXTRADEFS"
+        SYSEXTRAS="$SYSEXTRAS w32g_opus_dll.c w32g_ogg_dll.c"
+      ])
+    else
+      AC_CHECK_HEADER(opus/opus.h,, [
+        have_opus=yes
+        EXTRADEFS="-DAU_OPUS -DAU_OPUS_DLL $EXTRADEFS"
+        EXTRALIBS="$EXTRALIBS $OPUS_LIBS $OGG_LIBS"
+      ])
+    fi
+  else
+  XIPH_PATH_OGG([
+    XIPH_PATH_OPUS([
+      have_opus=yes
+      SYSEXTRAS="$SYSEXTRAS opus_a.c"
+      EXTRADEFS="$EXTRADEFS -DAU_OPUS $OGG_CFLAGS $OPUS_CFLAGS"
+      EXTRALIBS="$EXTRALIBS $OPUS_LIBS $OGG_LIBS"
+      if test "x$MINGWGCC" = xyes ; then
+        EXTRADEFS="-DAU_OPUS_DLL $EXTRADEFS"
+        SYSEXTRAS="$SYSEXTRAS w32g_opus_dll.c w32g_ogg_dll.c"
+      fi
+    ],[
+      AC_MSG_WARN([Unable to configure opus, but ogg is there (???)])
+    ])
+  ],[
+    AC_MSG_WARN(Unable to configure opus!)
+    have_opus=no
+  ])
+  fi
+else
+  AC_MSG_RESULT(no)
+fi
+
 dnl ogg's speex
 AC_MSG_CHECKING(enable_audio=speex)
 if test "x$au_enable_speex" = xyes; then
-  AC_CACHE_VAL(have_speex,
-  [AC_TRY_LINK([
-  #include <speex.h>
-  #include <ogg/ogg.h>
-  ],
-  [
-    SpeexBits *dummy;
-  ],
-  [have_speex=yes], [have_speex=no])])
-  AC_MSG_RESULT($have_speex)
-  if test "x$have_speex" = xyes; then
+  AC_MSG_RESULT(yes, configuring speex)
+  if test "x$CYGNUS" = xyes || test "x$MSYS" = xyes; then
+    have_speex=yes
     SYSEXTRAS="$SYSEXTRAS speex_a.c"
     EXTRALIBS="$EXTRALIBS -lspeex -logg"
     EXTRADEFS="$EXTRADEFS -DAU_SPEEX"
+    dnl EXTRADEFS="$EXTRADEFS -DAU_SPEEX -DAU_SPEEX_DLL"
+    dnl SYSEXTRAS="$SYSEXTRAS w32g_speex_dll.c"
+  else
+    AC_CACHE_VAL(timidity_cv_have_speex,
+    [AC_TRY_LINK([
+    #include <speex/speex.h>
+    #include <ogg/ogg.h>
+    ],
+    [
+      SpeexBits *dummy;
+    ],
+    [have_speex=yes], [have_speex=no])])
+    AC_MSG_RESULT($have_speex)
+    if test "x$have_speex" = xyes; then
+      SYSEXTRAS="$SYSEXTRAS speex_a.c"
+      EXTRALIBS="$EXTRALIBS -lspeex -logg"
+      EXTRADEFS="$EXTRADEFS -DAU_SPEEX"
+    fi
   fi
 else
   AC_MSG_RESULT(no)
@@ -1240,19 +1705,56 @@ fi
 dnl Win32 Gogo-no-coder
 AC_MSG_CHECKING(enable_audio=gogo)
 if test "x$au_enable_gogo" = xyes; then
-  if test "x$MSYS" = "xyes"; then
+  if test "x$CYGNUS" = xyes || test "x$MSYS" = xyes; then
     AC_MSG_RESULT(yes, configuring gogo)
   else
     AC_MSG_WARN(May be gogo is not supported.  You need hack the gogo_a.c)
   fi
-  have_gogo=yes
+  AC_CHECK_HEADER(gogo/gogo.h, [ 
+    have_gogo=yes
+  ])
   SYSEXTRAS="$SYSEXTRAS gogo_a.c w32_gogo.c"
   EXTRADEFS="$EXTRADEFS -DAU_GOGO -DAU_GOGO_DLL"
-  EXTRALIBS="$EXTRALIBS -lgogo"
+dnl  EXTRALIBS="$EXTRALIBS -lgogo"
+else
+  AC_MSG_RESULT(no)
+fi
+
+dnl Win32 LAME
+AC_MSG_CHECKING(enable_audio=lame)
+if test "x$au_enable_lame" = xyes; then
+  if test "x$CYGNUS" = xyes || test "x$MSYS" = xyes; then
+    AC_MSG_RESULT([yes, configuring lame])
+    have_lame=yes
+  else
+    AC_MSG_WARN(May be lame is not supported.  You need hack the lame_a.c)
+  fi
+dnl  AC_CHECK_HEADERS(timidity/BladeMP3EncDLL.h timidity/LameEnc.h, [ 
+dnl    have_lame=yes
+dnl  ],,
+dnl  [[
+dnl  #if HAVE_BLADEMP3ENCDLL_H
+dnl  # include "windows.h"
+dnl  # include "BladeMP3EncDLL.h"
+dnl  #endif
+dnl  ]])
+  SYSEXTRAS="$SYSEXTRAS lame_a.c"
+  EXTRADEFS="$EXTRADEFS -DAU_LAME"
+dnl  EXTRALIBS="$EXTRALIBS"
 else
   AC_MSG_RESULT(no)
 fi
 
+dnl Benchmark
+AC_MSG_CHECKING(enable_audio=benchmark)
+if test "x$au_enable_npipe" = xno; then
+  AC_MSG_RESULT(no)
+else
+  AC_MSG_RESULT(yes)
+dnl  SYSEXTRAS="$SYSEXTRAS benchmark_a.c"
+  EXTRADEFS="$EXTRADEFS -DAU_BENCHMARK"
+fi
+
 dnl Pseudo audio device (Undocumented).
 if test "x$au_enable_none" = xyes; then
     EXTRADEFS="$EXTRADEFS -DAU_NONE -DAU_AUDRIV"
@@ -1262,35 +1764,39 @@ dnl
 dnl TIMIDITY_OUTPUT_ID
 dnl
 AC_MSG_CHECKING(default output mode)
-if test "x$DEFAULT_PLAYMODE" = x; then
+if test "x$DEFAULT_PLAYMODE" = "x"; then
   DEFAULT_PLAYMODE=`echo $enable_audio | sed 's/,.*//'`
 fi
 case ".$DEFAULT_PLAYMODE" in
-  .default)  TIMIDITY_OUTPUT_ID=d ;;
-  .oss)      TIMIDITY_OUTPUT_ID=d ;;
-  .alsa)     TIMIDITY_OUTPUT_ID=s ;;
-  .sun)      TIMIDITY_OUTPUT_ID=d ;;
-  .hpux)     TIMIDITY_OUTPUT_ID=d ;;
-  .irix)     TIMIDITY_OUTPUT_ID=d ;;
-  .mme)      TIMIDITY_OUTPUT_ID=d ;;
-  .sb_dsp)   TIMIDITY_OUTPUT_ID=d ;;
-  .darwin)   TIMIDITY_OUTPUT_ID=d ;;
-  .w32)      TIMIDITY_OUTPUT_ID=d ;;
-  .alib)     TIMIDITY_OUTPUT_ID=A ;;
-  .nas)      TIMIDITY_OUTPUT_ID=n ;;
-  .arts)     TIMIDITY_OUTPUT_ID=R ;;
-  .esd)      TIMIDITY_OUTPUT_ID=e ;;
-  .portaudio)      TIMIDITY_OUTPUT_ID=p ;;  
-  .wav)      TIMIDITY_OUTPUT_ID=w ;;
-  .au)       TIMIDITY_OUTPUT_ID=u ;;
-  .aiff)     TIMIDITY_OUTPUT_ID=a ;;
-  .list)     TIMIDITY_OUTPUT_ID=l ;;
-  .vorbis)   TIMIDITY_OUTPUT_ID=v ;;
-  .flac)     TIMIDITY_OUTPUT_ID=F ;;
-  .speex)    TIMIDITY_OUTPUT_ID=S ;;
-  .gogo)     TIMIDITY_OUTPUT_ID=g ;;
-  .jack)     TIMIDITY_OUTPUT_ID=j ;;
-  *)         TIMIDITY_OUTPUT_ID= ;;
+  .default)    TIMIDITY_OUTPUT_ID=d ;;
+  .oss)        TIMIDITY_OUTPUT_ID=d ;;
+  .alsa)       TIMIDITY_OUTPUT_ID=s ;;
+  .sun)        TIMIDITY_OUTPUT_ID=d ;;
+  .hpux)       TIMIDITY_OUTPUT_ID=d ;;
+  .irix)       TIMIDITY_OUTPUT_ID=d ;;
+  .mme)        TIMIDITY_OUTPUT_ID=d ;;
+  .sb_dsp)     TIMIDITY_OUTPUT_ID=d ;;
+  .darwin)     TIMIDITY_OUTPUT_ID=d ;;
+  .w32)        TIMIDITY_OUTPUT_ID=d ;;
+  .alib)       TIMIDITY_OUTPUT_ID=A ;;
+  .nas)        TIMIDITY_OUTPUT_ID=n ;;
+  .arts)       TIMIDITY_OUTPUT_ID=R ;;
+  .esd)        TIMIDITY_OUTPUT_ID=e ;;
+  .portaudio)  TIMIDITY_OUTPUT_ID=p ;;  
+  .npipe)      TIMIDITY_OUTPUT_ID=N ;;
+  .wav)        TIMIDITY_OUTPUT_ID=w ;;
+  .au)         TIMIDITY_OUTPUT_ID=u ;;
+  .aiff)       TIMIDITY_OUTPUT_ID=a ;;
+  .list)       TIMIDITY_OUTPUT_ID=l ;;
+  .vorbis)     TIMIDITY_OUTPUT_ID=v ;;
+  .flac)       TIMIDITY_OUTPUT_ID=F ;;
+  .opus)       TIMIDITY_OUTPUT_ID=U ;;
+  .speex)      TIMIDITY_OUTPUT_ID=S ;;
+  .gogo)       TIMIDITY_OUTPUT_ID=g ;;
+  .lame)       TIMIDITY_OUTPUT_ID=L ;;
+  .jack)       TIMIDITY_OUTPUT_ID=j ;;
+  .ao)         TIMIDITY_OUTPUT_ID=O ;;
+  *)           TIMIDITY_OUTPUT_ID= ;;
 esac
 AC_MSG_RESULT($DEFAULT_PLAYMODE/$TIMIDITY_OUTPUT_ID)
 
@@ -1299,26 +1805,24 @@ AC_MSG_RESULT($DEFAULT_PLAYMODE/$TIMIDITY_OUTPUT_ID)
 # Interface Section
 #
 
-interface_targets='dynamic ncurses slang motif tcltk emacs vt100 xaw xskin gtk alsaseq winsyn winsyng portmidisyng'
+interface_targets='dynamic ncurses slang motif tcltk emacs vt100 xaw xskin gtk alsaseq winsyn winsyng portmidisyng npsyn'
 
 AC_ARG_ENABLE(interface,
-  [  --enable-interface=[interface_list]
-                          Comma separated interface list ],
+  AS_HELP_STRING([--enable-interface=[interface_list]], [Comma separated interface list]),
   [ for i in `echo $enableval | sed 's/,/ /g'`; do
       eval "enable_$i=yes"
     done ])
 
 #  Dynamic link configuration
 AC_ARG_ENABLE(dynamic,
-  [  --enable-dynamic        Enable dynamic link interface   (default is no)
-  --enable-dynamic=dynamic_list
-                          Comma separated dynamic interface list],
+  AS_HELP_STRING([--enable-dynamic], [Enable dynamic link interface (default is no)])
+  AS_HELP_STRING([--enable-dynamic=dynamic_list] [Comma separated dynamic interface list]),
   [ dnl --enable-dynamic=yes to --enable-dynamic=dynamic
     if test "x$enable_dynamic" = xyes; then
       enable_dynamic=dynamic
-    elif test "x$enable_dynamic" != xno; then
+    elif test "x$enable_dynamic" != "xno"; then
       for i in `echo $enableval | sed 's/,/ /g'`; do
-       eval "enable_$i=dynamic"
+        eval "enable_$i=dynamic"
       done
     fi])
 
@@ -1329,18 +1833,31 @@ done
 
 case ".$join_targets" in
 .*dynamic*) NEEDDLOPEN=yes;;
-*)         NEEDDLOPEN=no;;
+*)          NEEDDLOPEN=no;;
 esac
 
 dnl check -fpic option for gcc
 if test "x$GCC" = xyes; then SHCFLAGS="$SHCFLAGS -fPIC"; fi
 case "x$enable_ump" in xyes|xdynamic) EXTRACFLAGS="$EXTRACFLAGS -DXP_UNIX $SHCFLAGS";; esac
 
+dnl check -masm option for gcc
+dnl if test "x$GCC" = xyes; then EXTRACFLAGS="$EXTRACFLAGS -masm=intel"; fi
+
 dnl Which type of dynamic loader?
 if test "$NEEDDLOPEN" = "yes"; then
   have_dl=no
-
-  WAPI_CHECK_FUNC(LoadLibrary,,[LoadLibrary(0);],have_dl=w32)
+  KEEPLIBS=$LIBS
+  LIBS=""
+
+    AC_CHECK_FUNC(socket,,
+     WAPI_CHECK_LIB(ws2_32,WSAStartup,
+       [#include <winsock.h>],
+       [WSAStartup(0,0);],
+       [ EXTRALIBS="$EXTRALIBS -lws2_32"
+        EXTRADEFS="$EXTRADEFS -DWINSOCK" ]
+     )
+    )
+  WAPI_CHECK_FUNC(LoadLibrary,,[LoadLibrary((LPSTR)0);],have_dl=w32)
   test $wapi_cv_func_LoadLibrary = yes && have_dl=w32
 
   if test "$have_dl" = "no"; then
@@ -1393,6 +1910,8 @@ if test "$NEEDDLOPEN" = "yes"; then
       AC_MSG_WARN(no method to open a shared object)
       ;;
   esac
+
+  LIBS=$KEEPLIBS
 fi
 
 if test "$NEEDDLOPEN" = "yes"; then
@@ -1400,11 +1919,28 @@ if test "$NEEDDLOPEN" = "yes"; then
   AC_DEFINE_UNQUOTED(SHARED_LIB_EXT,".$so", shared library extention)
   dnl needless?
   dnl EXTRADEFS="$EXTRADEFS \$(DEF_SHLIB_DIR)"
-  test "x$GCC" = xyes -a "x$timidity_cv_ccoption_rdynamic" = xyes  && timidity_LDFLAGS="-rdynamic"
+  if test "x$GCC" = xyes; then
+    if test "x$timidity_cv_ccoption_rdynamic" = xyes; then
+      timidity_LDFLAGS="-rdynamic"
+    else
+      timidity_LDFLAGS="-Wl,--export-dynamic"
+    fi
+  fi
 fi
 
 AM_CONDITIONAL(NEEDDLOPEN, test "$NEEDDLOPEN" = "yes")
 
+dnl xdnd support
+AC_ARG_ENABLE(xdnd,
+  AS_HELP_STRING([--enable-xdnd], [Enable xdnd support             (default is no)]),
+  [ if test "$enableval" = "yes"; then
+    AC_DEFINE(XDND,1,Define to 1 if you want xdnd support.)
+    XDND_SRCS="xdnd.c"
+    enable_xdnd=yes
+    fi
+  ])
+AM_CONDITIONAL(ENABLE_XDND, test "x$enable_xdnd" = xyes)
+
 dnl
 dnl Each interface section
 dnl
@@ -1412,7 +1948,7 @@ dnl
 dnl ncurses
 AM_CONDITIONAL(ENABLE_NCURSES, false)
 CONFIG_INTERFACE(ncurses,NCURSES,n,
-  [  --enable-ncurses        Enable ncurses interface        (default is no)],
+  AS_HELP_STRING([--enable-ncurses], [Enable ncurses interface        (default is no)]),
   [ AC_CHECK_HEADERS(ncurses.h ncurses/curses.h curses.h)
 
 dnl #include <ncurses/curses.h> is failure on Plamo Linux 1.3/ncurses 1.9.9e
@@ -1423,49 +1959,67 @@ dnl configure must check ncurses header with -I/usr/include/ncurses option.
 
   case "$ac_cv_header_curses_h$ac_cv_header_ncurses_curses_h$ac_cv_header_ncurses_h" in
     *yes*);;
-    *) for i in /usr/include /usr/local/include; do
-         if test -f "$i/ncurses/curses.h" -a -f "$i/ncurses/unctrl.h"; then
-           AC_MSG_WARN(ncurses test is failure.  Please check config.h and common.makefile later)
-           CPPFLAGS="$CPPFLAGS -I$i/ncurses"
-           break
-         fi
-       done
-       ;;
+    *)  for i in /usr/include /usr/local/include; do
+          if test -f "$i/ncurses/curses.h" -a -f "$i/ncurses/unctrl.h"; then
+            AC_MSG_WARN(ncurses test is failure.  Please check config.h and common.makefile later)
+            CPPFLAGS="$CPPFLAGS -I$i/ncurses"
+            break
+          fi
+        done
+        ;;
     esac
 
     AC_CHECK_LIB(ncurses,initscr,lib_curses_opt=-lncurses,
       [ dnl checking pdcurses
-       AC_CHECK_LIB(curses,PDC_set_ctrl_break,
+        AC_CHECK_LIB(curses,PDC_set_ctrl_break,
           [ lib_curses_opt=-lcurses
-           AC_DEFINE(USE_PDCURSES,1,Define to 1 if you use PDcurses)
-           lib_user32_opt="$lib_user32_test"
-         ],
-         [ dnl checking libpdcurses
-           AC_CHECK_LIB(pdcurses,PDC_set_ctrl_break,
-           [ lib_curses_opt=-lpdcurses
-             AC_DEFINE(USE_PDCURSES,1,Define to 1 if you use PDcurses)
-             lib_user32_opt="$lib_user32_test"
-           ],
-           [ dnl OpenBSD use -lcurses instead of -lncurses.
-             case "$target" in
-               *openbsd*)
-                 AC_CHECK_LIB(curses,initscr,lib_curses_opt=-lcurses,
-                   [ AC_MSG_WARN(ncurses interface is not enabled)
-                     enable_ncurses=no ])
-                 ;;
-               *)
-                 if test "x$VCPP" = xyes || test "x$BORLANDC" = xyes || test "x$WATCOM_C" = xyes || test "x$DMC" = xyes; then
-                   lib_curses_opt=libpdcurses.lib
-                   AC_DEFINE(USE_PDCURSES,1,Define to 1 if you use PDcurses)
-                 else
-                   AC_MSG_WARN(ncurses interface is not enabled)
-                   enable_ncurses=no
-                 fi
-                 ;;
-             esac
-           ])
-       ],
-       $lib_user32_test)
+            AC_DEFINE(USE_PDCURSES,1,Define to 1 if you use PDcurses)
+            lib_user32_opt="$lib_user32_test"
+            AC_CHECK_LIB(curses, vwprintw,
+              AC_DEFINE(HAVE_VWPRINTW, 1,
+                [Define to 1 if you have the `vwprintw' function.]))
+          ],
+          [ dnl checking libpdcurses
+            AC_CHECK_LIB(pdcurses,PDC_set_ctrl_break,
+            [ lib_curses_opt=-lpdcurses
+              AC_DEFINE(USE_PDCURSES,1,Define to 1 if you use PDcurses)
+              lib_user32_opt="$lib_user32_test"
+              AC_CHECK_LIB(pdcurses, vwprintw,
+                AC_DEFINE(HAVE_VWPRINTW, 1,
+                  [Define to 1 if you have the `vwprintw' function.]))
+            ],
+            [ dnl OpenBSD use -lcurses instead of -lncurses.
+              case "$target" in
+                *openbsd*)
+                  AC_CHECK_LIB(curses,initscr,lib_curses_opt=-lcurses,
+                    [ AC_MSG_WARN(ncurses interface is not enabled)
+                      enable_ncurses=no ])
+                  ;;
+                *-cygwin*|*-mingw*)
+                  lib_curses_opt=-lpdcurses
+                  EXTRAINCS="$EXTRAINCS -I\${top_srcdir}/pdcurses"
+                  timidity_LDFLAGS="$timidity_LDFLAGS -L\${top_srcdir}/pdcurses/win32"
+                  AC_DEFINE(USE_PDCURSES,1,Define to 1 if you use PDcurses)
+                  AC_DEFINE(HAVE_VWPRINTW, 1,
+                    [Define to 1 if you have the `vwprintw' function.])
+                  AC_MSG_RESULT([use internal pdcurses])
+                  ;;
+                *)
+                  if test "x$VCPP" = xyes || test "x$BORLANDC" = xyes || test "x$WATCOM_C" = xyes || test "x$DMC" = xyes || test "x$POCC" = xyes; then
+                    lib_curses_opt=libpdcurses.lib
+                    AC_DEFINE(USE_PDCURSES,1,Define to 1 if you use PDcurses)
+                    AC_CHECK_LIB(pdcurses, vwprintw,
+                      AC_DEFINE(HAVE_VWPRINTW, 1,
+                        [Define to 1 if you have the `vwprintw' function.]))
+                  else
+                    AC_MSG_WARN(ncurses interface is not enabled)
+                    enable_ncurses=no
+                  fi
+                  ;;
+              esac
+            ])
+        ],
+        $lib_user32_test)
       ])
   ],
   [ LIBS="$LIBS $lib_curses_opt"
@@ -1486,15 +2040,28 @@ dnl configure must check ncurses header with -I/usr/include/ncurses option.
 dnl slang
 AM_CONDITIONAL(ENABLE_SLANG, false)
 CONFIG_INTERFACE(slang,SLANG,s,
-  [  --enable-slang          Enable slang interface          (default is no)],
+  AS_HELP_STRING([--enable-slang], [Enable slang interface          (default is no)]),
   [ AC_CHECK_LIB(slang,SLang_init_tty,:,
     [ enable_slang=no
       AC_MSG_WARN(slang interface is not enabled)
     ])
     AC_CHECK_HEADERS(slang/slang.h slang.h)
   ],
-  [ LIBS="$LIBS -lslang"
-    INTERFACE_SRCS="$INTERFACE_SRCS slang_c.c"
+  [ case "$target" in
+       *openbsd*)
+        AC_CHECK_LIB(termcap,initscr,
+                     [ LIBS="$LIBS -lslang -ltermcap"
+                       INTERFACE_SRCS="$INTERFACE_SRCS slang_c.c"
+                     ]
+                     [ AC_MSG_WARN(slang interface is not enabled)
+                       enable_slang=no
+                     ])
+        ;;
+       *)
+        LIBS="$LIBS -lslang"
+        INTERFACE_SRCS="$INTERFACE_SRCS slang_c.c"
+       ;;
+    esac
   ],
   [ s_so_libs="-lslang"
     AC_CHECK_LIB(termcap,initscr,s_so_libs="$s_so_libs -ltermcap")
@@ -1503,9 +2070,9 @@ CONFIG_INTERFACE(slang,SLANG,s,
 dnl Motif
 AM_CONDITIONAL(ENABLE_MOTIF, false)
 CONFIG_INTERFACE(motif,MOTIF,m,
-  [  --enable-motif          Enable motif interface          (default is no)],
+  AS_HELP_STRING([--enable-motif], [Enable motif interface          (default is no)]),
   [ if test "x$with_x" != xyes; then
-       AC_MSG_ERROR(motif: --with-x option must be specified)
+        AC_MSG_ERROR(motif: --with-x option must be specified)
     fi
     if test "x$have_xm" != xyes; then
       AC_MSG_WARN(Motif library is not found.)
@@ -1516,7 +2083,7 @@ CONFIG_INTERFACE(motif,MOTIF,m,
     lib_xt_opt=-lXt
     lib_xext_opt=-lXext
     if test "x$have_xprelibs" = xyes; then
-       lib_xprelibs_opt='-lSM -lICE'
+        lib_xprelibs_opt='-lSM -lICE'
     fi
     INTERFACE_SRCS="$INTERFACE_SRCS motif_c.c motif_i.c motif_p.c"
   ],
@@ -1529,9 +2096,9 @@ CONFIG_INTERFACE(motif,MOTIF,m,
 dnl Tcl/Tk
 AM_CONDITIONAL(ENABLE_TCLTK, false)
 CONFIG_INTERFACE(tcltk,TCLTK,k,
-  [  --enable-tcltk          Enable tcltk interface          (default is no)],
+  AS_HELP_STRING([--enable-tcltk], [Enable tcltk interface          (default is no)]),
   [ if test "x$with_x" != xyes; then
-       AC_MSG_ERROR(tcltk: --with-x option must be specified)
+        AC_MSG_ERROR(tcltk: --with-x option must be specified)
     fi
 
     dnl save flags
@@ -1545,16 +2112,16 @@ CONFIG_INTERFACE(tcltk,TCLTK,k,
 
     tcl_lib=
     tk_lib=
-    for l in tcl tcl8.4 tcl84 tcl8.3 tcl8.0jp tcl7.6jp tcl80jp tcl76jp tcl8.0 tcl7.6 tcl80 tcl76; do
+    for l in tcl tcl8.6 tcl8.5 tcl8.4 tcl84 tcl8.3 tcl8.0jp tcl7.6jp tcl80jp tcl76jp tcl8.0 tcl7.6 tcl80 tcl76; do
       case "x$tcl_lib" in x) AC_CHECK_LIB($l,Tcl_Init,tcl_lib=-l$l);; esac
     done
     LIBS="$LIBS $tcl_lib"
-    for l in tk tk8.4 tcl84 tk8.3 tk8.0jp tk4.2jp tk80jp tk42jp tk8.0 tk4.2 tk80 tk42; do
+    for l in tk tk8.6 tk8.5 tk8.4 tcl84 tk8.3 tk8.0jp tk4.2jp tk80jp tk42jp tk8.0 tk4.2 tk80 tk42; do
       case "x$tk_lib" in x) AC_CHECK_LIB($l,Tk_Init,tk_lib=-l$l);; esac
     done
 
     LIBS=$KEEPLIBS
-    if test "x$tcl_lib" = x -o "x$tk_lib" = x; then
+    if test "x$tcl_lib" = "x" -o "x$tk_lib" = "x"; then
       CPPFLAGS=$KEEPCPPFLAGS
       LDFLAGS=$KEEPLDFLAGS
       enable_tcltk=no
@@ -1563,19 +2130,19 @@ CONFIG_INTERFACE(tcltk,TCLTK,k,
       tcltk_dep='tclIndex'
     fi
   ],
-  [ LIBS=`echo $LIBS | sed "s/-lX11/$tk_lib $tcl_lib -lX11/"`
+  [ LIBS="$tk_lib $tcl_lib -lX11 $LIBS"
     case "$target" in
       *-*-bsdi*)
-       EXTRALIBS="$EXTRALIBS -lipc"
-       ;;
+        EXTRALIBS="$EXTRALIBS -lipc"
+        ;;
     esac
     INTERFACE_SRCS="$INTERFACE_SRCS tk_c.c"
   ],
   [ k_so_libs="$tcl_libdir $tk_libdir $tcl_lib $tk_lib $lib_dl_opt"
     case "$target" in
       *-*-bsdi*)
-       k_so_libs="$k_so_libs -lipc"
-       ;;
+        k_so_libs="$k_so_libs -lipc"
+        ;;
     esac
     k_so_libs="$k_so_libs -lX11 -lm"
   ])
@@ -1584,28 +2151,29 @@ AM_CONDITIONAL(ENABLE_DYNAMIC_TCLTK, test "x$enable_tcltk" = "xdynamic")
 dnl Emacs
 AM_CONDITIONAL(ENABLE_EMACS, false)
 CONFIG_INTERFACE(emacs,EMACS,e,
-  [  --enable-emacs          Enable emacs interface          (default is no)],
+  AS_HELP_STRING([--enable-emacs], [Enable emacs interface          (default is no)]),
   ,
   [ ELFILES="$ELFILES timidity.el"
     INTERFACE_SRCS="$INTERFACE_SRCS emacs_c.c"
   ],
-  [ ELFILES="$ELFILES timidity.el" ])
+  [ AM_CONDITIONAL(ENABLE_EMACS, true)
+    ELFILES="$ELFILES timidity.el" ])
 
 dnl VT100
 AM_CONDITIONAL(ENABLE_VT100, false)
 CONFIG_INTERFACE(vt100,VT100,T,
-  [  --enable-vt100          Enable VT100 interface          (default is no)],
+  AS_HELP_STRING([--enable-vt100], [Enable VT100 interface          (default is no)]),
   ,
   [ INTERFACE_SRCS="$INTERFACE_SRCS vt100_c.c vt100.c" ])
 
 dnl X Athena Widget
 AM_CONDITIONAL(ENABLE_XAW, false)
 CONFIG_INTERFACE(xaw,XAW,a,
-  [  --enable-xaw            Enable athena interface         (default is no)],
+  AS_HELP_STRING([--enable-xaw], [Enable athena interface         (default is no)]),
   [ if test "x$with_x" != xyes; then
-       AC_MSG_ERROR(xaw: --with-x option must be specified)
+        AC_MSG_ERROR(xaw: --with-x option must be specified)
     fi
-    if test "x$have_xaw" != "xyes" -a "x$have_xaw" != "x3d"; then
+    if test "x$have_xaw" = "xno"; then
       AC_MSG_WARN(X Athena Widget library is not found.)
       enable_xaw=no
     fi ],
@@ -1618,13 +2186,29 @@ CONFIG_INTERFACE(xaw,XAW,a,
     fi
     lib_xmu_opt=-lXmu
     lib_xt_opt=-lXt
-    if test "x$have_xaw" = x3d; then
-      AC_DEFINE(XAW3D,1,Define to 1 if you have libXaw3d.)
-      lib_xaw_opt=-lXaw3d
-    else
-      lib_xaw_opt=-lXaw
+    if test "x$enable_xft" = xyes && test "x$have_xaw" != "xno"; then
+      XFT_CFLAGS="$(pkg-config --cflags xft)";
+      EXTRACT_CPPFLAGS(CPPFLAGS,CFLAGS,$XFT_CFLAGS)
+      lib_xft_opt="-lXft";
     fi
-    INTERFACE_SRCS="$INTERFACE_SRCS xaw_c.c xaw_i.c"
+    case "$have_xaw" in
+      "yes")
+        lib_xaw_opt=-lXaw
+        ;;
+      "3d")
+        AC_DEFINE(XAW3D,1,Define to 1 if you use libXaw3d.)
+        lib_xaw_opt=-lXaw3d
+        ;;
+      "plus")
+        AC_DEFINE(XAWPLUS,1,Define to 1 if you use libXawPlus.)
+        lib_xaw_opt="-lXpm -lXawPlus"
+        ;;
+      "next")
+        AC_DEFINE(NEXTAW,1,Define to 1 if you use libneXtaw.)
+        lib_xaw_opt=-lneXtaw
+        ;;
+    esac
+    INTERFACE_SRCS="$INTERFACE_SRCS xaw_c.c xaw_i.c x_trace.c $XDND_SRCS"
   ],
   [ if test "x$have_xext" = xyes; then
       a_so_libs="-lXext -lX11"
@@ -1633,17 +2217,33 @@ CONFIG_INTERFACE(xaw,XAW,a,
     fi
     case "$target" in
       *darwin*)
-       a_so_libs="$a_so_libs -lcc_dynamic"
-       ;;
+        a_so_libs="$a_so_libs -lcc_dynamic"
+        ;;
     esac
     if test "x$have_xprelibs" = xyes; then
       a_so_libs="-lSM -lICE $a_so_libs"
     fi
-    if test "x$have_xaw" = xyes; then
-      a_so_libs="-lXaw -lXmu -lXt $a_so_libs"
-    elif test "x$have_xaw" = x3d; then
-      AC_DEFINE(XAW3D,1,Define to 1 if you have libXaw3d.)
-      a_so_libs="-lXaw3d -lXmu -lXt $a_so_libs"
+    case "$have_xaw" in
+      "yes")
+        a_so_libs="-lXaw -lXmu -lXt $a_so_libs"
+        ;;
+      "3d")
+        AC_DEFINE(XAW3D,1,Define to 1 if you use libXaw3d.)
+        a_so_libs="-lXaw3d -lXmu -lXt $a_so_libs"
+        ;;
+      "plus")
+        AC_DEFINE(XAWPLUS,1,Define to 1 if you use libXawPlus.)
+        a_so_libs="-lXawPlus -lXpm -lXmu -lXt $a_so_libs"
+        ;;
+      "next")
+        AC_DEFINE(NEXTAW,1,Define to 1 if you use libneXtaw.)
+        a_so_libs="-lneXtaw -lXmu -lXt $a_so_libs"
+        ;;
+    esac
+    if test "x$enable_xft" = xyes && test "x$have_xaw" != "xno"; then
+      XFT_CFLAGS="$(pkg-config --cflags xft)";
+      EXTRACT_CPPFLAGS(CPPFLAGS,CFLAGS,$XFT_CFLAGS)
+      a_so_libs="$a_so_libs -lXft";
     fi
     a_so_libs="$ldflags_x_opt $a_so_libs"
   ])
@@ -1652,9 +2252,9 @@ AM_CONDITIONAL(ENABLE_DYNAMIC_XAW, test "x$enable_xaw" = "xdynamic")
 dnl X skin
 AM_CONDITIONAL(ENABLE_XSKIN, false)
 CONFIG_INTERFACE(xskin,XSKIN,i,
-  [  --enable-xskin          Enable X skin interface         (default is no)],
+  AS_HELP_STRING([--enable-xskin], [Enable X skin interface         (default is no)]),
   [ if test "x$with_x" != xyes; then
-       AC_MSG_ERROR(xskin: --with-x option must be specified)
+        AC_MSG_ERROR(xskin: --with-x option must be specified)
     fi
   ],
   [ INTERFACE_SRCS="$INTERFACE_SRCS xskin_c.c xskin_i.c xskin_loadBMP.c xskin_spectrum.c" ],
@@ -1663,7 +2263,7 @@ CONFIG_INTERFACE(xskin,XSKIN,i,
 dnl GTK+
 AM_CONDITIONAL(ENABLE_GTK, false)
 CONFIG_INTERFACE(gtk, GTK, g,
-  [  --enable-gtk            Enable GTK+ interface           (default is no)],
+  AS_HELP_STRING([--enable-gtk], [Enable GTK+ interface           (default is no)]),
   [ AM_PATH_GTK_2_0(2.0.0,
     [AC_DEFINE(HAVE_GTK_2,1,Define to 1 if you have GTK+ 2.x)],
     [AM_PATH_GTK(1.1.3,,enable_gtk=no)]) ],
@@ -1672,22 +2272,22 @@ CONFIG_INTERFACE(gtk, GTK, g,
     INTERFACE_SRCS="$INTERFACE_SRCS gtk_c.c gtk_i.c gtk_p.c"
   ],
   [ if test "x$GCC" = xyes; then
-       dnl Do not include -rdynamic option in $g_so_libs.
-       for i in $GTK_LIBS; do
-           case "x$i" in
-               x-rdynamic) ;;
-               *) g_so_libs="$g_so_libs $i" ;;
-           esac
-       done
+        dnl Do not include -rdynamic option in $g_so_libs.
+        for i in $GTK_LIBS; do
+            case "x$i" in
+                x-rdynamic) ;;
+                *) g_so_libs="$g_so_libs $i" ;;
+            esac
+        done
     else
-       g_so_libs="$GTK_LIBS"
+        g_so_libs="$GTK_LIBS"
     fi
     EXTRACT_CPPFLAGS(CPPFLAGS,CFLAGS,$GTK_CFLAGS) ])
 
 dnl TiMidity Network MIDI Server
 AM_CONDITIONAL(ENABLE_SERVER, false)
 CONFIG_INTERFACE(server,SERVER,r,
-  [  --enable-server         Enable server interface         (default is no)],
+  AS_HELP_STRING([--enable-server], [Enable server interface         (default is no)]),
   ,
   [ INTERFACE_SRCS="$INTERFACE_SRCS server_c.c"
     AC_CHECK_HEADERS(sys/soundcard.h)
@@ -1696,62 +2296,82 @@ CONFIG_INTERFACE(server,SERVER,r,
 dnl TiMidity ALSA sequencer server
 AM_CONDITIONAL(ENABLE_ALSASEQ, false)
 CONFIG_INTERFACE(alsaseq,ALSASEQ,A,
-  [  --enable-alsaseq        Enable ALSA sequencer server interface
-                                                          (default is no)],
-  ,
+  AS_HELP_STRING([--enable-alsaseq], [Enable ALSA sequencer server interface
+                                                          (default is no)]),
   [ INTERFACE_SRCS="$INTERFACE_SRCS alsaseq_c.c"
-    AM_PATH_ALSA
+  ],
+  [ AM_PATH_ALSA
+  ],
+  [ MY_DEFINE(IA_ALSASEQ)
   ])
 
 dnl TiMidity Windows synthesizer server
 AM_CONDITIONAL(ENABLE_WINSYN, false)
 CONFIG_INTERFACE(winsyn,WINSYN,W,
-  [  --enable-winsyn        Enable Windows Synthesizer interface
-                                                          (default is no)],
+  AS_HELP_STRING([--enable-winsyn], [Enable Windows Synthesizer interface
+                                                          (default is no)]),
   ,
-  [ WINSYN="yes"; INTERFACE_SRCS="$INTERFACE_SRCS winsyn_c.c rtsyn_common.c rtsyn_winmm.c" ])
+  [ WINSYN="yes"; INTERFACE_SRCS="$INTERFACE_SRCS winsyn_c.c rtsyn_common.c rtsyn_winmm.c"; ])
 
 dnl TiMidity PortMIDI synthesizer server
 AM_CONDITIONAL(ENABLE_PORTMIDISYN, false)
 CONFIG_INTERFACE(portmidisyn,PORTMIDISYN,P,
-  [  --enable-portmidisyn        Enable PortMIDI Synthesizer interface
-                                                          (default is no)],
+  AS_HELP_STRING([--enable-portmidisyn], [Enable PortMIDI Synthesizer interface
+                                                          (default is no)]),
+  ,
+  [ INTERFACE_SRCS="$INTERFACE_SRCS rtsyn_common.c rtsyn_portmidi.c portmidisyn_c.c";
+    if test "x$CYGNUS" = xyes || test "x$MSYS" = xyes; then
+        LIBS="$LIBS -lportmidi";
+    fi ])
+
+dnl TiMidity NamedPipe synthesizer server
+AM_CONDITIONAL(ENABLE_NPSYN, false)
+CONFIG_INTERFACE(npsyn,NPSYN,W,
+  AS_HELP_STRING([--enable-npsyn], [Enable Windows Named Pipe Synthesizer interface
+                                                          (default is no)]),
   ,
-  [ INTERFACE_SRCS="$INTERFACE_SRCS portmidisyn_c.c rtsyn_common.c rtsyn_portmidi.c" ])
+  [ NPSYN="yes"; INTERFACE_SRCS="$INTERFACE_SRCS npsyn_c.c rtsyn_common.c rtsyn_npipe.c"; ])
+
+
 
 dnl TiMidity Windows GUI synthesizer server
 AM_CONDITIONAL(ENABLE_W32G_SYN, false)
 CONFIG_INTERFACE(winsyng,W32G_SYN,W,
-  [  --enable-winsyng        Enable Windows GUI Synthesizer interface
-                                                          (default is no)],
+  AS_HELP_STRING([--enable-winsyng], [Enable Windows GUI Synthesizer interface
+                                                          (default is no)]),
   ,
   [ 
   W32G_GUI=yes
-  if test "x$VCPP" = xyes || test "x$BORLANDC" = xyes || test "x$WATCOM_C" = xyes || test "x$DMC" = xyes; then
-    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"
-    lib_w32gui_opt='gdi32.lib comctl32.lib comdlg32.lib ole32.lib'
+  if test "x$VCPP" = xyes || test "x$BORLANDC" = xyes || test "x$WATCOM_C" = xyes || test "x$DMC" = xyes || test "x$POCC" = xyes; then
+    INTERFACE_SRCS="$INTERFACE_SRCS w32g_ini.c w32g_pref.c w32g_syn.c w32g_utl.c w32g_soundspec.c winsyn_c.c rtsyn_common.c rtsyn_winmm.c"
+    lib_w32gui_opt='gdi32.lib comctl32.lib comdlg32.lib ole32.lib shlwapi.lib'
     lib_user32_opt='user32.lib'
+    EXTRADEFS="$EXTRADEFS -D__W32G__ -DTWSYNG32"
     if test "x$VCPP" = xyes; then
-         VCPP_LDFLAGS="$VCPP_LDFLAGS -subsystem:windows "
-       fi
-       if test "x$BORLANDC" = xyes; then
-         BORLANDC_START='C0W32.OBJ'
-         CFLAGS="$CFLAGS -tW"
-         lib_w32gui_opt="-aa $lib_w32gui_opt"
-       fi
-       if test "x$WATCOM_C" = xyes; then
-         CFLAGS="$CFLAGS -bw"
-         WATCOM_LDFLAGS="$WATCOM_LDFLAGS SYS nt_win"
-       fi
-       if test "x$DMC" = xyes; then
-         DLLFLAG="-WA"
-         lib_w32gui_opt="$lib_w32gui_opt -L/exet:nt/su:windows:4.0"
-       fi
+          VCPP_LDFLAGS="$VCPP_LDFLAGS -subsystem:windows "
+        fi
+        if test "x$BORLANDC" = xyes; then
+          BORLANDC_START='C0W32.OBJ'
+          CFLAGS="$CFLAGS -tW"
+          lib_w32gui_opt="-aa $lib_w32gui_opt"
+        fi
+        if test "x$WATCOM_C" = xyes; then
+          CFLAGS="$CFLAGS -bw"
+          WATCOM_LDFLAGS="$WATCOM_LDFLAGS SYS nt_win"
+        fi
+        if test "x$DMC" = xyes; then
+          DLLFLAG="-WA"
+          lib_w32gui_opt="$lib_w32gui_opt -L/exet:nt/su:windows:4.0"
+        fi
+    if test "x$POCC" = xyes; then
+          POCC_LDFLAGS="$POCC_LDFLAGS -subsystem:windows "
+    fi
   else
-       lib_w32gui_opt='-lgdi32 -lcomctl32 -lcomdlg32 -lole32'
+    lib_w32gui_opt='-lgdi32 -lcomctl32 -lcomdlg32 -lole32 -lshlwapi'
     lib_user32_opt='-luser32'
+    EXTRADEFS="$EXTRADEFS -D__W32G__ -DTWSYNG32"
     LDFLAGS="-mwindows $LDFLAGS"
-    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"
+    INTERFACE_SRCS="$INTERFACE_SRCS w32g_ini.c w32g_pref.c w32g_syn.c w32g_utl.c w32g_soundspec.c winsyn_c.c rtsyn_common.c rtsyn_winmm.c"
   fi
   ])
 
@@ -1759,44 +2379,49 @@ CONFIG_INTERFACE(winsyng,W32G_SYN,W,
 dnl Windows GUI
 AM_CONDITIONAL(ENABLE_W32GUI, false)
 CONFIG_INTERFACE(w32gui, W32GUI, w,
-  [  --enable-w32gui         Enable Windows GUI interface    (default is no)],
+  AS_HELP_STRING([--enable-w32gui], [Enable Windows GUI interface    (default is no)]),
   ,
   [
   W32G_GUI=yes 
-  if test "x$VCPP" = xyes || test "x$BORLANDC" = xyes || test "x$WATCOM_C" = xyes || test "x$DMC" = xyes; then
-       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"
-    lib_w32gui_opt='gdi32.lib comctl32.lib comdlg32.lib ole32.lib'
+  if test "x$VCPP" = xyes || test "x$BORLANDC" = xyes || test "x$WATCOM_C" = xyes || test "x$DMC" = xyes || test "x$POCC" = xyes; then
+    INTERFACE_SRCS="$INTERFACE_SRCS w32g_c.c w32g_ini.c w32g_i.c w32g_playlist.c w32g_utl.c w32g_soundspec.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"
+    lib_w32gui_opt='gdi32.lib comctl32.lib comdlg32.lib ole32.lib shlwapi.lib'
     lib_user32_opt='user32.lib'
+    EXTRADEFS="$EXTRADEFS -D__W32G__ "
     if test "x$VCPP" = xyes; then
-         VCPP_LDFLAGS="$VCPP_LDFLAGS -subsystem:windows "
-       fi
-       if test "x$BORLANDC" = xyes; then
-         BORLANDC_START='C0W32.OBJ'
-         CFLAGS="$CFLAGS -tW"
-         lib_w32gui_opt="-aa $lib_w32gui_opt"
-       fi
-       if test "x$WATCOM_C" = xyes; then
-         CFLAGS="$CFLAGS -bw"
-         WATCOM_LDFLAGS="$WATCOM_LDFLAGS SYS nt_win"
-       fi
-       if test "x$DMC" = xyes; then
-         lib_w32gui_opt="$lib_w32gui_opt -L/SU:window"
-         DLLFLAG="-WA"
-       fi
+          VCPP_LDFLAGS="$VCPP_LDFLAGS -subsystem:windows "
+        fi
+        if test "x$BORLANDC" = xyes; then
+          BORLANDC_START='C0W32.OBJ'
+          CFLAGS="$CFLAGS -tW"
+          lib_w32gui_opt="-aa $lib_w32gui_opt"
+        fi
+        if test "x$WATCOM_C" = xyes; then
+          CFLAGS="$CFLAGS -bw"
+          WATCOM_LDFLAGS="$WATCOM_LDFLAGS SYS nt_win"
+        fi
+        if test "x$DMC" = xyes; then
+          lib_w32gui_opt="$lib_w32gui_opt -L/SU:window"
+          DLLFLAG="-WA"
+        fi
+    if test "x$POCC" = xyes; then
+          POCC_LDFLAGS="$POCC_LDFLAGS -subsystem:windows "
+    fi
   else
-    lib_w32gui_opt='-lgdi32 -lcomctl32 -lcomdlg32 -lole32'
+    lib_w32gui_opt='-lgdi32 -lcomctl32 -lcomdlg32 -lole32 -lshlwapi'
     lib_user32_opt='-luser32'
+    EXTRADEFS="$EXTRADEFS -D__W32G__ "
     LDFLAGS="-mwindows $LDFLAGS"
-    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"
+    INTERFACE_SRCS="$INTERFACE_SRCS w32g_c.c w32g_ini.c w32g_i.c w32g_playlist.c w32g_utl.c w32g_soundspec.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"
   fi
   ])
 
 dnl UMP configuration
 AM_CONDITIONAL(ENABLE_PLUGIN, false)
 CONFIG_INTERFACE(ump, PLUGIN, p,
-  [  --enable-ump            UMP configuration               (default is no)],
+  AS_HELP_STRING([--enable-ump], [UMP configuration               (default is no)]),
   [ if test ! -d ump; then
-       AC_MSG_ERROR(UMP Package is not exists.  Can't configure it.)
+        AC_MSG_ERROR(UMP Package is not exists.  Can't configure it.)
     fi
     AC_CHECK_HEADER(X11/xpm.h,,AC_MSG_ERROR([UMP Package needs xpm.h[,] but could not find it.]))
     AC_CHECK_LIB(Xpm,XpmCreatePixmapFromData,:,AC_MSG_ERROR([UMP Package needs libXpm.a[,] but could not find it.]))
@@ -1812,17 +2437,17 @@ CONFIG_INTERFACE(ump, PLUGIN, p,
 
 dnl Window Driver interface
 AC_ARG_ENABLE(windrv,
-  [  --enable-windrv         Windows Driver interface(requires winsyn) ],
+  AS_HELP_STRING([--enable-windrv], [Windows Driver interface(requires winsyn) ]),
   [ if test "$enableval" = "yes"; then
-      if test "x$VCPP" != "xyes" && test "x$MINGWGCC" != "xyes" && test "x$BORLANDC" != "xyes" && test "x$WATCOM_C" != "xyes" && test "x$DMC" != "xyes"; then
-       AC_MSG_ERROR(windrv: Only Support VC++ or Mingw or Borland C or Open Watcom and Digital Mars)
-         elif test "x$WINSYN" != "xyes"; then
-       AC_MSG_ERROR(windrv: Driver must have winsyn interface)
-         else
+      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
+        AC_MSG_ERROR(windrv: Only Support VC++ or Mingw or Borland C or Open Watcom PellesC and Digital Mars)
+          elif test "x$WINSYN" != xyes; then
+        AC_MSG_ERROR(windrv: Driver must have winsyn interface)
+          else
     AC_DEFINE(WINDRV,1,Define to 1 if you cpmpile windos driver.)
     WINDRV=yes
-    if test "x$WATCOM_C" = "xyes"; then DLLFLAG="-bd" ;fi
-    if test "x$DMC" = "xyes"; then DLLFLAG="-WD" ;fi
+    if test "x$WATCOM_C" = xyes; then DLLFLAG="-bd" ;fi
+    if test "x$DMC" = xyes; then DLLFLAG="-WD" ;fi
     CFLAGS="$CFLAGS -DANOTHER_MAIN "
       fi
     fi ])
@@ -1831,7 +2456,7 @@ CFLAGS="$CFLAGS $DLLFLAG "
 dnl Offix support
 dnl this rely on  CFLAGS and LIBS
 AC_ARG_ENABLE(offix,
-  [  --enable-offix          Enable offix support            (default is no)],
+  AS_HELP_STRING([--enable-offix], [Enable offix support            (default is no)]),
   [ if test "$enableval" = "yes"; then
       KEEPCPPFLAGS=$CPPFLAGS
       KEEPLIBS=$LIBS
@@ -1840,86 +2465,196 @@ AC_ARG_ENABLE(offix,
       LDFLAGS="$LDFLAGS $offix_lib_dir"
       LIBS="$LIBS $lib_xmu_opt $lib_xt_opt $lib_xprelibs_opt $lib_xext_opt -lX11"
       AC_CHECK_LIB(Dnd,DndInitialize,[
-       LIBS=$KEEPLIBS
-       lib_offix_opt="-lDnd"
-       AC_DEFINE(OFFIX,1,Define to 1 if you need offix support)
+        LIBS=$KEEPLIBS
+        lib_offix_opt="-lDnd"
+        AC_DEFINE(OFFIX,1,Define to 1 if you need offix support)
       ],
       [ LDFLAGS=$KEEPLDFLAGS
-       CPPFLAGS=$KEEPCPPFLAGS
-       LIBS=$KEEPLIBS
+        CPPFLAGS=$KEEPCPPFLAGS
+        LIBS=$KEEPLIBS
       ])
     fi
   ])
 
 dnl Network section
 AC_ARG_ENABLE(network,
-  [  --enable-network        Enable network support          (default is no)],
+  AS_HELP_STRING([--enable-network], [Enable network support          (default is no)]),
   [ if test "$enableval" = "yes"; then
       AC_DEFINE(SUPPORT_SOCKET,1,Define to 1 if you need network support)
     fi ])
-AM_CONDITIONAL(ENABLE_NETWORK, test "x$enable_network" = "xyes")
+AM_CONDITIONAL(ENABLE_NETWORK, test "x$enable_network" = xyes)
+
+dnl Multi-thread support
+AC_ARG_ENABLE(thread,
+  AS_HELP_STRING([--enable-thread], [Enable thread support           (default is no)]),
+  [ if test "$enableval" = "yes"; then
+      AC_DEFINE(ENABLE_THREAD,1,Define to 1 if you need thread support)
+    fi ])
+AM_CONDITIONAL(ENABLE_THREAD, test "x$enable_thread" = xyes)
+
+dnl LargeFile Source support
+AC_ARG_ENABLE(largefile,
+  AS_HELP_STRING([--enable-largefile], [Enable LargeFile Source support (default is no)]),
+  [ if test "$enableval" = "yes"; then
+      AC_DEFINE(_FILE_OFFSET_BITS, 64, [Get 64-bit file size support])
+      AC_DEFINE(_LARGEFILE_SOURCE, 1, [Define for ftello and fseeko extension.])
+    fi ])
+AM_CONDITIONAL(ENABLE_LARGEFILE, test "x$enable_largefile" = xyes)
 
 dnl Sound Spectrogram Viewer
 AC_ARG_ENABLE(spectrogram,
-  [  --enable-spectrogram    Enable Sound Spectrogram Viewer (default is no)],
+  AS_HELP_STRING([--enable-spectrogram], [Enable Sound Spectrogram Viewer (default is no)]),
   [ if test "$enableval" = "yes"; then
-      if test "x$with_x" != xyes; then
-       AC_MSG_ERROR(spectrogram: --with-x option must be specified)
+      if test "x$CYGNUS" = xyes || test "x$MSYS" = xyes; then
+        if test "x$W32G_GUI" = xyes; then
+          AC_MSG_RESULT(use w32g_soundspec.c)
+          AC_DEFINE(W32SOUNDSPEC,1,Define to 1 if you need spectrogram viewer.)
+        else
+          AC_MSG_RESULT(use w32_soundspec.c)
+          AC_DEFINE(W32SOUNDSPEC,1,Define to 1 if you need spectrogram viewer.)
+          SYSEXTRAS="$SYSEXTRAS w32_soundspec.c"
+          lib_w32gui_opt='-lgdi32'
+        fi
+      elif test "x$with_x" = xyes; then
+        LIBS="-lX11 $LIBS"
+      else
+        AC_MSG_ERROR(spectrogram: --with-x option must be specified)
       fi
-      AC_DEFINE(SUPPORT_SOUNDSPEC,1,Define to 1 if you need spectrogram vewer.)
+      AC_DEFINE(SUPPORT_SOUNDSPEC,1,Define to 1 if you need spectrogram viewer.)
     fi ])
-AM_CONDITIONAL(ENABLE_SOUND_SPEC, test "x$enable_spectrogram" = "xyes")
 
-dnl Wave Spline Interpolations
+AM_CONDITIONAL(W32SOUNDSPEC, test "x$enable_spectrogram" = xyes -a "x$WIN32" = xyes)
+AM_CONDITIONAL(ENABLE_SOUND_SPEC, test "x$enable_spectrogram" = xyes -a "x$with_x" = xyes)
+
+dnl Wave Resample Interpolations
 AC_ARG_ENABLE(spline,
-  [  --enable-spline=[method]  Specify spline method.
-                                  one of no,linear,cubic,lagrange,newton,gauss
-                                                          (default is linear)],
+  AS_HELP_STRING([--enable-spline=[method]],
+    [Specify spline method.  one of no,linear,cubic,lagrange,newton,gauss,sharp,linerper,sine,square (default is gauss)]),
   [ case "x$enableval" in
       xlinear)
+        AC_DEFINE(DEFAULT_RESAMPLATION_NUM,1,Define resampler num.)
         AC_DEFINE(DEFAULT_RESAMPLATION,resample_linear,Define resampler.)
-       ;;
+        AC_DEFINE(DEFAULT_RESAMPLATION_ORDER,0,Define resampler order.)
+        ;;
       xcubic)
+        AC_DEFINE(DEFAULT_RESAMPLATION_NUM,2,Define resampler num.)
         AC_DEFINE(DEFAULT_RESAMPLATION,resample_cspline,Define resampler.)
-       ;;
+        AC_DEFINE(DEFAULT_RESAMPLATION_ORDER,0,Define resampler order.)
+        ;;
       xlagrange)
+        AC_DEFINE(DEFAULT_RESAMPLATION_NUM,3,Define resampler num.)
         AC_DEFINE(DEFAULT_RESAMPLATION,resample_lagrange,Define resampler.)
-       ;;
+        AC_DEFINE(DEFAULT_RESAMPLATION_ORDER,0,Define resampler order.)
+        ;;
       xnewton)
+        AC_DEFINE(DEFAULT_RESAMPLATION_NUM,4,Define resampler num.)
         AC_DEFINE(DEFAULT_RESAMPLATION,resample_newton,Define resampler.)
-       ;;
+        AC_DEFINE(DEFAULT_RESAMPLATION_ORDER,11,Define resampler order.)
+        ;;
       xgauss)
+        AC_DEFINE(DEFAULT_RESAMPLATION_NUM,5,Define resampler num.)
         AC_DEFINE(DEFAULT_RESAMPLATION,resample_gauss,Define resampler.)
-       ;;
+        AC_DEFINE(DEFAULT_RESAMPLATION_ORDER,24,Define resampler order.)
+        ;;
+      xsharp)
+        AC_DEFINE(DEFAULT_RESAMPLATION_NUM,6,Define resampler num.)
+        AC_DEFINE(DEFAULT_RESAMPLATION,resample_sharp,Define resampler.)
+        AC_DEFINE(DEFAULT_RESAMPLATION_ORDER,2,Define resampler order.)
+        ;;
+      xlinerper)
+        AC_DEFINE(DEFAULT_RESAMPLATION_NUM,7,Define resampler num.)
+        AC_DEFINE(DEFAULT_RESAMPLATION,resample_liner_p,Define resampler.)
+        AC_DEFINE(DEFAULT_RESAMPLATION_ORDER,100,Define resampler order.)
+        ;;
+      xsine)
+        AC_DEFINE(DEFAULT_RESAMPLATION_NUM,8,Define resampler num.)
+        AC_DEFINE(DEFAULT_RESAMPLATION,resample_sine,Define resampler.)
+        AC_DEFINE(DEFAULT_RESAMPLATION_ORDER,0,Define resampler order.)
+        ;;
+      xsquare)
+        AC_DEFINE(DEFAULT_RESAMPLATION_NUM,9,Define resampler num.)
+        AC_DEFINE(DEFAULT_RESAMPLATION,resample_square,Define resampler.)
+        AC_DEFINE(DEFAULT_RESAMPLATION_ORDER,0,Define resampler order.)
+        ;;
       xno)
+        AC_DEFINE(DEFAULT_RESAMPLATION_NUM,0,Define resampler num.)
         AC_DEFINE(DEFAULT_RESAMPLATION,resample_none,Define resampler.)
-       ;;
+        AC_DEFINE(DEFAULT_RESAMPLATION_ORDER,0,Define resampler order.)
+        ;;
       *)
-       AC_MSG_ERROR(Invalid method of --enable-spline)
-       ;;
+        AC_MSG_ERROR(Invalid method of --enable-spline)
+        ;;
+    esac ])
+
+dnl Wave Resample Filter
+AC_ARG_ENABLE(filter,
+  AS_HELP_STRING([--enable-filter=[method]],
+    [Specify filter method.  one of no,lpf12,lpf24,lpfbw,lpf12x2,lpf24x2,lpf6,lpf18,lpftfo,hpfbw,bpfbw (default is no)]),
+  [ case "x$enableval" in
+      xlpf12)
+        AC_DEFINE(DEFAULT_RESAMPLATION_FILTER,1,Define resampler filter.)
+        ;;
+      xlpf24)
+        AC_DEFINE(DEFAULT_RESAMPLATION_FILTER,2,Define resampler filter.)
+        ;;
+      xlpfbw)
+        AC_DEFINE(DEFAULT_RESAMPLATION_FILTER,3,Define resampler filter.)
+        ;;
+      xlpf12x2)
+        AC_DEFINE(DEFAULT_RESAMPLATION_FILTER,4,Define resampler filter.)
+        ;;
+      xlpf24x2)
+        AC_DEFINE(DEFAULT_RESAMPLATION_FILTER,5,Define resampler filter.)
+        ;;
+      xlpf6)
+        AC_DEFINE(DEFAULT_RESAMPLATION_FILTER,6,Define resampler filter.)
+        ;;
+      xlpf8)
+        AC_DEFINE(DEFAULT_RESAMPLATION_FILTER,7,Define resampler filter.)
+        ;;
+      xlpftfo)
+        AC_DEFINE(DEFAULT_RESAMPLATION_FILTER,8,Define resampler filter.)
+        ;;
+      xhpfbw)
+        AC_DEFINE(DEFAULT_RESAMPLATION_FILTER,9,Define resampler filter.)
+        ;;
+      xbpfbw)
+        AC_DEFINE(DEFAULT_RESAMPLATION_FILTER,10,Define resampler filter.)
+        ;;
+      xno)
+        AC_DEFINE(DEFAULT_RESAMPLATION_FILTER,0,Define resampler filter.)
+        ;;
+      *)
+        AC_MSG_ERROR(Invalid method of --enable-filter)
+        ;;
     esac ])
 
 dnl WRD interface
 AC_ARG_ENABLE(wrd,
-  [  --enable-wrd            Enable WRD interface for X      (default is no)],
+  AS_HELP_STRING([--enable-wrd], [Enable WRD interface      (default is no)]),
   [ if test "$enableval" = "yes"; then
-      if test "x$with_x" != xyes; then
-       AC_MSG_ERROR(wrd: --with-x option must be specified)
-      fi
-      AC_DEFINE(WRDT_X,1,Define to 1 if you need wrd support for X.)
-      enable_sherry_wrd=yes
-      AC_CHECK_LIB(z,zlibVersion,:,enable_sherry_wrd=no)
-      AC_CHECK_HEADER(png.h,,enable_sherry_wrd=no)
-      AC_CHECK_LIB(png,png_init_io,:,enable_sherry_wrd=no,-lz)
-      if test "$enable_sherry_wrd" = yes; then
-       AC_DEFINE(ENABLE_SHERRY,1,Define to 1 if you enable Sherry WRD)
-       lib_zip_opt=-lz
-       lib_png_opt=-lpng
+      if test "x$CYGNUS" = xyes || test "x$MSYS" = xyes; then
+        LIBS="-lgdi32 $LIBS"
+        INTERFACE_SRCS="$INTERFACE_SRCS wrdt_wcon.c wrdt_tty.c"
+      elif test "x$with_x" = xyes; then
+        LIBS="-lX11 $LIBS"
+        AC_DEFINE(WRDT_X,1,Define to 1 if you need wrd support for X.)
+        enable_sherry_wrd=yes
+        AC_CHECK_LIB(z,zlibVersion,:,enable_sherry_wrd=no)
+        AC_CHECK_HEADER(png.h,,enable_sherry_wrd=no)
+        AC_CHECK_LIB(png,png_init_io,:,enable_sherry_wrd=no,-lz)
+        if test "$enable_sherry_wrd" = yes; then
+          AC_DEFINE(ENABLE_SHERRY,1,Define to 1 if you enable Sherry WRD)
+          lib_zip_opt=-lz
+          lib_png_opt=-lpng
+        else
+           AC_MSG_WARN([Sherry WRD is disabled: png.h, libpng.a, libz.a are required])
+        fi
+        if test "x$have_xext" = xyes; then
+          lib_xext_opt=-lXext
+        fi
       else
-        AC_MSG_WARN([Sherry WRD is disabled: png.h, libpng.a, libz.a are required])
-      fi
-      if test "x$have_xext" = xyes; then
-       lib_xext_opt=-lXext
+        AC_MSG_ERROR(wrd: --with-x option must be specified)
       fi
     fi ])
 
@@ -1927,38 +2662,155 @@ AC_ARG_ENABLE(wrd,
 dnl end of interfaces
 
 
+dnl
+dnl Data section
+dnl
+
+dnl Internal audio datatype format
+if test "${enable_datatype}" = ""; then
+  AC_DEFINE(DATA_T_DOUBLE,1,[Define to 1 if you need `double' audio data type.])
+  AC_DEFINE(VERSION_DATA_T,"f64",[Define version information prefix.])
+else
+  AC_ARG_ENABLE(datatype,
+    AS_HELP_STRING([--enable-datatype=[type]],
+      [Specify audio data type.  one of int32,float,double (default is double)]),
+    [ case "x$enableval" in
+        xint32)
+          AC_DEFINE(DATA_T_INT32,1,[Define to 1 if you need `int32' audio data type.])
+          AC_DEFINE(VERSION_DATA_T,"i32",[Define version information prefix.])
+          ;;
+        xfloat)
+          AC_DEFINE(DATA_T_FLOAT,1,[Define to 1 if you need `float' audio data type.])
+          AC_DEFINE(VERSION_DATA_T,"f32",[Define version information prefix.])
+          ;;
+        xdouble)
+          AC_DEFINE(DATA_T_DOUBLE,1,[Define to 1 if you need `double' audio data type.])
+          AC_DEFINE(VERSION_DATA_T,"f64",[Define version information prefix.])
+          ;;
+        *)
+          AC_MSG_ERROR(Invalid type of --enable-datatype)
+          ;;
+      esac ])
+fi
+
+dnl Ext-Instruction
+if test "${enable_ext_instruct}" != ""; then
+  AC_ARG_ENABLE(ext-instruct,
+    AS_HELP_STRING([--enable-ext-instruct=[instruction]],
+      [Specify arch optimize flag.  one of none,mmx,sse,sse2,sse3,ssse3,sse41,sse42,avx,avx2 (default is none)]),
+    [ case "x$enableval" in
+        xnone)
+          ;;
+        xmmx)
+          AC_DEFINE(USE_MMX,1,[Define to 1 if you need MMX instructions.])
+          AC_DEFINE(VERSION_EXT_INST,"mmx",[Define ext-instruction information prefix.])
+          if test "x$GCC" = xyes; then
+            CFLAGS="$CFLAGS -mmmx"
+          fi
+          ;;
+        xsse)
+          AC_DEFINE(USE_SSE,1,[Define to 1 if you need SSE instructions.])
+          AC_DEFINE(VERSION_EXT_INST,"sse",[Define ext-instruction information prefix.])
+          if test "x$GCC" = xyes; then
+            CFLAGS="$CFLAGS -msse -mfpmath=sse,387"
+          fi
+          ;;
+        xsse2)
+          AC_DEFINE(USE_SSE2,1,[Define to 1 if you need SSE2 instructions.])
+          AC_DEFINE(VERSION_EXT_INST,"sse2",[Define ext-instruction information prefix.])
+          if test "x$GCC" = xyes; then
+            CFLAGS="$CFLAGS -msse2 -mfpmath=sse,387"
+          fi
+          ;;
+        xsse3)
+          AC_DEFINE(USE_SSE3,1,[Define to 1 if you need SSE3 instructions.])
+          AC_DEFINE(VERSION_EXT_INST,"sse3",[Define ext-instruction information prefix.])
+          if test "x$GCC" = xyes; then
+            CFLAGS="$CFLAGS -msse3 -mfpmath=sse,387"
+          fi
+          ;;
+        xssse3)
+          AC_DEFINE(USE_SSSE3,1,[Define to 1 if you need SSSE3 instructions.])
+          AC_DEFINE(VERSION_EXT_INST,"ssse3",[Define ext-instruction information prefix.])
+          if test "x$GCC" = xyes; then
+            CFLAGS="$CFLAGS -mssse3 -mfpmath=sse,387"
+          fi
+          ;;
+        xsse41)
+          AC_DEFINE(USE_SSE4,1,[Define to 1 if you need SSE4 instructions.])
+          AC_DEFINE(USE_SSE41,1,[Define to 1 if you need SSE4.1 instructions.])
+          AC_DEFINE(VERSION_EXT_INST,"sse41",[Define ext-instruction information prefix.])
+          if test "x$GCC" = xyes; then
+            CFLAGS="$CFLAGS -msse4.1 -mfpmath=sse,387"
+          fi
+          ;;
+        xsse42)
+          AC_DEFINE(USE_SSE4,1,[Define to 1 if you need SSE4 instructions.])
+          AC_DEFINE(USE_SSE42,1,[Define to 1 if you need SSE4.2 instructions.])
+          AC_DEFINE(VERSION_EXT_INST,"sse42",[Define ext-instruction information prefix.])
+          if test "x$GCC" = xyes; then
+            CFLAGS="$CFLAGS -msse4.2 -mfpmath=sse,387"
+          fi
+          ;;
+        xavx)
+          AC_DEFINE(USE_AVX,1,[Define to 1 if you need AVX instructions.])
+          AC_DEFINE(VERSION_EXT_INST,"avx",[Define ext-instruction information prefix.])
+          if test "x$GCC" = xyes; then
+            CFLAGS="$CFLAGS -mavx -mfpmath=sse,387"
+          fi
+          ;;
+        xavx2)
+          AC_DEFINE(USE_AVX2,1,[Define to 1 if you need AVX2 instructions.])
+          AC_DEFINE(VERSION_EXT_INST,"avx2",[Define ext-instruction information prefix.])
+          if test "x$GCC" = xyes; then
+            CFLAGS="$CFLAGS -mavx2 -mfpmath=sse,387"
+          fi
+          ;;
+        *)
+          AC_MSG_ERROR(Invalid type of --enable-datatype)
+          ;;
+      esac ])
+fi
+
+
 #
 # Finish up
 #
 
-AM_CONDITIONAL(ENABLE_WRD, test "x$enable_wrd" = "xyes")
+AM_CONDITIONAL(ENABLE_WRD, test "x$enable_wrd" = xyes)
 AM_CONDITIONAL(W32G_GUI, test "x$W32G_GUI" = xyes)
 AM_CONDITIONAL(WINDRV, test "x$WINDRV" = xyes)
+AM_CONDITIONAL(CYGNUS, test "x$CYGNUS" = xyes)
 AM_CONDITIONAL(MSYS, test "x$MSYS" = xyes)
 AM_CONDITIONAL(VCPP, test "x$VCPP" = xyes)
+AM_CONDITIONAL(POCC, test "x$POCC" = xyes)
 AM_CONDITIONAL(BORLANDC, test "x$BORLANDC" = xyes)
 AM_CONDITIONAL(WATCOM_C, test "x$WATCOM_C" = xyes)
 AM_CONDITIONAL(DMC, test "x$DMC" = xyes)
 AM_CONDITIONAL(MINGWGCC, test "x$MINGWGCC" = xyes)
 
-AM_CONDITIONAL(W32READDIR, test "x$W32READDIR" = "xyes")
+AM_CONDITIONAL(W32READDIR, test "x$W32READDIR" = xyes)
 
 SET_UNIQ_WORDS(LDFLAGS,$LDFLAGS)
 SET_UNIQ_WORDS(SHLDFLAGS,$SHLDFLAGS)
 SET_UNIQ_WORDS(CFLAGS,$EXTRACFLAGS $CFLAGS)
 SET_UNIQ_WORDS(CPPFLAGS,$CPPFLAGS $EXTRADEFS)
 
-if test "x$oss_device" != x; then
+if test "x$oss_device" != "x"; then
   AC_DEFINE_UNQUOTED(OSS_DEVICE,"$oss_device", oss device name)
 fi
 
-if test "x$TIMIDITY_OUTPUT_ID" != x; then
+if test "x$TIMIDITY_OUTPUT_ID" != "x"; then
   AC_DEFINE_UNQUOTED(TIMIDITY_OUTPUT_ID,"$TIMIDITY_OUTPUT_ID", the output specification)
 fi
 
-if test "x$with_x" = xyes; then
-  dnl Order of X-library is: -lXm -lXaw -lXmu -lXt -lSM -lICE -lXext -lX11
-  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/"`
+if test "x$au_enable_nas"      = xyes -o \
+        "x$enable_motif"       = xyes -o \
+        "x$enable_tcltk"       = xyes -o \
+        "x$enable_xaw"         = xyes -o \
+        "x$enable_xskin"       = xyes -a "x$with_x" = xyes; then
+  dnl Order of X-library is: -lXdnd -lXm -lXaw -lXft -lXmu -lXt -lSM -lICE -lXext -lX11
+  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"
 fi
 LIBS="$LIBS $lib_dl_opt $lib_png_opt $lib_zip_opt $lib_user32_opt $lib_w32gui_opt $EXTRALIBS"
 SHLD="$SHLD $SHLDFLAGS"
@@ -1970,8 +2822,11 @@ AC_SUBST(timidity_LDFLAGS)
 AC_SUBST(WATCOM_LDFLAGS)
 AC_SUBST(DMC_LDFLAGS)
 AC_SUBST(VCPP_LDFLAGS)
+AC_SUBST(POCC_LDFLAGS)
 AC_SUBST(SYSEXTRAS)
 AC_SUBST(EXTRALIBS)
+AC_SUBST(EXTRAINCS)
+AC_SUBST(EXTRADEFS)
 AC_SUBST(NETSRCS)
 AC_SUBST(ELFILES)
 AC_SUBST(SHLD)
@@ -1980,6 +2835,7 @@ AC_SUBST(dynamic_targets)
 AC_SUBST(so)
 AC_SUBST(LN_S)
 AC_SUBST(WISH)
+AC_SUBST(TCLSH)
 AC_SUBST(tcltk_dep)
 AC_SUBST(program_transform_name)
 AC_SUBST(INTERFACE_SRCS)
@@ -1994,6 +2850,7 @@ AC_CONFIG_FILES([
   doc/Makefile
   doc/C/Makefile
   doc/ja_JP.eucJP/Makefile
+  doc/ja_JP.utf8/Makefile
   interface/Makefile
   interface/motif_bitmaps/Makefile
   interface/bitmaps/Makefile