#
# SPECIAL CONSIDERATIONS!!
# SEE https://github.com/haikuports/haikuports/issues/5122 !!!
#
SUMMARY="Standardized interface for PCI access"
DESCRIPTION="Standardized interface for accessing PCI devices."
HOMEPAGE="https://www.x.org/releases/individual/lib/"
COPYRIGHT="2006, 2007 IBM Corporation
	2006 Eric Anholt
	2011 Mark Kettenis
	2012 Robert Millan
	2007, 2008, 2009, 2011, 2012, 2013 Oracle and/or its affiliates.
	2009, 2012 Red Hat, Inc.
	2007 Paulo R. Zanoni, Tiago Vignatti
	2009 Tiago Vignatti
	2000 The XFree86 Project, Inc.
	2009, 2012 Samuel Thibault
	2009 Michael Lorenz
	2008, 2011 Mark Kettenis
	2008 Juan Romero Pardines"
LICENSE="MIT"
REVISION="2"
SOURCE_URI="https://www.x.org/releases/individual/lib/libpciaccess-$portVersion.tar.bz2"
CHECKSUM_SHA256="3df543e12afd41fea8eac817e48cbfde5aed8817b81670a4e9e493bb2f5bf2a4"
PATCHES="libpciaccess-$portVersion.patchset"

ARCHITECTURES="!all"
SECONDARY_ARCHITECTURES="!x86"

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

PROVIDES="
	libpciaccess$secondaryArchSuffix = $portVersion
	lib:libpciaccess$secondaryArchSuffix = $libVersionCompat
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"

PROVIDES_devel="
	libpciaccess${secondaryArchSuffix}_devel = $portVersion
	devel:libpciaccess$secondaryArchSuffix = $libVersion
	"
REQUIRES_devel="
	libpciaccess$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:util_macros
	"
BUILD_PREREQUIRES="
	cmd:awk
	cmd:gcc$secondaryArchSuffix
	cmd:ld$secondaryArchSuffix
	cmd:make
	cmd:pkg_config$secondaryArchSuffix
	"

defineDebugInfoPackage libpciaccess$secondaryArchSuffix \
	$libDir/libpciaccess.so.$libVersion

PATCH()
{
	if [ "$effectiveTargetArchitecture" = x86_gcc2 ]; then
		sed -i -e "s/\(err(1, \)\(\"Couldn't initialize PCI system\");\)/\1\"%s\", \2/;" \
			scanpci/scanpci.c
	fi
}

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

INSTALL()
{
	make install
	rm $libDir/*.la

	prepareInstalledDevelLib libpciaccess
	fixPkgconfig

	packageEntries devel \
		$developDir
}
