SUMMARY="Libraries to dump and manipulate DWARF data"
DESCRIPTION="DWARF is a widely used, standardized debugging data format. \
DWARF was originally designed along with Executable and Linkable Format (ELF),\
although it is independent of object file formats. The name is a medieval \
fantasy complement to ELF that has no official meaning, although the \
backronym 'Debugging With Attributed Record Formats' was later proposed.

The DWARF Debugging Information Format is of interest to programmers working \
on compilers and debuggers (and anyone interested in reading or writing DWARF \
information). DWARF uses a data structure called a Debugging Information Entry \
(DIE) to represent each variable, type, procedure, etc. It was developed by a \
committee (known as the PLSIG at the time) starting around 1991. Starting \
around 1991 SGI developed the libdwarf and dwarfdump tools for internal use and \
as part of SGI IRIX developer tools. Since that time dwarfdump and libdwarf \
have been shipped (as an executable and archive respectively, not source) with \
every release of the SGI MIPS/IRIX C compiler. In 1994 (I think the correct \
year) SGI agreed to open-source libdwarf (and in 1999 to open-source dwarfdump) \
so anyone could use them.
"
HOMEPAGE="https://www.prevanders.net/dwarf.html"
COPYRIGHT="2000,2002,2004,2005 Silicon Graphics, Inc.
	2007-2010 David Anderson
	2007-2010 Sun Microsystems, Inc."
LICENSE="GNU GPL v2
	GNU LGPL v2.1"
REVISION="2"
SOURCE_URI="https://www.prevanders.net/libdwarf-$portVersion.tar.gz"
CHECKSUM_SHA256="46ccfb24ecd24bd7cce466d67a7bfeb62b9ed405dafdc924918d58c529abccb8"
SOURCE_DIR="dwarf-$portVersion"
PATCHES="libdwarf-20170709.patchset"

ARCHITECTURES="all"
SECONDARY_ARCHITECTURES="x86"

# On x86_gcc2 we don't want to install the commands in bin/<arch>/, but in bin/.
commandSuffix=$secondaryArchSuffix
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandSuffix=
fi

PROVIDES="
	libdwarf$secondaryArchSuffix = $portVersion compat >= 1
	cmd:dwarfdump$commandSuffix = $portVersion
	lib:libdwarf$secondaryArchSuffix = $portVersion compat >= 1
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libelf$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

PROVIDES_devel="
	libdwarf${secondaryArchSuffix}_devel = $portVersion
	devel:libdwarf$secondaryArchSuffix = $portVersion compat >= 1
	"
REQUIRES_devel="
	lib:libdwarf$secondaryArchSuffix == $portVersion base
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libelf$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:awk
	cmd:gcc$secondaryArchSuffix
	cmd:grep
	cmd:ld$secondaryArchSuffix
	cmd:make
	"

BUILD()
{
	cd libdwarf
	runConfigure ./configure --enable-shared
	make
	cd ../dwarfdump
	LDFLAGS="-L../libdwarf" ./configure $configureDirArgs
	LIBRARY_PATH=$LIBRARY_PATH:%A/../libdwarf
	make $jobArgs
}

INSTALL()
{
	cd libdwarf
	make install bindir=$binDir libdir=$libDir incdir=$includeDir
	cp libdwarf.so.1 $libDir
	cp libdwarf.a $libDir

	cd ../dwarfdump
	make install mandir=$manDir

	prepareInstalledDevelLibs libdwarf

	packageEntries devel $developDir
}
