1# $Id: rst2htm.mk,v 1.17 2025/08/09 22:42:24 sjg Exp $ 2# 3# @(#) Copyright (c) 2009, Simon J. Gerraty 4# 5# SPDX-License-Identifier: BSD-2-Clause 6# 7# Please send copies of changes and bug-fixes to: 8# sjg@crufty.net 9# 10 11# convert reStructuredText to HTML, using rst2html.py from 12# docutils - http://docutils.sourceforge.net/ 13 14# pickup customizations 15.-include <local.rst2htm.mk> 16 17.if empty(TXTSRCS) 18TXTSRCS != 'ls' -1t ${.CURDIR}/*.txt ${.CURDIR}/*.rst 2>/dev/null; echo 19.endif 20RSTSRCS ?= ${TXTSRCS} 21HTMFILES ?= ${RSTSRCS:R:T:O:u:%=%.htm} 22PDFFILES ?= ${RSTSRCS:R:T:O:u:%=%.pdf} 23# can be empty, 4 or 5 24HTML_VERSION ?= 25RST2HTML ?= rst2html${HTML_VERSION} 26RST2PDF ?= rst2pdf 27RST2S5 ?= rst2s5 28# the following will run RST2S5 if the target name contains the word 'slides' 29# otherwise it uses RST2HTML 30RST2HTM = ${"${.TARGET:T:M*slides*}":?${RST2S5}:${RST2HTML}} 31RST2HTM_SLIDES_FLAGS ?= ${RST2S5_FLAGS} 32RST2HTM_DOC_FLAGS ?= ${RST2HTML_FLAGS} 33RST2HTM_FLAGS ?= ${"${.TARGET:T:M*slides*}":?${RST2HTM_SLIDES_FLAGS}:${RST2HTM_DOC_FLAGS}} 34 35RST2PDF_FLAGS ?= ${"${.TARGET:T:M*slides*}":?${RST2PDF_SLIDES_FLAGS}:${RST2PDF_DOC_FLAGS}} 36 37RST_SUFFIXES ?= .rst .txt 38 39CLEANFILES += ${HTMFILES} ${PDFFILES} 40 41html: ${HTMFILES} 42pdf: ${PDFFILES} 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