#!../../mhc/mhc
;;; build-ps: -*- 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 = <prog
		   <print "Cannot Find make-printable.mhtml!">
		   <unset-var continue>>>>

<when <get-var continue>>
  <print Running TeX for the first time...>
  <cgi-exec tex <get-var output-stream> "<returns">
  <print <system-error-output retrieve clear>>
  <print Running texindex...>
  <cgi-exec texindex metahtml.??>
  <print <system-error-output retrieve clear>>
  ;;; 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>
  <print <system-error-output retrieve clear>>
  <cgi-exec cp metahtml.aux metahtml.newaux>
  <print <system-error-output retrieve clear>>
  <print Running TeX for the second time...>
  <cgi-exec tex <get-var output-stream> "<returns">
  <print <system-error-output retrieve clear>>
  <print Running dvips -o metahtml.ps <get-var dvifile>...>
  <cgi-exec dvips -o metahtml.ps <get-var dvifile>>
  <print <system-error-output retrieve clear>>
  <print Deleting intermediate files...>
  <cgi-exec rm *.aux *.cp *.fn *.fns *.ky *.kys *.log *.pg *.pgs
	    *.toc *.tp *.tps *.vr *.vrs *.cps>
  <print <system-error-output retrieve clear>>
  <print Done.>
</when>
