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

name                py-mysql
version             1.2.3
revision            1
categories-append   devel databases
platforms           darwin
license             {MIT GPL-2+}
maintainers         nomaintainer

description         Python interface to mysql

long_description    A package containing a Python module that allows you to \
                    connect to MySQL databases

homepage            http://sourceforge.net/projects/mysql-python/
master_sites        sourceforge:mysql-python

distname            MySQL-python-${version}

checksums           rmd160  e394e7bf08127068795aeebfbaea7dc3b2127c86 \
                    sha256  7de66fbbf923634e7c965aeaefa74642ba75ae20ee1cefcefc3009595b7a7e6e

python.versions     27

if {${name} ne ${subport}} {
    depends_build   port:py${python.version}-setuptools

    patch.pre_args-replace  -p0 -p1
    patchfiles          patch-site.cfg.diff

    post-patch {
        reinplace "s|@MYSQL_CONFIG@|${prefix}/${mysql_config}|g" \
            ${worksrcpath}/site.cfg
    }

    pre-configure {
        if {![variant_isset mysql51] &&
            ![variant_isset mysql55] &&
            ![variant_isset mysql56] &&
            ![variant_isset mariadb55]} {
            return -code error "you must select either mysql51, mysql55, mysql55, mysql56, or mariadb55"
        }
    }

    post-destroot {
        xinstall -m 755 -d ${destroot}${prefix}/share/doc/${subport}
        xinstall -m 644 -W ${worksrcpath} \
            HISTORY README \
            ${destroot}${prefix}/share/doc/${subport}
    }

    set mysql_config {}

    variant mysql51 conflicts mysql55 mysql56 mariadb55 description {Build with mysql51} {
        depends_lib-append  port:mysql51
        set mysql_config lib/mysql51/bin/mysql_config
    }

    variant mysql55 conflicts mysql51 mysql56 mariadb55 description {Build with mysql55} {
        depends_lib-append  port:mysql55
        set mysql_config lib/mysql55/bin/mysql_config
    }

    variant mysql56 conflicts mysql51 mysql55 mariadb55 description {Build with mysql56} {
        depends_lib-append  port:mysql56
        set mysql_config lib/mysql56/bin/mysql_config
    }

    variant mariadb55 conflicts mysql51 mysql55 mysql56 description {Build with mariadb55} {
        depends_lib-append  port:mariadb
        set mysql_config lib/mariadb/bin/mysql_config
    }

    # If legacy +mysql5 variant change to replacement +mysql51 variant.
    if {[variant_isset mysql5]} {
        default_variants-append +mysql51
    }

    if {![variant_isset mysql51] && ![variant_isset mysql55] && ![variant_isset mysql56] && ![variant_isset mariadb55]} {
        default_variants-append +mariadb55
    }

    livecheck.type      none
}
