2 # $DragonFly: doc/share/mk/doc.html.mk,v 1.2 2006/08/06 20:58:06 justin Exp $
4 # This include file <doc.html.mk> handles building and installing of
5 # HTML documentation in the DragonFlyBSD Documentation Project.
7 # Documentation using DOCFORMAT=html is expected to be marked up
8 # according to the HTML DTD
11 # ------------------------------------------------------------------------
13 # Document-specific variables
15 # DOC This should be set to the name of the HTML
16 # marked-up file, without the .sgml or .docb suffix.
18 # It also determins the name of the output files -
21 # DOCBOOKSUFFIX The suffix of your document, defaulting to .sgml
23 # SRCS The names of all the files that are needed to
24 # build this document - This is useful if any of
25 # them need to be generated. Changing any file in
26 # SRCS causes the documents to be rebuilt.
29 # ------------------------------------------------------------------------
31 # Variables used by both users and documents:
33 # TIDYFLAGS Additional flags to pass to Tidy. Typically
34 # used to set "-raw" flag to handle 8bit characters.
36 # EXTRA_CATALOGS Additional catalog files that should be used by
37 # any SGML processing applications.
39 # NO_TIDY If you do not want to use tidy, set this to "YES".
41 # Documents should use the += format to access these.
44 MASTERDOC?= ${.CURDIR}/${DOC}.sgml
46 KNOWN_FORMATS= html txt tar pdb
50 HTMLCATALOG= ${PREFIX}/share/sgml/html/catalog
54 .if ${MACHINE_ARCH} != "i386"
59 NSGMLS?= ${PREFIX}/bin/onsgmls
60 SGMLNORM?= ${PREFIX}/bin/osgmlnorm
62 NSGMLS?= ${PREFIX}/bin/nsgmls
63 SGMLNORM?= ${PREFIX}/bin/sgmlnorm
66 PKG_CREATE?= /usr/sbin/pkg_create
68 XARGS?= /usr/bin/xargs
70 # for now disable TIDY for compatibility reasons
72 TIDY?= ${PREFIX}/bin/tidy
73 TIDYOPTS?= -i -m -raw -preserve -f /dev/null -asxml ${TIDYFLAGS}
74 HTML2PDB?= ${PREFIX}/bin/iSiloBSD
75 HTML2PDBOPTS?= -y -d0 -Idef ${HTML2PDBFLAGS}
78 GZIP_CMD?= gzip -qf ${GZIP}
80 BZIP2_CMD?= bzip2 -qf ${BZIP2}
82 ZIP_CMD?= ${PREFIX}/bin/zip -j ${ZIP}
85 # ------------------------------------------------------------------------
88 .if ${.OBJDIR} != ${.CURDIR}
89 LOCAL_CSS_SHEET= ${.OBJDIR}/${CSS_SHEET:T}
90 CLEANFILES+= ${LOCAL_CSS_SHEET}
92 LOCAL_CSS_SHEET= ${CSS_SHEET:T}
95 .for _curformat in ${FORMATS}
98 # Create a 'bogus' doc for any format we support or not. This is so
99 # that we can fake up a target for it later on, and this target can print
100 # the warning message about the unsupported format.
101 _docs+= ${DOC}.${_curformat}
102 CLEANFILES+= ${DOC}.${_curformat}
103 CLEANFILES+= PLIST.${_curformat}
106 .if ${LOCAL_CSS_SHEET} != ${CSS_SHEET}
107 CLEANFILES+= ${LOCAL_CSS_SHEET}
110 .elif ${_cf} == "txt"
111 CLEANFILES+= ${DOC}.html
113 .elif ${_cf} == "pdb"
114 _docs+= ${.CURDIR:T}.pdb
115 CLEANFILES+= ${.CURDIR:T}.pdb
121 # Build a list of install-${format}.${compress_format} targets to be
122 # by "make install". Also, add ${DOC}.${format}.${compress_format} to
123 # ${_docs} and ${CLEANFILES} so they get built/cleaned by "all" and
127 .if defined(INSTALL_COMPRESSED) && !empty(INSTALL_COMPRESSED)
128 .for _curformat in ${FORMATS}
130 .for _curcomp in ${INSTALL_COMPRESSED}
132 .if ${_cf} != "html-split"
133 _curinst+= install-${_curformat}.${_curcomp}
134 _docs+= ${DOC}.${_curformat}.${_curcomp}
135 CLEANFILES+= ${DOC}.${_curformat}.${_curcomp}
138 _docs+= ${.CURDIR:T}.${_curformat}.${_curcomp}
139 CLEANFILES+= ${.CURDIR:T}.${_curformat}.${_curcomp}
151 ${DOC}.html: ${SRCS} ${LOCAL_IMAGES_LIB} ${LOCAL_IMAGES_PNG} ${LOCAL_CSS_SHEET}
152 ${SGMLNORM} -c ${HTMLCATALOG} ${SRCS:S|^|${.CURDIR}/|} > ${.TARGET}
153 .if !defined(NO_TIDY)
154 -${TIDY} ${TIDYOPTS} ${.TARGET}
157 ${DOC}.txt: ${DOC}.html
158 ${HTML2TXT} ${HTML2TXTOPTS} ${.ALLSRC} > ${.TARGET}
160 ${DOC}.pdb: ${DOC}.html ${LOCAL_IMAGES_LIB} ${LOCAL_IMAGES_PNG}
161 ${HTML2PDB} ${HTML2PDBOPTS} ${DOC}.html ${.TARGET}
163 ${.CURDIR:T}.pdb: ${DOC}.pdb
164 ${LN} -f ${.ALLSRC} ${.TARGET}
166 .if defined(INSTALL_COMPRESSED) && !empty(INSTALL_COMPRESSED)
167 .for _curcomp in ${INSTALL_COMPRESSED}
168 ${.CURDIR:T}.pdb.${_curcomp}: ${DOC}.pdb.${_curcomp}
169 ${LN} -f ${.ALLSRC} ${.TARGET}
173 ${DOC}.tar: ${SRCS} ${LOCAL_IMAGES} ${LOCAL_CSS_SHEET}
174 ${TAR} cf ${.TARGET} -C ${.CURDIR} ${SRCS} \
175 -C ${.OBJDIR} ${IMAGES} ${CSS_SHEET:T}
178 # Build targets for any formats we've missed that we don't handle.
180 .for _curformat in ${ALL_FORMATS}
181 .if !target(${DOC}.${_curformat})
182 ${DOC}.${_curformat}:
183 @${ECHO_CMD} \"${_curformat}\" is not a valid output format for this document.
188 # ------------------------------------------------------------------------
194 # Lets you quickly check that the document conforms to the DTD without
195 # having to convert it to any other formats
199 ${NSGMLS} -s -c ${HTMLCATALOG} ${MASTERDOC}
202 # ------------------------------------------------------------------------
208 # The list of compression extensions this Makefile knows about. If you
209 # add new compression schemes, add to this list (which is a list of
210 # extensions, hence bz2, *not* bzip2) and extend the _PROG_COMPRESS_*
214 KNOWN_COMPRESS= gz bz2 zip
217 # You can't build suffix rules to do compression, since you can't
218 # wildcard the source suffix. So these are defined .USE, to be tacked on
219 # as dependencies of the compress-* targets.
222 _PROG_COMPRESS_gz: .USE
223 ${GZIP_CMD} < ${.ALLSRC} > ${.TARGET}
225 _PROG_COMPRESS_bz2: .USE
226 ${BZIP2_CMD} < ${.ALLSRC} > ${.TARGET}
228 _PROG_COMPRESS_zip: .USE
229 ${ZIP_CMD} ${.TARGET} ${.ALLSRC}
232 # Build a list of targets for each compression scheme and output format.
233 # Don't compress the html-split output format.
235 .for _curformat in ${KNOWN_FORMATS}
237 .for _curcompress in ${KNOWN_COMPRESS}
238 ${DOC}.${_cf}.${_curcompress}: ${DOC}.${_cf} _PROG_COMPRESS_${_curcompress}
243 # Build targets for any formats we've missed that we don't handle.
245 .for _curformat in ${ALL_FORMATS}
246 .for _curcompress in ${KNOWN_COMPRESS}
247 .if !target(${DOC}.${_curformat}.${_curcompress})
248 ${DOC}.${_curformat}.${_curcompress}:
249 @${ECHO_CMD} \"${_curformat}.${_curcompress}\" is not a valid output format for this document.
255 # ------------------------------------------------------------------------
259 # Build install-* targets, one per allowed value in FORMATS.
261 # "beforeinstall" and "afterinstall" are hooks in to this process.
262 # Redefine them to do things before and after the files are installed,
266 # Build a list of install-format targets to be installed. These will be
267 # dependencies for the "realinstall" target.
270 .if !defined(INSTALL_ONLY_COMPRESSED) || empty(INSTALL_ONLY_COMPRESSED)
271 _curinst+= ${FORMATS:S/^/install-/g}
274 realinstall: ${_curinst}
276 .for _curformat in ${KNOWN_FORMATS}
278 .if !target(install-${_cf})
279 install-${_curformat}: ${DOC}.${_curformat}
280 @[ -d ${DESTDIR} ] || ${MKDIR} -p ${DESTDIR}
281 ${INSTALL_DOCS} ${.ALLSRC} ${DESTDIR}
282 .if !empty(CSS_SHEET)
283 ${INSTALL_DOCS} ${CSS_SHEET} ${DESTDIR}
285 .for _curimage in ${IMAGES_LIB}
286 @[ -d ${DESTDIR}/${LOCAL_IMAGES_LIB_DIR}/${_curimage:H} ] || \
287 ${MKDIR} -p ${DESTDIR}/${LOCAL_IMAGES_LIB_DIR}/${_curimage:H}
288 ${INSTALL_DOCS} ${LOCAL_IMAGES_LIB_DIR}/${_curimage} \
289 ${DESTDIR}/${LOCAL_IMAGES_LIB_DIR}/${_curimage:H}
291 # Install the images. First, loop over all the image names that contain a
292 # directory separator, make the subdirectories, and install. Then loop over
293 # the ones that don't contain a directory separator, and install them in the
295 .for _curimage in ${IMAGES_PNG:M*/*:M*share*}
296 ${MKDIR} -p ${DESTDIR:H:H}/${_curimage:H:S|${IMAGES_EN_DIR}/||:S|${.CURDIR}||}
297 ${INSTALL_DOCS} ${_curimage} ${DESTDIR:H:H}/${_curimage:H:S|${IMAGES_EN_DIR}/||:S|${.CURDIR}||}
299 .for _curimage in ${IMAGES_PNG:N*/*}
300 ${INSTALL_DOCS} ${.CURDIR}/${_curimage} ${DESTDIR}
303 ${LN} -f ${DESTDIR}/${.ALLSRC} ${DESTDIR}/${.CURDIR:T}.${_curformat}
306 .for _compressext in ${KNOWN_COMPRESS}
307 install-${_cf}.${_compressext}: ${DOC}.${_cf}.${_compressext}
308 @[ -d ${DESTDIR} ] || ${MKDIR} -p ${DESTDIR}
309 ${INSTALL_DOCS} ${.ALLSRC} ${DESTDIR}
315 # Build install- targets for any formats we've missed that we don't handle.
318 .for _curformat in ${ALL_FORMATS}
319 .if !target(install-${_curformat})
320 install-${_curformat}:
321 @${ECHO_CMD} \"${_curformat}\" is not a valid output format for this document.
323 .for _compressext in ${KNOWN_COMPRESS}
324 install-${_curformat}.${_compressext}:
325 @${ECHO_CMD} \"${_curformat}.${_compressext}\" is not a valid output format for this document.
331 # ------------------------------------------------------------------------
337 # realpackage is what is called in each subdirectory when a package
338 # target is called, or, rather, package calls realpackage in each
339 # subdirectory as it goes.
341 # packagelist returns the list of targets that would be called during
345 realpackage: ${FORMATS:S/^/package-/}
347 @${ECHO_CMD} ${FORMATS:S/^/package-/}
350 # Build a list of package targets for each output target. Each package
351 # target depends on the corresponding install target running.
354 .for _curformat in ${KNOWN_FORMATS}
356 PLIST.${_curformat}: ${DOC}.${_curformat}
357 @${ECHO_CMD} ${DOC}.${_curformat} > PLIST.${_curformat}
358 .if ${_cf} == "html" && \
359 (!empty(LOCAL_IMAGES_LIB) || !empty(IMAGES_PNG) || !empty(CSS_SHEET))
360 @${ECHO_CMD} ${LOCAL_IMAGES_LIB} ${IMAGES_PNG} ${CSS_SHEET} | \
361 ${XARGS} -n1 >> PLIST.${_curformat}
362 .elif ${_cf} == "pdb"
363 @${ECHO_CMD} ${.CURDIR:T}.${_curformat} >> PLIST.${_curformat}
366 ${PACKAGES}/${.CURDIR:T}.${LANGCODE}.${_curformat}.tgz: PLIST.${_curformat}
367 @${PKG_CREATE} -v -f PLIST.${_curformat} -p ${DESTDIR} -s ${.OBJDIR} \
368 -c -"FDP ${.CURDIR:T} ${_curformat} package" \
369 -d -"FDP ${.CURDIR:T} ${_curformat} package" ${.TARGET}
371 package-${_curformat}: ${PACKAGES}/${.CURDIR:T}.${LANGCODE}.${_curformat}.tgz
375 # Build install- targets for any formats we've missed that we don't handle.
378 .for _curformat in ${ALL_FORMATS}
379 .if !target(package-${_curformat})
380 package-${_curformat}:
381 @${ECHO_CMD} \"${_curformat}\" is not a valid output format for this document.
385 .if ${LOCAL_CSS_SHEET} != ${CSS_SHEET}
386 ${LOCAL_CSS_SHEET}: ${CSS_SHEET}
387 ${CP} -p ${.ALLSRC} ${.TARGET}