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

name                libwmf
version             0.2.8.4
revision            9
categories          graphics fonts
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.

platforms           darwin

homepage            http://wvware.sourceforge.net/libwmf.html
master_sites        sourceforge:wvware

checksums           rmd160  98cd631adb5bb332d9224d04bc8a265c105435f2 \
                    sha256  5b345c69220545d003ad52bfd035d5d6f4f075e65204114a9e875e84895a7cf8

depends_build \
    port:pkgconfig

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

patchfiles          configure.ac.diff

use_autoreconf      yes
autoreconf.args     -fvi

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

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 x11 {
    depends_lib-append  port:xorg-libX11
    depends_build-append    port:mkfontscale

    configure.args-delete   --without-x
    configure.args-append   --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-delete  port:expat
    depends_lib-append  port:libxml2
    configure.args-delete   --with-expat
    configure.args-append   --with-libxml2
}

livecheck.url   http://sourceforge.net/projects/wvware/files/libwmf/
livecheck.regex "${name}\/(\\d+(?:\\.\\d+)*)"
