xref: /freebsd/contrib/bmake/mk/rst2htm.mk (revision c59c3bf34db360695f07735bebc76a768cac5afc)
1*c59c3bf3SSimon J. Gerraty# SPDX-License-Identifier: BSD-2-Clause
2*c59c3bf3SSimon J. Gerraty#
3*c59c3bf3SSimon J. Gerraty# $Id: rst2htm.mk,v 1.15 2024/02/17 17:26:57 sjg Exp $
43cbdda60SSimon J. Gerraty#
53cbdda60SSimon J. Gerraty#	@(#) Copyright (c) 2009, Simon J. Gerraty
63cbdda60SSimon J. Gerraty#
73cbdda60SSimon J. Gerraty#	This file is provided in the hope that it will
83cbdda60SSimon J. Gerraty#	be of use.  There is absolutely NO WARRANTY.
93cbdda60SSimon J. Gerraty#	Permission to copy, redistribute or otherwise
103cbdda60SSimon J. Gerraty#	use this file is hereby granted provided that
113cbdda60SSimon J. Gerraty#	the above copyright notice and this notice are
123cbdda60SSimon J. Gerraty#	left intact.
133cbdda60SSimon J. Gerraty#
143cbdda60SSimon J. Gerraty#	Please send copies of changes and bug-fixes to:
153cbdda60SSimon J. Gerraty#	sjg@crufty.net
163cbdda60SSimon J. Gerraty#
173cbdda60SSimon J. Gerraty
183cbdda60SSimon J. Gerraty# convert reStructuredText to HTML, using rst2html.py from
193cbdda60SSimon J. Gerraty# docutils - http://docutils.sourceforge.net/
203cbdda60SSimon J. Gerraty
2198875883SSimon J. Gerraty# pickup customizations
2298875883SSimon J. Gerraty.-include <local.rst2htm.mk>
2398875883SSimon J. Gerraty
243cbdda60SSimon J. Gerraty.if empty(TXTSRCS)
253cbdda60SSimon J. GerratyTXTSRCS != 'ls' -1t ${.CURDIR}/*.txt ${.CURDIR}/*.rst 2>/dev/null; echo
263cbdda60SSimon J. Gerraty.endif
273cbdda60SSimon J. GerratyRSTSRCS ?= ${TXTSRCS}
283cbdda60SSimon J. GerratyHTMFILES ?= ${RSTSRCS:R:T:O:u:%=%.htm}
2998875883SSimon J. GerratyPDFFILES ?= ${RSTSRCS:R:T:O:u:%=%.pdf}
30b0c40a00SSimon J. Gerraty# can be empty, 4 or 5
31b0c40a00SSimon J. GerratyHTML_VERSION ?=
32b0c40a00SSimon J. GerratyRST2HTML ?= rst2html${HTML_VERSION}.py
335bcb7424SSimon J. GerratyRST2PDF ?= rst2pdf
343cbdda60SSimon J. GerratyRST2S5 ?= rst2s5.py
353cbdda60SSimon J. Gerraty# the following will run RST2S5 if the target name contains the word 'slides'
363cbdda60SSimon J. Gerraty# otherwise it uses RST2HTML
374c620fe5SSimon J. GerratyRST2HTM = ${"${.TARGET:T:M*slides*}":?${RST2S5}:${RST2HTML}}
384c620fe5SSimon J. GerratyRST2HTM_SLIDES_FLAGS ?= ${RST2S5_FLAGS}
394c620fe5SSimon J. GerratyRST2HTM_DOC_FLAGS ?= ${RST2HTML_FLAGS}
404c620fe5SSimon J. GerratyRST2HTM_FLAGS ?= ${"${.TARGET:T:M*slides*}":?${RST2HTM_SLIDES_FLAGS}:${RST2HTM_DOC_FLAGS}}
414c620fe5SSimon J. Gerraty
424c620fe5SSimon J. GerratyRST2PDF_FLAGS ?= ${"${.TARGET:T:M*slides*}":?${RST2PDF_SLIDES_FLAGS}:${RST2PDF_DOC_FLAGS}}
433cbdda60SSimon J. Gerraty
443cbdda60SSimon J. GerratyRST_SUFFIXES ?= .rst .txt
453cbdda60SSimon J. Gerraty
4698875883SSimon J. GerratyCLEANFILES += ${HTMFILES} ${PDFFILES}
473cbdda60SSimon J. Gerraty
483cbdda60SSimon J. Gerratyhtml:	${HTMFILES}
49d5e0a182SSimon J. Gerratypdf:	${PDFFILES}
503cbdda60SSimon J. Gerraty
515bcb7424SSimon J. Gerraty.SUFFIXES: ${RST_SUFFIXES} .htm .pdf
523cbdda60SSimon J. Gerraty
533cbdda60SSimon J. Gerraty${RST_SUFFIXES:@s@$s.htm@}:
544c620fe5SSimon J. Gerraty	${RST2HTM} ${RST2HTM_FLAGS} ${FLAGS.${.TARGET}} ${.IMPSRC} ${.TARGET}
553cbdda60SSimon J. Gerraty
565bcb7424SSimon J. Gerraty${RST_SUFFIXES:@s@$s.pdf@}:
574c620fe5SSimon J. Gerraty	${RST2PDF} ${RST2PDF_FLAGS} ${FLAGS.${.TARGET}} ${.IMPSRC} ${.TARGET}
585bcb7424SSimon J. Gerraty
593cbdda60SSimon J. Gerraty.for s in ${RSTSRCS:O:u}
603cbdda60SSimon J. Gerraty${s:R:T}.htm: $s
615bcb7424SSimon J. Gerraty${s:R:T}.pdf: $s
623cbdda60SSimon J. Gerraty.endfor
63