# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:et:sw=4:ts=4:sts=4
# $Id: Portfile 73309 2010-11-10 01:36:26Z ryandesign@macports.org $

PortSystem              1.0
PortGroup               qt4 1.0

name                    TOra
version                 2.1.3
revision                2
description             GUI tool for Oracle, PostgreSQL, and MySQL
long_description        Database developer/DBA frontend for various DB servers.
maintainers             scribus.info:petr
categories              aqua databases
platforms               macosx
homepage                http://torasql.com/
master_sites            sourceforge:tora
distname                tora-${version}

checksums               md5     ea4a75a9daeaf58492413e3f7fe40293 \
                        sha1    d33ea3bafb09c5382ef4e0cb0e8ca4ed848a9155 \
                        rmd160  084d90c94184939e24ac94109ff7940a33bed1d7

depends_build           port:cmake

# WARNING: postgresql83 is there due to qt4-mac's dependency on it.
# It's dangerous to mix library versions in one binary. It's required
# to spot qt4-mac's dependencies' version bumps.
depends_lib             port:qscintilla \
                        port:oracle-instantclient

patchfiles              patch-osx_tools-Info.plist.in.diff

configure.cmd           cmake
configure.pre_args      -DCMAKE_INSTALL_PREFIX=${prefix}/tmprelease/
# -Dmacports_prefix is there due to the patch for the Info.plist file
configure.args          -DCMAKE_LIBRARY_PATH=${prefix}/lib \
                        -DCMAKE_INCLUDE_PATH=${prefix}/include \
                        -DUSE_PCH=0 \
                        -Dmacports_prefix=${prefix} \
                        -DORACLE_PATH_INCLUDES=${prefix}/lib/oracle/sdk/include \
                        -DORACLE_PATH_LIB=${prefix}/lib/oracle \
                        -DWANT_BUNDLE=1 \
                        -DWANT_BUNDLE_STANDALONE=0 \
                        -DWANT_RPM=0 \
                        -DWANT_INTERNAL_QSCINTILLA=0 \
                        -DENABLE_DB2=0 \
                        ${qt_cmake_defines} .


#
# Postgresql - it should follow qt4-mac variants for this DB
variant psql83 conflicts psql84 psql90 psql91 \
description {Enable Postgre SQL Driver version 8.3} {}

variant psql84 conflicts psql83 psql90 psql91 \
description {Enable Postgre SQL Driver version 8.4} {}

variant psql90 conflicts psql83 psql84 psql91 \
description {Enable Postgre SQL Driver version 9.0} {}

variant psql91 conflicts psql83 psql84 psql90 \
description {Enable Postgre SQL Driver version 9.1} {}

set psql_version ""
if {[variant_isset psql83]} {
    set psql_version "83"
} elseif {[variant_isset psql84]} {
    set psql_version "84"
} elseif {[variant_isset psql90]} {
    set psql_version "90"
} elseif {[variant_isset psql91]} {
    set psql_version "91"
}

if {${psql_version} != ""} {
    depends_lib-append port:postgresql${psql_version}
    lunshift header_path ${prefix}/include/postgresql${psql_version}
    lunshift library_path ${prefix}/lib/postgresql${psql_version}
    configure.pre_args-append   -DENABLE_PGSQL=1 \
                                -DPOSTGRESQL_PATH_INCLUDES=${prefix}/include/postgresql${psql_version} \
                                -DPOSTGRESQL_PATH_LIB=${prefix}/lib/postgresql${psql_version}
} else {
    configure.pre_args-append   -DENABLE_PGSQL=0
}

#
# Oracle
variant no_oracle description {Disable support for Oracle} {
    depends_lib-delete          port:oracle-instantclient
    configure.pre_args-append   -DENABLE_ORACLE=0
}

#
# Debug
variant debug description {provide a debug build in case of difficulties} {
    configure.pre_args-append   -DWANT_DEBUG=1
}

destroot {
    file copy ${worksrcpath}/src/${name}.app ${destroot}${applications_dir}
}
