SUMMARY="Advanced tftp server and client"
DESCRIPTION="atftp is a client/server implementation of the TFTP protocol \
that implements RFCs 1350, 2090, 2347, 2348, and 2349. The server is \
multi-threaded and the client presents a friendly interface using libreadline."
HOMEPAGE="https://sourceforge.net/projects/atftp/"
COPYRIGHT="2000-2021 Jean-Pierre Lefebvre & Remi Lefebvre"
LICENSE="GNU GPL v2"
REVISION="1"
SOURCE_URI="https://sourceforge.net/projects/atftp/files/atftp-$portVersion.tar.gz"
CHECKSUM_SHA256="d3c9cd0d971dfc786d7a5f4055c35d4e66aafc8102ac03473ef225bdf7edb26a"
SOURCE_FILENAME="atftp-$portVersion.tar.gz"
PATCHES="atftp-$portVersion.patchset"

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

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

PROVIDES="
	atftp$secondaryArchSuffix = $portVersion
	cmd:atftp$commandSuffix = $portVersion
	cmd:atftpd$commandSuffix = $portVersion
	cmd:in.tftpd$commandSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	lib:libncurses$secondaryArchSuffix
	lib:libpcre$secondaryArchSuffix
	lib:libreadline$secondaryArchSuffix
	"

BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	devel:libncurses$secondaryArchSuffix
	devel:libpcre$secondaryArchSuffix
	devel:libreadline$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:awk
	cmd:find
	cmd:gcc$secondaryArchSuffix
	cmd:make
	"

PATCH()
{
	sed -i "s/-lpthread/-lroot/g" configure
}

BUILD()
{
	export LDFLAGS="-lnetwork -lbsd"
	export CPPFLAGS="-D_BSD_SOURCE"
	runConfigure --omit-dirs "binDir sbinDir" ./configure \
		--bindir=$commandBinDir \
		--sbindir=$commandBinDir
	make $jobArgs
}

INSTALL()
{
	make install
}
