Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 24 May 2003 12:17:38 +0200
From:      Dag-Erling Smorgrav <des@ofug.org>
To:        Marc Fonvieille <blackend@freebsd.org>
Cc:        doc@freebsd.org
Subject:   Re: doc build with .OBJDIR
Message-ID:  <xzpptm8tzr1.fsf@flood.ping.uio.no>
In-Reply-To: <20030524085738.GB806@nosferatu.blackend.org> (Marc Fonvieille's message of "Sat, 24 May 2003 10:57:38 %2B0200")
References:  <xzp1xyqzjxg.fsf@flood.ping.uio.no> <20030523015453.GF92953@nitro.dk> <xzphe7mxudr.fsf@flood.ping.uio.no> <xzpd6iaxua1.fsf@flood.ping.uio.no> <20030523141349.GF402@nitro.dk> <20030523203245.GG3794@nosferatu.blackend.org> <20030524085738.GB806@nosferatu.blackend.org>

next in thread | previous in thread | raw e-mail | index | archive | help
--=-=-=

Marc Fonvieille <blackend@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@ofug.org


--=-=-=
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: attachment; filename=document.mk
Content-Transfer-Encoding: quoted-printable

#!/usr/bin/make -f
#-
# Copyright (c) 2002 Dag-Erling Co=EFdan Sm=F8rgrav
# 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		?=3D html dvi
PAPER_TYPE	?=3D A4
DOCBASE		?=3D .
DOCBOOK_BASE	?=3D /usr/local/share/xsl/docbook
DOCBOOK_XHTML	?=3D ${DOCBOOK_BASE}/xhtml/docbook.xsl
DOCBOOK_FO	?=3D ${DOCBOOK_BASE}/fo/docbook.xsl
CATALOG_FILES	+=3D /usr/local/share/xml/catalog
.if exists(${.CURDIR}/catalog)
CATALOG_FILES	+=3D ${.CURDIR}/catalog
.endif
XSLTENV		?=3D SGML_CATALOG_FILES=3D"${CATALOG_FILES:S/ /:/g}"
XSLTPROC	?=3D env ${XSLTENV} xsltproc
XMLLINT		?=3D env ${XSLTENV} xmllint
TIDY		?=3D tidy
TIDYFLAGS	?=3D -indent -wrap 76 -raw -quiet -preserve -xml
FOP		?=3D fop
LATEX		?=3D latex --interaction nonstopmode
LATEX_EXTLIST	?=3D .aux .log .toc .lof .lot .idx
BIBTEX		?=3D bibtex
DVIPS		?=3D dvips
PS2PDF		?=3D ps2pdf

XSLT_PARAMS	+=3D author.othername.in.middle=3D"1"
.ifdef HTML_STYLESHEET
XSLT_PARAMS	+=3D html.stylesheet=3D"'${HTML_STYLESHEET}'"
.endif
.ifdef SECTION_AUTOLABEL
XSLT_PARAMS	+=3D section.autolabel=3D"1"
.endif
XSLT_PARAMS	+=3D toc.section.depth=3D"3"
XSLT_PARAMS	+=3D make.year.ranges=3D"1"
XSLT_PARAMS	+=3D paper.type=3D"'${PAPER_TYPE}'"

XSLT_PARAM_ARGS	 =3D ${XSLT_PARAMS:S/^/--param /:S/=3D/ /}

SRCS		 =3D
HTML		 =3D
DVI		 =3D
.for document in ${DOCUMENTS}

.if exists(${document}.xml)
SRCS		+=3D ${document}.xml
.if !empty(FORMATS:Mhtml)
HTML		+=3D ${document}.html
TARGETS		+=3D ${document}.html
.endif
.if !empty(FORMATS:Mpdf)
PDF		+=3D ${document}.pdf
TARGETS		+=3D ${document}.pdf
CLEANFILES	+=3D ${document}.fo
.endif
.endif

.if exists(${document}.tex)
SRCS		+=3D ${document}.tex
.for ext in ${LATEX_EXTLIST}
CLEANFILES	+=3D ${document}${ext}
.endfor
.if !empty(FORMATS:Mdvi)
DVI		+=3D ${document}.dvi
TARGETS		+=3D ${document}.dvi
.endif
.if !empty(FORMATS:Mpdf)
PDF		+=3D ${document}.pdf
TARGETS		+=3D ${document}.pdf
CLEANFILES	+=3D ${document}.dvi ${document}.ps
.endif
.if exists(${document}.bib)
${document}.dvi: ${document}.tex ${document}.bib
.endif
.endif

.endfor

CLEANFILES	+=3D ${TARGETS}

.MAIN: all

depend all install clean:
	@${MAKE} do-${.TARGET}
.for subdir in ${SUBDIR}
	@echo "=3D=3D=3D> ${DIRPREFIX}${subdir} [${.TARGET}]"
	@(cd ${subdir} && ${MAKE} ${.TARGET} DIRPREFIX=3D"${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=3D`cksum ${.TARGET:.dvi=3D.aux}`; \
	    ${LATEX} ${.IMPSRC} && \
		if [ -f ${.IMPSRC:R}.bib ] ; then \
		    ${BIBTEX} ${.IMPSRC:R}; \
		fi && \
		if [ "$$sum" !=3D "`cksum ${.TARGET:.dvi=3D.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} !=3D NO && ${TIDY} !=3D no
	@perl -p -i -e 's/(?<!html) xmlns=3D"[^\"]+"//g' $@
	${TIDY} ${TIDYFLAGS} -m $@
.endif

.xml.fo: ${DOCBOOK_FO}
	${XSLTPROC} -o ${.TARGET} ${XSLT_PARAM_ARGS} --catalogs\
	    ${DOCBOOK_FO} ${.IMPSRC}

.fo.pdf:
	${FOP} ${.IMPSRC} ${.TARGET}

--=-=-=--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?xzpptm8tzr1.fsf>