# -*- 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 117868 2014-03-15 15:48:56Z ryandesign@macports.org $

PortSystem          1.0
PortGroup           github 1.0
PortGroup           qt4 1.0

github.setup        goldendict goldendict e4adc5f
version             1.0.1-20120825
# FIXME: add proper categories
categories          office
platforms           darwin
maintainers         nomaintainer
license             GPL-3+

description         Dictionary lookup program

long_description    A feature-rich dictionary lookup program, \
                    supporting multiple dictionary formats \
                    (StarDict/Babylon/Lingvo/Dictd) and online \
                    dictionaries, featuring perfect article \
                    rendering with the complete markup, \
                    illustrations and other content retained, \
                    and allowing you to type in words without \
                    any accents or correct case.

homepage            http://goldendict.org/

checksums           rmd160  e7bc51564dda4c93dfb34af2a4b13eb0bf879e58 \
                    sha256  e65408498d4662e6d04c29b93ee0692718288c9995be87de54348783215d56f9

depends_lib-append  port:bzip2 \
                    port:hunspell \
                    port:libogg \
                    port:libvorbis \
                    port:libiconv \
                    port:phonon \
                    port:zlib

patchfiles          patch-goldendict.pro.diff

post-patch {
    reinplace "s|@VERSION@|${version}|g" ${worksrcpath}/goldendict.pro
}

configure.cmd       ${qt_qmake_cmd}
configure.pre_args
configure.universal_args-delete --disable-dependency-tracking

post-configure {
    # For some reason the Makefile qmake generates hardcodes the compiler
    # that qt4-mac was made with as the one used to build lionsupport.o.
    # Replace it with $(CC) which we set up for the correct compiler and
    # -arch flags with the build.args below.
    reinplace -E "/-o build\\/lionsupport.o/s/^(\[\[:space:\]\]+)\[^\[:space:\]\]+/\\1\\$\\(CC\\)/" ${worksrcpath}/Makefile
}

variant universal {}

build.args          CC="${configure.cc} [get_canonical_archflags cc]" \
                    CXX="${configure.cxx} [get_canonical_archflags cxx]" \
                    LINK="${configure.cxx} [get_canonical_archflags cxx]" \
                    XXXOBJC="${configure.cc} [get_canonical_archflags cc]"

destroot {
    copy ${worksrcpath}/GoldenDict.app ${destroot}${applications_dir}
}
