#! /bin/sh

# A. Flatau  9-Jul-1993; modified by M. Kaufmann many times thereafter.

# This file was originally part of create-acl2-texinfo, which created
# both Emacs Info files and a .ps file.  Now, create-acl2-texinfo
# creates Emacs Info files and create-acl2-tex creates a .ps file.
# Keep the two files in sync.

# This script should be run by executing
#   make DOC
# or
#   make TEX
# from the main ACL2 directory.  The make variables PREFIX and ACL2_SUFFIX are
# used in this script.

rm -f doc/workxxx.tex

rm -rf doc/TEX
mkdir doc/TEX
chmod 775 doc/TEX

# Some ACL2 images start up inside LP; some don't.  (Value :q) always gets us
# out of the loop, and should also be harmless when executed in raw Lisp.
# However, note that Lispworks requires that the two forms not all be on the
# same line.

echo '(value :q)' > doc/workxxx.tex
echo '(lp)' >> doc/workxxx.tex
echo '(include-book "doc/write-acl2-texinfo")' >> doc/workxxx.tex
echo '(write-tex-file :dir-string "doc/TEX/" :file "acl2-book")' >> doc/workxxx.tex
echo ':q' >> doc/workxxx.tex

./${PREFIX}saved_acl2${ACL2_SUFFIX} < doc/workxxx.tex

cd doc/TEX

cp ../texinfo.tex .
texi2dvi acl2-book.tex

# We do it again because otherwise some index entries are wrong.

texi2dvi acl2-book.tex

dvips acl2-book.dvi -o acl2-book.ps

gzip acl2-book.dvi
gzip acl2-book.ps

# Make all files world-readable after changing back to doc/.

cd ..

rm -f workxxx.tex

chmod a+r TEX/*

# See notes at the bottom of create-acl2-texinfo for how to debug bad documentation.
