--- Portfile.orig	2008-10-04 13:57:50.000000000 -0700
+++ Portfile	2008-10-04 14:00:44.000000000 -0700
@@ -1,101 +1,207 @@
-# $Id: Portfile 40203 2008-09-25 09:22:48Z mww@macports.org $
+# -*- 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 39612 2008-08-26 16:49:49Z jwa@macports.org $
 
 PortSystem 1.0
 
-name			postgresql83
-version			8.3.4
-categories		databases
-platforms		darwin
-maintainers		mww jwa
-description		The most advanced open-source database available anywhere.
-long_description PostgreSQL is Object-Relational Database Management System. \
-				It supports almost all SQL constructs, including transactions, \
-				subselects, and user-defined types and functions. Write-ahead \
-				logging means increased performance while retaining data \
-				integrity.
-
-homepage		http://www.postgresql.org/
-master_sites		http://ftp3.de.postgresql.org/pub/Mirrors/ftp.postgresql.org/source/v${version}/ \
-			postgresql:source/v${version}/
-distname		postgresql-${version}
-
-checksums		md5 c339b9d3c0c4add64c7a76640fc93744 \
-			sha1 3e6fd905fd3fe9698b50e5376ed15b7d6e3bb602 \
-			rmd160 13cb20672b0dc6fe52346d7c906a0842e0c872ac
-
-use_bzip2		yes
-
-depends_lib		port:readline port:openssl port:zlib port:libxml2 port:libxslt port:ossp-uuid
-depends_build		port:bison
-
-worksrcdir		postgresql-${version}
-
-set libdir		${prefix}/lib/${name}
-configure.args	--sysconfdir=${prefix}/etc/${name} \
-				--bindir=${libdir}/bin \
-				--libdir=${libdir} \
-				--includedir=${prefix}/include/${name} \
-				--datadir=${prefix}/share/${name} \
-				--mandir=${prefix}/share/man \
-				--without-docdir \
-				--with-includes=${prefix}/include \
-				--with-libraries=${prefix}/lib \
-				--with-openssl \
-				--with-bonjour \
-				--with-readline \
-				--with-zlib \
-				--with-libxml \
-				--with-libxslt \
-				--enable-thread-safety \
-				--enable-integer-datetimes \
-				--with-ossp-uuid
-configure.cppflags-append	-I${prefix}/include/ossp
+name            postgresql83
+version         8.3.4
+
+categories      databases
+platforms       darwin
+maintainers     mww jwa
+
+distname        postgresql-${version}
+worksrcdir      postgresql-${version}
+
+set pathConf    ${prefix}/etc/${name}
+set pathLib     ${prefix}/lib/${name}
+set pathInc     ${prefix}/include/${name}
+set pathBin     ${pathLib}/bin
+set pathMan     ${prefix}/share/man
+set pathDoc     ${prefix}/share/doc/${name}
+set pathData    ${prefix}/share/${name}
+
+description     The world's most advanced open-source database.
+long_description \
+                PostgreSQL is Object-Relational Database Management System. \
+                It supports almost all SQL constructs, including transactions, \
+                subselects, and user-defined types and functions. Write-ahead \
+                logging means increased performance while retaining data \
+                integrity. \n\n\
+                default_variants +doc +bonjour +krb5 +tclSys +perl +python \n\n\
+                Install paths:\n\
+                config:\t   ${pathConf}\n\
+                include:\t  ${pathInc}\n\
+                lib:\t\t    ${pathLib}\n\
+                bin:\t\t    ${pathBin}\n\
+                man:\t\t    ${pathMan}\n\
+                doc:\t\t    ${pathDoc}\n\
+                data:\t\t   ${pathData}\n
+
+homepage        http://www.postgresql.org/
+master_sites    http://www.postgresql.org/ftp/source/v${version}/ \
+                ftp://ftp7.us.postgresql.org/pub/postgresql/source/v${version}/ \
+                postgresql:source/v${version}/
+
+use_bzip2       yes
+
+checksums       md5 c339b9d3c0c4add64c7a76640fc93744 \
+                sha1 3e6fd905fd3fe9698b50e5376ed15b7d6e3bb602 \
+                rmd160 13cb20672b0dc6fe52346d7c906a0842e0c872ac
+
+depends_lib     port:readline \
+                port:openssl \
+                port:ossp-uuid \
+                port:zlib \
+                port:libxml2 \
+                port:libxslt
+
+depends_build   port:bison
+
+configure.args-append \
+                --sysconfdir=${pathConf} \
+                --bindir=${pathBin} \
+                --libdir=${pathLib} \
+                --includedir=${pathInc} \
+                --datadir=${pathData} \
+                --mandir=${pathMan} \
+                --enable-thread-safety \
+                --enable-integer-datetimes \
+                --without-docdir \
+                --with-includes=${prefix}/include \
+                --with-libraries=${prefix}/lib \
+                --with-openssl \
+                --with-ossp-uuid \
+                --with-readline \
+                --with-zlib \
+                --with-libxml \
+                --with-libxslt
+
+configure.cflags-append \
+                -I${prefix}/include \
+                -I${prefix}/include/ossp
 
-build.type		gnu
+build.type      gnu
 build.target
 
-test.run		yes
-test.target		check
+test.run        yes
+test.target     check
 
-livecheck.check	regex
-livecheck.url	${homepage}
-livecheck.regex	(8.3.\[0-9\]+)
+livecheck.check regex
+livecheck.url   ${homepage}/versions.rss
+livecheck.regex (8.3.\[0-9\]+)
 
-set contribs	"adminpack dblink fuzzystrmatch lo uuid-ossp pg_buffercache pg_trgm pgcrypto tsearch2 vacuumlo xml2"
+set contribs    "adminpack dblink fuzzystrmatch lo uuid-ossp pg_buffercache pg_trgm pgcrypto tsearch2 vacuumlo xml2"
 
 post-build {
-	foreach contrib ${contribs} {
-		system "cd ${worksrcpath}/contrib/${contrib}/ && ${build.cmd}"
-	}
+    foreach contrib ${contribs} {
+        system "cd ${worksrcpath}/contrib/${contrib}/ && ${build.cmd}"
+    }
 }
 
 post-destroot {
-	foreach contrib ${contribs} {
-		system "echo contrib: \"${contrib}\""
-		system "cd ${worksrcpath}/contrib/${contrib}/ && \
-			${destroot.cmd} install ${destroot.destdir} && touch DONE"
-	}
-	system "cd ${destroot}${prefix}/bin && ln -sf ${libdir}/bin/psql psql83"
-	file delete -force ${destroot}${prefix}/share/doc/${name} \
-		${destroot}${prefix}/share/man
+    foreach contrib ${contribs} {
+        system "echo contrib: \"${contrib}\""
+        system "cd ${worksrcpath}/contrib/${contrib}/ && \
+            ${destroot.cmd} install ${destroot.destdir} && touch DONE"
+    }
+    system "cd ${destroot}${prefix}/bin && ln -sf ${pathLib}/bin/psql psql83"
+    file delete -force ${destroot}${prefix}/share/doc/${name} \
+        ${destroot}${prefix}/share/man
+}
+
+post-install {
+    ui_msg "\nTo use the postgresql server, install the ${name}-server port\n"
+
+    if {[variant_isset doc]} {
+        ui_msg "Documentation is installed in\n${pathDoc}/html/\n\
+        Update this path in pgAdmin3 Preferences:General\n"
+    }
+}
+
+
+# -- Variants
+
+default_variants +doc +bonjour +krb5 +tclSys +perl +python
+
+
+# --enable section
+
+variant dependency description {automatic dependency tracking} {
+    configure.args-append   --enable-depend
+}
+
+variant profiling description {add profiling support} {
+    configure.args-append   --enable-profiling
+}
+
+variant debug description {add debug symbols and enable assertion checking} {
+    configure.args-append   --enable-debug --enable-cassert
+}
+
+variant nls description {add native language support} {
+    configure.args-append   --enable-nls
+}
+
+variant NOlargefile description {DISABLE large file support} {
+    configure.args-append   --disable-largefile
+}
+
+variant NOshared description {DISABLE shared libs} {
+    configure.args-append   --disable-shared
+}
+
+variant NOrpath description {DISABLE rpath search for executables} {
+    configure.args-append   --disable-rpath
+}
+
+variant NOspinlocks description {DISABLE spinlocks} {
+    configure.args-append   --disable-spinlocks
+}
+
+
+# --with section
+
+variant bonjour description {add support for Bonjour} {
+    configure.args-append   --with-bonjour
 }
 
-variant python description {add support for python} {
-	depends_lib-append		port:python25
-	configure.args-append	--with-python
-	configure.env-append	PYTHON=${prefix}/bin/python2.5
+variant doc description {add documentation} {
+    configure.args-delete  --without-docdir
+    configure.args-append  --with-docdir=${pathDoc}
 }
 
 variant krb5 description {add support for Kerberos 5 authentication} {
-	configure.args-append	--with-krb5
+    configure.args-append   --with-krb5
 }
 
-variant perl description {add Perl support} {
-	depends_lib-append			bin:perl:perl5.8
-	configure.args-append		--with-perl
+variant ldap description {add support for LDAP} {
+    configure.args-append   --with-ldap
 }
 
-post-install {
-	ui_msg "\nTo use the postgresql server, install the postgresql83-server port"
+variant pam description {add support for PAM authentication} {
+    configure.args-append   --with-pam
+}
+
+variant perl description {add Perl modules (PL/Perl)} {
+    depends_lib-append      bin:perl:perl5.8
+    configure.args-append   --with-perl
+}
+
+variant python description {add Python modules (PL/Python)} {
+    depends_lib-append      port:python25
+    configure.args-append   --with-python
+    configure.env-append    PYTHON=${prefix}/bin/python2.5
+}
+
+variant tclPort conflicts tclSys description {add Tcl modules (PL/Tcl; MacPorts Tcl)} {
+    configure.args-append   --with-tcl \
+                            --with-tclconfig=${prefix}/lib/
+}
+
+variant tclSys conflicts tclPort description {add Tcl modules (PL/Tcl; System Tcl framework)} {
+    configure.args-append   --with-tcl \
+                            --with-tclconfig=/System/Library/Frameworks/Tcl.framework/
 }
 
