SUMMARY="A suite of tools compiling mdoc from the OpenBSD project"
DESCRIPTION="A suite of tools compiling mdoc, the roff macro language of \
choice for BSD manual pages, and man, the predominant historical language for \
UNIX manuals. It is small, ISO C, ISC-licensed, and quite fast. The main \
component of the toolset is the mandoc utility program, based on the libmandoc \
validating compiler, to format output for UTF-8 and ASCII UNIX terminals, \
HTML 5, PostScript, and PDF."
HOMEPAGE="http://mandoc.bsd.lv/"
# Copyrights should be updated on every new release
# http://mandoc.bsd.lv/cgi-bin/cvsweb/LICENSE
COPYRIGHT="2008-2012, 2014 Kristaps Dzonsons
	2010-2017 Ingo Schwarze
	2009, 2010, 2011, 2012 Joerg Sonnenberger
	2013 Franco Fichtner
	2014 Baptiste Daroussin
	2016 Ed Maste
	2017 Michael Stapelberg
	1999, 2004 Marc Espie
	1998, 2004, 2010 Todd C. Miller
	2008, 2017 Otto Moerbeek
	2004 Ted Unangst
	1994 Christos Zoulas
	2003, 2007, 2008, 2014 Jason McIntyre
	2014 Baptiste Daroussin
	1989, 1990, 1993, 1994 The Regents of the University of California
	1994 Christos Zoulas"
LICENSE="ISC
	BSD (2-clause)
	BSD (3-clause)"
REVISION="2"
SOURCE_URI="http://mandoc.bsd.lv/snapshots/mandoc-$portVersion.tar.gz"
CHECKSUM_SHA256="0b0c8f67958c1569ead4b690680c337984b879dfd2ad4648d96924332fd99528"
PATCHES="mandoc-$portVersion.patchset"
if [ "$effectiveTargetArchitecture" = x86_gcc2 ]; then
	PATCHES="$PATCHES
		mandoc-$portVersion-gcc2.patch"
fi

ARCHITECTURES="all"

PROVIDES="
	mandoc = $portVersion
	cmd:apropos = $portVersion
	cmd:demandoc = $portVersion
	cmd:makewhatis = $portVersion
	cmd:man = $portVersion
	cmd:mandoc = $portVersion
	cmd:mandocd = $portVersion
	cmd:soelim = $portVersion
	cmd:whatis = $portVersion
	"
REQUIRES="
	haiku
	lib:libz
	"
CONFLICTS="
	cmd:man
	"
REPLACES="
	man
	"

BUILD_REQUIRES="
	haiku_devel
	devel:libz
	"
BUILD_PREREQUIRES="
	cmd:cc
	cmd:make
	"

TEST_REQUIRES="
	cmd:diff
	cmd:perl
	"
BUILD_PREREQUIRES+="$TEST_REQUIRES"

USER_SETTINGS_FILES="settings/man.conf"

BUILD()
{
	cat > configure.local << EOF
		CFLAGS='-O2 -pipe -D_BSD_SOURCE'
		DBDIR='$(finddir B_SYSTEM_VAR_DIRECTORY)/mandoc'
		HAVE_ERR=1
		HAVE_PROGNAME=1
		HAVE_STRSEP=1
		LDFLAGS="-lbsd"
		LN='ln -sf'
		MANDIR='$manDir'
		PREFIX='$prefix'
		SBINDIR="\${PREFIX}/bin"
		SYSCONFDIR='$sysconfDir'
EOF
	./configure

	make $jobArgs
}

INSTALL()
{
	make install

	sed -i \
		-e "s|/etc/man.conf|$(finddir B_SYSTEM_SETTINGS_DIRECTORY)/man.conf|" \
		$manDir/man1/apropos.1 \
		$manDir/man1/man.1 \
		$manDir/man5/man.conf.5 \
		$manDir/man8/makewhatis.8
}

# Won't work unless UTF-8 support is re-enabled
#TEST()
#{
#	make regress
#}
