# -*- 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.13 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  2dd20f342b318f893b533499cfced55ee5043790 \
                    sha256  18ba69febd2f515d98a2352de284a8051896062ac9728d2ead07bc39ea75a068 \
                    size    3044235
github.tarball_from archive

depends_build       path:bin/pkg-config:pkgconfig

depends_lib         port:expat \
                    port: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
}
