#!../../mhc/mhc
;;; build-ps.mhc: -*- Meta-HTML -*-  Build a postscript version of the Manual.
;;;
;;; Copyright (c) 1996 Brian J. Fox
;;; Author: Brian J. Fox (bfox@ai.mit.edu) Sat Nov  2 09:50:54 1996.
<set-var mhc::explicit-output-only=true>

<defun print>
  <with-open-stream s *standard-output* mode=write-create>
    <stream-put s <concat <prog %body> "\n">>
  </with-open-stream>
</defun>

<set-var continue=true>

;;; Make this environment look just like the canonical source one.
<include canonical-source.mhtml>

<print Building metahtml.texi from the existing databases...>
<set-var output-stream=metahtml.texi dvifile=metahtml.dvi>
<set-var bps::output=<include make-printable.mhtml alt="Cannot Find File!">>

<when <string-eq <get-var bps::output> "Cannot Find File!">>
  <unset-var continue>
  <print <get-var bps::output>>
</when>

<when <get-var continue>>
  <print Running TeX for the first time...>
  <cgi-exec tex <get-var output-stream>>
  <print Running texindex...>
  <cgi-exec texindex *.??>
  ;;; Now, add the variable definitions to the xref file.
  <set-var data=<include metahtml.fns verbatim>>
  <subst-in-var data "\\\\initial[^\n]+\n" "">
  <subst-in-var data "\\\\entry \\{\\\\code" "'xrdef">
  <subst-in-var data "\\}\\}\\{" "-pg}{">
  <with-open-stream s metahtml.aux type=file mode=append>
    <stream-put s <get-var data>>
  </with-open-stream>
  <cgi-exec cp metahtml.aux metahtml.newaux>
  <print Running TeX for the second time...>
  <cgi-exec tex <get-var output-stream>>
  <print Running dvips -o metahtml.ps <get-var dvifile>...>
  <cgi-exec dvips -o metahtml.ps <get-var dvifile>>
  <print Deleting intermediate files...>
  <cgi-exec rm *.aux *.cp *.fn *.fns *.ky *.kys *.log *.pg *.pgs
	    *.toc *.tp *.tps *.vr *.vrs>
  <print Done.>
</when>
