SUMMARY="A powerful, open source object-relational database system"
DESCRIPTION="PostgreSQL is a powerful, open source object-relational database \
system. It has more than 15 years of active development and a proven \
architecture that has earned it a strong reputation for reliability, data \
integrity, and correctness.

* It runs on all major operating systems, including Linux, UNIX (AIX, BSD, \
HP-UX, SGI IRIX, Mac OS X, Solaris, Tru64), and Windows.
* It is fully ACID compliant, has full support for foreign keys, joins, \
views, triggers, and stored procedures (in multiple languages).
* It includes most SQL:2008 data types, including INTEGER, NUMERIC, BOOLEAN, \
CHAR, VARCHAR, DATE, INTERVAL, and TIMESTAMP.
* It supports storage of binary large objects, including pictures, sounds, or \
video.
* It has native programming interfaces for C/C++, Java, .Net, Perl, Python, \
Ruby, Tcl, ODBC, among others, and exceptional documentation."
HOMEPAGE="http://www.postgresql.org/" 
LICENSE="PostgreSQL"
COPYRIGHT="1996-2014 PostgreSQL Global Development Group"
SOURCE_URI="http://ftp.postgresql.org/pub/source/v$portVersion/postgresql-$portVersion.tar.bz2"
CHECKSUM_SHA256="14176ffb1f90a189e7626214365be08ea2bfc26f26994bafb4235be314b9b4b0"
SOURCE_DIR="postgresql-$portVersion"
PATCHES="postgresql-$portVersion.patchset"
REVISION="2"
ARCHITECTURES="x86_gcc2 ?x86 !x86_64"
SECONDARY_ARCHITECTURES="x86 x86_gcc2"

PROVIDES="
	postgresql$secondaryArchSuffix = $portVersion compat >= 9
	cmd:clusterdb$secondaryArchSuffix = $portVersion compat >= 9
	cmd:createdb$secondaryArchSuffix = $portVersion compat >= 9
	cmd:createlang$secondaryArchSuffix = $portVersion compat >= 9
	cmd:createuser$secondaryArchSuffix = $portVersion compat >= 9
	cmd:dropdb$secondaryArchSuffix = $portVersion compat >= 9
	cmd:droplang$secondaryArchSuffix = $portVersion compat >= 9
	cmd:dropuser$secondaryArchSuffix = $portVersion compat >= 9
	cmd:ecpg$secondaryArchSuffix = $portVersion compat >= 9
	cmd:initdb$secondaryArchSuffix = $portVersion compat >= 9
	cmd:pg_basebackup$secondaryArchSuffix = $portVersion compat >= 9
	cmd:pg_config$secondaryArchSuffix = $portVersion compat >= 9
	cmd:pg_controldata$secondaryArchSuffix = $portVersion compat >= 9
	cmd:pg_ctl$secondaryArchSuffix = $portVersion compat >= 9
	cmd:pg_dump$secondaryArchSuffix = $portVersion compat >= 9
	cmd:pg_dumpall$secondaryArchSuffix = $portVersion compat >= 9
	cmd:pg_isready$secondaryArchSuffix = $portVersion compat >= 9
	cmd:pg_receivexlog$secondaryArchSuffix = $portVersion compat >= 9
	cmd:pg_resetxlog$secondaryArchSuffix = $portVersion compat >= 9
	cmd:pg_restore$secondaryArchSuffix = $portVersion compat >= 9
	cmd:postgres$secondaryArchSuffix = $portVersion compat >= 9
	cmd:postmaster$secondaryArchSuffix = $portVersion compat >= 9
	cmd:psql$secondaryArchSuffix = $portVersion compat >= 9
	cmd:reindexdb$secondaryArchSuffix = $portVersion compat >= 9
	cmd:vacuumdb$secondaryArchSuffix = $portVersion compat >= 9
	lib:libecpg$secondaryArchSuffix = $portVersion compat >= 9
	lib:libecpg_compat$secondaryArchSuffix = $portVersion compat >= 9
	lib:libpgtypes$secondaryArchSuffix = $portVersion compat >= 9
	lib:libpq$secondaryArchSuffix = $portVersion compat >= 9
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libreadline$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"
BUILD_REQUIRES="
	devel:libreadline$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:aclocal
	cmd:awk
	cmd:bison
	cmd:flex
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"
PROVIDES_devel="
	postgresql${secondaryArchSuffix}_devel = $portVersion
	devel:libpgport$secondaryArchSuffix = $portVersion
	devel:libpgcommon$secondaryArchSuffix = $portVersion
	devel:libecpg$secondaryArchSuffix = $portVersion
	devel:libpgtypes$secondaryArchSuffix = $portVersion
	devel:libpq$secondaryArchSuffix = $portVersion
	devel:libecpg_compat$secondaryArchSuffix = $portVersion
	"
REQUIRES_devel="
	postgresql${secondaryArchSuffix} == $portVersion base
	"

BUILD()
{
	runConfigure ./configure
	make $jobArgs
}

INSTALL()
{
	make install
	
	prepareInstalledDevelLibs libpgport \
		libpgcommon \
		libecpg \
		libpgtypes \
		libpq \
		libecpg_compat
	fixPkgconfig

	mkdir -p $developLibDir/postgresql/pgxs
	mv $libDir/postgresql/pgxs $developLibDir/postgresql/

	packageEntries devel \
		$developDir
}

TEST()
{
	make check
}
