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