doc build with .OBJDIR
Dag-Erling Smorgrav
des at ofug.org
Sat May 24 10:17:43 UTC 2003
Marc Fonvieille <blackend at freebsd.org> writes:
> Well, nothing is easy, our .mk files are very "hairy" cause of multiples
> add-ons etc. All the thing should be rewritten from the beginning, but
> who would be enough "crazy" to take that task? :))
A rewrite is definitely needed. That would also be a good occasion to
transition from SGML to XML, if at all possible (XML tools are a
couple of orders of magnitude faster than SGML tools...)
As for images, the obvious solution (to me) is to start by recursing
into share/images and build all images there before building the
documents themselves.
For the curious, I've attached my document.mk which I use for pretty
much everything I produce outside the FreeBSD doc tree. It's the nth
generation of something I originally wrote for ThinkSec way back when.
Not a doc.project.mk replacement, but a different take on a similar
theme.
DES
--
Dag-Erling Smorgrav - des at ofug.org
-------------- next part --------------
#!/usr/bin/make -f
#-
# Copyright (c) 2002 Dag-Erling Co?dan Sm?rgrav
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer
# in this position and unchanged.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. The name of the author may not be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# $Id: document.mk,v 1.6 2002/11/08 21:15:28 des Exp $
#
FORMATS ?= html dvi
PAPER_TYPE ?= A4
DOCBASE ?= .
DOCBOOK_BASE ?= /usr/local/share/xsl/docbook
DOCBOOK_XHTML ?= ${DOCBOOK_BASE}/xhtml/docbook.xsl
DOCBOOK_FO ?= ${DOCBOOK_BASE}/fo/docbook.xsl
CATALOG_FILES += /usr/local/share/xml/catalog
.if exists(${.CURDIR}/catalog)
CATALOG_FILES += ${.CURDIR}/catalog
.endif
XSLTENV ?= SGML_CATALOG_FILES="${CATALOG_FILES:S/ /:/g}"
XSLTPROC ?= env ${XSLTENV} xsltproc
XMLLINT ?= env ${XSLTENV} xmllint
TIDY ?= tidy
TIDYFLAGS ?= -indent -wrap 76 -raw -quiet -preserve -xml
FOP ?= fop
LATEX ?= latex --interaction nonstopmode
LATEX_EXTLIST ?= .aux .log .toc .lof .lot .idx
BIBTEX ?= bibtex
DVIPS ?= dvips
PS2PDF ?= ps2pdf
XSLT_PARAMS += author.othername.in.middle="1"
.ifdef HTML_STYLESHEET
XSLT_PARAMS += html.stylesheet="'${HTML_STYLESHEET}'"
.endif
.ifdef SECTION_AUTOLABEL
XSLT_PARAMS += section.autolabel="1"
.endif
XSLT_PARAMS += toc.section.depth="3"
XSLT_PARAMS += make.year.ranges="1"
XSLT_PARAMS += paper.type="'${PAPER_TYPE}'"
XSLT_PARAM_ARGS = ${XSLT_PARAMS:S/^/--param /:S/=/ /}
SRCS =
HTML =
DVI =
.for document in ${DOCUMENTS}
.if exists(${document}.xml)
SRCS += ${document}.xml
.if !empty(FORMATS:Mhtml)
HTML += ${document}.html
TARGETS += ${document}.html
.endif
.if !empty(FORMATS:Mpdf)
PDF += ${document}.pdf
TARGETS += ${document}.pdf
CLEANFILES += ${document}.fo
.endif
.endif
.if exists(${document}.tex)
SRCS += ${document}.tex
.for ext in ${LATEX_EXTLIST}
CLEANFILES += ${document}${ext}
.endfor
.if !empty(FORMATS:Mdvi)
DVI += ${document}.dvi
TARGETS += ${document}.dvi
.endif
.if !empty(FORMATS:Mpdf)
PDF += ${document}.pdf
TARGETS += ${document}.pdf
CLEANFILES += ${document}.dvi ${document}.ps
.endif
.if exists(${document}.bib)
${document}.dvi: ${document}.tex ${document}.bib
.endif
.endif
.endfor
CLEANFILES += ${TARGETS}
.MAIN: all
depend all install clean:
@${MAKE} do-${.TARGET}
.for subdir in ${SUBDIR}
@echo "===> ${DIRPREFIX}${subdir} [${.TARGET}]"
@(cd ${subdir} && ${MAKE} ${.TARGET} DIRPREFIX="${DIRPREFIX}${subdir}/")
.endfor
.if !target(do-depend)
do-depend: ${SRCS}
.endif
.if !target(do-all)
do-all: ${TARGETS}
.endif
.if !target(do-install)
do-install:
.endif
.if !target(do-clean)
do-clean:
.if !empty(CLEANFILES)
rm -f ${CLEANFILES}
.endif
.endif
.SUFFIXES:
.SUFFIXES: .tex .dvi .xml .html .fo .ps .pdf
.tex.dvi:
sh -c 'sum=`cksum ${.TARGET:.dvi=.aux}`; \
${LATEX} ${.IMPSRC} && \
if [ -f ${.IMPSRC:R}.bib ] ; then \
${BIBTEX} ${.IMPSRC:R}; \
fi && \
if [ "$$sum" != "`cksum ${.TARGET:.dvi=.aux}`" ]; then \
${LATEX} ${.IMPSRC}; \
fi'
.dvi.ps:
${DVIPS} -o ${.TARGET} ${.IMPSRC}
.ps.pdf:
${PS2PDF} ${.IMPSRC} ${.TARGET}
.xml.html: ${DOCBOOK_XHTML}
${XSLTPROC} -o ${.TARGET} ${XSLT_PARAM_ARGS} --catalogs\
${DOCBOOK_XHTML} ${.IMPSRC}
.if defined(TIDY) && ${TIDY} != NO && ${TIDY} != no
@perl -p -i -e 's/(?<!html) xmlns="[^\"]+"//g' $@
${TIDY} ${TIDYFLAGS} -m $@
.endif
.xml.fo: ${DOCBOOK_FO}
${XSLTPROC} -o ${.TARGET} ${XSLT_PARAM_ARGS} --catalogs\
${DOCBOOK_FO} ${.IMPSRC}
.fo.pdf:
${FOP} ${.IMPSRC} ${.TARGET}
More information about the freebsd-doc
mailing list