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

github.setup        caolanm libwmf 0.2.15 v
revision            0
categories          graphics fonts
license             LGPL
maintainers         nomaintainer
description         Library for converting WMF (Window Metafile Format) files
long_description \
    ${name} is a library for reading vector images in Microsoft's native \
    Windows Metafile Format (WMF) and for either a) displaying them in, \
    e.g., an X window, or b) converting them to more standard/open file \
    formats.

homepage            https://wvware.sourceforge.net/libwmf.html

checksums           rmd160  e3c3ae693afd3ac0a4b43b4c8c9c5bdaf151873f \
                    sha256  bbc90f22b9e86d5f1890d7da11cf7a8e61f429d4c220d900c285021deabe7a52 \
                    size    2766626
github.tarball_from archive

depends_build       path:bin/pkg-config:pkgconfig

depends_lib         port:expat \
                    path:lib/pkgconfig/freetype2.pc:freetype \
                    path:lib/pkgconfig/gdk-pixbuf-2.0.pc:gdk-pixbuf2 \
                    path:include/turbojpeg.h:libjpeg-turbo \
                    port:libpng \
                    port:zlib

use_autoreconf      yes
autoreconf.args     -fvi

configure.args      --with-expat \
                    --with-fontdir=${prefix}/share/fonts/${name} \
                    --with-jpeg \
                    --without-x

post-destroot {
    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath} AUTHORS COPYING CREDITS ChangeLog \
        NEWS README TODO ${destroot}${prefix}/share/doc/${name}
}

variant lite conflicts x11 xml2 description "Install a minimal version" {
    depends_lib     port:freetype
    configure.args  --disable-heavy \
                    --with-fontdir=${prefix}/share/fonts/${name}
}

variant x11 {
    depends_lib-append      port:xorg-libX11
    depends_build-append    port:mkfontscale

    configure.args-replace  --without-x \
                            --with-x

    post-destroot {
        system "mkfontscale ${destroot}${prefix}/share/fonts/${name} && mkfontdir ${destroot}${prefix}/share/fonts/${name}"
    }
}

variant xml2 description "Use libxml2 not expat" {
    depends_lib-replace     port:expat \
                            port:libxml2
    configure.args-replace  --with-expat \
                            --with-libxml2
}
