# $Id: Portfile 66853 2010-04-23 23:13:03Z ryandesign@macports.org $

PortSystem          1.0

name                unixODBC
conflicts           libiodbc virtuoso
version             2.3.0
revision            1
categories          databases
platforms           darwin
maintainers         alakazam cotsworth.com:simon
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            http://www.unixodbc.org/
master_sites        ${homepage} \
                    ftp://ftp.easysoft.com/pub/beta/unixODBC/

checksums           md5     f2ad22cbdffe836c58987ed2332c2e99 \
                    sha1    b2839b5210906e3ee286a4b621f177db9c7be7a8 \
                    rmd160  166a96c31fe013ced6b6ef93da5871f672cfe456

depends_lib         port:libiconv port:libtool port:readline

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

use_parallel_build  yes

post-destroot {
    # DOCS
    xinstall -d -m 0755 ${destroot}${prefix}/share/doc/${name}
    
    foreach doc [glob ${worksrcpath}/\[A-Z\]*\[A-Z\]\[A-Z\]\[A-Z\] ${worksrcpath}/doc/*.\[a-z\]\[a-z\]\[a-z\]*] {
        if {[string match "*.html" $doc]} {
            reinplace "s|${homepage}doc/||g" $doc
        }
        
        xinstall -m 0644 $doc ${destroot}${prefix}/share/doc/${name}
    }
    
    foreach dir {AdministratorManual lst ProgrammerManual ProgrammerManual/Tutorial UserManual} {
        xinstall -d -m 0755 ${destroot}${prefix}/share/doc/${name}/$dir
        
        foreach file [glob ${worksrcpath}/doc/$dir/*.\[a-z\]\[a-z\]\[a-z\]*] {
            if {[string match "*.html" $file]} {
                reinplace "s|${homepage}doc/||g" $file
            }
            
            xinstall -m 0644 $file ${destroot}${prefix}/share/doc/${name}/$dir
        }
    }
    
    # TEMPLATES
    xinstall -d -m 0755 ${destroot}${prefix}/share/${name}
    
    foreach template [glob ${portpath}/${filesdir}/*.template] {
    	xinstall -m 0644 $template ${destroot}${prefix}/share/${name}
    }
    
    foreach driver [glob ${destroot}${prefix}/share/${name}/*.driver.*] {
        reinplace "s|__PREFIX__|${prefix}|g" $driver
    }
    
    # CONFIG
    foreach ini [glob ${destroot}${prefix}/etc/*.ini] {
        system "mv $ini $ini.dist"
    }
    
    destroot.keepdirs ${destroot}${prefix}/etc/ODBCDataSources
}

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