commit 1a16bf3d7749c5c5be7b37f3e1172f16563d074b parent b1884f1995bd13eb58789e5ac892cd74d0c3cbf2 Author: Wolfgang Corcoran-Mathe <wcm@sigwinch.xyz> Date: Tue, 6 Feb 2024 13:37:41 -0500 Add basic build script. Make is not a great tool for Texinfo. Diffstat:
A | doc/r7rs-small/build.sh | | | 66 | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
1 file changed, 66 insertions(+), 0 deletions(-)
diff --git a/doc/r7rs-small/build.sh b/doc/r7rs-small/build.sh @@ -0,0 +1,66 @@ +#!/bin/sh + +usage () { + printf 'Usage: %s [-s] <target>\n' "$(basename $0)" 1>&2 + echo + cat 1>&2 <<EOF +Helper script for building R7RS-small from Texinfo. Currently +supported targets are 'html' and 'pdf'. + +The default target is 'html'. + +Output splitting is controlled by the -s flag. Set it if you +want split files. Default output is unsplit. + +The command contained in the MAKEINFO environment variable +(or 'makeinfo' if it is empty) will be used. Additional options +in MAKEINFOFLAGS will be passed to this command. +EOF + exit 1 +} + +input_file="r7rs-small.texinfo" +split="" +makeinfo_cmd="${MAKEINFO:-makeinfo}" +makeinfo_flags="$MAKEINFOFLAGS" + +while getopts hs opt +do + case "$opt" in + s) split=yes + shift + ;; + *) usage ;; + esac +done + +if test "$split" != "yes" +then + makeinfo_flags="$makeinfo_flags --no-split" +fi + +target_flag="" +case "${1:-html}" in # target +html) + target_flag="--html" + ;; +pdf) + target_flag="--pdf" + ;; +*) + printf "Error: target '%s' not yet supported.\n" "$1" + exit 1 + ;; +esac + +if ! test -f $input_file -a -r $input_file +then + printf "Error: %s is not a readable regular file.\n"\ + $input_file + exit 1 +fi + +printf "%s %s %s %s\n" "$makeinfo_cmd" "$makeinfo_flags"\ + "$target_flag" "$input_file" 1>&2 + +$makeinfo_cmd $makeinfo_flags $target_flag $input_file