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

github.setup        HodsonTech palmgoogle-mac 1.3 v
github.tarball_from archive
revision            0

name                palmgoogle-mac
categories          palm python
license             {GPL-2 MIT}
maintainers         {jeff.hodson:hodsontech.com @HodsonTech} openmaintainer
conflicts           palm365-mac

description         Sync a Palm OS PDA with Google Calendar/Tasks/Contacts via a jpilot plugin
long_description    palmgoogle-mac bidirectionally syncs a Palm OS PDA's \
                    calendar, tasks, and contacts with a Google account. \
                    It runs automatically as a jpilot plugin -- a \
                    down-sync when jpilot launches, and a full push-up + \
                    down-sync right after every HotSync -- with no manual \
                    sync command needed day to day. One-time setup requires \
                    creating a free Google Cloud OAuth client, which \
                    ${prefix}/share/${name}/setup.py walks through. Not \
                    installable alongside palm365-mac -- both are \
                    full-rebuild engines against the same Palm databases, \
                    and running two independent ones at once is a real \
                    hazard, not a supported configuration.

homepage            https://github.com/HodsonTech/palmgoogle-mac

checksums           rmd160  7c9276a9512a75230ffa7af63763b40b7f5d4627 \
                    sha256  5ff0e91adc2e781016a99200afb05e24ebe8def67b9f5e26365810ca56ad26c5 \
                    size    29079

set py_ver          3.14
set py_ver_nodot    [string map {. {}} ${py_ver}]

depends_build-append \
                    path:lib/pkgconfig/gtk+-3.0.pc:gtk3

depends_lib-append \
                    port:jpilot \
                    port:pilot-link \
                    port:python${py_ver_nodot} \
                    port:py${py_ver_nodot}-requests \
                    port:py${py_ver_nodot}-palm-sync-core

use_configure       no

build {
    system -W ${worksrcpath}/jpilot-plugin \
        "${configure.cc} -arch ${configure.build_arch} -bundle \
         -Wl,-undefined,dynamic_lookup \
         -DPYTHON_BIN=\\\"${prefix}/bin/python${py_ver}\\\" \
         -DSYNC_CWD=\\\"${prefix}/share/${name}\\\" \
         -I vendor \
         `${prefix}/bin/pkg-config --cflags gtk+-3.0` \
         -o libpalmgoogleplugin.so palmgoogleplugin.c"
}

destroot {
    xinstall -d ${destroot}${prefix}/lib/jpilot/plugins
    xinstall -m 755 ${worksrcpath}/jpilot-plugin/libpalmgoogleplugin.so \
        ${destroot}${prefix}/lib/jpilot/plugins/

    xinstall -d ${destroot}${prefix}/share/${name}
    foreach f {config.example.toml google_client.py google_field_mapper.py \
               pc3_seed.py setup.py sync_to_palm.py README.md LICENSE} {
        xinstall -m 644 ${worksrcpath}/${f} ${destroot}${prefix}/share/${name}/
    }

    xinstall -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 ${worksrcpath}/jpilot-plugin/COPYING \
        ${destroot}${prefix}/share/doc/${name}/COPYING.plugin
}

notes "
palmgoogle-mac needs a one-time setup step before it can sync anything --\n\
it creates a free Google Cloud OAuth client (a real Google requirement,\n\
not something this port can skip) and writes your config.\n\
\n\
    cd ${prefix}/share/${name} && ${prefix}/bin/python${py_ver} setup.py\n\
\n\
After that, just launch jpilot and HotSync -- syncing happens\n\
automatically from then on, no manual commands needed.
"
