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

name                unixODBC
conflicts           virtuoso virtuoso-7
if {[file exists ${prefix}/lib/libodbc.a]} {
    conflicts-append libiodbc
}
version             2.3.12
revision            0
checksums           rmd160  2886fcb0bd0c006a1077e6fd9acc62f52329b15e \
                    sha256  f210501445ce21bf607ba51ef8c125e10e22dffdffec377646462df5f01915ec \
                    size    1753915

categories          databases
maintainers         nomaintainer
license             LGPL-2+
description         Provides ODBC 3 connectivity for Unix

long_description    The unixODBC project provides UNIX applications with \
                    the same ODBC 3.51 API and facilities available under Windows. \
                    It provides a Driver Manager that supports the full ODBC \
                    API and performs the ODBC 3 to ODBC 2 translations with \
                    UNICODE to ANSI conversion. It also includes a set of \
                    graphical utilities that allow users to specify \
                    connections to DBMSes to be used by applications, \
                    a collection of ODBC drivers including a simple text-based \
                    driver, an NNTP driver, a Postgres driver and others, \
                    and a selection of templates and libraries that to aid \
                    in the construction of ODBC drivers. It works with MySQL, \
                    Postgres, StarOffice, Applixware, iHTML, PHP, Perl \
                    DBD::ODBC, Paradox 9, and many other applications and \
                    drivers. Connection pooling is also provided to increase \
                    performance with applications such as PHP.

homepage            https://www.unixodbc.org/
master_sites        ${homepage} \
                    ftp://ftp.unixodbc.org/pub/unixODBC/

depends_lib-append  port:libiconv \
                    port:libtool \
                    port:readline

configure.args-append \
                    --enable-static \
                    --enable-shared \
                    --with-libiconv-prefix=${prefix}

post-destroot {
    # DOCS
    xinstall -d -m 0755 ${destroot}${prefix}/share/doc/${name}
    xinstall -m 0644 \
        {*}[glob ${worksrcpath}/\[A-Z\]*\[A-Z\]\[A-Z\]\[A-Z\] ${worksrcpath}/doc/*.\[a-z\]\[a-z\]\[a-z\]*] \
        ${destroot}${prefix}/share/doc/${name}
    foreach dir {AdministratorManual lst ProgrammerManual ProgrammerManual/Tutorial UserManual} {
        xinstall -d -m 0755 ${destroot}${prefix}/share/doc/${name}/${dir}
        xinstall -m 0644 \
            {*}[glob ${worksrcpath}/doc/$dir/*.\[a-z\]\[a-z\]\[a-z\]*] \
            ${destroot}${prefix}/share/doc/${name}/${dir}
    }

    # TEMPLATES
    xinstall -d -m 0755 ${destroot}${prefix}/share/${name}
    xinstall -m 0644 {*}[glob ${filespath}/*.template] ${destroot}${prefix}/share/${name}
    reinplace "s|__PREFIX__|${prefix}|g" {*}[glob ${destroot}${prefix}/share/${name}/*.driver.*]

    # CONFIG
    foreach ini [glob ${destroot}${prefix}/etc/*.ini] {
        move ${ini} ${ini}.dist
    }

    destroot.keepdirs ${destroot}${prefix}/etc/ODBCDataSources
}

livecheck.type  regex
livecheck.url   ${homepage}download.html
livecheck.regex ${name}-(\\d+(\\.\\d+)*).tar.gz
