%%
%% This is file `abc.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% abc.dtx  (with options: `package')
%% 
%%  Copyright 2006-2016 Enrico Gregorio
%% 
%%  This program is provided under the terms of the
%%  LaTeX Project Public License distributed from CTAN
%%  archives in directory macros/latex/base/lppl.txt.
%% 
%%  Author: Enrico Gregorio
%%          Enrico dot Gregorio at univr dot it
%% 
%%  This work has the LPPL maintenance status "author-maintained".
%% 
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{abc}
  [2016/05/15 v2.0b Enrico Gregorio]

\RequirePackage{ifluatex}
\newif\ifabc@shellescape
\newif\ifabc@generate
\newif\ifabc@warning
\newif\ifabc@saveall
\newif\ifabc@mup
\DeclareOption{mup}{\abc@muptrue}
\DeclareOption{noshellescape}{\abc@shellescapefalse\abc@warningtrue
  \abc@savealltrue}
\DeclareOption{shellescape}{\abc@shellescapetrue}
\DeclareOption{nogenerate}{\abc@generatefalse}
\DeclareOption{generate}{\abc@generatetrue}
\DeclareOption{nosaveall}{\abc@saveallfalse}
\DeclareOption{saveall}{\abc@savealltrue}
\def\abc@epsext{eps}
\DeclareOption{ps2eps}{\def\abc@pscmd{ps2eps -f}}
\DeclareOption{ps2epsi}{\def\abc@pscmd{ps2epsi}\def\abc@epsext{epsi}}
\DeclareOption{ps2epsidos}{\def\abc@pscmd{ps2epsi}\def\abc@epsext{epi}}
\ExecuteOptions{generate,shellescape,nosaveall,ps2eps}
\ifluatex
  \ExecuteOptions{saveall}
\fi
\ProcessOptions\relax
\RequirePackage{verbatim}
\RequirePackage{keyval}
\RequirePackage{graphicx}
\RequirePackage{ifpdf}
\newif\ifabc@unprocessedfiles
\newcounter{abc@count}
\ifabc@mup
\newcommand{\abc@cmd}{mup}       % virtually no choice
\newcommand{\abc@parm}{-F}       % -F MUST stay
\newcommand{\abc@epstopdfcmd}{epstopdf}
\newcommand{\abc@pdfext}{pdf}
\def\normalabcoutputfile{out-mup}
\def\normalmupoutputfile{\normalabcoutputfile}
\def\mup{\abc}
\def\endmup{\endabc}
\def\mupinput{\abcinput}
\def\abc@ext{.mup}
\def\abc@packagename{mup}
\else
\newcommand{\abc@cmd}{abcm2ps}       % virtually no choice
\newcommand{\abc@parm}{-O= -c}       % -O= MUST stay
\newcommand{\abc@epstopdfcmd}{epstopdf}
\newcommand{\abc@pdfext}{pdf}
\def\normalabcoutputfile{out-abc}
\def\abc@ext{.abc}
\def\abc@packagename{abc}
\fi
\def\abc@tempfile{\normalabcoutputfile}
\def\abc@opt{}
\let\abc@postopt\@empty
\ifpdf
  \let\abc@finalext\abc@pdfext
\else
  \let\abc@finalext\abc@epsext
\fi
\newif\ifabc@center
\abc@centertrue
\newcommand{\abcwidth}{\linewidth}  % only fractions of \linewidth
\let\mupwidth\abcwidth
\newwrite\abc@out
\def\abc@startgen{%
  \@bsphack
  \immediate\openout\abc@out\abc@tempfile\abc@ext
  \let\do\@makeother\dospecials
  \catcode`\^^M\active \catcode`\^^I=12
  \def\verbatim@processline{%
  \immediate\write\abc@out
    {\the\verbatim@line}}%
  \verbatim@start}
\def\abc@finishgen{%
  \immediate\closeout\abc@out
  \@esphack
  \abc@process
}
\ifluatex
  \IfFileExists{shellesc.sty}
    {\RequirePackage{shellesc}\let\abc@shell\ShellEscape}
    {\def\abc@shell{\immediate\write18}}
\else
  \def\abc@shell{\immediate\write18}
\fi
\def\abc@doshellcommand{%
  \abc@shell{%
    \ifabc@mup
      \abc@cmd\space
      \abc@opt\space
      \abc@parm\space
      \abc@tempfile\abc@ext\space
    \else
      \abc@cmd\space
      \abc@parm\space
      \abc@opt\space
      \abc@tempfile\abc@ext\space
    \fi
    \ifx\abc@postopt\@empty
    \else\space\abc@postopt\fi
  }%
  \abc@shell{%
    \abc@pscmd\space\abc@tempfile.ps
  }%
  \ifpdf
    \abc@shell{%
      \abc@epstopdfcmd\space\abc@tempfile.\abc@epsext
    }%
  \fi
}
\def\abc@nodoshellcommand{%
\immediate\write\abc@outsh{%
  \abc@cmd\space
  \abc@parm\space
  \abc@opt\space
  \abc@tempfile\abc@ext\space
  \ifx\abc@postopt\@empty
  \else\space\abc@postopt\fi}%
\immediate\write\abc@outsh{%
  \abc@pscmd\space\abc@tempfile.ps}%
\ifpdf
  \immediate\write\abc@outsh{%
    \abc@epstopdfcmd\space\abc@tempfile.\abc@epsext}%
\fi
  }
\AtEndDocument{%
  \ifabc@warning\ifabc@unprocessedfiles
    \PackageWarningNoLine{\abc@packagename}{%
      \ifabc@shellescape
        You have set the `shellescape' option, but you ran%
        \MessageBreak
        (pdf)latex without the `-shell-escape' command line%
        \MessageBreak
        option. Fix it either with the `noshellescape' option%
        \MessageBreak
        in your document or the correct call of (pdf)latex%
      \else
        Remember to generate the [eps,pdf] files before compiling%
        \MessageBreak
       again. Use the file \abc@tempfile.sh for a list or as a script%
      \fi}%
  \fi\fi}
\ifabc@shellescape
  \let\abc@process\abc@doshellcommand
\else
  \newwrite\abc@outsh
  \immediate\openout\abc@outsh\abc@tempfile.sh
  \AtEndDocument{\closeout\abc@outsh}
  \let\abc@process\abc@nodoshellcommand
\fi
\ifabc@generate
  \let\abc@start\abc@startgen
  \let\abc@finish\abc@finishgen
\else
  \let\abc@start\comment
  \let\abc@finish\endcomment
\fi
\def\abc{\@makeother\%\@ifnextchar[\abc@grab{\abc@grab[]}}
\define@key{abc}{name}[]{%
  \if!#1!\stepcounter{abc@count}%
    \edef\abc@tempfile{\normalabcoutputfile-\@arabic\c@abc@count}%
  \else
    \def\abc@tempfile{#1}%
  \fi
}
\define@key{abc}{options}{\def\abc@opt{#1}}
\define@key{abc}{postoptions}{\def\abc@postopt{#1}}
\define@key{abc}{program}{\def\abc@cmd{#1}\let\abc@parm\@empty}
\define@key{abc}{width}{\def\abc@width{#1}}
\define@key{abc}{center}[true]{\csname abc@center#1\endcsname}
\define@key{abc}{extension}{\def\abc@ext{.#1}}
\def\abc@grab[#1]{\let\abc@width=\abcwidth
  \ifabc@saveall
    \setkeys{abc}{name,#1}%
  \else
    \setkeys{abc}{#1}%
  \fi\abc@start}
\def\endabc{%
  \abc@finish
  \trivlist\item[]\ifabc@center\centering\fi
  \IfFileExists{\abc@tempfile.\abc@finalext}
    {\includegraphics[width=\abc@width]{\abc@tempfile.\abc@finalext}}%
    {\global\abc@warningtrue\fbox{\abc@tempfile}%
     \global\abc@unprocessedfilestrue}%
  \endtrivlist
}
\def\abcinput{\@ifnextchar[\abc@grabinput{\abc@grabinput[]}}
\def\abc@grabinput[#1]#2{\let\abc@width=\abcwidth\setkeys{abc}{#1}%
  \begingroup\def\abc@tempfile{#2}%
  \IfFileExists{\abc@tempfile\abc@ext}
  {%
    \abc@process
    \begin{center}
    \IfFileExists{\abc@tempfile.\abc@finalext}
      {\includegraphics[width=\abc@width]{\abc@tempfile.\abc@finalext}}%
      {\fbox{\abc@tempfile}}%
    \end{center}%
  \endgroup
  }
  {\PackageWarning{\abc@packagename}{No file \abc@tempfile\abc@ext\space found}}%
}
\endinput
%%
%% End of file `abc.sty'.
