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

name                logtalk
version             3.101.0
revision            0

categories          lang
maintainers         {logtalk.org:pmoura @pmoura}
license             Apache-2
platforms           any
supported_archs     noarch

description         Logtalk - Open source object-oriented logic programming language

long_description    Logtalk is an object-oriented logic programming language that extends and \
                    leverages the Prolog language with a feature set suitable for programming \
                    in the large. Logtalk supports modern code encapsulation and code reuse   \
                    mechanisms without compromising the declarative programming features of   \
                    Prolog. Logtalk is implemented in highly portable code and can use most   \
                    modern and standards compliant Prolog implementations as a back-end       \
                    compiler. As a multi-paradigm language, it includes support for modules,  \
                    prototypes, classes, protocols (interfaces), categories (components and   \
                    hot patching), event-driven programming, and high-level multi-threading   \
                    programming. Its distribution uses a commercial friendly license and      \
                    includes full documentation, portable libraries, a comprehensive set of   \
                    portable developer tools, and a large number of programming examples to   \
                    help get you started.

homepage            https://logtalk.org/
master_sites        ${homepage}files/

checksums           rmd160  c73fba3ed3d61da616c8574d848a3ab7e1b5e9d3 \
                    sha256  11fa813e5fb89d50a379ff5850185f338d3551f446494e5536fdb98805611ad1 \
                    size    39540609

use_bzip2           yes

depends_lib         port:shared-mime-info

use_configure       no

build               {}

destroot {
    system -W ${worksrcpath}/scripts "./install.sh -p ${destroot}${prefix}"
}

post-destroot {
    delete ${destroot}${prefix}/share/mime
}

package.flat no

post-pkg {
    set resources ${workpath}/${name}-${version}.pkg/Contents/Resources/
    file copy -force -- ${workpath}/${worksrcdir}/scripts/macos/License.html ${resources}
    file copy -force -- ${workpath}/${worksrcdir}/scripts/macos/ReadMe.html ${resources}
    file copy -force -- ${workpath}/${worksrcdir}/scripts/macos/Welcome.html ${resources}
    file copy -force -- ${workpath}/${worksrcdir}/scripts/macos/postflight ${resources}
}

post-activate {
    ui_msg "****************************************************************************"
    ui_msg "* Integration scripts have been created for running Logtalk with selected"
    ui_msg "* backend Prolog compilers (which must be properly installed for running"
    ui_msg "* the scripts!):"
    ui_msg "*"
    ui_msg "* B-Prolog (8.1 or later):           bplgt       (experimental)"
    ui_msg "* Ciao Prolog (1.22.0 or later):     ciaolgt     (experimental; first run may require sudo)"
    ui_msg "* CxProlog (0.98.1 or later):        cxlgt"
    ui_msg "* ECLiPSe (6.1#143 or later):        eclipselgt"
    ui_msg "* GNU Prolog (1.4.5 or later):       gplgt"
    ui_msg "* JIProlog (4.1.7.1 or later):       jiplgt      (first run may require sudo)"
    ui_msg "* Quintus Prolog (3.3 or later):     quintuslgt  (experimental)"
    ui_msg "* SICStus Prolog (4.1.0 or later):   sicstuslgt"
    ui_msg "* SWI-Prolog (6.6.0 or later):       swilgt"
    ui_msg "* Tau Prolog (0.3.2 or later):       taulgt"
    ui_msg "* Trealla Prolog (2.84.29 or later): tplgt"
    ui_msg "* XSB (3.8.0 or later):              xsblgt      (first run may require sudo)"
    ui_msg "* XVM (10.0.0 or later):             xvmlgt"
    ui_msg "* YAP (6.3.4 or later):              yaplgt"
    ui_msg "*"
    ui_msg "* To complete the Logtalk installation, define the environment variables:"
    ui_msg "*"
    ui_msg "*     LOGTALKHOME=${prefix}/share/logtalk"
    ui_msg "*     LOGTALKUSER=\$HOME/logtalk"
    ui_msg "*"
    ui_msg "* After, run the \"logtalk_user_setup\" shell script once before running the"
    ui_msg "* integration scripts to ensure their LOGTALKUSER directory is up-to-date."
    ui_msg "* See the file \$LOGTALKHOME/CUSTOMIZE.md for details on how to customize"
    ui_msg "* your working environment."
    ui_msg "*"
    if {[file exists ${prefix}/share/mime/packages/logtalk.xml]} {
        delete ${prefix}/share/mime/packages/logtalk.xml
    }
    xinstall -d ${prefix}/share/mime/packages
    xinstall -m 644 ${prefix}/share/logtalk/scripts/freedesktop/logtalk.xml ${prefix}/share/mime/packages
    system "${prefix}/bin/update-mime-database ${prefix}/share/mime; true"
    ui_msg "* Added the Logtalk mime-type to the Shared MIME-info Database."
    ui_msg "****************************************************************************"
}
