SUMMARY="A generic library of support scripts"
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"
COPYRIGHT="2004-2010 Free Software Foundation, Inc."
LICENSE="GNU GPL v2"
REVISION="2"
SOURCE_URI="https://ftp.gnu.org/gnu/libtool/libtool-$portVersion.tar.gz"
CHECKSUM_SHA256="e3bd4d5d3d025a36c21dd6af7ea818a2afcd4dfc1ea5a17b39d7854bcd0c06e3"
PATCHES="libtool-$portVersion.patchset"

ARCHITECTURES="all ?arm"
SECONDARY_ARCHITECTURES="x86_gcc2 x86"

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.1 compat >= 7
	"
REQUIRES="
	haiku$secondaryArchSuffix
	libtool${secondaryArchSuffix}_libltdl == $portVersion base
	cmd:aclocal
	cmd:automake
	cmd:find
	cmd:sed
	cmd:tar
	cmd:xargs
	"

SUMMARY_libltdl="The libtool libltdl library"
PROVIDES_libltdl="
	libtool${secondaryArchSuffix}_libltdl = $portVersion compat >= 2.4
	lib:libltdl$secondaryArchSuffix = 7.3.1 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$secondaryArchSuffix
	cmd:make
	cmd:nm
	cmd:ranlib
	cmd:sed
	cmd:xargs
	"

BUILD()
{
	export MAKEINFO=/bin/true
	export HELP2MAN=/bin/true
	export PATCH=/bin/true
	export XZ=/bin/true
	touch README-release

	cp m4/libtool.m4 m4/libtool.m4.bak
	./bootstrap --force
	mv m4/libtool.m4.bak m4/libtool.m4
		# bootstrap copies back the file from the system over the current ones.
		# But we must run it, because libtool is shipped with old aclocal-1.15
		# files and we have only a newer aclocal. So just restore the file.
	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
}
