# -*- 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.1
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-1 netatalk-
    version             4.4.1
    revision            0
    github.tarball_from releases
    distname            netatalk-${version}
    use_xz              yes

    compiler.c_standard 2011

    checksums       rmd160  efbb51075f9cff30bbaeac64cc380d088c74eff8 \
                    sha256  8fcab0bf3b39cd8a94fe3ee7a8264c6000515a3af377da3416696609ab13316d \
                    size    1125588
    
    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.1
    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."
}
