diff -ru libmikmod-3.2.0.orig/configure libmikmod-3.2.0/configure
--- libmikmod-3.2.0.orig/configure	2012-06-01 09:15:40.000000000 -0400
+++ libmikmod-3.2.0/configure	2012-10-11 20:54:47.000000000 -0400
@@ -2854,7 +2854,7 @@
 
 libmikmod_driver_af=yes
 libmikmod_driver_aix=no
-libmikmod_driver_alsa=yes
+libmikmod_driver_alsa=no
 libmikmod_driver_nas=no
 libmikmod_driver_hp=no
 libmikmod_driver_oss=yes
@@ -13236,7 +13236,7 @@
 
 
 # Change extension, as we use libtool
-LIBOBJS="`echo $LIBOBJS|sed -e 's/\.o/\.lo/g'`"
+#LIBOBJS="`echo $LIBOBJS|sed -e 's/\.o/\.lo/g'`"
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for floor in -lm" >&5
 $as_echo_n "checking for floor in -lm... " >&6; }
@@ -13501,7 +13501,7 @@
 	 	libmikmod_driverlist="osx $libmikmod_driverlist"
 	 	$as_echo "#define DRV_OSX 1" >>confdefs.h
 
-	 	LIBRARY_LIB="-framework CoreAudio $LIBRARY_LIB"
+	 	LIBRARY_LIB="-Wl,-framework,CoreAudio $LIBRARY_LIB"
 	fi
 fi
 
@@ -13512,7 +13512,7 @@
 		libmikmod_driverlist="mac $libmikmod_driverlist"
 		$as_echo "#define DRV_MAC 1" >>confdefs.h
 
-		LIBRARY_LIB="-framework Carbon $LIBRARY_LIB"
+		LIBRARY_LIB="-Wl,-framework,Carbon $LIBRARY_LIB"
 	fi
 fi
 
@@ -13648,7 +13648,7 @@
 	then
 		CFLAGS="$CFLAGS -Wall -Werror"
 	else
-		CFLAGS="$CFLAGS -Wall"
+		CFLAGS="$CFLAGS"
 	fi
 
 	# pgcc 2.95.2 appears not to be able to compile libmikmod, although regular
diff -ru libmikmod-3.2.0.orig/docs/libmikmod-config.1.in libmikmod-3.2.0/docs/libmikmod-config.1.in
--- libmikmod-3.2.0.orig/docs/libmikmod-config.1.in	2012-03-14 13:02:59.000000000 -0400
+++ libmikmod-3.2.0/docs/libmikmod-config.1.in	2012-10-11 20:51:30.000000000 -0400
@@ -16,7 +16,7 @@
 to the .m4 macros for GNU autoconf that are included with \fIlibmikmod\fP.
 
 .SH OPTIONS
-.l
+
 \fIlibmikmod-config\fP accepts the following options:
 .TP 8
 .B  \-\-version
diff -ru libmikmod-3.2.0.orig/include/mikmod.h.in libmikmod-3.2.0/include/mikmod.h.in
--- libmikmod-3.2.0.orig/include/mikmod.h.in	2012-05-12 05:52:13.000000000 -0400
+++ libmikmod-3.2.0/include/mikmod.h.in	2012-10-11 20:51:30.000000000 -0400
@@ -85,7 +85,7 @@
 
 @DOES_NOT_HAVE_SIGNED@
 
-#if defined(__arch64__) || defined(__alpha) || defined(__x86_64) || defined(__powerpc64__)
+#if defined(__arch64__) || defined(__alpha) || defined(__x86_64) || defined(__powerpc64__) || defined(_LP64)
 /* 64 bit architectures */
 
 typedef signed char     SBYTE;      /* 1 byte, signed */
diff -ru libmikmod-3.2.0.orig/libmikmod/Makefile.in libmikmod-3.2.0/libmikmod/Makefile.in
--- libmikmod-3.2.0.orig/libmikmod/Makefile.in	2012-06-01 09:16:08.000000000 -0400
+++ libmikmod-3.2.0/libmikmod/Makefile.in	2012-10-11 20:51:30.000000000 -0400
@@ -23,14 +23,16 @@
 LIBOBJS=@LIBOBJS@
 LIBRARY_LIB=@LIBRARY_LIB@
 
+SHELL=/bin/bash
+
 CC=@CC@
 INSTALL=@INSTALL@
 LIBTOOL=@LIBTOOL@
-MKINSTALLDIRS=${top_srcdir}/mkinstalldirs
+MKINSTALLDIRS=install -d
 
 DEFS=@DEFS@
 CFLAGS=@CFLAGS@ -Dunix
-COMPILE=$(LIBTOOL) --silent --mode=compile $(CC) $(DEFS) $(CFLAGS) -I$(top_srcdir)/include -I$(top_builddir) -I$(top_builddir)/include -DMIKMOD_H=$(top_srcdir)/include/mikmod.h
+COMPILE=$(LIBTOOL) --silent --mode=compile $(CC) $(DEFS) $(CPPFLAGS) $(CFLAGS) -I$(top_srcdir)/include -I$(top_builddir) -I$(top_builddir)/include -DMIKMOD_H=$(top_srcdir)/include/mikmod.h
 
 LIB = libmikmod.la
 OBJ = $(LIBOBJS) $(DLOBJS) \
@@ -73,7 +75,7 @@
 	rm -f Makefile
 
 $(LIB): $(OBJ)
-	$(LIBTOOL) --mode=link $(CC) -version-info 3:0:0 -o $@ $(OBJ) $(LIBRARY_LIB) -rpath $(DESTDIR)$(libdir)
+	$(LIBTOOL) --mode=link $(CC) -no-undefined -version-info 3:0:0 $(LDFLAGS) -o $@ $(OBJ) $(LIBRARY_LIB) -rpath $(DESTDIR)$(libdir)
 
 dl_hpux.lo:	$(top_srcdir)/dlapi/dl_hpux.c \
 			$(top_srcdir)/dlapi/dlfcn.h
diff -ru libmikmod-3.2.0.orig/macintosh/mikmod.h libmikmod-3.2.0/macintosh/mikmod.h
--- libmikmod-3.2.0.orig/macintosh/mikmod.h	2012-06-01 09:15:42.000000000 -0400
+++ libmikmod-3.2.0/macintosh/mikmod.h	2012-10-11 20:51:30.000000000 -0400
@@ -83,7 +83,7 @@
 
 
 
-#if defined(__arch64__) || defined(__alpha)
+#if defined(__arch64__) || defined(__alpha) || defined(__x86_64) || defined(_LP64)
 /* 64 bit architectures */
 
 typedef signed char     SBYTE;      /* 1 byte, signed */
diff -ru libmikmod-3.2.0.orig/playercode/mplayer.c libmikmod-3.2.0/playercode/mplayer.c
--- libmikmod-3.2.0.orig/playercode/mplayer.c	2012-03-14 15:21:57.000000000 -0400
+++ libmikmod-3.2.0/playercode/mplayer.c	2012-10-11 20:51:30.000000000 -0400
@@ -50,6 +50,8 @@
 /* The currently playing module */
 MODULE *pf = NULL;
 
+#define NUMVOICES(mod) (md_sngchn < (mod)->numvoices ? md_sngchn : (mod)->numvoices)
+
 #define	HIGH_OCTAVE		2	/* number of above-range octaves */
 
 static	UWORD oldperiods[OCTAVE*2]={
@@ -246,14 +248,14 @@
 	MP_VOICE *a;
 	ULONG t,k,tvol,pp;
 
-	for (t=0;t<md_sngchn;t++)
+	for (t=0;t<NUMVOICES(mod);t++)
 		if (((mod->voice[t].main.kick==KICK_ABSENT)||
 			 (mod->voice[t].main.kick==KICK_ENV))&&
 		   Voice_Stopped_internal(t))
 			return t;
 
 	tvol=0xffffffUL;t=-1;a=mod->voice;
-	for (k=0;k<md_sngchn;k++,a++) {
+	for (k=0;k<NUMVOICES(mod);k++,a++) {
 		/* allow us to take over a nonexisting sample */
 		if (!a->main.s)
 			return k;
@@ -2247,12 +2249,12 @@
 
 	switch (dat) {
 	case 0x0: /* past note cut */
-		for (t=0;t<md_sngchn;t++)
+		for (t=0;t<NUMVOICES(mod);t++)
 			if (mod->voice[t].master==a)
 				mod->voice[t].main.fadevol=0;
 		break;
 	case 0x1: /* past note off */
-		for (t=0;t<md_sngchn;t++)
+		for (t=0;t<NUMVOICES(mod);t++)
 			if (mod->voice[t].master==a) {
 				mod->voice[t].main.keyoff|=KEY_OFF;
 				if ((!(mod->voice[t].venv.flg & EF_ON))||
@@ -2261,7 +2263,7 @@
 			}
 		break;
 	case 0x2: /* past note fade */
-		for (t=0;t<md_sngchn;t++)
+		for (t=0;t<NUMVOICES(mod);t++)
 			if (mod->voice[t].master==a)
 				mod->voice[t].main.keyoff|=KEY_FADE;
 		break;
@@ -2737,7 +2739,7 @@
 			if (a->dct!=DCT_OFF) {
 				int t;
 
-				for (t=0;t<md_sngchn;t++)
+				for (t=0;t<NUMVOICES(mod);t++)
 					if ((!Voice_Stopped_internal(t))&&
 					   (mod->voice[t].masterchn==channel)&&
 					   (a->main.sample==mod->voice[t].main.sample)) {
@@ -2979,6 +2981,11 @@
 	if (!(mod->voice=(MP_VOICE*)MikMod_calloc(md_sngchn,sizeof(MP_VOICE))))
 		return 1;
 
+        /* mod->numvoices was used during loading to clamp md_sngchn.
+           After loading it's used to remember how big mod->voice is.
+        */
+        mod->numvoices = md_sngchn;
+
 	Player_Init_internal(mod);
 	return 0;
 }
@@ -3044,7 +3051,7 @@
 	if (pf!=mod) {
 		/* new song is being started, so completely stop out the old one. */
 		if (pf) pf->forbid=1;
-		for (t=0;t<md_sngchn;t++) Voice_Stop_internal(t);
+		for (t=0;t<NUMVOICES(mod);t++) Voice_Stop_internal(t);
 	}
 	pf=mod;
 	MUTEX_UNLOCK(vars);
diff -ru libmikmod-3.2.0.orig/win32/mikmod_build.h libmikmod-3.2.0/win32/mikmod_build.h
--- libmikmod-3.2.0.orig/win32/mikmod_build.h	2012-03-14 13:03:00.000000000 -0400
+++ libmikmod-3.2.0/win32/mikmod_build.h	2012-10-11 20:51:30.000000000 -0400
@@ -85,7 +85,7 @@
 
 
 
-#if defined(__arch64__) || defined(__alpha) || defined(__x86_64) || defined(__powerpc64__)
+#if defined(__arch64__) || defined(__alpha) || defined(__x86_64) || defined(__powerpc64__) || defined(_LP64)
 /* 64 bit architectures */
 
 typedef signed char     SBYTE;      /* 1 byte, signed */
