1#!/usr/local/bin/bash
2
3fast_mode=false
4update_mode=false
5
6set -- $(getopt fu "$@")
7while [ $# -gt 0 ]; do
8	case "$1" in
9		-f)
10			fast_mode=true
11			;;
12		-u)
13			update_mode=true
14			;;
15		--)
16			shift
17			break
18			;;
19		-*)
20			echo "$0: error - unrecognized option $1" 1>&2
21			exit 1
22			;;
23		*)
24			break
25	esac
26	shift
27done
28
29PDFTEX_OPT="-shell-escape -halt-on-error"
30
31if $update_mode; then
32	make -C ..
33	../yosys -p 'help -write-tex-command-reference-manual'
34fi
35
36if ! $fast_mode; then
37	md5sum *.aux *.bbl *.blg > autoloop.old
38fi
39
40set -ex
41
42pdflatex $PDFTEX_OPT manual.tex
43
44if ! $fast_mode; then
45	bibtex manual.aux
46	bibtex weblink.aux
47
48	while
49		md5sum *.aux *.bbl *.blg > autoloop.new
50		! cmp autoloop.old autoloop.new
51	do
52		cp autoloop.new autoloop.old
53		pdflatex $PDFTEX_OPT manual.tex
54	done
55
56	rm -f autoloop.old
57	rm -f autoloop.new
58fi
59
60