bsd.doc.mk revision 1.64.60.1 1 1.64.60.1 tls # $NetBSD: bsd.doc.mk,v 1.64.60.1 2014/08/10 06:53:30 tls Exp $
2 1.19 cgd # @(#)bsd.doc.mk 8.1 (Berkeley) 8/14/93
3 1.1 cgd
4 1.53 tv .include <bsd.init.mk>
5 1.28 mycroft
6 1.64.60.1 tls # The makefile should set these:
7 1.64.60.1 tls # SECTION one of usd, smm, or psd (lower-case)
8 1.64.60.1 tls # ARTICLE name of this document
9 1.64.60.1 tls # SRCS roff source files
10 1.64.60.1 tls # DEPSRCS additional roff source files implicitly included
11 1.64.60.1 tls # MACROS name(s) of roff macro packages, including the -m
12 1.64.60.1 tls # ROFF_PIC set to "yes" to use pic(1)
13 1.64.60.1 tls # ROFF_EQN set to "yes" to use eqn(1)
14 1.64.60.1 tls # ROFF_TBL set to "yes" to use tbl(1)
15 1.64.60.1 tls # ROFF_REFER set to "yes" to use refer(1)
16 1.64.60.1 tls # EXTRAHTMLFILES additional files emitted as part of HTML build
17 1.64.60.1 tls #
18 1.64.60.1 tls # PAGES unknown (XXX)
19 1.64.60.1 tls # EXTRA extra files to install (XXX)
20 1.64.60.1 tls #
21 1.64.60.1 tls # If there are multiple docs to be generated, set these:
22 1.64.60.1 tls # SUBARTICLES= name1 name2 ...
23 1.64.60.1 tls # SRCS.name1= roff source files
24 1.64.60.1 tls # SRCS.name2= more roff source files
25 1.64.60.1 tls # SRCS. : = :
26 1.64.60.1 tls # DEPSRCS.name1= additional included roff source files
27 1.64.60.1 tls # DEPSRCS.name2= more additional included roff source files
28 1.64.60.1 tls # DEPSRCS. : = :
29 1.64.60.1 tls #
30 1.64.60.1 tls # I'm hoping that MACROS and ROFF_* can be uniform across all
31 1.64.60.1 tls # subarticles.
32 1.64.60.1 tls
33 1.64.60.1 tls
34 1.64.60.1 tls # Old bsd.doc.mk files tend to invoke tbl and other preprocessors
35 1.64.60.1 tls # directly; they should be changed to set ROFF_* instead.
36 1.64.60.1 tls #
37 1.64.60.1 tls # Also they set e.g. DIR=usd/72.mydocument; this should be changed
38 1.64.60.1 tls # to SECTION=usd and ARTICLE=mydocument. The article numbers are
39 1.64.60.1 tls # no longer present in the file system and do not need to be known
40 1.64.60.1 tls # at build time.
41 1.64.60.1 tls #
42 1.64.60.1 tls
43 1.64.60.1 tls # 20130908 dholland: Make sure all makefiles have been converted to the
44 1.64.60.1 tls # new scheme.
45 1.64.60.1 tls .if !defined(SECTION)
46 1.64.60.1 tls .error "bsd.doc.mk: SECTION must be defined"
47 1.64.60.1 tls .endif
48 1.64.60.1 tls .if target(paper.ps)
49 1.64.60.1 tls .error "bsd.doc.mk: target(paper.ps) is true -- this is not allowed"
50 1.64.60.1 tls .endif
51 1.64.60.1 tls
52 1.64.60.1 tls # 20130908 dholland: right now we cannot generate pdf from roff sources,
53 1.64.60.1 tls # so build compressed postscript instead. XXX. (and: yech)
54 1.64.60.1 tls TOOL_ROFF_PDF?=false "No roff pdf support"
55 1.64.60.1 tls PRINTABLE=ps.gz
56 1.64.60.1 tls #PRINTABLE=ps
57 1.64.60.1 tls #PRINTABLE=pdf
58 1.64.60.1 tls
59 1.64.60.1 tls # If there aren't subarticles, we generate one doc that has the same
60 1.64.60.1 tls # name as the top-level article.
61 1.64.60.1 tls SUBARTICLES?=${ARTICLE}
62 1.64.60.1 tls SRCS.${ARTICLE}?=${SRCS}
63 1.64.60.1 tls DEPSRCS.${ARTICLE}?=${DEPSRCS}
64 1.1 cgd
65 1.64.60.1 tls ##### Build
66 1.63 lukem
67 1.64.60.1 tls .for SA in ${SUBARTICLES}
68 1.53 tv .if ${MKDOC} != "no"
69 1.64.60.1 tls realall: ${SA}.txt
70 1.64.60.1 tls realall: ${SA}.${PRINTABLE}
71 1.64.60.1 tls .if ${MKHTML} != "no" && ${MKGROFFHTMLDOC} != "no"
72 1.64.60.1 tls realall: ${SA}.html
73 1.64.60.1 tls .endif
74 1.64.60.1 tls .endif
75 1.64.60.1 tls .endfor # SUBARTICLES
76 1.64.60.1 tls
77 1.64.60.1 tls .if defined(ROFF_PIC) && ${ROFF_PIC} != "no"
78 1.64.60.1 tls ROFFFLAGS+=-p
79 1.64.60.1 tls .endif
80 1.64.60.1 tls .if defined(ROFF_EQN) && ${ROFF_EQN} != "no"
81 1.64.60.1 tls ROFFFLAGS+=-e
82 1.64.60.1 tls .endif
83 1.64.60.1 tls .if defined(ROFF_TBL) && ${ROFF_TBL} != "no"
84 1.64.60.1 tls ROFFFLAGS+=-t
85 1.64.60.1 tls .endif
86 1.64.60.1 tls .if defined(ROFF_REFER) && ${ROFF_REFER} != "no"
87 1.64.60.1 tls ROFFFLAGS+=-R
88 1.64.60.1 tls .endif
89 1.64.60.1 tls ROFFFLAGS+=-I${.CURDIR}
90 1.64.60.1 tls
91 1.64.60.1 tls .for SA in ${SUBARTICLES}
92 1.64.60.1 tls
93 1.64.60.1 tls #
94 1.64.60.1 tls # Find the sources.
95 1.64.60.1 tls #
96 1.64.60.1 tls # We can't use .IMPSRC in the rules because they aren't suffix rules
97 1.64.60.1 tls # (they could be for some docs, but not others) and we can't use
98 1.64.60.1 tls # .ALLSRC because that includes DEPSRCS.
99 1.64.60.1 tls #
100 1.64.60.1 tls # As far as I know, the only ways to get the path discovered via .PATH
101 1.64.60.1 tls # are those two magic variables or the P modifier.
102 1.64.60.1 tls #
103 1.64.60.1 tls # For some reason the P modifier finds the path to a variable name,
104 1.64.60.1 tls # not the path to a word in a variable.
105 1.64.60.1 tls #
106 1.14 mycroft
107 1.64.60.1 tls .for S in ${SRCS.${SA}}
108 1.64.60.1 tls SRCS2.${SA}+=${${S}:P}
109 1.64.60.1 tls .endfor
110 1.64.60.1 tls .for S in ${DEPSRCS.${SA}}
111 1.64.60.1 tls DEPSRCS2.${SA}+=${${S}:P}
112 1.64.60.1 tls .endfor
113 1.46 mycroft
114 1.64.60.1 tls #
115 1.64.60.1 tls # Note: we use TOOL_ROFF_DOCASCII because TOOL_ROFF_ASCII invokes
116 1.64.60.1 tls # the nroff wrapper instead of groff directly, and that doesn't
117 1.64.60.1 tls # understand -I.
118 1.64.60.1 tls #
119 1.64.60.1 tls # We use TOOL_ROFF_DOCHTML because TOOL_ROFF_HTML uses -mdoc2html,
120 1.64.60.1 tls # which is great if it works but doesn't work with at least some of
121 1.64.60.1 tls # the non-mdoc docs. (e.g. the curses one) TOOL_ROFF_DOCHTML uses
122 1.64.60.1 tls # groff -Thtml, which produces fairly blah output but works with these
123 1.64.60.1 tls # docs. It might end up being necessary to choose one or the other on
124 1.64.60.1 tls # a per-document basis... sigh.
125 1.64.60.1 tls #
126 1.46 mycroft
127 1.64.60.1 tls ${SA}.txt: ${SRCS2.${SA}} ${DEPSRCS2.${SA}}
128 1.64.60.1 tls ${_MKTARGET_FORMAT}
129 1.64.60.1 tls ${TOOL_ROFF_DOCASCII} ${ROFFFLAGS} ${MACROS} ${PAGES} ${SRCS2.${SA}} \
130 1.64.60.1 tls > ${.TARGET}
131 1.64.60.1 tls
132 1.64.60.1 tls ${SA}.ps: ${SRCS2.${SA}} ${DEPSRCS2.${SA}}
133 1.64.60.1 tls ${_MKTARGET_FORMAT}
134 1.64.60.1 tls ${TOOL_ROFF_PS} ${ROFFFLAGS} ${MACROS} ${PAGES} ${SRCS2.${SA}} \
135 1.64.60.1 tls > ${.TARGET}
136 1.48 mycroft
137 1.64.60.1 tls ${SA}.pdf: ${SRCS2.${SA}} ${DEPSRCS2.${SA}}
138 1.64.60.1 tls ${_MKTARGET_FORMAT}
139 1.64.60.1 tls ${TOOL_ROFF_PDF} ${ROFFFLAGS} ${MACROS} ${PAGES} ${SRCS2.${SA}} \
140 1.64.60.1 tls > ${.TARGET}
141 1.64.60.1 tls
142 1.64.60.1 tls ${SA}.html: ${SRCS2.${SA}} ${DEPSRCS2.${SA}}
143 1.64.60.1 tls ${_MKTARGET_FORMAT}
144 1.64.60.1 tls ${TOOL_ROFF_DOCHTML} ${ROFFFLAGS} ${MACROS} ${PAGES} ${SRCS2.${SA}} \
145 1.64.60.1 tls -P -I -P ${SA} \
146 1.64.60.1 tls > ${.TARGET}
147 1.64.60.1 tls
148 1.64.60.1 tls ${SA}.ps.gz: ${SA}.ps
149 1.64.60.1 tls ${TOOL_GZIP} -9 -c ${.ALLSRC} > ${.TARGET}
150 1.64.60.1 tls
151 1.64.60.1 tls .endfor # SUBARTICLES
152 1.64.60.1 tls
153 1.64.60.1 tls ##### Install
154 1.64.60.1 tls
155 1.64.60.1 tls DOCINST:=
156 1.64.60.1 tls .for SA in ${SUBARTICLES}
157 1.64.60.1 tls DOCINST+=${SA}.txt ${SA}.${PRINTABLE}
158 1.64.60.1 tls .if ${MKHTML} != "no" && ${MKGROFFHTMLDOC} != "no"
159 1.64.60.1 tls DOCINST+=${SA}.html
160 1.57 mycroft .endif
161 1.64.60.1 tls .endfor
162 1.64.60.1 tls .if ${MKHTML} != "no" && ${MKGROFFHTMLDOC} != "no"
163 1.64.60.1 tls DOCINST+=${EXTRAHTMLFILES}
164 1.23 christos .endif
165 1.64.60.1 tls
166 1.64.60.1 tls .if ${MKDOC} != "no"
167 1.64.60.1 tls docinstall:
168 1.64.60.1 tls .for D in ${DOCINST}
169 1.64.60.1 tls ${_MKTARGET_INSTALL}
170 1.64.60.1 tls ${INSTALL_FILE} -o ${DOCOWN} -g ${DOCGRP} -m ${DOCMODE} ${D} \
171 1.64.60.1 tls ${DESTDIR}${DOCDIR}/${SECTION}/${ARTICLE}/${D}
172 1.64.60.1 tls .endfor
173 1.64.60.1 tls .else
174 1.64.60.1 tls docinstall: ;
175 1.57 mycroft .endif
176 1.57 mycroft
177 1.64.60.1 tls .PHONY: docinstall
178 1.64.60.1 tls realinstall: docinstall
179 1.64.60.1 tls
180 1.64.60.1 tls ##### Clean
181 1.64.60.1 tls
182 1.64.60.1 tls cleandoc:
183 1.64.60.1 tls .for SA in ${SUBARTICLES}
184 1.64.60.1 tls rm -f ${SA}.txt ${SA}.ps ${SA}.ps.gz ${SA}.html
185 1.23 christos .endfor
186 1.64.60.1 tls rm -f ${EXTRAHTMLFILES} [eE]rrs mklog ${CLEANFILES}
187 1.28 mycroft
188 1.64.60.1 tls .PHONY: cleandoc
189 1.64.60.1 tls clean: cleandoc
190 1.53 tv
191 1.64.60.1 tls ##### Extra custom rules
192 1.53 tv
193 1.53 tv .if !target(print)
194 1.64.60.1 tls print: ;
195 1.64.60.1 tls .PHONY: print
196 1.64.60.1 tls .for SA in ${SUBARTICLES}
197 1.64.60.1 tls print: print.${SA}
198 1.64.60.1 tls .PHONY: print.{SA}
199 1.64.60.1 tls print.${SA}: ${SA}.ps
200 1.53 tv lpr -P${PRINTER} ${.ALLSRC}
201 1.64.60.1 tls .endfor
202 1.22 perry .endif
203 1.1 cgd
204 1.64.60.1 tls spell: ;
205 1.64.60.1 tls .PHONY: spell
206 1.64.60.1 tls .for SA in ${SUBARTICLES}
207 1.64.60.1 tls spell: spell.${SA}
208 1.64.60.1 tls .PHONY: spell.{SA}
209 1.64.60.1 tls spell.${SA}: ${SRCS2} ${DEPSRCS2}
210 1.64.60.1 tls spell ${SRCS2} | sort | comm -23 - spell.ok > paper.spell
211 1.64.60.1 tls .endfor
212 1.31 mycroft
213 1.53 tv ##### Pull in related .mk logic
214 1.64.60.1 tls
215 1.53 tv .include <bsd.obj.mk>
216 1.55 bjh21 .include <bsd.sys.mk>
217 1.45 tron
218 1.53 tv ${TARGETS}: # ensure existence
219