forked-daapd and libantlr3c on SheevaPlug
11/10 Update: As several people have pointed out, since this post was written, forked-daapd has been added to the standard Debian repositories. Thus, if you are running Debian Squeeze (or newer), installing it is now as simple as 'apt-get install forked-daapd' and none of the below is necessary.
I recently purchased a SheevaPlug to use as a home server in an environment of mostly Macs. I'll post in more detail about my SheevaPlug setup later, but here I wanted to detail how I got forked-daapd running. I've got a Debian installation on my plug (previously Lenny, now upgraded to Squeeze) and while installing most things is as easy as 'apt-get install package', getting forked-daapd running turned out to be a major pain due to one of the dependency libraries, libantlr3c. I'm not aware of anyone else who installed libantlr3c on the SheevaPlug, so I'm posting how I got it to work here.
The forked-daapd package is very new and very under development, so there aren't any packages in the Debian repositories. Over at the Ubuntu forums, someone posted instructions on compiling forked-daapd on Ubuntu 9.10. Since Ubuntu and Debian are quite similar under the hood, I figured the same instructions should work on my plug, but problems occurred with getting the libantlr3c libraries to compile. After installing all the dependency libraries from the repositories, the configure script ran to completion, but the resulting make failed immediately. The first error was a bad compiler flag '-m32', which does nothing on an ARM machine like the plug anyways, so I just deleted it from the makefile, but then I started getting weird errors during the make like
/usr/lib/gcc/arm-linux-gnueabi/4.3.2/include/stddef.h:214: error: duplicate 'unsigned'
/usr/lib/gcc/arm-linux-gnueabi/4.3.2/include/stddef.h:214: error: two or more data types in declaration specifiers
It turns out that something went wrong in the configure script and it couldn't find a bunch of standard headers that were exactly where they ought to be in /usr/include, and thus the generated antlr3config.h was completely wrong. The only solution I found was hand-editing this file to have the correct values -- once I did that, I was able to manually compile and install the static library.
The forked-daapd instructions at the Ubuntu forums used antlr 3.1.3 -- I used 3.2 and didn't have any problems, but make sure you use the same version of the jar file and the C headers. The instructions below are what I used to install 3.2 (after dealing with dependencies by running the configure script and installing the next missing dependency until it succeeded):
Install antlr3 from the repos and grab and extract the C header sources:
sudo apt-get install antlr3
wget http://antlr.org/download/C/libantlr3c-3.2.tar.gz
tar xvfz libantlr3c-3.2.tar.gz
Grab my modified antlr3config.h, or modify the faulty one generated by ./configure to suit your system:
wget http://blog.zortrium.net/files/sheeva-antlr3config.h
mv sheeva-antlr3config.h libantlr3c-3.2/antlr3config.h
Now we manually compile and build a static library file. If your antlr3config.h is right and you have all the dependencies, the compilation should go off without a hitch.
cd libantlr3c-3.2/src
gcc -c -O2 -I.. -I../include *.c
ar cru libantlr3c.a *.o
ranlib libantlr3c.a
Now install the header files and library file into /usr/local:
sudo cp libantlr3c.a /usr/local/lib/
sudo cp ../antlr3config.h /usr/local/include/
sudo cp ../include/*.h /usr/local/include/
Now we have to fix the system-installed antlr to use the right jarfile:
wget http://www.antlr.org/download/antlr-3.2.jar
sudo mv antlr-3.2.jar /usr/share/java/
sudo vi /usr/bin/antlr
At the last step, just change the classpath line in /usr/bin/antlr (which is just a text file) to point to the new jarfile -- for instance, I changed mine to
export CLASSPATH=/usr/share/java/stringtemplate.jar:/usr/share/java/antlr-3.2.jar
Finally, after all of this, you're back in sync with the Ubuntu instructions and can proceed from the 'Configure and build forked-daapd' section. Forked-daapd itself has a bunch of other dependencies I had to install, but all were easily installed from the Debian repositories. The only snag I ran into was that the Lenny version of avahi-daemon is too old for forked-daapd -- this was one of the factors that prompted me to upgrade my plug to Squeeze, at which point I didn't have any other issues. Forked-daapd is now running great on my plug and streaming movies to my Mac clients over Front Row.
First post
I'm joining the modern web world and starting a blog of sorts. Not too much of a singular purpose yet -- I'll post about tech things that interest me, projects I'm working on, and various problems I've solved that I (and hopefully others) may find useful in the future.