freebsd-src/mk/rst2htm.mk
Simon J. Gerraty ee914ef902 Import bmake-20210621
Lots more unit tests and code cleanup

Relevant changes from ChangeLog

	o job.c: Print -de error information when running multiple jobs
	o var.c: only report error for unmatched regex subexpression
	when linting (-dL) since we cannot tell when an unmatched
	subexpression is an expected result.
	reduce memory allocations in the modifiers ':D' and ':U'
	reduce memory allocation and strlen calls in modifier ':from=to'
	in the ':Q' modifier, only allocate memory if necessary
	improve performance for LazyBuf
	reduce debug logging and memory allocation for ${:U...}
	reduce verbosity of the -dv debug logging for standard cases
	fix double varname expansion in the variable modifier '::='
	o var.c: avoid evaluating many modifiers in parse only mode
	in strict mode (-dL) many variable references are parsed twice,
	the first time just to report parse errors early, so we want to
	avoid side effects and wasted effort to the extent possible.
2021-06-25 11:16:24 -07:00

56 lines
1.6 KiB
Makefile

# $Id: rst2htm.mk,v 1.12 2021/05/26 04:20:31 sjg Exp $
#
# @(#) Copyright (c) 2009, Simon J. Gerraty
#
# This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY.
# Permission to copy, redistribute or otherwise
# use this file is hereby granted provided that
# the above copyright notice and this notice are
# left intact.
#
# Please send copies of changes and bug-fixes to:
# sjg@crufty.net
#
# convert reStructuredText to HTML, using rst2html.py from
# docutils - http://docutils.sourceforge.net/
.if empty(TXTSRCS)
TXTSRCS != 'ls' -1t ${.CURDIR}/*.txt ${.CURDIR}/*.rst 2>/dev/null; echo
.endif
RSTSRCS ?= ${TXTSRCS}
HTMFILES ?= ${RSTSRCS:R:T:O:u:%=%.htm}
# can be empty, 4 or 5
HTML_VERSION ?=
RST2HTML ?= rst2html${HTML_VERSION}.py
RST2PDF ?= rst2pdf
RST2S5 ?= rst2s5.py
# the following will run RST2S5 if the target name contains the word 'slides'
# otherwise it uses RST2HTML
RST2HTM = ${"${.TARGET:T:M*slides*}":?${RST2S5}:${RST2HTML}}
RST2HTM_SLIDES_FLAGS ?= ${RST2S5_FLAGS}
RST2HTM_DOC_FLAGS ?= ${RST2HTML_FLAGS}
RST2HTM_FLAGS ?= ${"${.TARGET:T:M*slides*}":?${RST2HTM_SLIDES_FLAGS}:${RST2HTM_DOC_FLAGS}}
RST2PDF_FLAGS ?= ${"${.TARGET:T:M*slides*}":?${RST2PDF_SLIDES_FLAGS}:${RST2PDF_DOC_FLAGS}}
RST_SUFFIXES ?= .rst .txt
CLEANFILES += ${HTMFILES}
html: ${HTMFILES}
.SUFFIXES: ${RST_SUFFIXES} .htm .pdf
${RST_SUFFIXES:@s@$s.htm@}:
${RST2HTM} ${RST2HTM_FLAGS} ${FLAGS.${.TARGET}} ${.IMPSRC} ${.TARGET}
${RST_SUFFIXES:@s@$s.pdf@}:
${RST2PDF} ${RST2PDF_FLAGS} ${FLAGS.${.TARGET}} ${.IMPSRC} ${.TARGET}
.for s in ${RSTSRCS:O:u}
${s:R:T}.htm: $s
${s:R:T}.pdf: $s
.endfor