%%
%% This is file `embedall.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% embedall.dtx  (with options: `package')
%% 
%% This is a generated file.
%% 
%% Copyright (C) 2013 by Alberto Sartori
%% 
%% This file 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.
%% 
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{embedall}
    [2013/10/10 v1.0 embed files in pdf]

\RequirePackage{embedfile}
\RequirePackage{graphicx}
\RequirePackage{listings}
\RequirePackage{letltxmacro}

\newcommand\embedall@all{1}
\newcommand\embedall@graphicx{0}
\newcommand\embedall@list{0}
\newcommand\embedall@source{0}

\DeclareOption{graphicx}{\def\embedall@graphicx{1}\def\embedall@all{0}}
\DeclareOption{listings}{\def\embedall@list{1}\def\embedall@all{0}}
\DeclareOption{source}{\def\embedall@source{1}\def\embedall@all{0}}

\ProcessOptions

\LetLtxMacro\embedall@latex@includegraphics\includegraphics
\newcommand\embedall@includegraphics[2][]{%
    \embedfile[desc=image]{#2}
    \embedall@latex@includegraphics[#1]{#2}%
}

\LetLtxMacro\embedall@latex@lstinputlisting\lstinputlisting
\newcommand\embedall@lstinputlisting[2][]{%
    \embedfile[desc=listing file]{#2}
    \embedall@latex@lstinputlisting[#1]{#2}%
}

\DeclareRobustCommand\embedinput[2][input file]{%
    \input{#2}%
    \embedfile[desc={#1}]{#2}%
}

\ifnum\embedall@all=1%
    \def\embedall@graphicx{1}
    \def\embedall@list{1}
    \def\embedall@source{1}
\fi
\ifnum\embedall@graphicx=1%
    \LetLtxMacro\includegraphics\embedall@includegraphics
\fi
\ifnum\embedall@list=1%
    \LetLtxMacro\lstinputlisting\embedall@lstinputlisting
\fi

\IfFileExists{./\jobname.tex}{%
    \ifnum\embedall@source=1%
        \embedfile[desc=main source file]{\jobname.tex}\fi}{}

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