# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
# $Id: Portfile 84550 2011-09-27 21:05:11Z snc@macports.org $

PortSystem          1.0
PortGroup           archcheck 1.0

name                mediatomb
version             0.12.1
revision            3
categories          net multimedia
platforms           darwin
maintainers         gmail.com:yattenator
description         Open source (GPL) UPnP MediaServer
long_description \
    MediaTomb is an open source (GPL) UPnP MediaServer \
    with a nice web user interface, it allows you to stream \
    your digital media through your home network and \
    listen to/watch it on a variety of UPnP compatible devices.

homepage            http://mediatomb.cc/
master_sites        sourceforge

checksums           md5     e927dd5dc52d3cfcebd8ca1af6f0d3c2 \
                    sha1    86e880584cc9c8aaf3926d56048510d1d06e76b4 \
                    rmd160  ecb61ca2483f76421beef1036ac442b8f805fa96

depends_lib         port:libiconv port:zlib port:spidermonkey \
                    port:openssl \
                    port:file port:curl port:libexif port:expat

archcheck.files     lib/libiconv.dylib \
    lib/libz.dylib \
    lib/libjs.dylib \
    lib/libmagic.dylib \
    lib/libcurl.dylib \
    lib/libexif.dylib \
    lib/libexpat.dylib

use_autoreconf      yes

patchfiles          patch-configure.ac.diff

if {${configure.compiler} == "clang"} {
    configure.compiler llvm-gcc-4.2
}

configure.args      \
    --enable-libjs --with-js-h=${prefix}/include/js --enable-libexif \
    --disable-sqlite3 --disable-mysql \
    --disable-taglib --disable-id3lib \
    --disable-ffmpeg --disable-libextractor \
    --enable-sighup \
    --with-search=${prefix} \
    --with-curl-cfg=${prefix}/bin/curl-config

default_variants    +sqlite3 +taglib +ffmpeg

variant sqlite3 description {Use SQLite 3 database} {
    depends_lib-append      port:sqlite3
    archcheck.files-append  lib/libsqlite3.dylib
    configure.args-append   --enable-sqlite3
    configure.args-delete   --disable-sqlite3
}

variant mysql4 conflicts mysql5 description {Use MySQL 4 database} {
    depends_lib-append      port:mysql4
    archcheck.files-append  lib/mysql/libmysqlclient.dylib
    configure.args-append   --enable-mysql \
        --with-mysql-cfg=${prefix}/bin/mysql_config
    configure.args-delete   --disable-mysql
}

variant mysql5 conflicts mysql4 description {Use MySQL 5 database} {
    depends_lib-append      path:bin/mysql_config5:mysql5
    archcheck.files-append  lib/mysql5/mysql/libmysqlclient.dylib
    configure.args-append   --enable-mysql \
        --with-mysql-cfg=${prefix}/bin/mysql_config5
    configure.args-delete   --disable-mysql
}

variant taglib conflicts id3lib description {Use TagLib for tag access} {
    depends_lib-append      port:taglib
    archcheck.files-append  lib/libtag.dylib
    configure.args-append   --enable-taglib \
        --with-taglib-cfg=${prefix}/bin/taglib-config
    configure.args-delete   --disable-taglib
}

variant id3lib conflicts taglib description {Use id3lib for tag access} {
    depends_lib-append      port:id3lib
    archcheck.files-append  lib/libid3.dylib
    configure.args-append   --enable-id3lib
    configure.args-delete   --disable-id3lib
}

variant ffmpeg conflicts libextractor description {Use ffmpeg for gathering metadata} {
    depends_lib-append      path:lib/libavcodec.dylib:ffmpeg
    archcheck.files-append  lib/libavcodec.dylib
    configure.args-append   --enable-ffmpeg
    configure.args-delete   --disable-ffmpeg
}

variant libextractor conflicts ffmpeg description {Use libextractor for gathering metadata} {
    depends_lib-append      port:libextractor
    archcheck.files-append  lib/libextractor.dylib
    configure.args-append   --enable-libextractor
    configure.args-delete   --disable-libextractor
}

notes "******************************************************
* To use UTF-8 filename and metadata on Mac OS X, add:
*   <filesystem-charset>UTF-8-MAC</filesystem-charset>
*   <metadata-charset>UTF-8-MAC</metadata-charset>
* to <import> section of ~/.mediatomb/config.xml.
******************************************************
* In order to use MySQL for MediaTomb database:
* 1. Create DB on mysqld and grant all privilege to DB user.
* 2. Run \"mediatomb\" once on your shell.
* 3. Edit auto-generated ~/.mediatomb/config.xml.
*    In <server> section, edit <mysql> config like this:
*    <mysql enabled=\"yes\">
*      <host>localhost</host>
*      <username>dbusername</username>
*      <password>dbpassword</password>
*      <database>dbname</database>
*    </mysql>
* If sqlite3 is enabled,
*    <sqlite3 enabled=\"no\">
* is also needed to disable it.
******************************************************"

livecheck.regex MediaTomb\\/(\\d+(\\.\\d+)+)\\/
livecheck.url   "http://sourceforge.net/api/file/index/project-id/129766/mtime/desc/rss?path=%2FMediaTomb"
