# -*- 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                        sane-frontends
version                     1.0.15git
categories                  graphics
# Some content is LGPL-2+ or public-domain, but the package as a whole is GPL-2+
license                     GPL-2+
maintainers                 nomaintainer
homepage                    http://www.sane-project.org/

description                 Frontends for scanner access

long_description            These are the frontends for the Scanner Access Now \
                            Easy project. They allow you to access various \
                            scanners either locally or remote using saned.

# The SANE project has not released an updated sane-frontends
# tarball in nearly 5 years.  However, they have made updates
# to sane-frontends as the API for sane-backends has changed
# over that time.  Accordingly, it appears that fetching
# sane-frontends from the official git repository is the
# best bet for getting a compilable sane-frontends
fetch.type                  git
git.url                     https://gitlab.com/sane-project/frontends.git
git.branch                  1928f945eefa3b97b5c76d586082435bb23c2969

depends_lib                 port:sane-backends

configure.cppflags-append   -fno-common

post-configure {
    # Exit if a configuration error occurs.
    # https://gitlab.com/sane-project/frontends/-/issues/41
    if {![file exists ${worksrcpath}/Makefile]} {
        return -code error "configuration failed"
    }
}

platform darwin arm {
    depends_build-append    port:automake

    post-patch {
        # Use newer config.guess and config.sub to support Apple Silicon.
        # https://gitlab.com/sane-project/frontends/-/issues/40
        set automake_dirs [glob -directory ${prefix}/share automake-*]
        set automake_dir [lindex [lsort -command vercmp $automake_dirs] end]
        copy -force ${automake_dir}/config.guess ${automake_dir}/config.sub \
            ${worksrcpath}
    }
}

livecheck.url               https://gitlab.com/sane-project/frontends/-/commits/master?limit=1&format=atom
livecheck.version           ${git.branch}
livecheck.regex             {<id>https://gitlab\.com/sane-project/frontends/commit/([0-9a-f]+)</id>}
