xref: /freebsd/contrib/bmake/mk/rst2htm.mk (revision 783d3ff6)
1# SPDX-License-Identifier: BSD-2-Clause
2#
3# $Id: rst2htm.mk,v 1.15 2024/02/17 17:26:57 sjg Exp $
4#
5#	@(#) Copyright (c) 2009, Simon J. Gerraty
6#
7#	This file is provided in the hope that it will
8#	be of use.  There is absolutely NO WARRANTY.
9#	Permission to copy, redistribute or otherwise
10#	use this file is hereby granted provided that
11#	the above copyright notice and this notice are
12#	left intact.
13#
14#	Please send copies of changes and bug-fixes to:
15#	sjg@crufty.net
16#
17
18# convert reStructuredText to HTML, using rst2html.py from
19# docutils - http://docutils.sourceforge.net/
20
21# pickup customizations
22.-include <local.rst2htm.mk>
23
24.if empty(TXTSRCS)
25TXTSRCS != 'ls' -1t ${.CURDIR}/*.txt ${.CURDIR}/*.rst 2>/dev/null; echo
26.endif
27RSTSRCS ?= ${TXTSRCS}
28HTMFILES ?= ${RSTSRCS:R:T:O:u:%=%.htm}
29PDFFILES ?= ${RSTSRCS:R:T:O:u:%=%.pdf}
30# can be empty, 4 or 5
31HTML_VERSION ?=
32RST2HTML ?= rst2html${HTML_VERSION}.py
33RST2PDF ?= rst2pdf
34RST2S5 ?= rst2s5.py
35# the following will run RST2S5 if the target name contains the word 'slides'
36# otherwise it uses RST2HTML
37RST2HTM = ${"${.TARGET:T:M*slides*}":?${RST2S5}:${RST2HTML}}
38RST2HTM_SLIDES_FLAGS ?= ${RST2S5_FLAGS}
39RST2HTM_DOC_FLAGS ?= ${RST2HTML_FLAGS}
40RST2HTM_FLAGS ?= ${"${.TARGET:T:M*slides*}":?${RST2HTM_SLIDES_FLAGS}:${RST2HTM_DOC_FLAGS}}
41
42RST2PDF_FLAGS ?= ${"${.TARGET:T:M*slides*}":?${RST2PDF_SLIDES_FLAGS}:${RST2PDF_DOC_FLAGS}}
43
44RST_SUFFIXES ?= .rst .txt
45
46CLEANFILES += ${HTMFILES} ${PDFFILES}
47
48html:	${HTMFILES}
49pdf:	${PDFFILES}
50
51.SUFFIXES: ${RST_SUFFIXES} .htm .pdf
52
53${RST_SUFFIXES:@s@$s.htm@}:
54	${RST2HTM} ${RST2HTM_FLAGS} ${FLAGS.${.TARGET}} ${.IMPSRC} ${.TARGET}
55
56${RST_SUFFIXES:@s@$s.pdf@}:
57	${RST2PDF} ${RST2PDF_FLAGS} ${FLAGS.${.TARGET}} ${.IMPSRC} ${.TARGET}
58
59.for s in ${RSTSRCS:O:u}
60${s:R:T}.htm: $s
61${s:R:T}.pdf: $s
62.endfor
63