bsd.doc.mk revision 1.67 1 # $NetBSD: bsd.doc.mk,v 1.67 2014/07/06 18:22:03 dholland Exp $
2 # @(#)bsd.doc.mk 8.1 (Berkeley) 8/14/93
3
4 .include <bsd.init.mk>
5
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
17 #
18 # PAGES unknown (XXX)
19 # EXTRA extra files to install (XXX)
20 #
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
25 # SRCS. : = :
26 # DEPSRCS.name1= additional included roff source files
27 # DEPSRCS.name2= more additional included roff source files
28 # DEPSRCS. : = :
29 #
30 # I'm hoping that MACROS and ROFF_* can be uniform across all
31 # subarticles.
32
33
34 # Old bsd.doc.mk files tend to invoke tbl and other preprocessors
35 # directly; they should be changed to set ROFF_* instead.
36 #
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
40 # at build time.
41 #
42
43 # 20130908 dholland: Make sure all makefiles have been converted to the
44 # new scheme.
45 .if !defined(SECTION)
46 .error "bsd.doc.mk: SECTION must be defined"
47 .endif
48 .if target(paper.ps)
49 .error "bsd.doc.mk: target(paper.ps) is true -- this is not allowed"
50 .endif
51
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"
55 PRINTABLE=ps.gz
56 #PRINTABLE=ps
57 #PRINTABLE=pdf
58
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}
64
65 ##### Build
66
67 .for SA in ${SUBARTICLES}
68 .if ${MKDOC} != "no"
69 realall: ${SA}.txt
70 realall: ${SA}.${PRINTABLE}
71 .if ${MKHTML} != "no" && ${MKGROFFHTMLDOC} != "no"
72 realall: ${SA}.html
73 .endif
74 .endif
75 .endfor # SUBARTICLES
76
77 .if defined(ROFF_PIC) && ${ROFF_PIC} != "no"
78 ROFFFLAGS+=-p
79 .endif
80 .if defined(ROFF_EQN) && ${ROFF_EQN} != "no"
81 ROFFFLAGS+=-e
82 .endif
83 .if defined(ROFF_TBL) && ${ROFF_TBL} != "no"
84 ROFFFLAGS+=-t
85 .endif
86 .if defined(ROFF_REFER) && ${ROFF_REFER} != "no"
87 ROFFFLAGS+=-R
88 .endif
89 ROFFFLAGS+=-I${.CURDIR}
90
91 .for SA in ${SUBARTICLES}
92
93 #
94 # Find the sources.
95 #
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.
99 #
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.
102 #
103 # For some reason the P modifier finds the path to a variable name,
104 # not the path to a word in a variable.
105 #
106
107 .for S in ${SRCS.${SA}}
108 SRCS2.${SA}+=${${S}:P}
109 .endfor
110 .for S in ${DEPSRCS.${SA}}
111 DEPSRCS2.${SA}+=${${S}:P}
112 .endfor
113
114 #
115 # Note: we use TOOL_ROFF_DOCASCII because TOOL_ROFF_ASCII invokes
116 # the nroff wrapper instead of groff directly, and that doesn't
117 # understand -I.
118 #
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.
125 #
126
127 ${SA}.txt: ${SRCS2.${SA}} ${DEPSRCS2.${SA}}
128 ${_MKTARGET_FORMAT}
129 ${TOOL_ROFF_DOCASCII} ${ROFFFLAGS} ${MACROS} ${PAGES} ${SRCS2.${SA}} \
130 > ${.TARGET}
131
132 ${SA}.ps: ${SRCS2.${SA}} ${DEPSRCS2.${SA}}
133 ${_MKTARGET_FORMAT}
134 ${TOOL_ROFF_PS} ${ROFFFLAGS} ${MACROS} ${PAGES} ${SRCS2.${SA}} \
135 > ${.TARGET}
136
137 ${SA}.pdf: ${SRCS2.${SA}} ${DEPSRCS2.${SA}}
138 ${_MKTARGET_FORMAT}
139 ${TOOL_ROFF_PDF} ${ROFFFLAGS} ${MACROS} ${PAGES} ${SRCS2.${SA}} \
140 > ${.TARGET}
141
142 ${SA}.html: ${SRCS2.${SA}} ${DEPSRCS2.${SA}}
143 ${_MKTARGET_FORMAT}
144 ${TOOL_ROFF_DOCHTML} ${ROFFFLAGS} ${MACROS} ${PAGES} ${SRCS2.${SA}} \
145 -P -I -P ${SA} \
146 > ${.TARGET}
147
148 ${SA}.ps.gz: ${SA}.ps
149 ${TOOL_GZIP} -9 -c ${.ALLSRC} > ${.TARGET}
150
151 .endfor # SUBARTICLES
152
153 ##### Install
154
155 DOCINST:=
156 .for SA in ${SUBARTICLES}
157 DOCINST+=${SA}.txt ${SA}.${PRINTABLE}
158 .if ${MKHTML} != "no" && ${MKGROFFHTMLDOC} != "no"
159 DOCINST+=${SA}.html
160 .endif
161 .endfor
162 .if ${MKHTML} != "no" && ${MKGROFFHTMLDOC} != "no"
163 DOCINST+=${EXTRAHTMLFILES}
164 .endif
165
166 .if ${MKDOC} != "no"
167 docinstall:
168 .for D in ${DOCINST}
169 ${_MKTARGET_INSTALL}
170 ${INSTALL_FILE} -o ${DOCOWN} -g ${DOCGRP} -m ${DOCMODE} ${D} \
171 ${DESTDIR}${DOCDIR}/${SECTION}/${ARTICLE}/${D}
172 .endfor
173 .else
174 docinstall: ;
175 .endif
176
177 .PHONY: docinstall
178 realinstall: docinstall
179
180 ##### Clean
181
182 cleandoc:
183 .for SA in ${SUBARTICLES}
184 rm -f ${SA}.txt ${SA}.ps ${SA}.ps.gz ${SA}.html
185 .endfor
186 rm -f ${EXTRAHTMLFILES} [eE]rrs mklog ${CLEANFILES}
187
188 .PHONY: cleandoc
189 clean: cleandoc
190
191 ##### Extra custom rules
192
193 .if !target(print)
194 print: ;
195 .PHONY: print
196 .for SA in ${SUBARTICLES}
197 print: print.${SA}
198 .PHONY: print.{SA}
199 print.${SA}: ${SA}.ps
200 lpr -P${PRINTER} ${.ALLSRC}
201 .endfor
202 .endif
203
204 spell: ;
205 .PHONY: spell
206 .for SA in ${SUBARTICLES}
207 spell: spell.${SA}
208 .PHONY: spell.{SA}
209 spell.${SA}: ${SRCS2} ${DEPSRCS2}
210 spell ${SRCS2} | sort | comm -23 - spell.ok > paper.spell
211 .endfor
212
213 ##### Pull in related .mk logic
214
215 .include <bsd.obj.mk>
216 .include <bsd.sys.mk>
217
218 ${TARGETS}: # ensure existence
219