]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/mk/bsd.doc.mk
MFH r289384-r293170
[FreeBSD/FreeBSD.git] / share / mk / bsd.doc.mk
1 #       from: @(#)bsd.doc.mk    5.3 (Berkeley) 1/2/91
2 # $FreeBSD$
3 #
4 # The include file <bsd.doc.mk> handles installing BSD troff documents.
5 #
6 #
7 # +++ variables +++
8 #
9 # DCOMPRESS_CMD Program to compress troff documents.  Output is to stdout.
10 #               [${COMPRESS_CMD}]
11 #
12 # DESTDIR       Change the tree where the documents get installed.  [not set]
13 #
14 # DOC           Document name.  [paper]
15 #
16 # EXTRA         Extra files (not SRCS) that make up the document.  [not set]
17 #
18 # LPR           Printer command.  [lpr]
19 #
20 # MACROS        Macro packages used to build the document.  [not set]
21 #
22 # WITHOUT_DOCCOMPRESS If you do not want formatted troff documents to be
23 #               compressed when they are installed.  [not set]
24 #
25 # PRINTERDEVICE Indicates which output formats will be generated
26 #               (ascii, ps, html).  [ascii]
27 #
28 # SRCDIR        Directory where source files live.  [${.CURDIR}]
29 #
30 # SRCS          List of source files.  [not set]
31 #
32 # TRFLAGS       Additional flags to groff(1).  [not set]
33 #
34 # USE_EQN       If set, preprocess with eqn(1).  [not set]
35 #
36 # USE_PIC       If set, preprocess with pic(1).  [not set]
37 #
38 # USE_REFER     If set, preprocess with refer(1).  [not set]
39 #
40 # USE_SOELIM    If set, preprocess with soelim(1).  [not set]
41 #
42 # USE_TBL       If set, preprocess with tbl(1).  [not set]
43 #
44 # VOLUME        Volume the document belongs to.  [not set]
45
46 .include <bsd.init.mk>
47
48 PRINTERDEVICE?= ascii
49
50 BIB?=           bib
51 GREMLIN?=       grn
52 GRIND?=         vgrind -f
53 INDXBIB?=       indxbib
54 PIC?=           pic
55 REFER?=         refer
56 .for _dev in ${PRINTERDEVICE:Mascii}
57 ROFF.ascii?=    groff -Tascii -P-c ${TRFLAGS} -mtty-char ${MACROS} ${PAGES:C/^/-o/1}
58 .endfor
59 .for _dev in ${PRINTERDEVICE:Nascii}
60 ROFF.${_dev}?=  groff -T${_dev} ${TRFLAGS} ${MACROS} ${PAGES:C/^/-o/1}
61 .endfor
62 SOELIM?=        soelim
63 TBL?=           tbl
64
65 DOC?=           paper
66 LPR?=           lpr
67
68 .if defined(USE_EQN)
69 TRFLAGS+=       -e
70 .endif
71 .if defined(USE_PIC)
72 TRFLAGS+=       -p
73 .endif
74 .if defined(USE_REFER)
75 TRFLAGS+=       -R
76 .endif
77 .if defined(USE_SOELIM)
78 TRFLAGS+=       -I${.CURDIR}
79 .endif
80 .if defined(USE_TBL)
81 TRFLAGS+=       -t
82 .endif
83
84 .if defined(NO_ROOT)
85 .if !defined(TAGS) || ! ${TAGS:Mpackage=*}
86 TAGS+=          package=${PACKAGE:Uruntime}
87 .endif
88 TAG_ARGS=       -T ${TAGS:[*]:S/ /,/g}
89 .endif
90
91 DCOMPRESS_EXT?= ${COMPRESS_EXT}
92 DCOMPRESS_CMD?= ${COMPRESS_CMD}
93 .for _dev in ${PRINTERDEVICE:Mhtml}
94 DFILE.html=     ${DOC}.html
95 .endfor
96 .for _dev in ${PRINTERDEVICE:Nhtml}
97 .if ${MK_DOCCOMPRESS} == "no"
98 DFILE.${_dev}=  ${DOC}.${_dev}
99 .else
100 DFILE.${_dev}=  ${DOC}.${_dev}${DCOMPRESS_EXT}
101 .endif
102 .endfor
103
104 UNROFF?=        unroff
105 HTML_SPLIT?=    yes
106 UNROFFFLAGS?=   -fhtml
107 .if ${HTML_SPLIT} == "yes"
108 UNROFFFLAGS+=   split=1
109 .endif
110
111 # Compatibility mode flag for groff.  Use this when formatting documents with
112 # Berkeley me macros (orig_me(7)).
113 COMPAT?=        -C
114
115 .PATH: ${.CURDIR} ${SRCDIR}
116
117 .for _dev in ${PRINTERDEVICE}
118 all: ${DFILE.${_dev}}
119 .endfor
120
121 .if !target(print)
122 .for _dev in ${PRINTERDEVICE}
123 print: ${DFILE.${_dev}}
124 .endfor
125 print:
126 .for _dev in ${PRINTERDEVICE}
127 .if ${MK_DOCCOMPRESS} == "no"
128         ${LPR} ${DFILE.${_dev}}
129 .else
130         ${DCOMPRESS_CMD} -d ${DFILE.${_dev}} | ${LPR}
131 .endif
132 .endfor
133 .endif
134
135 .for _dev in ${PRINTERDEVICE:Nascii:Nps:Nhtml}
136 CLEANFILES+=    ${DOC}.${_dev} ${DOC}.${_dev}${DCOMPRESS_EXT}
137 .endfor
138 CLEANFILES+=    ${DOC}.ascii ${DOC}.ascii${DCOMPRESS_EXT} \
139                 ${DOC}.ps ${DOC}.ps${DCOMPRESS_EXT} \
140                 ${DOC}.html ${DOC}-*.html
141
142 realinstall:
143 .if ${PRINTERDEVICE:Mhtml}
144         cd ${SRCDIR}; \
145         ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},docs} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
146             ${DOC}*.html ${DESTDIR}${BINDIR}/${VOLUME}/
147 .endif
148 .for _dev in ${PRINTERDEVICE:Nhtml}
149         ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},docs} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE} \
150             ${DFILE.${_dev}} ${DESTDIR}${BINDIR}/${VOLUME}/
151 .endfor
152
153 spell: ${SRCS}
154         (cd ${.CURDIR}; spell ${SRCS} ) | sort | \
155                 comm -23 - ${.CURDIR}/spell.ok > ${DOC}.spell
156
157 BINDIR?=        /usr/share/doc
158 BINMODE=        444
159
160 SRCDIR?=        ${.CURDIR}
161
162 .if defined(EXTRA) && !empty(EXTRA)
163 _stamp.extra: ${EXTRA}
164         touch ${.TARGET}
165 .endif
166
167 CLEANFILES+=    _stamp.extra
168 .for _dev in ${PRINTERDEVICE:Nhtml}
169 .if !target(${DFILE.${_dev}})
170 .if target(_stamp.extra)
171 ${DFILE.${_dev}}: _stamp.extra
172 .endif
173 ${DFILE.${_dev}}: ${SRCS}
174 .if ${MK_DOCCOMPRESS} == "no"
175         ${ROFF.${_dev}} ${.ALLSRC:N_stamp.extra} > ${.TARGET}
176 .else
177         ${ROFF.${_dev}} ${.ALLSRC:N_stamp.extra} | ${DCOMPRESS_CMD} > ${.TARGET}
178 .endif
179 .endif
180 .endfor
181
182 .for _dev in ${PRINTERDEVICE:Mhtml}
183 .if !target(${DFILE.html})
184 .if target(_stamp.extra)
185 ${DFILE.html}: _stamp.extra
186 .endif
187 ${DFILE.html}: ${SRCS}
188 .if defined(MACROS) && !empty(MACROS)
189         cd ${SRCDIR}; ${UNROFF} ${MACROS} ${UNROFFFLAGS} \
190             document=${DOC} ${SRCS}
191 .else # unroff(1) requires a macro package as an argument
192         cd ${SRCDIR}; ${UNROFF} -ms ${UNROFFFLAGS} \
193             document=${DOC} ${SRCS}
194 .endif
195 .endif
196 .endfor
197
198 DISTRIBUTION?=  doc
199
200 .include <bsd.obj.mk>