%%
%% This is file `feynmp-auto.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% feynmp-auto.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2013 by Enrico Gregorio
%% <Enrico dot Gregorio at univr dot it>
%% -------------------------------------------------------
%% 
%% This work may be distributed and/or modified under the
%% conditions of the LaTeX Project Public License, either
%% version 1.3c 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.3 or later is part of all distributions
%% of LaTeX version 2005/12/01 or later.
%% 
%% This work has the LPPL maintenance status `maintained'.
%% 
%% The Current Maintainer of this work is Enrico Gregorio.
%% 
%% This work consists of the files
%%   feynmp-auto.dtx
%%   feynmp-auto.ins
%% and the derived file feynmp-auto.sty.
%% 
\NeedsTeXFormat{LaTeX2e}[2008/04/05]
\ProvidesPackage{feynmp-auto}
    [2013/05/03 v1.1 Automatic processing of feynmp graphics]
\@ifundefined{eTeXversion}
  {\PackageError{feynmp-auto}{LaTeX engine too old, aborting}
   {Please upgrade your TeX system}\@@end}{}
\newif\iffnmpa@force
\DeclareOption{force}{\fnmpa@forcetrue}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{feynmp}}
\ProcessOptions\relax
\RequirePackage{feynmp}
\RequirePackage{ifpdf,ifxetex}
\RequirePackage{pdftexcmds}
\ifnum\pdf@shellescape=\z@
  \PackageWarningNoLine{feynmp-auto}
    {The automatic feature can't be used\MessageBreak
     because `shell escape' is disabled}
\fi
\ifpdf
  \DeclareGraphicsRule{*}{mps}{*}{}
\fi
\ifxetex
  \DeclareGraphicsRule{*}{eps}{*}{}
\fi
\ifdefined\pdf@filemdfivesum
  \def\fnmpa@mdfivesum{0}
  \def\fnmpa@gethash{%
    \IfFileExists{\thefmffile.mp}
      {\edef\fnmpa@mdfivesum{\pdf@filemdfivesum{\thefmffile.mp}}}
      {}%
  }
  \def\fnmpa@processmp{%
    \IfFileExists{\thefmffile.mp}
      {\fnmpa@compare}
      {}%
  }
  \def\fnmpa@compare{%
    \ifnum\pdf@strcmp{\fnmpa@mdfivesum}{\pdf@filemdfivesum{\thefmffile.mp}}=\z@
      % do nothing, the files is unmodified
    \else
      \immediate\write18{mpost \thefmffile}%
    \fi
  }
\else
  \let\fnmpa@gethash\relax
  \def\fnmpa@processmp{%
    \IfFileExists{\thefmffile.mp}{\immediate\write18{mpost \thefmffile}}{}%
  }
\fi
\iffnmpa@force
  \let\fnmpa@gethash\relax
  \def\fnmpa@processmp{%
    \IfFileExists{\thefmffile.mp}{\immediate\write18{mpost \thefmffile}}{}%
  }
\fi
\def\fmffile#1{%
  \def\thefmffile{#1}%
  \equaltojobname{\thefmffile}{%
    \PackageError{feynmp}
      {The argument of \fmffile MUST NOT be identical\MessageBreak
       to the name of your main input file!  I will use fmfdefault.mf\MessageBreak
       this time around, but you'd better fix your code now!}%
      {Invalid argument to \string\fmffile!}%
    \def\thefmffile{fmfdefault}}{}%
  \if@fmfio
    \fnmpa@gethash % Added
    \@ifundefined{ifmeasuring@}%
      {}%
      {\def\if@fmfio{\ifmeasuring@\else}}%
    \immediate\openout\@outfmf=\thefmffile.mp\relax
    \fmfcmd{\p@rcent\space \thefmffile.mp -- do not edit, %
            generated automatically by \jobname.tex^^J%
            input feynmp^^J%
            require_RCS_revision "\fmf@revision";}%
  \fi
  \setcounter{fmfgraph}{0}}
\def\endfmffile{%
  \fmfcmd{\p@rcent\space the end.^^J%
          end.^^J%
          endinput;}%
  \if@fmfio
    \immediate\closeout\@outfmf
  \fi
  \fnmpa@processmp % Added
  \let\thefmffile\relax
}
\endinput
%%
%% End of file `feynmp-auto.sty'.
