1276305Sngie# $Id: rst2htm.mk,v 1.9 2014/02/22 01:52:41 sjg Exp $
2246149Ssjg#
3246149Ssjg#	@(#) Copyright (c) 2009, Simon J. Gerraty
4246149Ssjg#
5246149Ssjg#	This file is provided in the hope that it will
6246149Ssjg#	be of use.  There is absolutely NO WARRANTY.
7246149Ssjg#	Permission to copy, redistribute or otherwise
8246149Ssjg#	use this file is hereby granted provided that 
9246149Ssjg#	the above copyright notice and this notice are
10246149Ssjg#	left intact. 
11246149Ssjg#      
12246149Ssjg#	Please send copies of changes and bug-fixes to:
13246149Ssjg#	sjg@crufty.net
14246149Ssjg#
15246149Ssjg
16246149Ssjg# convert reStructuredText to HTML, using rst2html.py from
17246149Ssjg# docutils - http://docutils.sourceforge.net/
18246149Ssjg
19246149Ssjg.if empty(TXTSRCS)
20246149SsjgTXTSRCS != 'ls' -1t ${.CURDIR}/*.txt ${.CURDIR}/*.rst 2>/dev/null; echo
21246149Ssjg.endif
22246149SsjgRSTSRCS ?= ${TXTSRCS}
23246149SsjgHTMFILES ?= ${RSTSRCS:R:T:O:u:%=%.htm}
24246149SsjgRST2HTML ?= rst2html.py
25276305SngieRST2PDF ?= rst2pdf
26246149SsjgRST2S5 ?= rst2s5.py
27246149Ssjg# the following will run RST2S5 if the target name contains the word 'slides'
28246149Ssjg# otherwise it uses RST2HTML
29246149SsjgRST2HTM = ${"${.TARGET:T:M*slides*}":?${RST2S5} ${RST2S5_FLAGS}:${RST2HTML} ${RST2HTML_FLAGS}}
30246149Ssjg
31246149SsjgRST_SUFFIXES ?= .rst .txt
32246149Ssjg
33246149SsjgCLEANFILES += ${HTMFILES}
34246149Ssjg
35246149Ssjghtml:	${HTMFILES}
36246149Ssjg
37276305Sngie.SUFFIXES: ${RST_SUFFIXES} .htm .pdf
38246149Ssjg
39246149Ssjg${RST_SUFFIXES:@s@$s.htm@}:
40246149Ssjg	${RST2HTM} ${.IMPSRC} ${.TARGET}
41246149Ssjg
42276305Sngie${RST_SUFFIXES:@s@$s.pdf@}:
43276305Sngie	${RST2PDF} ${.IMPSRC} ${.TARGET}
44276305Sngie
45246149Ssjg.for s in ${RSTSRCS:O:u}
46246149Ssjg${s:R:T}.htm: $s
47276305Sngie${s:R:T}.pdf: $s
48246149Ssjg.endfor
49