Compiling MediaTomb for the Drobo
This guide assumes that you already have a cross-compiling environment setup such as the one described in Setup a Cross-Compile Environment for Drobo. I used this article Building MediaTomb for the Drobo using Ubunutu to get my system working and to create this guide.
This guide was created using MediaTomb 12.1 for Drobo FS.
Prepare MediaTomb Build Environment
# Activate/Enter the chroot
sudo schroot -c drobofs -d /root
# create a directory for downloaded archives (if you didn't already do so)
mkdir -p /root/download
# create mediatomb build directory (I use the application name)
mkdir -p /root/mediatomb
# create directory for resulting binaries (I use a target directory for this application build)
mkdir -p /root/mediatomb/arm
# Define the following environment variables for the application build directory
export CFLAGS="-I/root/mediatomb/arm/include -march=armv5te" export CPPFLAGS=${CFLAGS} export LDFLAGS="-L/root/mediatomb/arm/lib -Wl,-rpath -Wl,/mnt/DroboFS/Shares/DroboApps/mediatomb/lib" export CC=arm-none-linux-gnueabi-gcc
Build Dependencies
ZLib
Download Zlib from http://www.zlib.net/ to ~/download/.
# Download code wget -P ~/download http://zlib.net/zlib-1.2.5.tar.gz # Extract code cd ~/mediatomb tar xfz ~/download/zlib-1.2.5.tar.gz cd zlib-1.2.5 # configure, build, and install ./configure --prefix=/root/mediatomb/arm --shared make make install
Expat
Download Expat from http://sourceforge.net/projects/expat/.
# Download code wget -P ~/download http://downloads.sourceforge.net/project/expat/expat/2.0.1/expat-2.0.1.tar.gz # Extract code cd ~/mediatomb tar xfz ~/download/expat-2.0.1.tar.gz cd expat-2.0.1 # configure, build, and install ./configure --host=arm-none-linux-gnueabi --prefix=/root/mediatomb/arm make make install
SQLite
Download SQLite from http://www.sqlite.org/download.html.
# Download code wget -P ~/download http://www.sqlite.org/sqlite-amalgamation-3.6.23.1.tar.gz # Extract code cd ~/mediatomb tar xfz ~/download/sqlite-amalgamation-3.6.23.1.tar.gz cd sqlite-3.6.23.1 # configure, build, and install ./configure --host=arm-none-linux-gnueabi --prefix=/root/mediatomb/arm make make install
File
Download File from http://www.darwinsys.com/file/. Note: The site admin removed the 4.24 version of file and I had issues compiling the latest versions, but download 4.24 from my link provided below.
# Download code wget -P ~/download ftp://ftp.sunfreeware.com/pub/freeware/SOURCES/file-4.24.tar.gz # Extract code cd ~/mediatomb tar xfz ~/download/file-4.24.tar.gz cd file-4.24
# Edit magic/Makefile.am in vi or some other editor
# Change line 224 from ${MAGIC}: $(EXTRA_DIST) $(FILE_COMPILE) # to ${MAGIC}: $(EXTRA_DIST)
# generate build scripts aclocal autoheader autoconf libtoolize automake # configure, build, and install ./configure --host=arm-none-linux-gnueabi --prefix=/root/mediatomb/arm make make install
libexif
Download libexif from http://libexif.sourceforge.net.
# Download code wget -P ~/download http://downloads.sourceforge.net/project/libexif/libexif/0.6.19/libexif-0.6.19.tar.gz # Extract code cd ~/mediatomb tar xfz ~/download/libexif-0.6.19.tar.gz cd libexif-0.6.19 # configure, build, and install ./configure --host=arm-none-linux-gnueabi --prefix=/root/mediatomb/arm make make install
TagLib
Download TagLib from http://developer.kde.org/~wheeler/taglib.html to ~/download/, I used taglib-1.6.3.tar.gz for this guide.
# Extract code cd ~/mediatomb tar xfz ~/download/taglib-1.6.3.tar.gz cd taglib-1.6.3 # configure, build, and install ./configure --host=arm-none-linux-gnueabi --prefix=/root/mediatomb/arm make make install
id3lib
id3lib is available from http://id3lib.sourceforge.net/; however, since TagLib is being used it is not needed. See the mediatomb documentation for details on using id3lib if needed.
libjs - SpiderMonkey
Download SpiderMonkey from http://ftp.mozilla.org/pub/mozilla.org/js/.
# Download code wget -P ~/download http://ftp.mozilla.org/pub/mozilla.org/js/older-packages/js-1.5.tar.gz # Extract code cd ~/mediatomb tar xfz ~/download/js-1.5.tar.gz # be tidy and rename the directory so the version is obvious mv js js-1.5 cd js-1.5/src
# run make, this will fail on the first attempt make BUILD_OPT=1 -f Makefile.ref CC=arm-none-linux-gnueabi-gcc LD=arm-none-linux-gnueabi-ld
# first copy jscpucfg to the target drobo and execute it. to generate jsautocfg.h
# NOTE: run this on the Drobo, NOT on the build system ./jscpucfg > jsautocfg.h
# copy the resulting jsautocfg.h back to your build system to replace the 0 byte version
# repeat make, should run successfully
make BUILD_OPT=1 -f Makefile.ref CC=arm-none-linux-gnueabi-gcc LD=arm-none-linux-gnueabi-ld
# there is no install target, so manually install
# from dir: js-1.5/src mkdir /root/mediatomb/arm/include/smjs/ cp *.{h,tbl} /root/mediatomb/arm/include/smjs/ cp Linux_All_OPT.OBJ/*.h /root/mediatomb/arm/include/smjs/ cp Linux_All_OPT.OBJ/js /root/mediatomb/arm/bin/ cp Linux_All_OPT.OBJ/libjs.so /root/mediatomb/arm/lib/
Build Mediatomb
Download MediaTomb from http://mediatomb.cc/pages/download#source_code.
# Download code wget -P ~/download http://downloads.sourceforge.net/mediatomb/mediatomb-0.12.1.tar.gz # Extract code cd ~/mediatomb tar xfz ~/download/mediatomb-0.12.1.tar.gz cd mediatomb-0.12.1 # Configure MediaTomb options ./configure --host=arm-none-linux-gnueabi --prefix=/root/mediatomb/arm \ --disable-rpl-malloc --disable-mysql --disable-libmp4v2 \ --disable-ffmpeg --disable-lastfmlib --disable-curl --disable-youtube --disable-libextractor \ --enable-external-transcoding --enable-inotify \ --with-taglib-cfg=/root/mediatomb/arm/bin/taglib-config \ --with-search=/root/mediatomb/arm --with-js-h=/root/mediatomb/arm/include/smjs # build and install make make install
Mediatomb Configuration Summary
The resulting mediatomb configuration would be the following:
sqlite3 : yes mysql : disabled libjs : yes libmagic : yes inotify : yes libexif : yes id3lib : disabled taglib : yes libmp4v2 : disabled ffmpeg : disabled ffmpegthumbnailer : missing lastfmlib : disabled external transcoding : yes curl : no YouTube : disabled libextractor : db-autocreate : yes
Package the DroboApp
The binaries creating during this build are now installed to /root/mediatomb/arm which can be packaged and transferred to the Drobo. Only the output bin, lib/*.so*, share/file, and share/mediatomb directories are required at runtime; so the other files can be excluded during transfer and packaging.
We need to create a startup script for the DroboApp. For the Drobo FS, the script is named service.sh and could look similar to the following sample:
#!/bin/sh # # mediatomb . /etc/service.subr prog_dir=`dirname \`realpath $0\`` # define DroboApp name and version name="mediatomb" version="0.12.1" # also define the admin port since mediatomb would randomly assign it otherwise port=49152 pidfile=${prog_dir}/mediatomb.pid logfile=${prog_dir}/mediatomb.log # define the location of the shared libraries built for mediatomb # runtime library path was set during compile, so this should not be needed libdir=${prog_dir}/lib if [ -n ${libdir} ]; then export LD_LIBRARY_PATH=${libdir} fi export MEDIATOMB_DATADIR="${prog_dir}/share/mediatomb" export MEDIATOMB_MAGIC_FILE="${prog_dir}/share/file/magic" # define the start command start() { # launch the mediatomb daemon using the specified port and some other options ${prog_dir}/bin/mediatomb -d -m ${prog_dir} -f config -e eth0 -p ${port} \ -P ${pidfile} --logfile ${logfile} >> ${logfile} 2>&1 } # this standard stuff for service scripts case "$1" in start) start_service ;; stop) stop_service ;; restart) stop_service sleep 3 start_service ;; status) status ;; *) echo "Usage: $0 [start|stop|restart|status]" exit 1 ;; esac