# -*- 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           meson 1.0
PortGroup           legacysupport 1.1

name                netatalk
version             4.4.0
revision            0
categories          net
description         Netatalk is a freely-available Open Source AFP fileserver.
long_description    Netatalk is a freely-available Open Source AFP fileserver. \
                    It allows Unix-like operating systems to serve as file \
                    servers for Macintosh computers.

if {${subport} eq ${name}} {
    github.setup        Netatalk netatalk 4-4-0 netatalk-
    version             4.4.0
    revision            0
    github.tarball_from releases
    distname            netatalk-${version}
    use_xz              yes

    compiler.c_standard 2011

    checksums       rmd160  238bdb1456e276b1758b61009b4d46e62573ccde \
                    sha256  18ca32dc6c25e7ba3528594b784379f013888fa9840ffc478cd1fef55513825c \
                    size    1054224
    
    license             GPL-2+
    maintainers         {@trodemaster icloud.com:manuals-unread2u} openmaintainer
    
    homepage            https://netatalk.io
    
    depends_build-append       path:bin/pkg-config:pkgconfig \
                               port:cmark-gfm \
                               port:bison \
                               port:flex
    
    depends_lib         port:sqlite3 \
                        port:libevent \
                        port:libgcrypt \
                        port:iniparser \
                        port:tracker3 \
                        port:dbus \
                        port:talloc \
                        port:bstring
    
    configure.args-append -Dwith-init-style=none \
                          -Dwith-pam-config-path=${prefix}/etc/pam.d \
                          -Dwith-lockfile-path=${prefix}/var/run \
                          -Dwith-cnid-backends=sqlite,dbd,mysql \
                          -Dwith-cnid-default-backend=sqlite \
                          -Dwith-spotlight=true
    
    startupitem.create  yes
    startupitem.executable  ${prefix}/sbin/netatalk -d -F ${prefix}/etc/afp.conf
    startupitem.logfile ${prefix}/var/log/${name}.log
    startupitem.logfile.stderr ${prefix}/var/log/${name}-stderr.log
    startupitem.logevents yes
    startupitem.debug          yes
    
    notes "Upgrade details: https://netatalk.io/manual/en/Upgrading. Configuration files can be found in: ${prefix}/etc/. Log files can be found in: ${prefix}/var/log/."
}

# Netatalk 4.x stub port
subport netatalk4 {
    PortGroup           stub 1.0

    version             4.4.0
    revision            0
    
    categories          net
    license             GPL-2+
    maintainers         {@trodemaster icloud.com:manuals-unread2u} openmaintainer
    
    description         Netatalk is a freely-available Open Source AFP fileserver.
    long_description    Netatalk is a freely-available Open Source AFP fileserver. \
                        It allows Unix-like operating systems to serve as file \
                        servers for Macintosh computers.
    
    homepage            https://netatalk.io
    
    # This is a stub port that depends on the main netatalk port
    depends_run         port:netatalk
    
    notes "This is a stub port that provides netatalk4 as an alias for netatalk. \
           The main netatalk port will automatically select the appropriate version \
           based on your macOS version."
}

