# -*- 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$

PortSystem          1.0

name                hdhomerun_gui
version             20120405
categories          multimedia
platforms           darwin
license             GPL-3
maintainers         nomaintainer
description         HDHomeRun GTK GUI
long_description    ${description}
homepage            http://www.silicondust.com/

master_sites        http://download.silicondust.com/hdhomerun
distname            hdhomerun_config_gui_${version}
patchfiles          patch-libhdhomerun.diff \
                    patch-firmware_path.diff \
                    patch-missing_frameworks.diff
patch.args          -p1
extract.suffix      .tgz
worksrcdir          hdhomerun_config_gui
checksums           rmd160 e0d1b748878a93b569482c685071ed1706aa09ad \
                    sha256 a2a9bee89d2911dd15024da53329bccf7cc5f14f801af12f32e50e0b54529ed2
livecheck.type      regex
livecheck.url       http://www.silicondust.com/support/hdhomerun/downloads/
livecheck.regex     Current release: (\[0-9\]+)

depends_build       port:pkgconfig
depends_lib         port:hdhomerun port:gtk2
# VLC-devel would also be acceptable.  VLC09 is not.  Patch to handle
# this welcome
depends_run         port:VLC

post-patch {
    reinplace "s|@FIRMWARE_DIR@|${prefix}/share/hdhomerun/|g" \
        ${worksrcpath}/src/HDHRConfig.cpp
    reinplace "s|\${EXECUTABLE_NAME}|hdhomerun_config_gui|g" \
        ${worksrcpath}/OSX/Info.plist
    reinplace "s|\${PRODUCT_NAME}|HDHomeRun Config|g" \
        ${worksrcpath}/OSX/Info.plist
}

post-destroot {
    set app_contents \
        "${destroot}${applications_dir}/HDHomeRun Config.app/Contents"

    xinstall -d -m 0755 ${app_contents}/Resources
    xinstall -d -m 0755 ${app_contents}/MacOS

    xinstall -m 0644 ${filespath}/PkgInfo ${app_contents}
    xinstall -m 0644 ${worksrcpath}/OSX/Info.plist ${app_contents}
    xinstall -m 0644 ${worksrcpath}/OSX/hdhr.icns \
        ${app_contents}/Resources
    ln -s ${prefix}/bin/hdhomerun_config_gui ${app_contents}/MacOS/
}