--- /dev/null
+diff -Nur portmidi/pm_linux/Makefile portmidi-new/pm_linux/Makefile
+--- portmidi/pm_linux/Makefile 2008-06-14 02:23:43.000000000 +0200
++++ portmidi-new/pm_linux/Makefile 2008-11-24 12:01:48.000000000 +0100
+@@ -16,7 +16,7 @@
+ # simple to create.)\r
+ \r
+ # For debugging, define PM_CHECK_ERRORS\r
+-PMFLAGS = -DPM_CHECK_ERRORS\r
++PMFLAGS = -DNEWBUFFER\r
+ # Otherwise do not define PM_CHECK_ERRORS\r
+ # PMFLAGS = \r
+ \r
+@@ -31,10 +31,14 @@
+ # VFLAGS = -DPMNULL\r
+ \r
+ pmlib = pm_linux/libportmidi.a\r
++pmslib = pm_linux/libportmidi.so.0.0.0\r
+ \r
+ ptlib = porttime/libporttime.a\r
++ptslib = porttime/libporttime.so.0.0.0\r
+ \r
+-CC = gcc $(VFLAGS) $(PMFLAGS) -g -Ipm_common -Iporttime\r
++CC = gcc -fPIC $(CFLAGS) $(VFLAGS) $(PMFLAGS) -g -Ipm_common -Iporttime\r
++\r
++INSTALL = install\r
+ \r
+ pmobjects = pm_common/pmutil.o $(versions) pm_linux/pmlinux.o \\r
+ pm_common/portmidi.o\r
+@@ -46,11 +50,13 @@
+ all: $(pmlib) $(ptlib) pm_test/test pm_test/sysex pm_test/midithread \\r
+ pm_test/latency pm_test/midithru pm_test/qtest pm_test/mm\r
+ \r
+-$(pmlib): pm_linux/Makefile $(pmobjects)\r
++$(pmlib): pm_linux/Makefile $(pmobjects) $(ptlib)\r
+ ar -cr $(pmlib) $(pmobjects)\r
++ $(CC) -shared $(ptslib) $(ALSALIB) $(pmobjects) -Wl,-soname -Wl,libportmidi.so.0 -o $(pmslib)\r
+ \r
+ $(ptlib): pm_linux/Makefile $(ptobjects)\r
+ ar -cr $(ptlib) $(ptobjects)\r
++ $(CC) -shared $(ptobjects) -lpthread -Wl,-soname -Wl,libporttime.so.0 -o $(ptslib)\r
+ \r
+ pm_linux/pmlinuxalsa.o: pm_linux/Makefile pm_linux/pmlinuxalsa.c pm_linux/pmlinuxalsa.h\r
+ $(CC) -c pm_linux/pmlinuxalsa.c -o pm_linux/pmlinuxalsa.o\r
+@@ -83,6 +89,14 @@
+ pm_test/qtest: pm_linux/Makefile pm_test/qtest.o $(pmlib) $(ptlib)\r
+ $(CC) pm_test/qtest.o -o pm_test/qtest $(pmlib) $(ptlib) $(ALSALIB)\r
+ \r
++install:\r
++ $(INSTALL) -d $(DESTDIR)/usr/include\r
++ $(INSTALL) -m 644 pm_common/portmidi.h $(DESTDIR)/usr/include/\r
++ $(INSTALL) -m 644 porttime/porttime.h $(DESTDIR)/usr/include/\r
++ $(INSTALL) -d $(DESTDIR)/usr/lib\r
++ $(INSTALL) -m 644 pm_linux/libportmidi* $(DESTDIR)/usr/lib/\r
++ $(INSTALL) -m 644 porttime/libporttime* $(DESTDIR)/usr/lib/\r
++\r
+ clean:\r
+ rm -f *.o *~ core* */*.o */*.so */*~ */core* pm_test/*/pm_dll.dll \r
+ rm -f *.opt *.ncb *.plg pm_win/Debug/pm_dll.lib pm_win/Release/pm_dll.lib\r
+@@ -93,6 +107,9 @@
+ cleanest: cleaner\r
+ rm -f $(pmlib) $(ptlib) pm_test/test pm_test/sysex pm_test/midithread\r
+ rm -f pm_test/latency pm_test/midithru pm_test/qtest pm_test/mm\r
++ rm -f pm_linux/libportmidi.a pm_linux/libportmidi.so.0.0.0 pm_test/test pm_test/sysex \\r
++ pm_test/midithread pm_test/latency pm_test/midithru porttime/libporttime.a \\r
++ porttime/libporttime.so.0.0.0\r
+ \r
+ backup: cleanest\r
+ cd ..; zip -r portmidi.zip portmidi\r
+diff -Nur portmidi/pm_linux/pmlinux.c portmidi-new/pm_linux/pmlinux.c
+--- portmidi/pm_linux/pmlinux.c 2006-11-30 00:37:09.000000000 +0100
++++ portmidi-new/pm_linux/pmlinux.c 2008-11-24 11:59:21.000000000 +0100
+@@ -28,10 +28,10 @@
+ * devices.\r
+ */\r
+ #ifdef PMALSA\r
+- pm_linuxalsa_init();\r
++ return pm_linuxalsa_init();\r
+ #endif\r
+ #ifdef PMNULL\r
+- pm_linuxnull_init();\r
++ return pm_linuxnull_init();\r
+ #endif\r
+ return pmNoError;\r
+ }\r
+diff -Nur portmidi/pm_linux/pmlinuxalsa.c portmidi-new/pm_linux/pmlinuxalsa.c
+--- portmidi/pm_linux/pmlinuxalsa.c 2008-06-14 02:23:43.000000000 +0200
++++ portmidi-new/pm_linux/pmlinuxalsa.c 2008-11-24 11:58:30.000000000 +0100
+@@ -209,7 +209,7 @@
+ if (when == 0) when = now;\r
+ when = (when - now) + midi->latency;\r
+ if (when < 0) when = 0;\r
+- VERBOSE printf("timestamp %d now %d latency %d, ", \r
++ VERBOSE printf("timestamp %d now %d latency %li, ", \r
+ (int) timestamp, (int) now, midi->latency);\r
+ VERBOSE printf("scheduling event after %d\n", when);\r
+ /* message is sent in relative ticks, where 1 tick = 1 ms */\r
+@@ -243,8 +243,8 @@
+ alsa_descriptor_type desc = (alsa_descriptor_type) midi->descriptor;\r
+ if (!desc) return pmBadPtr;\r
+ \r
+- if (pm_hosterror = snd_seq_disconnect_to(seq, desc->this_port, \r
+- desc->client, desc->port)) {\r
++ if ((pm_hosterror = snd_seq_disconnect_to(seq, desc->this_port, \r
++ desc->client, desc->port))) {\r
+ // if there's an error, try to delete the port anyway, but don't\r
+ // change the pm_hosterror value so we retain the first error\r
+ snd_seq_delete_port(seq, desc->this_port);\r
+@@ -333,8 +333,8 @@
+ {\r
+ alsa_descriptor_type desc = (alsa_descriptor_type) midi->descriptor;\r
+ if (!desc) return pmBadPtr;\r
+- if (pm_hosterror = snd_seq_disconnect_from(seq, desc->this_port, \r
+- desc->client, desc->port)) {\r
++ if ((pm_hosterror = snd_seq_disconnect_from(seq, desc->this_port, \r
++ desc->client, desc->port))) {\r
+ snd_seq_delete_port(seq, desc->this_port); /* try to close port */\r
+ } else {\r
+ pm_hosterror = snd_seq_delete_port(seq, desc->this_port);\r
+diff -Nur portmidi/pm_test/Makefile portmidi-new/pm_test/Makefile
+--- portmidi/pm_test/Makefile 1970-01-01 01:00:00.000000000 +0100
++++ portmidi-new/pm_test/Makefile 2008-11-24 12:00:31.000000000 +0100
+@@ -0,0 +1,32 @@
++# For debugging, define PM_CHECK_ERRORS
++PMFLAGS = -DPM_CHECK_ERRORS
++# Use this for linux alsa (0.9x) version
++ALSALIB = -lasound
++pmlib = -lportmidi
++ptlib = -lporttime
++VFLAGS = -DPMALSA
++
++CC = gcc $(CFLAGS) $(VFLAGS) $(PMFLAGS) -g
++
++all: test sysex midithread latency midithru
++
++test: test.o
++ $(CC) test.c -o test $(pmlib) $(ptlib) $(ALSALIB)
++
++sysex: sysex.o
++ $(CC) sysex.c -o sysex $(pmlib) $(ptlib) $(ALSALIB)
++
++midithread: midithread.o
++ $(CC) midithread.c -o midithread \
++ $(pmlib) $(ptlib) $(ALSALIB)
++
++latency: latency.o
++ $(CC) latency.c -o latency $(pmlib) $(ptlib) \
++ $(ALSALIB) -lpthread -lm
++
++midithru: midithru.o
++ $(CC) midithru.c -o midithru $(pmlib) $(ptlib) \
++ $(ALSALIB) -lpthread -lm
++
++clean:
++ rm -f midithru latency midithread sysex test
--- /dev/null
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+inherit eutils
+
+DESCRIPTION="Platform Independent Library for MIDI"
+HOMEPAGE="http://www.cs.cmu.edu/~music/portmusic/portmidi/"
+MY_P="${PN}-src-${PV}"
+SRC_URI="${HOMEPAGE}/${MY_P}.zip"
+LICENSE="MIT"
+SLOT="0"
+KEYWORDS="~x86 ~amd64"
+IUSE=""
+DEPEND="media-libs/alsa-lib"
+S="${WORKDIR}/${PN}"
+
+src_unpack() {
+ unpack ${A} || die "unpack failed"
+ cd ${S}
+ epatch "${FILESDIR}/${P}.diff" || die "epatch failed"
+}
+
+src_compile() {
+ emake -f pm_linux/Makefile -j1 || die "emake failed"
+}
+
+src_install() {
+ ln -s libportmidi.so.0.0.0 pm_linux/libportmidi.so.0
+ ln -s libportmidi.so.0 pm_linux/libportmidi.so
+ ln -s libporttime.so.0.0.0 porttime/libporttime.so.0
+ ln -s libporttime.so.0 porttime/libporttime.so
+ dolib.so pm_linux/libportmidi.so* porttime/libporttime.so*
+ dolib.a pm_linux/libportmidi.a porttime/libporttime.a
+ insinto /usr/include
+ doins pm_common/portmidi.h porttime/porttime.h
+ insinto /usr/lib/portmidi
+ INSOPTIONS="${EXEOPTIONS}" doins \
+ pm_test/{latency,midithread,midithru,sysex,test}
+ dodoc license.txt README.txt pm_linux/README_LINUX.txt
+}