# -*- 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                pdflib
version             7.0.5p3
categories          print
platforms           darwin
license             Restrictive
maintainers         nomaintainer

description         PDFlib Lite (Source Code) is a subset of PDFlib
long_description    ${description}, a library of C routines that allow \
                    to programmatically generate PDF, the Adobe's \
                    Portable Document File format.
homepage            http://www.pdflib.com/download/free-software/pdflib-lite-7/

master_sites        http://distcache.freebsd.org/local-distfiles/ale/
distname            PDFlib-Lite-${version}
checksums           rmd160 daf4dea4e049bea4963dcc7d3dc0eabec47ca89b \
                    sha256 e5fb30678165d28b2bf066f78d5f5787e73a2a28d4902b63e3e07ce1678616c9 \
                    size   8179201

patchfiles          patch-configure.diff \
                    patch-perl_Makefile.diff \
                    patch-libtool.diff

configure.ccache    no
configure.args      --without-java \
                    --without-perl \
                    --without-py \
                    --without-ruby \
                    --without-tcl

# The existence of tiff header files interferes with PDFLib (#11789).
configure.cppflags-replace  -I${prefix}/include -isystem${prefix}/include

test.run            yes

post-destroot {
    xinstall -m 755 -d ${destroot}${prefix}/share/doc/
    file copy ${worksrcpath}/doc/pdflib ${destroot}${prefix}/share/doc/${name}
}

variant java description {Enable Java language binding} {
    configure.args-replace  --without-java --with-java=yes
}

variant perl description {Enable Perl language binding} {
    depends_lib-append      path:bin/perl:perl5
    configure.args-replace  --without-perl --with-perl=${prefix}/bin/perl
}

variant python27 description {Enable Python 2.7 binding} {
    set pyversion 2.7
    depends_lib-append      port:python[strsed ${pyversion} {g/[.]//}]
    configure.args-replace  --without-py --with-py=${frameworks_dir}/Python.framework/Versions/${pyversion}
    configure.args-append   --with-pyincl=${frameworks_dir}/Python.framework/Versions/${pyversion}/include/python${pyversion}
    configure.env-append    PYTHONBIN=${prefix}/bin/python${pyversion}
}

variant tcl description {Enable Tcl language binding} {
    depends_lib-append      path:bin/tclsh:tcl
    configure.args-replace  --without-tcl --with-tcl=${prefix}/bin/tclsh
}

variant ruby description {Enable Ruby language binding} {
    depends_lib-append          port:ruby
    pre-configure {
        set rubyIncl [file dirname [glob ${prefix}/lib/ruby/*/*/ruby.h]]
        configure.args-replace  --without-ruby --with-ruby=${prefix}
        configure.args-append   --with-rubyincl=${rubyIncl}
    }
}

if {[variant_isset universal]} {
    depends_build-append    port:libtool
    post-configure {
        file copy -force ${prefix}/bin/glibtool ${worksrcpath}/libtool
    }
}

# The web page says “Note that PDFlib Lite is no longer maintained by PDFlib GmbH”
# and that they “will not release new and updated versions”.
livecheck.type              none