# -*- 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
PortGroup                           lua 1.0
PortGroup                           makefile 1.0

name                                lua-luahpdf
github.setup                        jung-kurt luahpdf f0098346f8
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from                 tarball
version                             1.5
revision                            2
license                             MIT
categories                          lua devel
maintainers                         nomaintainer
description                         Lua module that lets you programmatically create PDF files
long_description                    LuaHPDF is a {*}${description} using Lua.

checksums                           rmd160  bfae209ac6046dc6bb282263f6ea1be0cd1c33da \
                                    sha256  ef620fa9fd17eabf0074ab216232585a3ea9302ea185c8c4a61754346655276d \
                                    size    45849

patchfiles                          patch-Makefile.diff \
                                    patch-lua_5.4.diff

build.args-append                   PLATFORM=macosx

depends_lib                         port:libharu \
                                    port:libpng \
                                    port:zlib

foreach branch ${lua.branches} {
    set subname                     luahpdf
    set branch_no_dot               [join [split ${branch} .] ""]
    set subport_name                lua${branch_no_dot}-${subname}

    subport ${subport_name} {}
    if {${subport} eq ${subport_name}} {
        lua.version                 ${branch}
        destroot.args-append        MODDIR=${prefix}/lib/lua/${lua.version}
    }
}

subport ${name} {
    distfiles
    patchfiles
    extract.rename                  no
    supported_archs                 noarch
    platforms                       any
    foreach deptype {depends_extract depends_patch depends_lib depends_build depends_run depends_test} {
        ${deptype}
    }
    proc lua::callback {} {}
    build {}
    destroot {
        set docdir                  ${destroot}${prefix}/share/doc/${subport}
        xinstall -d -m 0755         ${docdir}
        set f                       [open "${docdir}/README" w 0644]
        puts ${f}                   "[option subport] is a stub port"
        close                       ${f}
    }
}
