# -*- 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
# $Id: Portfile 100279 2012-12-06 22:11:44Z jwa@macports.org $

PortSystem 1.0

name		pgAdmin3
version		1.16.1

categories	aqua
maintainers	jwa

description	An administration program to PostgreSQL
long_description pgAdmin III is a powerful administration and development \
    platform for the PostgreSQL database, free for any use. The \
    application works on several platforms, e.g. GNU/Linux, FreeBSD, \
    OS X and Windows 2000/XP. This port is for OS X.

platforms	macosx
homepage	http://www.pgadmin.org/

master_sites	http://developer.pgadmin.org/ftp/release/v${version}/src/ \
    http://www.postgresql.org/ftp/pgadmin3/release/v${version}/src/ \
			postgresql:pgadmin3/release/v${version}/src/

distname	pgadmin3-${version}

checksums           rmd160  b2830f6dcc9b22592cc196e27b2e844a3717e1a9 \
                    sha256  d4ba243dc24dc28e6d0db4104baec373ab3bec11c6dc0e6cfa4bd665a5b7c28e

depends_lib port:openssl \
    port:libxml2 \
    port:libxslt \
    port:wxWidgets30

configure.args \
    --with-wx=${prefix} \
    --with-wx-version=2.9 \
    --with-libxml2=${prefix} \
    --with-libxslt=${prefix} \
    --with-arch-x86_64 \
    --enable-appbundle

use_parallel_build	no
build.target	all install

universal_variant no

post-configure {
    system -W ${worksrcpath} "patch -p0 <${filespath}/patch-Makefile.diff"
}

#destroot.violate_mtree	yes
destroot {
    xinstall -d -m 0755 ${destroot}${applications_dir}
    file copy ${worksrcpath}/${name}.app ${destroot}${applications_dir}/${name}.app
}

variant postgresql83 conflicts postgresql84 postgresql90 postgresql91 postgresql92 \
    description {support for PostgreSQL 8.3.x} {
	depends_lib-append	port:postgresql83
	configure.args-append	--with-pgsql=${prefix}/lib/postgresql83
}

variant postgresql84 conflicts postgresql83 postgresql90 postgresql91 postgresql92 \
    description {support for PostgreSQL 8.4.x} {
	depends_lib-append	port:postgresql84
	configure.args-append	--with-pgsql=${prefix}/lib/postgresql84
}

variant postgresql90 conflicts postgresql83 postgresql84 postgresql91 postgresql92 \
    description {support for PostgreSQL 9.0.x} {
	depends_lib-append	port:postgresql90
	configure.args-append	--with-pgsql=${prefix}/lib/postgresql90
}

variant postgresql91 conflicts postgresql83 postgresql84 postgresql90 postgresql92 \
    description {support for PostgreSQL 9.1.x} {
	depends_lib-append	port:postgresql91
	configure.args-append	--with-pgsql=${prefix}/lib/postgresql91
}

variant postgresql92 conflicts postgresql83 postgresql84 postgresql90 postgresql91 \
    description {support for PostgreSQL 9.2.x} {
	depends_lib-append	port:postgresql92
	configure.args-append	--with-pgsql=${prefix}/lib/postgresql92
}

if {![variant_isset postgresql83] && ![variant_isset postgresql84] && ![variant_isset postgresql90] && ![variant_isset postgresql91] && ![variant_isset postgresql92]} {
    default_variants        +postgresql92
}

variant debug description {provide a debug build in case of difficulties} {
    configure.args-append	--enable-debug
}

variant with_postgresql83 requires postgresql83 description {Legacy compatibility variant} {}
variant with_postgresql84 requires postgresql84 description {Legacy compatibility variant} {}
variant with_postgresql90 requires postgresql90 description {Legacy compatibility variant} {}
variant with_postgresql91 requires postgresql91 description {Legacy compatibility variant} {}
variant with_postgresql92 requires postgresql92 description {Legacy compatibility variant} {}

livecheck.type	regex
livecheck.url	${homepage}
livecheck.regex	pgAdmin v(1\\.\[0-9\]+\\.\[0-9\]+)
