# $Id: Portfile,v 1.1 2006/05/23 21:57:00 mww Exp $

PortSystem 1.0

name			postgresql81
version			8.1.4
categories		databases
platforms		darwin
maintainers		mww@opendarwin.org
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	postgresql:source/v${version}
set dbase		postgresql-base-${version}.tar.bz2
set dopt		postgresql-opt-${version}.tar.bz2
set dtest		postgresql-test-${version}.tar.bz2
distfiles		${dbase} ${dopt} ${dtest}

checksums		${dbase} sha1 b1d7df18dabbbff78a810625f7d626c7601ec3bc \
				${dopt} sha1 ba8ed68da796e67858f7c100f6d64f1586540f05 \
				${dtest} sha1 0ece7b23d8c9c6fecb0927e87afe4f3dbe877d3d
use_bzip2		yes

depends_lib		port:readline port:openssl port:zlib
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-rendezvous \
				--with-readline \
				--with-zlib \
				--enable-thread-safety \
				--enable-integer-datetimes \
				--enable-multibyte \
				--enable-unicode
configure.env	CPPFLAGS=-I${prefix}/include \
				CFLAGS="-I${worksrcpath}/src/interfaces/libpq -I${prefix}/include" \
				LDFLAGS="-L${prefix}/lib"

build.type		gnu
build.target

test.run		yes
test.target		check

set dbdir		${prefix}/var/db/${name}/defaultdb
set logdir		${prefix}/var/log/${name}
set contribs	"fulltextindex fuzzystrmatch pg_buffercache pg_trgm tsearch2 vacuumlo"

post-build {
	foreach contrib ${contribs} {
		system "cd ${worksrcpath}/contrib/${contrib}/ && ${build.cmd}"
	}
}

post-destroot {
	foreach contrib ${contribs} {
		system "echo contrib: \"${contrib}\""
		system "cd ${worksrcpath}/contrib/${contrib}/ && \
			${build.cmd} install ${destroot.destdir} && touch DONE"
	}
	system "cd ${destroot}${prefix}/bin && ln -sf ${libdir}/bin/psql psql81"
	file delete -force ${destroot}${prefix}/share/doc/${name} \
		${destroot}${prefix}/share/man
}

variant python {
	depends_lib-append		port:python24
	configure.args-append	--with-python
	configure.env-append	PYTHON=${prefix}/bin/python2.4
}

variant krb5 {
#	depends_lib-append			bin:kerberos:kerberos5
	configure.args-append		--with-krb5
}

variant perl {
	depends_lib-append			bin:perl:perl5.8
	configure.args-append		--with-perl
}

platform darwin 8 {
	configure.env-append	CC=/usr/bin/gcc-4.0 CPP=/usr/bin/cpp-4.0 CXX=/usr/bin/g++-4.0
}

post-install {
	ui_msg "\nTo use the postgresql server, install the postgresql81-server port"
}

