# -*- 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
# $Id: Portfile 107701 2013-07-04 13:49:47Z g5pw@macports.org $

PortSystem              1.0
PortGroup               github 1.0
PortGroup               python 1.0

github.setup            facebook phpsh 1.3
revision                2
categories              php devel
maintainers             nomaintainer
supported_archs         noarch
license                 BSD
platforms               darwin freebsd

python.default_version 27
python.link_binaries_suffix

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  5188164d79f107d3494a240b33b5e05b1344b40a \
                        sha256  2792485c541ad8420f912e01a6be85c07b9c352c087e3b4d54a5a61e53f51d0e

patchfiles              src-__init__.py.diff

pre-patch {
    eval reinplace -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
    xinstall -d ${mandir}
    move ${destroot}${python.prefix}/man/man1/phpsh.1 ${mandir}
}

set php_versions [ list 53 54 55 ]

foreach php_version $php_versions {
    variant php${php_version} description "Build ${name} with php${php_version}" {
        
        depends_lib-append      port:php${php_version}-posix \
                                port:php${php_version}-pcntl

    }
    post-patch {
        reinplace s|@@PHP_EXECUTABLE@@|${prefix}/bin/php${php_version}| src/__init__.py

    }
}

default_variants +php55
