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

PortSystem       1.0
PortGroup        qt4 1.0

name             qlandkarte
categories       gis
license          GPL-2+
version          0.7.3
revision         7
maintainers      nomaintainer

description      Use your Garmin GPS with Linux/Mac OS X
long_description QLandkarte is a QT Application similar to Garmin's MapSource.

homepage         http://qlandkarte.sourceforge.net/
master_sites     sourceforge:project/qlandkarte/qlandkarte/QLandkarte-${version}
distname         QLandkarte_${version}

checksums        md5 51f804235511f1c10ae8538f86743135

depends_lib-append port:proj4 \
                 port:libusb-compat

patchfiles       TWOPI.patch \
                 CGarminDBMap-constfix.patch

post-patch {
    # fix lack of CoreFoundation after libgarmin.a
    foreach pro_file { EtrexLegendC/EtrexLegendC.pro \
                       EtrexLegendCx/EtrexLegendCx.pro \
                       GPSMap60CSx/GPSMap60CSx.pro \
                       whatGarmin/whatGarmin.pro } {
        reinplace "s|IOKit|IOKit -framework CoreFoundation|" \
            ${worksrcpath}/src/device/${pro_file}
    }
}

configure.args   --with-extra-includes=${prefix}/lib/proj49/include \
                 --with-extra-libs=${prefix}/lib/proj49/lib \
                 --with-qt-dir=${qt_dir}

destroot {
    xinstall -d ${destroot}${applications_dir}
    copy ${worksrcpath}/bin/QLandkarte.app ${destroot}${applications_dir}
    ln -s ${applications_dir}/QLandkarte.app/Contents/MacOS/QLandkarte ${destroot}${prefix}/bin
    foreach plugin [glob -directory ${worksrcpath}/bin/plugins *] {
        copy ${plugin} ${destroot}${applications_dir}/QLandkarte.app/Contents/Resources/plugins/
    }
}
