#! /bin/sh

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

# This file (create-acl2-texinfo) originally created both Emacs Info
# files and a .ps file.  Now, this file 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 TEXINFO
# from the main ACL2 directory.  The environment variable ACL2 is used
# in this script; it is typically set in ../GNUmakefile.

rm -f doc/workxxx.texinfo

# The following lines should be commented out if we don't want to
# destroy what's in the saved/ subdirectories.

rm -rf doc/EMACS-old
mv -f doc/EMACS doc/EMACS-old
mkdir doc/EMACS
chmod 775 doc/EMACS

# 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.texinfo
echo '(lp)' >> doc/workxxx.texinfo
echo '(certify-book "doc/write-acl2-texinfo")' >> doc/workxxx.texinfo
# Note that we do not support ACL2_DOC_UNDOCUMENTED_FILE=t here.  We
# looked into it a bit (January 2011) and it seemed awkward to provide
# that support, unlike the case of HTML.
echo '(write-texinfo-file :dir-string "doc/EMACS/" :file "acl2-doc-emacs" :tex-only-flg nil :non-lucid-flg t)' >> doc/workxxx.texinfo
echo ':q' >> doc/workxxx.texinfo

${ACL2} < doc/workxxx.texinfo

## emacs -batch "doc/EMACS/acl2-doc-emacs.texinfo" -l "../make-texinfo.el" -f texinfo-format-buffer-and-save

# Replacement for "emacs -batch ..." command above:
# cd doc/EMACS ; makeinfo --force acl2-doc-emacs.texinfo ; cd ../..
echo ""
echo "Creating EMACS Info files...."
cd doc/EMACS ; makeinfo acl2-doc-emacs.texinfo ; cd ../..
echo "Done creating EMACS Info files."
echo ""
rm -f doc/workxxx.texinfo
chmod a+r doc/EMACS/*

# To debug bad documentation:
# Start up ACL2 in the source directory.
# (include-book "doc/write-acl2-texinfo")
# Apply DEFDOC to fix bad documentation.
# (write-texinfo-file :dir-string "doc/EMACS/" :file "acl2-doc-emacs" :tex-only-flg nil :non-lucid-flg t)
# One can write others too:
#
## # (write-texinfo-file :dir-string "doc/LEMACS/" :file "acl2-doc-lemacs" :tex-only-flg nil)
# (write-tex-file :dir-string "doc/TEX/" :file "acl2-book")
