Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/share/mk man0: support objdirs, tools, parallel builds



details:   https://anonhg.NetBSD.org/src/rev/5f8f1a1564ec
branches:  trunk
changeset: 375923:5f8f1a1564ec
user:      lukem <lukem%NetBSD.org@localhost>
date:      Mon May 22 12:55:44 2023 +0000

description:
man0: support objdirs, tools, parallel builds

man0 creates files, so write to the the OBJDIR instead of the
source directory.

Use TOOL_ appropriately.
Add MAKEVERBOSE support.

Add separate rules to generate:
- all.files: the list of all man files to process (based on mkman)
- manNpages.files: per-section files from all.files. (based on mkman)
- manNpages.ps: per-section .ps from manNpages.files, with
  per-file MAKEVERBOSE messages to stderr (as before, just prettier).
- manNpages.pdf: per-section .pdf from manNpages.ps.

Remove the now-obsolete mkman script.

Add TOOL_GROPS and _MKSHMSG_FORMAT to <bsd.own.mk>

diffstat:

 share/man/man0/Makefile |  130 ++++++++++++++++++++++++++++++-----------------
 share/man/man0/mkman    |   33 ------------
 share/mk/bsd.own.mk     |    5 +-
 3 files changed, 87 insertions(+), 81 deletions(-)

diffs (228 lines):

diff -r 21e47e0ebf99 -r 5f8f1a1564ec share/man/man0/Makefile
--- a/share/man/man0/Makefile   Mon May 22 12:55:04 2023 +0000
+++ b/share/man/man0/Makefile   Mon May 22 12:55:44 2023 +0000
@@ -1,7 +1,9 @@
 #      from: @(#)Makefile      5.9 (Berkeley) 7/1/91
-#      $NetBSD: Makefile,v 1.17 2012/02/07 19:13:31 joerg Exp $
+#      $NetBSD: Makefile,v 1.18 2023/05/22 12:55:44 lukem Exp $
 
-NOOBJ=         # defined
+#
+# Note: Needs ps2pdf to convert .ps to .pdf
+#
 
 .include <bsd.own.mk>
 
@@ -10,63 +12,97 @@ FILES=              makewhatis.sed
 FILESDIR=      /usr/share/man
 .endif
 
-CLEANFILES+=   man?
-CLEANFILES+=   man?pages.tmp
-CLEANFILES+=   man?pages.ps
-CLEANFILES+=   man?pages.pdf
-CLEANFILES+=   toc? tocx?
+SECTIONS?=     1 2 3 4 5 6 7 8 9
 
-SECTIONS?=     1 2 3 4 5 6 7 8 9
+MANSRCDIRS=    "${.CURDIR}/../../.." ../../..
 
 # Takes out some fluff from the PostScript files created by
 # grops which does some VM saving/restoring that bloats the
 # PDF file pdf2ps generates.              By uwe%NetBSD.org@localhost.
 OPTIMIZE_PDF?= \
-                       -e '/^\/level0 0 def/d'                 \
-                       -e '/^\/level0 save/d'                  \
-                       -e '/^level0 restore/d'                 
+                       -e '/^\/level0 0 def/d'         \
+                       -e '/^\/level0 save/d'          \
+                       -e '/^level0 restore/d'
+
+MAN0SRCS=
+.if ${MKMAN} != "no"
+MAN0SRCS+=     all.files
+MAN0SRCS+=     ${SECTIONS:@S@man${S}pages.files@}
+MAN0SRCS+=     ${SECTIONS:@S@man${S}pages.ps @}
+MAN0SRCS+=     ${SECTIONS:@S@man${S}pages.pdf@}
+.endif
+
+CLEANFILES+=   ${MAN0SRCS}
+CLEANFILES+=   *.tmp
+CLEANFILES+=   toc? tocx?
+
+all: ${MAN0SRCS}
 
-all: man man.ps man.pdf
+all.files:
+       ${_MKTARGET_CREATE}
+       find ${MANSRCDIRS} -name '*.[1-9]' -print       \
+       | xargs ${TOOL_MKMAGIC}                         \
+       | ${TOOL_GREP} troff                            \
+       | ${TOOL_SED} 's/:[     ]*.*$$//'               \
+       | ${TOOL_GREP} -F -v -f "${.CURDIR}/noman"      \
+       | ${TOOL_GREP} -v '#'                           \
+       | ${TOOL_GREP} -v '/obj\.'                      \
+       | ${TOOL_GREP} -v '/destdir\.'                  \
+       | ${TOOL_GREP} -v '/tooldir\.'                  \
+       > ${.TARGET}.tmp                                \
+       && ${MV} ${.TARGET}.tmp ${.TARGET} ;            \
+       rm -f ${.TARGET}.tmp
 
-man: 
-       ${HOST_SH} mkman
+
+.for _S in ${SECTIONS}
 
-man.ps: 
-       for i in ${SECTIONS} ;                                  \
-       do                                                      \
-               for f in `grep "$${i}\$$" intros` `cat man$${i}` ; \
-               do                                              \
-                       if [ ! -f $${f} ]; then                 \
-                               continue ;                      \
-                       fi ;                                    \
-                       if grep -q ^\\.TS back ;                \
-                       then                                    \
-                               echo >&2 $${f} ;                        \
-                               cat $${f} | tbl | troff -msafer -man -Tps ; \
-                       else                                    \
-                               echo >&2 $${f} "(tbl)" ;        \
-                               cat $${f} | troff -msafer -man -Tps ; \
-                       fi ;                                    \
-               done >man$${i}pages.tmp ;                       \
-               cat man$${i}pages.tmp                           \
-               | grep -v '^x stop'                             \
-               | grops >man$${i}pages.ps ;                     \
-               rm man$${i}pages.tmp ;          \
-       done
+man${_S}pages.files: all.files
+       ${_MKTARGET_CREATE}
+       cat ${.ALLSRC}                                  \
+       | ${TOOL_GREP} "${_S}\$$"                       \
+       | ${TOOL_SED} 's,\(.*/\)\([^/]*\),\2 \1\2,'     \
+       | sort                                          \
+       | ${TOOL_SED} 's/^.* //'                        \
+       > ${.TARGET}.tmp                                \
+       && ${MV} ${.TARGET}.tmp ${.TARGET} ;            \
+       rm -f ${.TARGET}.tmp
 
-man.pdf: 
-       for i in ${SECTIONS} ;                                  \
-       do                                                      \
-               echo Chewing on man$${i}pages.pdf ;             \
-               ${TOOL_SED}                                     \
-                       ${OPTIMIZE_PDF}                         \
-                       <man$${i}pages.ps >man$${i}pages.ps.tmp ; \
-               ps2pdf man$${i}pages.ps.tmp man$${i}pages.pdf ; \
-               rm man$${i}pages.ps.tmp ;                       \
-       done
+man${_S}pages.ps: man${_S}pages.files
+       ${_MKTARGET_CREATE}
+       for f in `${TOOL_GREP} "${_S}\$$" "${.CURDIR}/intros"` `cat ${.ALLSRC}` ; \
+       do                                              \
+               if [ ! -f $${f} ]; then                 \
+                       continue ;                      \
+               fi ;                                    \
+               if ${TOOL_GREP} -q ^\\.TS "${.CURDIR}/back" ; \
+               then                                    \
+                       ${_MKSHMSG_FORMAT} >&2 $${f} ;  \
+                       cat $${f} | ${TOOL_TBL} | ${TOOL_GROFF} -Z -msafer -man -Tps ; \
+               else                                    \
+                       ${_MKSHMSG_FORMAT} >&2 $${f} "(tbl)";   \
+                       cat $${f} | ${TOOL_GROFF} -Z -msafer -man -Tps ; \
+               fi ;                                    \
+       done > ${.TARGET}.troff.tmp                     \
+       && cat ${.TARGET}.troff.tmp                     \
+       | ${TOOL_GREP} -v '^x stop'                     \
+       | ${TOOL_GROPS}                                 \
+       > ${.TARGET}.tmp                                \
+       && ${MV} ${.TARGET}.tmp ${.TARGET} ;            \
+       rm -f ${.TARGET}.tmp ${.TARGET}.troff.tmp
+
+man${_S}pages.pdf: man${_S}pages.ps
+       ${_MKTARGET_CREATE}
+       cat ${.ALLSRC}                                  \
+       | ${TOOL_SED} ${OPTIMIZE_PDF}                   \
+       | ps2pdf - -                                    \
+       > ${.TARGET}.tmp                                \
+       && ${MV} ${.TARGET}.tmp ${.TARGET} ;            \
+       rm -f ${.TARGET}.tmp
+
+.endfor
 
 man.tgz:
        tar plzvcf manpages-ps.tgz man?pages.ps
        tar plzvcf manpages-pdf.tgz man?pages.pdf
 
-.include <bsd.prog.mk>
+.include <bsd.files.mk>
diff -r 21e47e0ebf99 -r 5f8f1a1564ec share/man/man0/mkman
--- a/share/man/man0/mkman      Mon May 22 12:55:04 2023 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +0,0 @@
-#!/bin/sh
-#      $NetBSD: mkman,v 1.5 2007/01/17 00:51:25 hubertf Exp $
-
-#
-# Find all manpage sources - run before tocrc
-#
-
-SRC=../../..
-
-echo Preparing data ...
-
-find ${SRC} -name '*.[1-9]' -print     \
-| xargs file                           \
-| grep troff                           \
-| sed 's/:[    ]*.*$//'                \
-| fgrep -v -f noman                    \
-| grep -v '#'                          \
-| grep -v '/obj\.'                     \
-| grep -v '/destdir\.'                 \
-| grep -v '/tooldir\.'                 \
->/tmp/mkman.$$
-
-for i in 1 2 3 4 5 6 7 8 9
-do
-       echo Creating man$i
-       grep "${i}\$"   </tmp/mkman.$$          \
-       | sed 's,\(.*/\)\([^/]*\),\2 \1\2,'     \
-       | sort                                  \
-       | sed 's/^.* //'                        \
-       >man${i}
-done
-
-rm /tmp/mkman.$$
diff -r 21e47e0ebf99 -r 5f8f1a1564ec share/mk/bsd.own.mk
--- a/share/mk/bsd.own.mk       Mon May 22 12:55:04 2023 +0000
+++ b/share/mk/bsd.own.mk       Mon May 22 12:55:44 2023 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: bsd.own.mk,v 1.1324 2023/05/15 16:12:39 christos Exp $
+#      $NetBSD: bsd.own.mk,v 1.1325 2023/05/22 12:55:45 lukem Exp $
 
 # This needs to be before bsd.init.mk
 .if defined(BSD_MK_COMPAT_FILE)
@@ -454,6 +454,7 @@ TOOL_GROFF_ENV= \
     GROFF_FONT_PATH=${GROFF_SHARE_PATH}/site-font:${GROFF_SHARE_PATH}/font \
     GROFF_TMAC_PATH=${GROFF_SHARE_PATH}/site-tmac:${GROFF_SHARE_PATH}/tmac
 TOOL_GROFF=            ${TOOL_GROFF_ENV} ${TOOLDIR}/bin/${_TOOL_PREFIX}groff ${GROFF_FLAGS}
+TOOL_GROPS=            ${TOOL_GROFF_ENV} ${TOOLDIR}/lib/groff/grops
 
 TOOL_HEXDUMP=          ${TOOLDIR}/bin/${_TOOL_PREFIX}hexdump
 TOOL_HP300MKBOOT=      ${TOOLDIR}/bin/${_TOOL_PREFIX}hp300-mkboot
@@ -571,6 +572,7 @@ TOOL_GMAKE=         gmake
 TOOL_GPT=              gpt
 TOOL_GREP=             grep
 TOOL_GROFF=            groff
+TOOL_GROPS=            grops
 TOOL_HEXDUMP=          hexdump
 TOOL_HP300MKBOOT=      hp300-mkboot
 TOOL_HPPAMKBOOT=       hppa-mkboot
@@ -1741,6 +1743,7 @@ MAKEVERBOSE?=             2
 _MKMSG_YACC?=          ${_MKMSG} "   yacc "
 
 _MKSHMSG_CREATE?=      ${_MKSHMSG} " create "
+_MKSHMSG_FORMAT?=      ${_MKSHMSG} " format "
 _MKSHMSG_INSTALL?=     ${_MKSHMSG} "install "
 
 _MKTARGET_BUILD?=      ${_MKMSG_BUILD} ${.CURDIR:T}/${.TARGET}



Home | Main Index | Thread Index | Old Index