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

name                    stardict
version                 3.0.7
revision                0
checksums               rmd160  cf0fb8a89ffba394c700c74be46690318aec0f80 \
                        sha256  d766f4efb1ae868855a47f39b2def66dd7a3232ca54c651c9cb3327b1bec50ea \
                        size    3744286

categories              textproc
maintainers             gmail.com:alexandernx
# dict/ChangeLog says the license for versions 3.0.1.3, 2.4.10, 4.0.0, 3.0.7,
# 3.0.6.4, 3.0.6.3, and 3.0.6 is now public domain. It still ships with GPL-3
# COPYING and LICENSE files but the new file copy-right.txt says those files
# should be ignored. I could find no explanation for how this license change
# was legally accomplished (e.g. a statement that all contributors agreed to
# the license change) and I suspect that it was not because it appears to have
# been subsequently reverted and the project's web page, at least the one on
# SourceForge, still says it's "Licensed under GPL terms." It's impossible to
# follow this project's development since it has moved from SourceForge to
# Google Code to SourceForge to GitHub to Gitee and the developer creates a new
# empty repository for each version of the software so there is no single place
# where the complete git history can be found and no single issue tracker.
# The mind boggles.
license                 GPL-3+

description             A full featured gtk2 dictionary

long_description        Very nice gnome dictionary. \
                        Can handle both local and web dictionaries. \
                        Though it needs a handful of gnome libraries for \
                        installation.

homepage                http://stardict-4.sourceforge.net/index_en.php
master_sites            sourceforge:project/stardict-4/${version}
use_7z                  yes
distname                ${name}-${version}-2-src
worksrcdir              ${name}-${version}

depends_build           port:gnome-doc-utils \
                        port:intltool \
                        port:itstool \
                        path:bin/pkg-config:pkgconfig \
                        port:yelp-tools

depends_lib             port:espeak-ng \
                        path:lib/pkgconfig/glib-2.0.pc:glib2 \
                        path:lib/pkgconfig/gtk+-3.0.pc:gtk3 \
                        port:json-glib \
                        port:libcanberra \
                        port:libsigcxx2

# libsigcxx2 requires C++11 or newer
compiler.cxx_standard   2011
configure.cxxflags-append \
                        -std=c++11

# error: variable length array of non-POD element type 'std::vector<gchar *>' (aka 'vector<char *>')
# https://github.com/huzheng001/stardict-3/issues/58
compiler.blacklist-append {clang < 900}

patchfiles              LC_ALL.patch \
                        malloc.patch

# reconfigure with our intltool.m4
pre-configure {
    copy -force ${prefix}/share/aclocal/intltool.m4 ${worksrcpath}/dict/m4/intltool.m4
}

# No configure scripts in archive.
use_autoreconf          yes
autoreconf.cmd          ./autogen.sh
depends_build-append    port:autoconf \
                        port:automake \
                        port:gnome-common \
                        port:libtool

configure.args          --disable-espeak \
                        --disable-festival \
                        --disable-flite \
                        --disable-gucharmap \
                        --disable-silent-rules \
                        --disable-spell \
                        --disable-tools

variant gnome description {Add Gnome support} {
    depends_lib-append  port:gconf \
                        port:libbonobo \
                        port:libgnome \
                        port:popt

    if {${os.platform} eq "darwin"} {
        # The build system erroneously assumes that if you did not use
        # the --enable-darwin-support flag then you are not on Darwin,
        # and starts using ELF-specific --version-script flags.
        build.args-append \
                        LD_VERSION_SCRIPT_OPTION= \
                        WORDNET_LD_VERSION_SCRIPT_OPTION= \
                        WORDNET_PARSEDATA_LD_VERSION_SCRIPT_OPTION=
    }
}

if {![variant_isset gnome]} {
    depends_build-append \
                        port:gconf

    configure.args-append \
                        --disable-gnome-support

    if {${os.platform} eq "darwin"} {
        # Enabling Darwin support disables Gnome support.
        configure.args-append \
                        --enable-darwin-support
    }
}

livecheck.regex     /${name}-(\\d+(?:\\.\\d+)+)
