--- old/exception_lists/packaging	Fri Jul 18 00:19:02 2014
+++ new/exception_lists/packaging	Fri Jul 18 00:19:02 2014
@@ -946,6 +946,8 @@
 #
 opt/onbld/bin/i386/elfsign	i386
 opt/onbld/bin/sparc/elfsign	sparc
+opt/onbld/bin/i386/mandoc	i386
+opt/onbld/bin/sparc/mandoc	sparc
 
 #
 # Private libdwarf
--- old/usr/src/cmd/mandoc/Makefile	Fri Jul 18 00:19:03 2014
+++ new/usr/src/cmd/mandoc/Makefile	Fri Jul 18 00:19:03 2014
@@ -10,40 +10,19 @@
 #
 
 #
-# Copyright 2012 Nexenta Systems, Inc.  All rights reserved.
+# Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
 # Copyright 2014 Garrett D'Amore <garrett@damore.org>
 #
 
 PROGS=		mandoc mandoc_preconv
-mandoc_OBJS =	arch.o att.o chars.o eqn.o eqn_html.o eqn_term.o 	\
-		html.o lib.o main.o man.o man_hash.o man_html.o		\
-		man_macro.o man_term.o man_validate.o mandoc.o mdoc.o	\
-		mdoc_argv.o mdoc_hash.o mdoc_html.o mdoc_macro.o	\
-		mdoc_man.o mdoc_term.o mdoc_validate.o msec.o out.o	\
-		read.o roff.o st.o tbl.o tbl_data.o tbl_html.o		\
-		tbl_layout.o tbl_opts.o tbl_term.o term.o term_ascii.o	\
-		term_ps.o tree.o vol.o
 
-preconv_OBJS =	preconv.o
-
-# We place preconv in /usr/lib.  This is done to avoid conflicting with
-# GNU groff, which puts it into /usr/bin.  We also rename it so that it
-# will only be seen by mandoc -- it isn't intended for general end-user use.
-
 ROOTPROGS =	$(ROOTBIN)/mandoc $(ROOTLIB)/mandoc_preconv
 
 OBJS=		$(preconv_OBJS) $(mandoc_OBJS)
 
 include		$(SRC)/cmd/Makefile.cmd
+include		$(SRC)/cmd/mandoc/Makefile.common
 
-CFLAGS +=	$(CC_VERBOSE)
-
-CPPFLAGS +=	-DHAVE_CONFIG_H -DUSE_WCHAR	\
-		-DOSNAME="\"illumos\""	\
-		-DVERSION="\"1.12.1\""
-
-.KEEP_STATE:
-
 all:		$(PROGS)
 
 mandoc_preconv:	$(preconv_OBJS)
--- /dev/null	Fri Jul 18 00:19:03 2014
+++ new/usr/src/cmd/mandoc/Makefile.common	Fri Jul 18 00:19:03 2014
@@ -0,0 +1,33 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2012 Nexenta Systems, Inc.  All rights reserved.
+# Copyright 2014 Garrett D'Amore <garrett@damore.org>
+#
+
+PROGS=		mandoc mandoc_preconv
+mandoc_OBJS =	arch.o att.o chars.o eqn.o eqn_html.o eqn_term.o 	\
+		html.o lib.o main.o man.o man_hash.o man_html.o		\
+		man_macro.o man_term.o man_validate.o mandoc.o mdoc.o	\
+		mdoc_argv.o mdoc_hash.o mdoc_html.o mdoc_macro.o	\
+		mdoc_man.o mdoc_term.o mdoc_validate.o msec.o out.o	\
+		read.o roff.o st.o tbl.o tbl_data.o tbl_html.o		\
+		tbl_layout.o tbl_opts.o tbl_term.o term.o term_ascii.o	\
+		term_ps.o tree.o vol.o
+
+preconv_OBJS =	preconv.o
+
+CFLAGS +=	$(CC_VERBOSE)
+
+CPPFLAGS +=	-DHAVE_CONFIG_H -DUSE_WCHAR	\
+		-DOSNAME="\"illumos\""	\
+		-DVERSION="\"1.12.1\""
--- old/usr/src/man/Makefile	Fri Jul 18 00:19:03 2014
+++ new/usr/src/man/Makefile	Fri Jul 18 00:19:03 2014
@@ -11,7 +11,7 @@
 
 #
 # Copyright 2011, Richard Lowe
-# Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
+# Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
 #
 
 SUBDIRS=	man1		\
--- old/usr/src/man/Makefile.man	Fri Jul 18 00:19:03 2014
+++ new/usr/src/man/Makefile.man	Fri Jul 18 00:19:03 2014
@@ -11,10 +11,10 @@
 
 #
 # Copyright 2011, Richard Lowe
-# Copyright 2013 Nexenta Systems, Inc.  All rights reserved.
+# Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
 #
 
-MANDOC=		$(ROOT)/usr/bin/mandoc
+MANDOC=		$(ONBLD_TOOLS)/bin/${MACH}/mandoc
 ROOTMAN=	$(ROOT)/usr/share/man
 ROOTHASMAN=	$(ROOT)/usr/has/man
 FILEMODE=	0444
--- old/usr/src/tools/Makefile	Fri Jul 18 00:19:03 2014
+++ new/usr/src/tools/Makefile	Fri Jul 18 00:19:03 2014
@@ -53,7 +53,8 @@
 #  special versions of commands for use only in build
 #
 UNSHIPPED_SUBDIRS = \
-	elfsign
+	elfsign \
+	mandoc
 
 sparc_SUBDIRS= \
 	chk4ubin \
--- /dev/null	Fri Jul 18 00:19:03 2014
+++ new/usr/src/tools/mandoc/Makefile	Fri Jul 18 00:19:03 2014
@@ -0,0 +1,51 @@
+#
+# This file and its contents are supplied under the terms of the
+# Common Development and Distribution License ("CDDL"), version 1.0.
+# You may only use this file in accordance with the terms of version
+# 1.0 of the CDDL.
+#
+# A full copy of the text of the CDDL should have accompanied this
+# source.  A copy of the CDDL is also available via the Internet at
+# http://www.illumos.org/license/CDDL.
+#
+
+#
+# Copyright 2014 Nexenta Systems, Inc.  All rights reserved.
+#
+
+
+PROG=		mandoc
+
+CMDDIR=	$(SRC)/cmd/mandoc
+
+include ../Makefile.tools
+
+include $(SRC)/cmd/mandoc/Makefile.common
+
+SRCS=	$(mandoc_OBJS:%.o=$(CMDDIR)/%.c)
+CLEANFILES=	$(PROG) $(OBJS)
+OBJS= $(mandoc_OBJS)
+PROG= mandoc
+
+.KEEP_STATE:
+
+install: all .WAIT $(ROOTONBLDMACHPROG)
+
+$(PROG):	$(OBJS)
+		$(LINK.c) -o $@ $(OBJS) $(LDLIBS)
+		$(POST_PROCESS)
+
+all:		$(PROG)
+
+
+%.o:		$(CMDDIR)/%.c
+		$(COMPILE.c) -o $@ $<
+
+%.o:		$(LIBDIR)/%.c
+		$(COMPILE.c) -o $@ $<
+
+clean:
+		$(RM) $(CLEANFILES)
+
+include ../Makefile.targ
+
