SUMMARY="Open Source ODBC sub-system"
DESCRIPTION="unixODBC is an Open Source ODBC sub-system and an ODBC SDK \
for Linux, Mac OSX, and UNIX."
HOMEPAGE="http://www.unixodbc.org/"
COPYRIGHT="1999-2020 Peter Harvey, Nick Gorham"
LICENSE="GNU GPL v2
	GNU LGPL v2"
REVISION="1"
SOURCE_URI="http://www.unixodbc.org/unixODBC-$portVersion.tar.gz"
CHECKSUM_SHA256="52833eac3d681c8b0c9a5a65f2ebd745b3a964f208fc748f977e44015a31b207"
SOURCE_DIR="unixODBC-$portVersion"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

libVersion="2.0.0"
libVersionCompat="$libVersion compat >= ${libVersion%%.*}"

GLOBAL_WRITABLE_FILES="
	settings/odbc.ini keep-old
	settings/odbcinst.ini keep-old
	"

PROVIDES="
	unixodbc$secondaryArchSuffix = $portVersion
	cmd:dltest$secondaryArchSuffix
	cmd:isql$secondaryArchSuffix
	cmd:iusql$secondaryArchSuffix
	cmd:odbcinst$secondaryArchSuffix
	cmd:slencheck$secondaryArchSuffix
	lib:libodbc$secondaryArchSuffix = $libVersionCompat
	lib:libodbccr$secondaryArchSuffix = $libVersionCompat
	lib:libodbcinst$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libiconv$secondaryArchSuffix
	lib:libltdl$secondaryArchSuffix
	lib:libreadline$secondaryArchSuffix
	"

PROVIDES_devel="
	unixodbc${secondaryArchSuffix}_devel = $portVersion
	cmd:odbc_config$secondaryArchSuffix
	devel:libodbc$secondaryArchSuffix = $libVersionCompat
	devel:libodbccr$secondaryArchSuffix = $libVersionCompat
	devel:libodbcinst$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES_devel="
	haiku$secondaryArchSuffix
	unixodbc$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libiconv$secondaryArchSuffix
	devel:libltdl$secondaryArchSuffix
	devel:libreadline$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:autoconf
	cmd:automake
	cmd:awk
	cmd:bison$secondaryArchSuffix
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:libtoolize$secondaryArchSuffix
	cmd:make
	"

defineDebugInfoPackage unixodbc$secondaryArchSuffix \
	"$binDir"/dltest \
	"$binDir"/isql \
	"$binDir"/iusql \
	"$binDir"/odbcinst \
	"$binDir"/slencheck \
	"$libDir"/libodbc.so.$libVersion \
	"$libDir"/libodbccr.so.$libVersion \
	"$libDir"/libodbcinst.so.$libVersion \

BUILD()
{
	autoreconf -fi

	runConfigure ./configure

	make $jobArgs
}

INSTALL()
{
	make install

	# remove libtool library files
	rm -f "$libDir"/libodbc*.la

	# prepare develop/lib
	prepareInstalledDevelLibs libodbc libodbccr libodbcinst
	fixPkgconfig

	# devel package
	packageEntries devel \
		"$binDir"/odbc_config \
		"$developDir"
}

TEST()
{
	make check
}
