# -*- 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 108098 2013-07-12 22:51:05Z devans@macports.org $

PortSystem      1.0

name            gnucash-docs
version         2.2.0
license         GPL-2 GFDL-1.1
categories      gnome x11
maintainers     nomaintainer
description     docs for gnucash
platforms       macosx
long_description \
                GnuCash is a personal and small-business \
                financial-accounting software, freely licensed under the \
                GNU GPL.  Designed to be easy to use, yet powerful and \
                flexible, GnuCash allows you to track bank accounts, \
                stocks, income and expenses. As quick and intuitive to \
                use as a checkbook register, it is based on professional \
                accounting principles to ensure balanced books and \
                accurate reports. \
                This package contains (1) the user manual and (2) the \
                Tutorial And Concepts Guide.  Both are available through \
                yelp, the gnome help browser, and an HTML copy is \
                installed in ${prefix}/share/doc/gnucash.
homepage        http://www.gnucash.org/
master_sites    http://www.gnucash.org/pub/gnucash/sources/stable/

                # gpg signature verified
checksums       md5 97a29e499baca1807a3944ae3c0ad61e

depends_lib     bin:scrollkeeper-config:rarian \
                port:libxml2 \
                bin:xsltproc:libxslt

depends_run     bin:yelp:yelp

supported_archs noarch

configure.args  --disable-scrollkeeper

build.target    all html

destroot {
    system "cd ${worksrcpath}; ${build.cmd} install prefix=${destroot}${prefix}"

    # Install HTML copies
    # Duplicate figures are removed, using symlinks instead.
    # If you update this, please check for additional localizations!

    file mkdir ${destpath}${prefix}/share/doc/gnucash/C
    file mkdir ${destpath}${prefix}/share/doc/gnucash/de_DE

    file copy ${portpath}/${filesdir}/index.html ${destpath}${prefix}/share/doc/gnucash

    file copy ${worksrcpath}/guide/C/gnucash-guide ${destpath}${prefix}/share/doc/gnucash/C
    system "rm -rf ${destpath}${prefix}/share/doc/gnucash/C/gnucash-guide/figures"
    system "ln -sf ${prefix}/share/gnome/help/gnucash/C/figures ${destpath}${prefix}/share/doc/gnucash/C/gnucash-guide/figures"

    file copy ${worksrcpath}/help/C/gnucash-help ${destpath}${prefix}/share/doc/gnucash/C
    system "rm -rf ${destpath}${prefix}/share/doc/gnucash/C/gnucash-help/figures"
    system "ln -sf ${prefix}/share/gnome/help/gnucash/C/figures ${destpath}${prefix}/share/doc/gnucash/C/gnucash-help/figures"

    file copy ${worksrcpath}/help/de_DE/gnucash-help ${destpath}${prefix}/share/doc/gnucash/de_DE
    file delete -force ${destpath}${prefix}/share/doc/gnucash/de_DE/gnucash-help/figures
    system "ln -sf ${prefix}/share/gnome/help/gnucash/de_DE/figures ${destpath}${prefix}/share/doc/gnucash/de_DE/gnucash-help/figures"
}

post-activate {
    system "${prefix}/bin/scrollkeeper-update"
}

livecheck.type  regex
livecheck.url   ${master_sites}
livecheck.regex "${name}-(\\d+(?:\\.\\d+)*)${extract.suffix}"
