SUMMARY="A pattern scanning and processing language"
DESCRIPTION="
If you are like many computer users, you would frequently like to make \
changes in various text files wherever certain patterns appear, or \
extract data from parts of certain lines while discarding the rest. To \
write a program to do this in a language such as C or Pascal is a \
time-consuming inconvenience that may take many lines of code. The job \
is easy with awk, especially the GNU implementation: gawk.

The awk utility interprets a special-purpose programming language that \
makes it possible to handle simple data-reformatting jobs with just a \
few lines of code.
"
HOMEPAGE="http://www.gnu.org/s/gawk"
COPYRIGHT="1983-2020 Free Software Foundation, Inc."
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://ftp.gnu.org/gnu/gawk/gawk-$portVersion.tar.gz"
CHECKSUM_SHA256="6168d8d1dc8f74bd17d9dc22fa9634c49070f232343b744901da15fb4f06bffd"
PATCHES="gawk-$portVersion.patchset"

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

GLOBAL_WRITABLE_FILES="
	settings/profile.d/gawk.csh keep-old
	settings/profile.d/gawk.sh keep-old
	"

# 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="
	gawk$secondaryArchSuffix = $portVersion compat >= 5
	cmd:awk$commandSuffix = $portVersion compat >= 3
	cmd:gawk$commandSuffix = $portVersion compat >= 3
	cmd:igawk$commandSuffix = $portVersion compat >= 3
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"
if [ "$targetArchitecture" = x86_gcc2 ]; then
	CONFLICTS="gawk"
fi

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

TEST_REQUIRES="
	cmd:cmp
	"

defineDebugInfoPackage gawk$secondaryArchSuffix \
	$commandBinDir/gawk

BUILD()
{
	AUTOCONF=: AUTOMAKE=: \
		runConfigure --omit-dirs binDir ./configure \
		--disable-rpath --with-gnu-ld --bindir=$commandBinDir
	make $jobArgs
}

INSTALL()
{
	make install
}

TEST()
{
	make check
}
