SUMMARY="A generic library support script"
SUMMARY_libltdl="The libtool libltdl library"
DESCRIPTION="GNU libtool is a set of shell scripts to automatically configure \
UNIX architectures to build shared libraries in a generic fashion."
HOMEPAGE="http://www.gnu.org/software/libtool"
LICENSE="GNU GPL v2"
REVISION="1"

ARCHITECTURES="x86_gcc2 x86 x86_64 arm"
SECONDARY_ARCHITECTURES="x86"

SOURCE_URI="ftp://ftp.gnu.org/gnu/libtool/libtool-2.4.2.tar.gz"
CHECKSUM_SHA256="b38de44862a987293cd3d8dfae1c409d514b6c4e794ebc93648febf9afc38918"
COPYRIGHT="2004-2010 Free Software Foundation, Inc."
PATCHES="
	2.4.2/adjust_config_for_packaging.patch
	2.4.2/remove_help2man_dependency.patch
	"

PROVIDES="
	libtool$secondaryArchSuffix = $portVersion compat >= 2.4
	cmd:libtool$secondaryArchSuffix = $portVersion compat >= 2.4
	cmd:libtoolize$secondaryArchSuffix = $portVersion compat >= 2.4
	devel:libltdl$secondaryArchSuffix = 7.3.0 compat >= 7
	"
REQUIRES="
	haiku$secondaryArchSuffix
	libtool_libltdl$secondaryArchSuffix == $portVersion base
	cmd:aclocal
	cmd:automake
	cmd:sed
	cmd:tar
	cmd:find
	cmd:xargs
	"
PROVIDES_libltdl="
	libtool_libltdl$secondaryArchSuffix = $portVersion compat >= 2.4
	lib:libltdl$secondaryArchSuffix = 7.3.0 compat >= 7
	"
REQUIRES_libltdl="
	haiku$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	"
BUILD_PREREQUIRES="
	cmd:aclocal
	cmd:autoconf >= 2.62
	cmd:autoheader >= 2.62
	cmd:find
	cmd:gcc$secondaryArchSuffix
	cmd:ld
	cmd:make
	cmd:nm
	cmd:ranlib
	cmd:sed
	cmd:xargs
	"

BUILD()
{
	./bootstrap
	SED='sed' NM='nm' LD=ld runConfigure ./configure \
		--with-gnu-ld
	make $jobArgs
	# Desperate move to remove the absolute paths from libtool. For some reason
	# only for the C++ compiler those are set (not for the C compiler). In
	# openSuse libtool doesn't have those variables set either, but building
	# according to their libroot.spec produces a libtool that has them set as
	# well. My guess is that one has to build libtool without a C++ compiler
	# installed to get that result.
	sed -i -e 's@^predep_objects=".*"$@predep_objects=""'@ \
		-e 's@^postdep_objects=".*"$@postdep_objects=""'@ \
		-e 's@^postdeps=".*"$@postdeps=""'@ \
		-e 's@^compiler_lib_search_path=".*"$@compiler_lib_search_path=""'@ \
		-e 's@^compiler_lib_search_dirs=".*"$@compiler_lib_search_dirs=""'@ \
		libtool
}

INSTALL()
{
	make install
	prepareInstalledDevelLibs libltdl

	# libltdl package
	packageEntries libltdl \
		$libDir/libltdl*

	# main package
	rmdir $libDir
}

TEST()
{
	make check
}
