hacking/editing portfile (MacPorts) to compile madplay for use with shell-fm (last.fm)


Vinh Nguyen


August 26, 2009

so recently i compiled shell-fm, a command-line last.fm player. in order to record music with shell-fm, i can output the stream of incoming data into tee, which saves the data to a file and at the same time pipes it out to stdout, and have that piped to madplay, a command-line player.

i had mplayer installed, but in order to get the piping of the streaming data to work, i had to to specify a cache '| mplayer -cache 32 -' (- means to take from stdin) in order for the music to play at the right rate. otherwise, the mplayer plays at a slower rate. the shell-fm wikidot recommends madplay.

madplay doesn't compile easily on a mac os x, so i had to resort to MacPorts for the installation. it installs fine, but madplay plays noise. googled it, and stumbled on this post. he figured out it was an endian issue.

i tried applying his patch ('patch < temp.patch') to the original source code, however, it didn't compile. figured out that i need the patch and the flags (CFLAGS, LDFLAGS) from Macports as well. i didn't know how to apply both patches. hopped on #MacPorts on the freenode, and spoke with toby.

i created the 2nd patch and called it temp.patch in /opt/local/var/macports/sources/rsync.macports.org/release/ports/audio/madplay/files. edited /opt/local/var/macports/sources/rsync.macports.org/release/ports/audio/madplay/Portfile and added temp.patch to the list of patch files. now running 'sudo port install madplay' did the trick after uninstalling (sources and portfiles still around). voila, i have a working install on mac os x.

toby committed the new patch to macports, so now things should work. to get the new patches, i had to run 'sudo port -d sync' to sync the newest patch files. i uninstalled and reinstalled and the new official patch works.

i learned how macports operated and how to apply patch files in this adventure.