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

name                feh
version             3.10.3
revision            0
categories          graphics
maintainers         nomaintainer
license             MIT

description         Fast lightweight image viewer

long_description    Simple and fast image viewer using imlib2 with file list \
                    and recursive file opening.

homepage            https://feh.finalrewind.org/
master_sites        ${homepage}
use_bzip2           yes

checksums           rmd160  876510ef4e18cb7487e3c193c1f4a5a7fa4c718f \
                    sha256  5426e2799770217af1e01c2e8c182d9ca8687d84613321d8ab4a66fe4041e9c8 \
                    size    2113623

depends_lib-append  port:curl \
                    port:desktop-file-utils \
                    port:imlib2 \
                    port:libexif \
                    path:include/turbojpeg.h:libjpeg-turbo \
                    port:libpng \
                    port:xorg-libXinerama \
                    port:xorg-libXt \
                    port:zlib

# Correct permissions
post-extract {
    system "chmod -R 755 ${worksrcpath}"
}

patchfiles-append   implicit.patch

# per config.mk
compiler.c_standard 2011

use_configure       no

# exif=1 - enable auto-rotate
# verscmp=0 - disable strverscmp
build.args          PREFIX=${prefix} \
                    'exif=1' \
                    'verscmp=0'

# filelist.c:255:40: error: passing argument 3 of 'scandir'
# from incompatible pointer type [-Wincompatible-pointer-types]
configure.cflags-append \
                    -Wno-incompatible-pointer-types

if {${universal_possible} && [variant_isset universal]} {
    foreach arch ${universal_archs_supported} {
        lappend merger_build_env(${arch}) \
                    CC=${configure.cc} \
                    "CFLAGS=${configure.cflags} [muniversal_get_arch_flag ${arch}]" \
                    CPPFLAGS=${configure.cppflags} \
                    "LDFLAGS=${configure.ldflags} [muniversal_get_arch_flag ${arch}]"
    }
} else {
    build.env       CC=${configure.cc} \
                    "CFLAGS=${configure.cflags} [get_canonical_archflags cc]" \
                    CPPFLAGS=${configure.cppflags} \
                    "LDFLAGS=${configure.ldflags} [get_canonical_archflags ld]"
}

destroot.args       PREFIX=${prefix}

post-activate {
    system "${prefix}/bin/update-desktop-database ${prefix}/share/applications"
}

livecheck.type      regex
livecheck.regex     ${name}-(\[0-9.\]+)${extract.suffix}
