# -*- 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
PortGroup               python 1.0

github.setup            facebookarchive phpsh 8427a3cd8a2cb8f8f0d85faf0bd9d49b10961a04
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from     tarball
version                 1.3-20140514
categories              php devel
maintainers             nomaintainer
supported_archs         noarch
license                 BSD
platforms               {darwin any} freebsd

python.default_version 27

homepage                http://www.phpsh.org
description             PHP read-eval-print-loop
long_description \
    phpsh is a read-eval-print-loop for PHP that features readline history, tab \
    completion, and quick access to documentation. It was developed at Facebook \
    and ironically, is written mostly in Python.
checksums               rmd160  cc125343ad114f371a7a86bea53f49ec02fafb35 \
                        sha256  23ed7e2bdbd5b2b0d1a3ee0667af4402d19dcc6561e1f2b31f8b2a6faf946994 \
                        size    5915531

patchfiles              src-__init__.py.diff

pre-patch {
    reinplace -q -locale C s|/etc/phpsh|${prefix}/etc/phpsh|g \
        ${worksrcpath}/setup.py ${worksrcpath}/rc.example.php \
        {*}[glob ${worksrcpath}/src/*] {*}[glob ${worksrcpath}/src/doc/*]
}

post-destroot {
    set mandir ${destroot}${prefix}/share/man/man1
    move ${destroot}${python.prefix}/man/man1/phpsh.1 ${mandir}
}

set php_suffixes {53 54 55 56 70 71 72}
set php_ports [regsub -all -- {(^|\s)} ${php_suffixes} {\0php}]

set variant_check {}
foreach php ${php_ports} {
    set i [lsearch -exact ${php_ports} ${php}]
    set c [lreplace ${php_ports} ${i} ${i}]
    variant ${php} conflicts {*}${c} description "Use ${php}" "
        depends_lib-append      port:${php}-pcntl

        post-patch {
            reinplace s|@@PHP_EXECUTABLE@@|${prefix}/bin/${php}| src/__init__.py
        }
    "
    if {${php} ne [lindex ${php_ports} end]} {
        lappend variant_check "!\[variant_isset ${php}\]"
    }
}

if [join ${variant_check} {&&}] {default_variants +[lindex ${php_ports} end]}

# archived project no longer supported or updated by Facebook
livecheck.type          none
