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

PortSystem              1.0
PortGroup               qt4 1.0
PortGroup               cmake 1.0

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

checksums               md5     ea4a75a9daeaf58492413e3f7fe40293 \
                        sha1    d33ea3bafb09c5382ef4e0cb0e8ca4ed848a9155 \
                        rmd160  084d90c94184939e24ac94109ff7940a33bed1d7

depends_lib             port:qscintilla-qt4

patchfiles              patch-cmake-modules-FindOracle.cmake.diff \
                        patch-osx_tools-Info.plist.in.diff \
                        patch-cmake-modules-FindQScintilla.cmake.diff \
                        patch-src-toextract.h \
                        patch-src-toextract.cpp \
                        patch-src-toreport.cpp

configure.pre_args      -DCMAKE_INSTALL_PREFIX=${prefix}/tmprelease/
# -Dmacports_prefix is there due to the patch for the Info.plist file
configure.args-append   -DUSE_PCH=0 \
                         -Dmacports_prefix=${prefix} \
                         -DWANT_BUNDLE=1 \
                         -DWANT_BUNDLE_STANDALONE=0 \
                         -DWANT_RPM=0 \
                         -DWANT_INTERNAL_QSCINTILLA=0 \
                         -DENABLE_DB2=0 \
                         -DENABLE_ORACLE=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 oracle description {Enable support for Oracle} {
    depends_lib-append          port:oracle-instantclient
    configure.args-delete       -DENABLE_ORACLE=0
    configure.args-append       -DENABLE_ORACLE=1 \
                                -DORACLE_PATH_INCLUDES=${prefix}/lib/oracle/sdk/include \
                                -DORACLE_PATH_LIB=${prefix}/lib/oracle \
}

default_variants +oracle

#
# 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}
}

