NAME=groff
VERSION=1.19.2
SOURCE=(http://ftp.gnu.org/gnu/groff/groff-$VERSION.tar.gz
	groff.man.mdoc.local.gz )
PATCH=groff.docdir.diff.gz
BUILD=${BUILD:-1tukaani}

build() {
	_explode 0
	_cflags -O2
	cd groff-$VERSION
	_patch 0 -p1 --verbose --backup --suffix=.orig

	# Default to A4:
	PAGE=A4 \
		./configure \
		--prefix=$PREFIX \
		--libdir=$LIBDIR \
		--with-appresdir=$SYSCONFDIR/X11/app-defaults \
		$CONFIGURE_TRIPLET
	make

	mkdir -p $PKG$PREFIX
	make install \
		prefix=$PKG$PREFIX \
		libdir=$PKG$LIBDIR \
		appresdir=$PKG$SYSCONFDIR/X11/app-defaults

	mkdir -p $PKG$X11PREFIX/{bin,man/man1}
	mv $PKG$BINDIR/gxditview $PKG$X11PREFIX/bin
	mv $PKG$PREFIX/man/man1/gxditview.1 $PKG$X11PREFIX/man/man1

	_doc 0 groff-$VERSION  BUG-REPORT COPYING FDL INSTALL \
			MORE.STUFF NEWS PROBLEMS PROJECTS README TODO VERSION

	# If you want all this stuff, it's in the source tarball:
	rm -rf $PKG$DOCDIR/groff-$VERSION/{*.ps,examples,html}

	# Do not use color ANSI output by default for man pages.
	# A silly "innovation" if ever there was one, sure to break
	# a ton of existing scripts otherwise...
	#
	# Comments by Larhzu: I want to see if I get any complains when
	# I turn this on in Tukaani. Colors work with 'man' because I
	# added '-R' to to the argument list of 'less'. If someone has
	# problems, I will revert back to the Slackware's behavior, just
	# let me know.
	# 
	# UPDATE: Pat is right. Although not everything does break,
	# there are a few problems so this is a better solution. Also
	# the mapping of unicode's hypens to hypen-minus makes searching
	# and copypasting much nicer. :-)
	#
	zcat ${SOURCE[1]} >> $PKG$DATADIR/groff/site-tmac/man.local
	zcat ${SOURCE[1]} >> $PKG$DATADIR/groff/site-tmac/mdoc.local

	# Make links:
	(
		cd $PKG$BINDIR
		ln -sf eqn geqn
		ln -sf indxbib gindxbib
		ln -sf pic gpic
		ln -sf refer grefer
		ln -sf soelim gsoelim
		ln -sf soelim zsoelim
		ln -sf tbl gtbl
		ln -sf troff gtroff
		ln -sf lookbib glookbib
		ln -sf nroff gnroff
		ln -sf neqn gneqn
	)

	_chfix
	_chgrp_bin
}
