SUMMARY="A code-searching tool similar to ack, but faster"
DESCRIPTION="A tool for searching code. It started off as a clone of Ack, but their \
feature sets have since diverged slightly.
* It searches code about 3–5× faster than ack.
* It ignores file patterns from your .gitignore and .hgignore.
* If there are files in your source repo you don't want to search, just add \
their patterns to a .agignore file.
* Ag uses Pthreads to take advantage of multiple CPU cores and search files in \
parallel."
HOMEPAGE="https://github.com/ggreer/the_silver_searcher/"
COPYRIGHT="2013-2018 Geoff Greer"
LICENSE="Apache v2"
REVISION="1"
SOURCE_URI="https://github.com/ggreer/the_silver_searcher/archive/$portVersion.tar.gz"
CHECKSUM_SHA256="6a0a19ca5e73b2bef9481c29a508d2413ca1a0a9a5a6b1bd9bbd695a7626cbf9"
SOURCE_FILENAME="the_silver_searcher-$portVersion.tar.gz"

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

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

PROVIDES="
	the_silver_searcher$secondaryArchSuffix = $portVersion
	cmd:ag$commandSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:liblzma$secondaryArchSuffix
	lib:libpcre$secondaryArchSuffix
	lib:libz$secondaryArchSuffix
	"

BUILD_REQUIRES="
	devel:liblzma$secondaryArchSuffix
	devel:libpcre$secondaryArchSuffix
	devel:libz$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	haiku${secondaryArchSuffix}_devel
	cmd:aclocal
	cmd:autoconf
	cmd:autoheader
	cmd:automake
	cmd:clang_format
	cmd:make
	cmd:gcc$secondaryArchSuffix
	cmd:pkg_config$secondaryArchSuffix
	"

TEST_REQUIRES="
	cmd:cram2
	cmd:git
	"

BUILD()
{
	aclocal
	autoconf
	autoheader
	automake --add-missing

	runConfigure --omit-dirs binDir ./configure \
		--bindir=$commandBinDir

	# Build fix, remove if solved
	sed --in-place '/HAVE_FOPENCOOKIE/d' src/config.h

	# Test fix
	sed -i 's/cram/cram2/g' Makefile

	make $jobArgs
}

INSTALL()
{
	make install
}

TEST()
{
	make test
}
