From b93c1b3ce744ad54253f4dda962f49d9286819e7 Mon Sep 17 00:00:00 2001
From: Juan RP <xtraeme@gmail.com>
Date: Sat, 13 Dec 2014 18:21:28 +0100
Subject: [PATCH] mdocml: update to 1.13.2; replaces openbsd-man now.

---
 srcpkgs/mdocml/files/man.conf      |  55 +++++++
 srcpkgs/mdocml/files/man.conf.5    | 225 +++++++++++++++++++++++++++++
 srcpkgs/mdocml/patches/cross.patch |  27 ++++
 srcpkgs/mdocml/template            |  25 ++--
 4 files changed, 322 insertions(+), 10 deletions(-)
 create mode 100644 srcpkgs/mdocml/files/man.conf
 create mode 100644 srcpkgs/mdocml/files/man.conf.5
 create mode 100644 srcpkgs/mdocml/patches/cross.patch

diff --git a/srcpkgs/mdocml/files/man.conf b/srcpkgs/mdocml/files/man.conf
new file mode 100644
index 00000000000..e96bb2f830e
--- /dev/null
+++ b/srcpkgs/mdocml/files/man.conf
@@ -0,0 +1,55 @@
+#	$OpenBSD: man.conf,v 1.20 2014/02/24 20:11:53 espie Exp $
+
+# Sheer, raging paranoia...
+_version	BSD.2
+
+# The whatis/apropos database.
+_whatdb 	/usr/share/man/mandoc.db
+_whatdb 	/usr/local/share/man/mandoc.db
+
+# Subdirectories for paths ending in '/', IN SEARCH ORDER.
+_subdir		{cat,man}0p {cat,man}1 {cat,man}1p {cat,man}8 {cat,man}6 {cat,man}2 {cat,man}3 {cat,man}5 {cat,man}7 {cat,man}4 {cat,man}9 {cat,man}3p {cat,man}3f {cat,man}n
+
+# Files typed by suffix and their commands.
+_suffix		.0
+_build		.0.gz			/usr/bin/zcat %s
+_build		.[0-9n]			/usr/bin/mandoc -Tutf8 %s
+_build		.[0-9n].gz		/usr/bin/zcat %s | /usr/bin/mandoc -Tutf8
+_build		.[0-9][a-z]		/usr/bin/mandoc -Tutf8 %s
+_build		.[0-9][a-z].gz		/usr/bin/zcat %s | /usr/bin/mandoc -Tutf8
+_build		.[0-9][a-z][a-z]	/usr/bin/mandoc -Tutf8 %s
+_build		.[0-9][a-z][a-z].gz	/usr/bin/zcat %s | /usr/bin/mandoc -Tutf8
+_build		.[0-9][a-z][a-z][a-z]	/usr/bin/mandoc -Tutf8 %s
+_build		.[0-9][a-z][a-z][a-z].gz	/usr/bin/zcat %s | /usr/bin/mandoc -Tutf8
+_build		.tbl			/usr/bin/mandoc -Tutf8 %s
+_build		.tbl.gz			/usr/bin/zcat %s | /usr/bin/mandoc -Tutf8
+
+# Sections and their directories.
+# All paths ending in '/' are the equivalent of entries specifying that
+# directory with all of the subdirectories listed for the keyword _subdir.
+
+# default
+_default	/usr/{share,local/share}/man/
+
+# Other sections that represent complete man subdirectories.
+local		/usr/local/share/man/
+
+# Specific section/directory combinations.
+0p		/usr/{share,local/share}/man/{cat,man}0p
+1		/usr/{share,local/share}/man/{cat,man}1
+1p		/usr/{share,local/share}/man/{cat,man}1p
+2		/usr/{share,local/share}/man/{cat,man}2
+3		/usr/{share,local/share}/man/{cat,man}3
+3F		/usr/{share,local/share}/man/{cat,man}3f
+3f		/usr/{share,local/share}/man/{cat,man}3f
+3P		/usr/{share,local/share}/man/{cat,man}3p
+3p		/usr/{share,local/share}/man/{cat,man}3p
+3x		/usr/{share,local/share}/man/{cat,man}3
+3am		/usr/{share,local/share}/man/{cat,man}3
+4		/usr/{share,local/share}/man/{cat,man}4
+5		/usr/{share,local/share}/man/{cat,man}5
+6		/usr/{share,local/share}/man/{cat,man}6
+7		/usr/{share,local/share}/man/{cat,man}7
+8		/usr/{share,local/share}/man/{cat,man}8
+9		/usr/{share,local/share}/man/{cat,man}9
+n		/usr/{share,local/share}/man/{cat,man}n
diff --git a/srcpkgs/mdocml/files/man.conf.5 b/srcpkgs/mdocml/files/man.conf.5
new file mode 100644
index 00000000000..53ef081a01b
--- /dev/null
+++ b/srcpkgs/mdocml/files/man.conf.5
@@ -0,0 +1,225 @@
+.\"	$OpenBSD: man.conf.5,v 1.13 2010/10/28 21:18:03 jmc Exp $
+.\"
+.\" Copyright (c) 1989, 1991, 1993
+.\"	The Regents of the University of California.  All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\"    notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\"    notice, this list of conditions and the following disclaimer in the
+.\"    documentation and/or other materials provided with the distribution.
+.\" 3. Neither the name of the University nor the names of its contributors
+.\"    may be used to endorse or promote products derived from this software
+.\"    without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\"	@(#)man.conf.5	8.5 (Berkeley) 1/2/94
+.\"
+.Dd $Mdocdate: October 28 2010 $
+.Dt MAN.CONF 5
+.Os
+.Sh NAME
+.Nm man.conf
+.Nd configuration file for
+.Xr man 1
+.Sh DESCRIPTION
+The
+.Xr man 1 ,
+.Xr apropos 1 ,
+and
+.Xr whatis 1
+commands
+search for manual pages or their database files as specified by the
+.Nm man.conf
+file.
+Manual pages are normally expected to be preformatted (see
+.Xr mandoc 1 )
+and named with a trailing
+.Sq .0 .
+.Pp
+The
+.Nm man.conf
+file contains two types of lines.
+.Pp
+The first type of line is a
+.Dq section
+line, which contains a section name followed by one or more directory paths.
+The directory paths may contain the normal shell globbing characters,
+including curly braces
+.Pq Sq {} ;
+to escape a shell globbing character, precede it with a backslash
+.Pq Sq \e .
+Lines in this format specify that manual pages for the section
+may be found in the following directories.
+.Pp
+Directories named with a trailing slash character
+.Pq Sq /
+are expected to contain subdirectories of manual pages, (see the keyword
+.Dq _subdir
+below) instead of manual pages.
+These subdirectories are searched instead of the directory.
+.Pp
+Before searching any directory for a manual page, the
+.Xr man 1
+command always searches the subdirectory with the same name
+as the current machine type, if it exists.
+No specification of these subdirectories is necessary in the
+.Nm man.conf
+file.
+.Pp
+Section names are unrestricted except for the reserved words specified
+below; in general, you should avoid anything with a leading underscore
+.Pq Sq _
+to avoid future incompatibilities.
+.Pp
+The section named
+.Dq _default
+is the list of directories that will
+be searched if no section is specified by the user.
+.Pp
+The second type of line is preceded with a
+.Dq keyword .
+The possible keywords and their meanings are as follows:
+.Bl -tag -width "_version"
+.It _build
+Man file names, regardless of their format, are expected to end in a
+.Sq .*
+pattern, i.e. a
+.Sq .\&
+followed by some suffix.
+The first field of a _build line lists a suffix which indicates
+files which need to be reformatted or manipulated in some way before
+being displayed to the user.
+The suffix may contain the normal shell globbing characters (NOT
+including curly braces
+.Pq Sq {} ) .
+The rest of the line must be a shell command line, the standard
+output of which is the manual page in a format which may be directly
+displayed to the user.
+Any occurrences of the string
+.Sq %s
+in the shell command line will
+be replaced by the name of the file which is being reformatted.
+.It _subdir
+The list
+.Pq in search order
+of subdirectories which will be searched in
+any directory named with a trailing slash
+.Pq Sq /
+character.
+This list is also used when a path is specified to the
+.Xr man 1
+utility by the user, using the
+.Ev MANPATH
+environment variable or the
+.Fl M
+and
+.Fl m
+options.
+.It _suffix
+Man file names, regardless of their format, are expected to end in a
+.Sq .*
+pattern, i.e. a
+.Sq .\&
+followed by some suffix.
+Each field of a _suffix line is a suffix which indicates
+files which do not need to be reformatted or manipulated
+in any way, but which may be directly displayed to the user.
+Each suffix may contain the normal shell globbing characters (NOT
+including curly braces
+.Pq Sq {} ) .
+.It _version
+The version of the configuration file.
+.It _whatdb
+The full pathname
+.Pq not just a directory path
+for a database to be used by the
+.Xr apropos 1
+and
+.Xr whatis 1
+commands.
+.El
+.Pp
+Multiple specifications for all types of lines are cumulative and the
+entries are used in the order listed in the file; multiple entries may
+be listed per line, as well.
+.Pp
+Empty lines or lines whose first non-whitespace character is a hash mark
+.Pq Sq #
+are ignored.
+.Sh FILES
+.Bl -tag -width /etc/man.conf -compact
+.It Pa /etc/man.conf
+standard manual directory search path
+.El
+.Sh EXAMPLES
+Given the following
+.Nm man.conf
+file:
+.Bd -literal -offset indent
+_version	BSD.2
+_subdir		cat1 cat3 cat2
+_suffix		.0
+_build		.[1-9]	/usr/bin/mandoc %s
+_build		.tbl	/usr/bin/mandoc %s
+_default	/usr/share/man/
+sect3		/usr/share/man/{old/,}cat3
+.Ed
+.Pp
+By default, the command
+.Dq Li man mktemp
+will search for
+.Dq mktemp.\*(Ltany_digit\*(Gt
+and
+.Dq mktemp.tbl
+in the directories
+.Pa /usr/share/man/cat1 ,
+.Pa /usr/share/man/cat3 ,
+and
+.Pa /usr/share/man/cat2 ,
+in that order.
+If on a machine of type
+.Dq vax ,
+the subdirectory
+.Dq vax
+in each directory would be searched as well,
+before the rest of the directory was searched.
+.Pp
+If
+.Dq mktemp.tbl
+was found first, the command
+.Dq /usr/bin/mandoc mktemp.tbl
+would be run to build a man page for display to the user.
+.Pp
+The command
+.Dq Li man sect3 mktemp
+would search the directories
+.Pa /usr/share/man/old/cat3
+and
+.Pa /usr/share/man/cat3 ,
+in that order, for the mktemp manual page.
+If a subdirectory with the same name as the current machine type
+existed in any of them, it would be searched as well, before each
+of them were searched.
+.Sh SEE ALSO
+.Xr apropos 1 ,
+.Xr machine 1 ,
+.Xr man 1 ,
+.Xr whatis 1 ,
+.Xr whereis 1 ,
+.Xr fnmatch 3 ,
+.Xr glob 3
diff --git a/srcpkgs/mdocml/patches/cross.patch b/srcpkgs/mdocml/patches/cross.patch
new file mode 100644
index 00000000000..4fb351f8370
--- /dev/null
+++ b/srcpkgs/mdocml/patches/cross.patch
@@ -0,0 +1,27 @@
+--- configure.orig	2014-12-13 18:15:59.590223371 +0100
++++ configure	2014-12-13 18:16:18.270172760 +0100
+@@ -131,13 +131,6 @@ __HEREDOC__
+ 
+ 	if ${COMP} ${3} -o "test-${1}" "test-${1}.c" 1>&3 2>&3; then
+ 		echo "${1}: ${CC} succeeded" 1>&3
+-	else
+-		echo "${1}: ${CC} failed with $?" 1>&3
+-		echo 1>&3
+-		return 1
+-	fi
+-
+-	if ./test-${1} 1>&3 2>&3; then
+ 		echo "${1}: yes" 1>&2
+ 		echo "${1}: yes" 1>&3
+ 		echo 1>&3
+@@ -145,9 +138,8 @@ __HEREDOC__
+ 		rm "test-${1}"
+ 		return 0
+ 	else
+-		echo "${1}: execution failed with $?" 1>&3
++		echo "${1}: ${CC} failed with $?" 1>&3
+ 		echo 1>&3
+-		rm "test-${1}"
+ 		return 1
+ 	fi
+ }
diff --git a/srcpkgs/mdocml/template b/srcpkgs/mdocml/template
index a49edee627e..c390df8913d 100644
--- a/srcpkgs/mdocml/template
+++ b/srcpkgs/mdocml/template
@@ -1,24 +1,29 @@
 # Template file for 'mdocml'
 pkgname=mdocml
-version=1.13.1
-revision=3
-build_style=gnu-makefile
+version=1.13.2
+revision=1
+build_style=configure
 makedepends="sqlite-devel"
-replaces="groff>=0 man-db>=0"
+provides="man-0_1"
+replaces="openbsd-man>=0 groff>=0 man-db>=0"
+conf_files="/etc/man.conf"
 short_desc="The mandoc UNIX manpage compiler toolset"
 maintainer="Juan RP <xtraeme@gmail.com>"
 license="ISC"
 homepage="http://mdocml.bsd.lv"
 distfiles="${homepage}/snapshots/mdocml-$version.tar.gz"
-checksum=7a18e728dc8555b1095bf7edbf086e1d6afb5508c06a7baecfd0b0e448648bf9
-
-do_install() {
-	make MANDIR=/usr/share/man BINDIR=/usr/bin \
-		EXAMPLEDIR=/usr/share/examples/mdocml \
-		PREFIX=/usr DESTDIR=${DESTDIR} install
+checksum=9074755da96e8afbf9634d7ffa29c1decda2f642e13d9d844f26cd1e06d9716b
 
+pre_configure() {
+	sed -i 's,PREFIX=.*,PREFIX=/usr,g' configure
+	sed -i 's,${PREFIX}/man,${PREFIX}/share/man,g' configure
+	sed -i "s,/usr/local,${XBPS_CROSS_BASE}/usr,g" configure
+}
+post_install() {
 	# remove devel stuff.
 	rm -rf ${DESTDIR}/usr/{include,lib}
 	# Daily cron job to generate man db
 	vinstall ${FILESDIR}/makewhatis.cron.daily 755 etc/cron.daily makewhatis
+	vman ${FILESDIR}/man.conf.5
+	vconf ${FILESDIR}/man.conf
 }