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

go.setup            github.com/rclone/rclone 1.74.3 v
go.offline_build    no
revision            0

homepage            https://rclone.org

description         Rclone is a command line cloud-service sync program

long_description \
    ${description} to sync files and directories to and from: Google Drive, \
    Amazon S3, Openstack Swift / Rackspace cloud files / Memset, Memstore, \
    Dropbox, Google Cloud Storage, Amazon Drive, Microsoft One Drive, Hubic, \
    Backblaze B2, Yandex Disk, SFTP, and the local filesystem.

checksums \
    rmd160  df88d3ff16773c514df42370f0ca784a1803aef1 \
    sha256  3ba8bc7fb216f8f0307357ac67842467f453050468d5751e9269954819148568 \
    size    16408221

categories          net
installs_libs       no
license             MIT
maintainers         {gmail.com:herby.gillot @herbygillot} \
                    openmaintainer

build.pre_args-append \
    -ldflags \" \
        -s \
        -X github.com/rclone/rclone/fs.Version=${github.tag_prefix}${version} \
    \"

set pre_args_tags -tags=noselfupdate

if {${os.platform} eq "darwin"} {
    set pre_args_tags $pre_args_tags,darwin
}

if {[variant_isset mount]} {
    set pre_args_tags $pre_args_tags,cmount
}

build.pre_args-append $pre_args_tags

variant mount description {Compile with mount command, requires macFUSE} {
    depends_run-append port:macfuse
}

destroot {
    xinstall -m 0755 ${worksrcpath}/${name} ${destroot}${prefix}/bin/

    set docdir ${prefix}/share/doc/${name}
    xinstall -d ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} \
        README.md COPYING MANUAL.txt MANUAL.html RELEASE.md notes.txt \
        ${destroot}${docdir}
    set mandir ${prefix}/share/man/man1
    xinstall -d ${destroot}${mandir}
    xinstall -m 0644 -W ${worksrcpath} rclone.1 ${destroot}${mandir}

    set bash_compl_path ${destroot}${prefix}/share/bash-completion/completions
    set fish_compl_path ${destroot}${prefix}/share/fish/vendor_completions.d
    set zsh_compl_path ${destroot}${prefix}/share/zsh/site-functions
    set bin_path ${destroot}${prefix}/bin
    xinstall -d ${bash_compl_path} ${fish_compl_path} ${zsh_compl_path}
    system "${bin_path}/rclone genautocomplete bash ${bash_compl_path}/${name}"
    system "${bin_path}/rclone genautocomplete fish ${fish_compl_path}/${name}.fish"
    system "${bin_path}/rclone genautocomplete zsh ${zsh_compl_path}/_${name}"
}
