# -*- 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            1
categories          graphics fonts
# Originally LGPL; unclear if now GPL.
# https://github.com/caolanm/libwmf/issues/29
license             LGPL
maintainers         nomaintainer
description         Library for converting WMF (Window Metafile Format) files
long_description \
    libwmf 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.

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

depends_build \
    path:bin/pkg-config:pkgconfig

depends_lib \
    port:zlib \
    port:libpng \
    path:include/turbojpeg.h:libjpeg-turbo \
    port:freetype \
    port:expat

patchfiles-append   no-gdk-pixbuf2.patch

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

# Don't use already-installed MacPorts headers instead of project local headers.
configure.cppflags-replace -I${prefix}/include -isystem${prefix}/include

post-destroot {
    xinstall -m 0755 -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 0644 -W ${worksrcpath} AUTHORS COPYING CREDITS ChangeLog \
        NEWS README TODO ${destroot}${prefix}/share/doc/${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
}
