# -*- 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 119472 2014-04-26 20:00:44Z snc@macports.org $

PortSystem          1.0

name                ZendFramework
version             2.2.5
categories          www lang
license             BSD
maintainers         snc openmaintainer
description         A framework for developing PHP web applications
long_description    This is a port of the Zend Framework. The Zend Framework \
                    aims to provide an architecture for developing entire \
                    applications with no other library dependencies. This code \
                    will always be actively developed, tested, and supported \
                    by Zend and the PHP Collaboration Project.
                  
homepage            http://framework.zend.com/
platforms           darwin freebsd
master_sites
dist_subdir         ZendFramework
if {$subport eq $name || $subport eq ""} {
            fetch {}
            checksum {}
            extract {}
            use_configure   no
            supported_archs noarch
            depends_lib       port:ZendFramework2
            patch {}
            build {}
            destroot {
                xinstall -d -m 755 ${destroot}${prefix}/share/doc/${name}/
                system "echo $name is a stub port > ${destroot}${prefix}/share/doc/${name}/README"
            }

}

subport ZendFramework1 {
    conflicts ZendFramework2
    version             1.12.6
    revision            0

    master_sites        http://packages.zendframework.com/releases/${name}-${version}/

    checksums           rmd160  41ff33ac803d879293d7b913aa083475601ada78 \
                        sha256  f7e7f870c7aa51b0d9b50023e577af012af1b5178865d6eb64faa2960d34661b

    livecheck.regex     {Zend Framework (1\.\d+\.\d+) Full}
}
subport ZendFramework2 {
    conflicts ZendFramework1
    version             2.3.1
    revision            0

    master_sites        https://packages.zendframework.com/releases/${name}-${version}/
    extract.suffix      .tgz

    checksums           rmd160  ff76b03cce97a653d6b1c759ac5370a4fd2a257f \
                        sha256  b121e3240c9c6cdb19c6c9921928f054c08a8a906052b9044ccfff8f544b56a7

    livecheck.regex     {Zend Framework (2\.\d+\.\d+) Full}
}

if {${name} ne ${subport}} {
    foreach php {php5 php53 php54} {
        eval [subst {
            variant ${php} conflicts manual_extensions description "Use ${php}" {
                depends_run port:${php}-apc port:${php}-calendar port:${php}-curl port:${php}-dba port:${php}-exif port:${php}-ftp port:${php}-gd port:${php}-gettext port:${php}-gmp port:${php}-iconv port:${php}-imap port:${php}-mbstring port:${php}-mcrypt port:${php}-memcache port:${php}-mssql port:${php}-mysql port:${php}-odbc port:${php}-openssl port:${php}-pcntl port:${php}-posix port:${php}-postgresql port:${php}-soap port:${php}-sockets port:${php}-SPL_Types port:${php}-sqlite port:${php}-tidy port:${php}-wddx port:${php}-xmlrpc port:${php}-xsl port:${php}-zip
            }
        }]
    }

    if {![variant_isset php5] && ![variant_isset php53] && ![variant_isset php54] && ![variant_isset manual_extensions]} {
        default_variants +php5
    }

    variant manual_extensions conflicts php5 php53 php54 description {Let me pick my own php extensions} {
        depends_run         path:bin/php:php5
    }

    set zf_main_dir     ${prefix}/www/${name}
    set zf_doc_dir      ${prefix}/share/doc/${name}

    use_configure       no

    build               {}

    destroot {
        # Copy everything to www.
        copy ${worksrcpath} ${destroot}${zf_main_dir}

        # Link the CLI Zend Tool into bin.
        ln -s ${zf_main_dir}/bin/zf.sh ${destroot}${prefix}/bin
        ln -s ${zf_main_dir}/bin/zf.sh ${destroot}${prefix}/bin/zf

        # Link the documentation into share/doc.
        xinstall -d ${destroot}${zf_doc_dir}
        foreach f [glob ${worksrcpath}/*.txt] {
            ln -s ${zf_main_dir}/[file tail ${f}] ${destroot}${zf_doc_dir}
        }
    }

    notes               "If this is your first install, you might want to add \
                        ${zf_main_dir}/library to the include_path in your php.ini \
                        (e.g. include_path = \".:${zf_main_dir}/library\"). \
                        \n\nIf you want to use the extra ZendX components \
                        you might want to add ${zf_main_dir}/extras/library too \
                        (e.g. include_path = \".:${zf_main_dir}/library:${zf_main_dir}/extra/library\")."

    livecheck.type      regex
    livecheck.url       http://framework.zend.com/downloads/latest
} else {
    livecheck.type      none
}
