# -*- 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.71.2 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  2e6953912597b379fa50343d2f51eec3acd854b2 \
    sha256  54c619a2f6921981f276f01a12209bf2f2b5d94f580cd8699e93aa7c3e9ee9ba \
    size    17427107

categories          net
installs_libs       no
license             MIT
maintainers         {eborisch @eborisch} \
                    {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}"
}
