2005-09-14  Mo DeJong  <mdejong@users.sourceforge.net>

	* acinclude.m4: Add AS_HELP_STRING decl so that
	the build systems works with autoconf 2.57.
	* autogen.sh: Add correct libtool and automake
	flags. Run autoconf after automake.
	* configure.ac: Require autoconf 2.57 or newer.
	Add AM_MAINTAINER_MODE to avoid regeneration insanity.
	Fix static win32 builds with --disable-shared is given.
	* src/Makefile.am: Install fluidsynth dll in
	the bin dir and not the lib dir. Fix build when
	builddir != srcdir.
	* src/fluid_dll.c: Init hinstance when build as a static
	library (not a dll).
	* src/fluid_dsound.c: Improve error message.
	* src/fluid_voice.c: Zero memory after malloc.

Index: acinclude.m4
===================================================================
RCS file: /cvsroot/fluid/fluidsynth/acinclude.m4,v
retrieving revision 1.7
diff -u -r1.7 acinclude.m4
--- acinclude.m4	12 Jun 2005 01:19:37 -0000	1.7
+++ acinclude.m4	14 Sep 2005 23:55:40 -0000
@@ -1,5 +1,7 @@
 dnl Some additional autoconf macros
 
+m4_ifdef([AS_HELP_STRING], , [m4_define([AS_HELP_STRING], m4_defn([AC_HELP_STRING]))])
+
 AC_DEFUN(AC_MIDISHARE,
 [
   AC_ARG_ENABLE(midishare, AS_HELP_STRING([--enable-midishare],
Index: autogen.sh
===================================================================
RCS file: /cvsroot/fluid/fluidsynth/autogen.sh,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 autogen.sh
--- autogen.sh	11 Mar 2003 16:56:52 -0000	1.1.1.1
+++ autogen.sh	14 Sep 2005 23:55:40 -0000
@@ -1,12 +1,16 @@
 #!/bin/sh
 
+rm -rf autom4te.cache
+
 # Some poor souls have linux distributions, that don't install pkg-config by default. 
 #pkg-config --version does actually nothing, but it will fail and give 'sort of' an error message...
 
 pkg-config --version > /dev/null    \
  && aclocal                         \
- && libtoolize -f                   \
+ && libtoolize --copy --force       \
  && autoheader                      \
- && autoconf                        \
- && automake -a
+ && automake --add-missing --copy   \
+ && autoconf
+
+rm -rf autom4te.cache
 
Index: configure.ac
===================================================================
RCS file: /cvsroot/fluid/fluidsynth/configure.ac,v
retrieving revision 1.15
diff -u -r1.15 configure.ac
--- configure.ac	12 Jun 2005 01:19:37 -0000	1.15
+++ configure.ac	14 Sep 2005 23:55:41 -0000
@@ -3,6 +3,7 @@
 dnl --------------------------------------------------
 
 AC_INIT(src/fluidsynth.c)
+AC_PREREQ(2.57)
 
 dnl *** NOTE *** Don't forget to update library version below also
 
@@ -17,6 +18,7 @@
 AC_SUBST(FLUIDSYNTH_VERSION)
 
 AM_INIT_AUTOMAKE(fluidsynth, $FLUIDSYNTH_VERSION)
+AM_MAINTAINER_MODE
 
 dnl Convert to quoted string for version.h substitution
 FLUIDSYNTH_VERSION="\"$VERSION\""
@@ -62,26 +64,35 @@
 
 dnl Machine specific checks and defines
 case "${host_os}" in
-darwin*)
+*darwin*)
   AC_DEFINE(DARWIN, 1, [Define if building for Mac OS X Darwin])
   ;;
-mingw*)
+*mingw*)
   mingw32_support="yes"
   CFLAGS="$CFLAGS -mms-bitfields"
   AC_DEFINE(MINGW32, 1, [Define if using the MinGW32 environment])
   LIBFLUID_LIBS="-ldsound -lwinmm"
-  LIBFLUID_CPPFLAGS="-DFLUIDSYNTH_DLL_EXPORTS"
+  dnl If --disable-shared was passed, don't use dll export/import flags
+  if test "$enable_shared" = "yes"; then
+      LIBFLUID_CPPFLAGS="-DFLUIDSYNTH_DLL_EXPORTS"
+      FLUIDSYNTH_CPPFLAGS=""
+      MINGW32_INSTALL_DLL=1
+  else
+      LIBFLUID_CPPFLAGS="-DFLUIDSYNTH_NOT_A_DLL"
+      FLUIDSYNTH_CPPFLAGS="-DFLUIDSYNTH_NOT_A_DLL"
+      MINGW32_INSTALL_DLL=0
+  fi
   LIBFLUID_LDFLAGS="-no-undefined"
-  FLUID_CPPFLAGS="-DFLUIDSYNTH_NOT_A_DLL"
   ;;
 esac
 
 AC_SUBST(LIBFLUID_LIBS)
 AC_SUBST(LIBFLUID_CPPFLAGS)
 AC_SUBST(LIBFLUID_LDFLAGS)
-AC_SUBST(FLUID_CPPFLAGS)
+AC_SUBST(FLUIDSYNTH_CPPFLAGS)
 
 AM_CONDITIONAL(MINGW32_SUPPORT, test "$mingw32_support" == "yes")
+AM_CONDITIONAL(MINGW32_INSTALL_DLL, test "$MINGW32_INSTALL_DLL" == "1")
 
 AC_ARG_ENABLE(double, AS_HELP_STRING([--enable-double],
 	[double floating point for dsp (default=float)]),
Index: src/Makefile.am
===================================================================
RCS file: /cvsroot/fluid/fluidsynth/src/Makefile.am,v
retrieving revision 1.10
diff -u -r1.10 Makefile.am
--- src/Makefile.am	29 Jun 2005 18:07:46 -0000	1.10
+++ src/Makefile.am	14 Sep 2005 23:55:41 -0000
@@ -93,7 +93,8 @@
 	fluid_voice.h \
 	fluid_aufile.c 
 
-INCLUDES = -I$(top_srcdir)/include $(LADCCA_CFLAGS) $(READLINE_CFLAGS) \
+INCLUDES = -I$(top_srcdir)/include -I$(top_builddir)/include \
+  $(LADCCA_CFLAGS) $(READLINE_CFLAGS) \
   $(JACK_CFLAGS) $(ALSA_CFLAGS)
 
 libfluidsynth_la_LIBADD = $(LIBFLUID_LIBS) $(LADCCA_LIBS) $(READLINE_LIBS) \
@@ -107,3 +108,16 @@
 fluidsynth_LDADD = libfluidsynth.la
 fluidsynth_LDFLAGS = @FCLDFLAGS@
 fluidsynth_CPPFLAGS = $(FLUIDSYNTH_CPPFLAGS)
+
+# Under Win32 (mingw) the fluidsynth dll needs to end up in
+# the bin/ dir not the lib/ dir. A static build would not
+# have created a dll.
+
+if MINGW32_INSTALL_DLL
+install-data-hook:
+	mv $(DESTDIR)$(libdir)/*fluidsynth*.dll $(DESTDIR)$(bindir)
+else
+install-data-hook:
+
+endif
+
Index: src/fluid_dll.c
===================================================================
RCS file: /cvsroot/fluid/fluidsynth/src/fluid_dll.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 fluid_dll.c
--- src/fluid_dll.c	11 Mar 2003 16:57:20 -0000	1.1.1.1
+++ src/fluid_dll.c	14 Sep 2005 23:55:41 -0000
@@ -44,6 +44,12 @@
 
 void* fluid_get_hinstance(void)
 {
+#ifdef FLUIDSYNTH_NOT_A_DLL
+  FLUID_LOG(FLUID_DBG, "static Main\n");
+  if (fluid_hinstance == NULL) {
+    fluid_hinstance = GetModuleHandle(NULL);
+  }
+#endif
   return (void*) fluid_hinstance;
 }
 #endif
Index: src/fluid_dsound.c
===================================================================
RCS file: /cvsroot/fluid/fluidsynth/src/fluid_dsound.c,v
retrieving revision 1.7
diff -u -r1.7 fluid_dsound.c
--- src/fluid_dsound.c	14 May 2004 13:45:22 -0000	1.7
+++ src/fluid_dsound.c	14 Sep 2005 23:55:42 -0000
@@ -96,7 +96,7 @@
 
   /* check if the globals are initialized */
   if (FLUID_HINSTANCE == NULL) {
-    FLUID_LOG(FLUID_ERR, "No hinstance needed for DirectSound");
+    FLUID_LOG(FLUID_ERR, "An hinstance is needed for DirectSound");
     return NULL;
   }
 
Index: src/fluid_voice.c
===================================================================
RCS file: /cvsroot/fluid/fluidsynth/src/fluid_voice.c,v
retrieving revision 1.15
diff -u -r1.15 fluid_voice.c
--- src/fluid_voice.c	11 Jun 2005 11:06:43 -0000	1.15
+++ src/fluid_voice.c	14 Sep 2005 23:55:45 -0000
@@ -141,6 +141,8 @@
     FLUID_LOG(FLUID_ERR, "Out of memory");
     return NULL;
   }
+  FLUID_MEMSET(voice, 0, sizeof(fluid_voice_t));
+
   voice->status = FLUID_VOICE_CLEAN;
   voice->chan = NO_CHANNEL;
   voice->key = 0;
