1 # $NetBSD: bsd.doc.mk,v 1.68 2015/08/04 08:36:14 dholland Exp $
2 # @(#)bsd.doc.mk 8.1 (Berkeley) 8/14/93
6 # The makefile should set these:
7 # SECTION one of usd, smm, or psd (lower-case)
8 # ARTICLE name of this document
9 # SRCS roff source files
10 # DEPSRCS additional roff source files implicitly included
11 # MACROS name(s) of roff macro packages, including the -m
12 # ROFF_PIC set to "yes" to use pic(1)
13 # ROFF_EQN set to "yes" to use eqn(1)
14 # ROFF_TBL set to "yes" to use tbl(1)
15 # ROFF_REFER set to "yes" to use refer(1)
16 # EXTRAHTMLFILES additional files emitted as part of HTML build
19 # EXTRA extra files to install (XXX)
21 # If there are multiple docs to be generated, set these:
22 # SUBARTICLES= name1 name2 ...
23 # SRCS.name1= roff source files
24 # SRCS.name2= more roff source files
26 # DEPSRCS.name1= additional included roff source files
27 # DEPSRCS.name2= more additional included roff source files
30 # I'm hoping that MACROS and ROFF_* can be uniform across all
34 # Old bsd.doc.mk files tend to invoke tbl and other preprocessors
35 # directly; they should be changed to set ROFF_* instead.
37 # Also they set e.g. DIR=usd/72.mydocument; this should be changed
38 # to SECTION=usd and ARTICLE=mydocument. The article numbers are
39 # no longer present in the file system and do not need to be known
43 # 20130908 dholland: Make sure all makefiles have been converted to the
46 .error
"bsd.doc.mk: SECTION must be defined"
49 .error
"bsd.doc.mk: target(paper.ps) is true -- this is not allowed"
52 # 20130908 dholland: right now we cannot generate pdf from roff sources,
53 # so build compressed postscript instead. XXX. (and: yech)
54 TOOL_ROFF_PDF?
=false
"No roff pdf support"
59 # If there aren't subarticles, we generate one doc that has the same
60 # name as the top-level article.
61 SUBARTICLES?
=${ARTICLE}
62 SRCS.
${ARTICLE}?
=${SRCS}
63 DEPSRCS.
${ARTICLE}?
=${DEPSRCS}
67 .for SA in
${SUBARTICLES}
70 realall
: ${SA}.
${PRINTABLE}
71 .if
${MKHTML} != "no" && ${MKGROFFHTMLDOC} != "no"
77 .if defined
(ROFF_PIC
) && ${ROFF_PIC} != "no"
80 .if defined
(ROFF_EQN
) && ${ROFF_EQN} != "no"
83 .if defined
(ROFF_TBL
) && ${ROFF_TBL} != "no"
86 .if defined
(ROFF_REFER
) && ${ROFF_REFER} != "no"
89 ROFFFLAGS
+=-I
${.CURDIR
}
91 .for SA in
${SUBARTICLES}
96 # We can't use .IMPSRC in the rules because they aren't suffix rules
97 # (they could be for some docs, but not others) and we can't use
98 # .ALLSRC because that includes DEPSRCS.
100 # As far as I know, the only ways to get the path discovered via .PATH
101 # are those two magic variables or the P modifier.
103 # For some reason the P modifier finds the path to a variable name,
104 # not the path to a word in a variable.
107 .for S in
${SRCS.
${SA}}
108 SRCS2.
${SA}+=${${S}:P
}
110 .for S in
${DEPSRCS.
${SA}}
111 DEPSRCS2.
${SA}+=${${S}:P
}
115 # Note: we use TOOL_ROFF_DOCASCII because TOOL_ROFF_ASCII invokes
116 # the nroff wrapper instead of groff directly, and that doesn't
119 # We use TOOL_ROFF_DOCHTML because TOOL_ROFF_HTML uses -mdoc2html,
120 # which is great if it works but doesn't work with at least some of
121 # the non-mdoc docs. (e.g. the curses one) TOOL_ROFF_DOCHTML uses
122 # groff -Thtml, which produces fairly blah output but works with these
123 # docs. It might end up being necessary to choose one or the other on
124 # a per-document basis... sigh.
127 ${SA}.txt
: ${SRCS2.
${SA}} ${DEPSRCS2.
${SA}}
129 ${TOOL_ROFF_DOCASCII} ${ROFFFLAGS} ${MACROS} ${PAGES} ${SRCS2.
${SA}} \
132 ${SA}.ps
: ${SRCS2.
${SA}} ${DEPSRCS2.
${SA}}
134 ${TOOL_ROFF_PS} ${ROFFFLAGS} ${MACROS} ${PAGES} ${SRCS2.
${SA}} \
135 |
${TOOL_SED} -e
'/^%%CreationDate:/d' \
138 ${SA}.pdf
: ${SRCS2.
${SA}} ${DEPSRCS2.
${SA}}
140 ${TOOL_ROFF_PDF} ${ROFFFLAGS} ${MACROS} ${PAGES} ${SRCS2.
${SA}} \
143 ${SA}.html
: ${SRCS2.
${SA}} ${DEPSRCS2.
${SA}}
145 ${TOOL_ROFF_DOCHTML} ${ROFFFLAGS} ${MACROS} ${PAGES} ${SRCS2.
${SA}} \
149 ${SA}.ps.gz
: ${SA}.ps
150 ${TOOL_GZIP} -9 -c
-n
${.ALLSRC
} > ${.TARGET
}
152 .endfor
# SUBARTICLES
157 .for SA in
${SUBARTICLES}
158 DOCINST
+=${SA}.txt
${SA}.
${PRINTABLE}
159 .if
${MKHTML} != "no" && ${MKGROFFHTMLDOC} != "no"
163 .if
${MKHTML} != "no" && ${MKGROFFHTMLDOC} != "no"
164 DOCINST
+=${EXTRAHTMLFILES}
171 ${INSTALL_FILE} -o
${DOCOWN} -g
${DOCGRP} -m
${DOCMODE} ${D} \
172 ${DESTDIR}${DOCDIR}/${SECTION}/${ARTICLE}/${D}
179 realinstall
: docinstall
184 .for SA in
${SUBARTICLES}
185 rm -f
${SA}.txt
${SA}.ps
${SA}.ps.gz
${SA}.html
187 rm -f
${EXTRAHTMLFILES} [eE
]rrs mklog
${CLEANFILES}
192 ##### Extra custom rules
197 .for SA in
${SUBARTICLES}
200 print.
${SA}: ${SA}.ps
201 lpr
-P
${PRINTER} ${.ALLSRC
}
207 .for SA in
${SUBARTICLES}
210 spell.
${SA}: ${SRCS2} ${DEPSRCS2}
211 spell
${SRCS2} |
sort | comm
-23 - spell.ok
> paper.spell
214 ##### Pull in related .mk logic
216 .
include <bsd.obj.mk
>
217 .
include <bsd.sys.mk
>
219 ${TARGETS}: # ensure existence