SUMMARY="The GNU macro processor"
DESCRIPTION="GNU M4 is an implementation of the traditional UNIX macro \
processor. It is mostly SVR4 compatible although it has some extensions \
(for example, handling more than 9 positional parameters to macros).

M4 is a macro processor in the sense that it copies its input to the output \
expanding macros as it goes. Macros are either builtin or user-defined and can \
take any number of arguments. Besides just doing macro expansion, M4 has \
builtin functions for including named files, running UNIX commands, doing \
integer arithmetic, manipulating text in various ways, recursion, etc. M4 can \
be used either as a front-end to a compiler or as a macro processor in its own \
right.
One of the biggest users of M4 is the GNU Autoconf project."
HOMEPAGE="https://www.gnu.org/software/m4/"
COPYRIGHT="2000, 2005-2014, 2016-2017, 2020-2021 Free Software Foundation, Inc."
LICENSE="GNU GPL v3"
REVISION="1"
SOURCE_URI="https://ftp.gnu.org/gnu/m4/m4-$portVersion.tar.gz"
CHECKSUM_SHA256="3be4a26d825ffdfda52a56fc43246456989a3630093cced3fbddf4771ee58a70"

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

commandSuffix=$secondaryArchSuffix
commandBinDir=$binDir
if [ "$targetArchitecture" = x86_gcc2 ]; then
	commandSuffix=
	commandBinDir=$prefix/bin
fi

PROVIDES="
	m4$secondaryArchSuffix = $portVersion compat >= 1.4
	cmd:m4$commandSuffix = $portVersion compat >= 1.4
	"
REQUIRES="
	haiku$secondaryArchSuffix
	"
if [ "$targetArchitecture" = x86_gcc2 ]; then
	REPLACES="
		m4
		"
fi

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

TEST_REQUIRES="
	cmd:diff
	cmd:help2man
	"

defineDebugInfoPackage m4$secondaryArchSuffix \
	$commandBinDir/m4

BUILD()
{
	runConfigure --omit-dirs binDir ./configure \
		--bindir=$commandBinDir \
		--with-gnu-ld \
		--enable-changeword --disable-gcc-warnings
	make $jobArgs
}

INSTALL()
{
	make install
}

TEST()
{
	make check
}
