%%
%% This is file `fmp.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% fmp.dtx  (with options: `package')
%% 
%% Copyright 2001 Marco Kuhlmann
%% 
%% This program may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either version
%% 1.2 of this license or (at your option) any later version. The
%% latest version of this license is in
%% 
%%     http://www.latex-project.org/lppl.txt
%% 
%% and version 1.2 or later is part of all distributions of LaTeX
%% version 1999/12/01 or later.
%% 
%% This program consists of the files fmp.ins and fmp.dtx
%% 
\NeedsTeXFormat{LaTeX2e}[1995/05/16]
\ProvidesPackage{fmp}
[2001/11/19 v1.1a Support for Functional MetaPost]
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{graphicx}}
\ProcessOptions
\@ifundefined{pdfoutput}{%
  \RequirePackage{graphicx}[1999/02/16]%
  \DeclareGraphicsRule{*}{eps}{*}{}}{%
  \RequirePackage[pdftex]{graphicx}[1994/12/15]%
  \DeclareGraphicsRule{*}{mps}{*}{}}
\RequirePackage{verbatim}
\newwrite\fmp@sourceout
\newwrite\fmp@scriptout
\newif\iffmp@sourceio
\fmp@sourceiofalse
\newif\iffmp@scriptio
\fmp@scriptiofalse
\newcounter{fmpfigure}
\newenvironment*{fmp}{}{}
\def\fmp{%
  \begingroup
    \@bsphack
    \let\do\@makeother\dospecials
    \catcode`\^^M\active
    \def\verbatim@processline{\fmp@sourcewrite{\the\verbatim@line}}%
    \verbatim@start}
\def\endfmp{%
    \@esphack
  \endgroup}
\def\fmp@sourcewrite#1{%
  \iffmp@sourceio \else \global\fmp@sourceiotrue\fmp@sourceopen \fi%
  \immediate\write\fmp@sourceout{#1}}
\def\fmp@sourceopen{%
  \immediate\openout\fmp@sourceout\fmp@sourcefilename%
  \edef\@tempa{\the\fmp@sourcepreamble}%
  \immediate\write\fmp@sourceout{\@tempa}}
\newcommand*{\fmpsourcefilename}[1]{%
  \gdef\fmp@sourcefilename{#1}}
\@onlypreamble{\fmpsourcefilename}
\def\fmp@sourcefilename{\jobname.hs}
\newtoks\fmp@sourcepreamble
\newcommand*{\fmpsourcepreamble}[1]{%
  \global\fmp@sourcepreamble={#1}}
\@onlypreamble{\fmpsourcepreamble}
\newcommand*{\fmpaddtosourcepreamble}[1]{%
  \fmp@sourcepreamble=\expandafter{\the\fmp@sourcepreamble#1}}
\@onlypreamble{\fmpaddtosourcepreamble}
\fmp@sourcepreamble={-- This is file `\fmp@sourcefilename',
  created automatically. Do not edit!^^J}
\def\fmp@sourceclose{%
  \iffmp@sourceio
    \edef\@tempa{\the\fmp@sourcepostamble}%
    \fmp@sourcewrite{\@tempa}%
    \immediate\closeout\fmp@sourceout
  \fi}
\AtEndDocument{\fmp@sourceclose}
\newtoks\fmp@sourcepostamble
\newcommand*{\fmpsourcepostamble}[1]{%
  \global\fmp@sourcepostamble={#1}}
\@onlypreamble{\fmpsourcepostamble}
\newcommand*{\fmpaddtosourcepostamble}[1]{%
  \fmp@sourcepostamble=\expandafter{\the\fmp@sourcepostamble#1}}
\@onlypreamble{\fmpaddtosourcepostamble}
\fmp@sourcepostamble={^^J-- End of file `\fmp@sourcefilename'}
\newcommand*{\fmpfigure}[2][]{%
  \fmp@scriptwrite{%
    generate "\fmp@figurebasename" \thefmpfigure\space #2}%
  \fmp@includegraphics{#1}{\fmp@figurebasename}{\thefmpfigure}%
  \refstepcounter{fmpfigure}}
\def\fmp@scriptwrite#1{%
  \iffmp@scriptio \else \global\fmp@scriptiotrue\fmp@scriptopen \fi%
  \immediate\write\fmp@scriptout{#1}}
\def\fmp@scriptopen{%
  \immediate\openout\fmp@scriptout\fmp@scriptfilename%
  \edef\@tempa{\the\fmp@scriptpreamble}%
  \immediate\write\fmp@scriptout{\@tempa}}
\newtoks\fmp@scriptpreamble
\newcommand*{\fmpscriptpreamble}[1]{%
  \global\fmp@scriptpreamble={#1}}
\@onlypreamble{\fmpscriptpreamble}
\newcommand*{\fmpaddtoscriptpreamble}[1]{%
  \fmp@scriptpreamble=\expandafter{\the\fmp@scriptpreamble#1}}
\@onlypreamble{\fmpaddtoscriptpreamble}
\fmp@scriptpreamble={hugs \fmp@sourcefilename\space <<!}
\newcommand*{\fmpscriptfilename}[1]{%
  \gdef\fmp@scriptfilename{#1}}
\@onlypreamble{\fmpscriptfilename}
\def\fmp@scriptfilename{fmpgenerate.sh}
\newcommand*{\fmpfigurebasename}[1]{%
  \gdef\fmp@figurebasename{#1}}
\@onlypreamble{\fmpfigurebasename}
\def\fmp@figurebasename{fmpfigure}
\def\fmp@includegraphics#1#2#3{%
  \leavevmode
  \IfFileExists{#2.#3}%
  {\includegraphics[#1]{#2.#3}}%
  {\typeout{fmp: Could not find file #2.#3}}}
\def\fmp@scriptclose{%
  \iffmp@scriptio
    \edef\@tempa{\the\fmp@scriptpostamble}%
    \fmp@scriptwrite{\@tempa}%
    \immediate\closeout\fmp@scriptout
  \fi}
\AtEndDocument{\fmp@scriptclose}
\newtoks\fmp@scriptpostamble
\newcommand*{\fmpscriptpostamble}[1]{%
  \global\fmp@scriptpostamble={#1}}
\@onlypreamble{\fmpscriptpostamble}
\newcommand*{\fmpaddtoscriptpostamble}[1]{%
  \fmp@scriptpostamble=\expandafter{\the\fmp@scriptpostamble#1}}
\@onlypreamble{\fmpaddtoscriptpostamble}
\fmp@scriptpostamble={:quit}

\endinput
%%
%% End of file `fmp.sty'.
