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

name                org-mode
version             9.4
categories          editors
license             GPL-3+
maintainers         {dports @drkp} openmaintainer
platforms           darwin
supported_archs     noarch

description         an Emacs Mode for Notes, Project Planning, and Authoring
long_description    Org is a mode for keeping notes, maintaining TODO lists, \
                    and doing project planning with a fast and effective     \
                    plain-text system.

homepage            https://orgmode.org/
master_sites        ${homepage}
distname            org-${version}

checksums           rmd160  d662b64035c3d4c6922d09a2cd5fd60122fc6fc8 \
                    sha256  c61da8cf76916565cf695d116332ccd56595e68cb369a618eb303d5a6d31bdc3 \
                    size    4724986

depends_lib         path:${emacs_binary}:${emacs_binary_provider}
depends_build       port:texinfo


configure {
    system -W ${worksrcpath} "make local.mk"
    reinplace "/^EMACS\[\[:space:\]\]*=/s|emacs|${emacs_binary}|g" ${worksrcpath}/local.mk
}

destroot.destdir    prefix=${destroot}${prefix}/share
destroot.target     install-lisp install-info

variant contrib description "Include additional contributed packages" {
    # Install all contrib elisp files except those listed in org_skip_contrib
    #   these have build dependencies not available in MacPorts
    post-configure {
        set org_skip_contrib "ob-arduino ob-clojure-literate ob-sclang"
        
        set localmk [open ${worksrcpath}/local.mk "a"]
        puts $localmk "ORG_ADD_CONTRIB="

        foreach f [glob -directory ${worksrcpath}/contrib/lisp -tails *.el] {
            set x [file rootname $f]
            if {[lsearch -exact $org_skip_contrib $x] == -1} {
                puts $localmk "ORG_ADD_CONTRIB+=$x"
            }
        }
        
        close $localmk
    }
}

platform darwin 10 {
    known_fail  yes
    pre-fetch {
        ui_error "${name} @${version} does not build on Mac OS X 10.6"
        return -code error "incompatible Mac OS X version"
    }
}

livecheck.type      regex
livecheck.url       ${homepage}Changes.html
livecheck.regex     {Version ([\w.]+)</h2>}
