# -*- 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            xsane
version         0.999
revision        3
license         GPL-2
categories      graphics x11
maintainers     {puffin.lb.shuttle.de:michael.klein @mklein-de} openmaintainer
description     X11 frontend for SANE
# http://www.xsane.org/ has been gone since June 2018
# no sign of further upstream development activity
homepage        https://www.openhub.net/p/${name}
platforms       darwin

long_description This is an X11 frontend for the Scanner Access Now Easy \
                 Project.

# all previous master_sites are gone as well but source is available from Ubuntu
master_sites    http://archive.ubuntu.com/ubuntu/pool/universe/x/xsane/

distname        ${name}_${version}.orig
worksrcdir      ${name}-${version}

# make directories in ${worksrcpath} traversible by all users
post-extract {
    fs-traverse item ${worksrcpath} {
        if {[file isdirectory ${item}]} {
            file attributes ${item} -permissions a+x
        }
    }
}

checksums       rmd160  3799a599ddf06b0ca297b2270b50d4b93e1f0e12 \
                sha256  5782d23e67dc961c81eef13a87b17eb0144cae3d1ffc5cf7e0322da751482b4b \
                size    2950621

depends_build   port:pkgconfig
depends_lib     path:lib/pkgconfig/gimp-2.0.pc:gimp2 \
                path:include/turbojpeg.h:libjpeg-turbo \
                path:lib/pkgconfig/gtk+-2.0.pc:gtk2 \
                port:libpng \
                port:sane-backends \
                port:tiff \
                port:lcms

patchfiles      patch-sane-options-handling-fix.diff \
                patch-gtk_adjustment_new.diff \
                patch-src__xsane-save.c-libpng15-compat.diff \
                patch-configure.diff \
                patch-getopt.c.diff

# gimp2 is not universal (https://trac.macports.org/ticket/29165)

if {![variant_isset disable_gimp]} {
    universal_variant no
}

post-destroot {
    if {![variant_isset disable_gimp]} {
        xinstall -d ${destroot}${prefix}/lib/gimp/2.0/plug-ins
        ln -sf ${prefix}/bin/xsane ${destroot}${prefix}/lib/gimp/2.0/plug-ins
    }
}

variant disable_gimp description {Disable building of GIMP plugin} {
    depends_lib-delete      path:lib/pkgconfig/gimp-2.0.pc:gimp2
    configure.args-append   --disable-gimp
}

livecheck.type  regex
livecheck.url   ${master_sites}
livecheck.regex "${name}_(\\d+(?:\\.\\d+)*)\\.orig${extract.suffix}"
