xref: /dragonfly/contrib/bmake/mk/rst2htm.mk (revision f9993810)
1# $Id: rst2htm.mk,v 1.12 2021/05/26 04:20:31 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.if empty(TXTSRCS)
20TXTSRCS != 'ls' -1t ${.CURDIR}/*.txt ${.CURDIR}/*.rst 2>/dev/null; echo
21.endif
22RSTSRCS ?= ${TXTSRCS}
23HTMFILES ?= ${RSTSRCS:R:T:O:u:%=%.htm}
24# can be empty, 4 or 5
25HTML_VERSION ?=
26RST2HTML ?= rst2html${HTML_VERSION}.py
27RST2PDF ?= rst2pdf
28RST2S5 ?= rst2s5.py
29# the following will run RST2S5 if the target name contains the word 'slides'
30# otherwise it uses RST2HTML
31RST2HTM = ${"${.TARGET:T:M*slides*}":?${RST2S5}:${RST2HTML}}
32RST2HTM_SLIDES_FLAGS ?= ${RST2S5_FLAGS}
33RST2HTM_DOC_FLAGS ?= ${RST2HTML_FLAGS}
34RST2HTM_FLAGS ?= ${"${.TARGET:T:M*slides*}":?${RST2HTM_SLIDES_FLAGS}:${RST2HTM_DOC_FLAGS}}
35
36RST2PDF_FLAGS ?= ${"${.TARGET:T:M*slides*}":?${RST2PDF_SLIDES_FLAGS}:${RST2PDF_DOC_FLAGS}}
37
38RST_SUFFIXES ?= .rst .txt
39
40CLEANFILES += ${HTMFILES}
41
42html:	${HTMFILES}
43
44.SUFFIXES: ${RST_SUFFIXES} .htm .pdf
45
46${RST_SUFFIXES:@s@$s.htm@}:
47	${RST2HTM} ${RST2HTM_FLAGS} ${FLAGS.${.TARGET}} ${.IMPSRC} ${.TARGET}
48
49${RST_SUFFIXES:@s@$s.pdf@}:
50	${RST2PDF} ${RST2PDF_FLAGS} ${FLAGS.${.TARGET}} ${.IMPSRC} ${.TARGET}
51
52.for s in ${RSTSRCS:O:u}
53${s:R:T}.htm: $s
54${s:R:T}.pdf: $s
55.endfor
56