Debian Codegraph @

texmf-dist/source/support/latex-make/texdepends.dtx

raw
1 % \iffalse meta-comment
2 %%
3 %% File: texdepends.dtx Copyright (C) 2004--2011 V. Danjean
4 %% [email protected]
5 %% Modified by Matthieu Gallet
6 %% [email protected]
7 %%
8 %% This program is free software; you can redistribute it and/or
9 %% modify it under the terms of the GNU General Public License
10 %% as published by the Free Software Foundation; either version 2
11 %% of the License, or (at your option) any later version.
12 %%
13 %% This program is distributed in the hope that it will be useful,
14 %% but WITHOUT ANY WARRANTY; without even the implied warranty of
15 %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 %% GNU General Public License for more details.
17 %%
18 %% You should have received a copy of the GNU General Public License
19 %% along with this program; if not, write to the Free Software
20 %% Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 %%
22 %
23 %<*dtx>
24 \ProvidesFile{texdepends.dtx}
25 %</dtx>
26 %<package>\NeedsTeXFormat{LaTeX2e}%
27 %<package>\ProvidesPackage{texdepends}%
28 % \fi
29 % \ProvidesFile{texdepends.dtx}
30 [2021/10/26 v2.4.3 No changes in texdepends.dtx]
31 % \iffalse
32 %<*driver>
33 \documentclass{ltxdoc}
34 \usepackage[latin1]{inputenc}
35 \usepackage[french,english]{babel}
36 \usepackage{pdfswitch}
37 \NoAutoSpaceBeforeFDP
38 \EnableCrossrefs
39 \CodelineIndex
40 \RecordChanges
41 \setcounter{IndexColumns}{2} % make a twocolumn index
42 \setlength{\columnseprule}{0pt} % no rules between columns ...
43 \setlength{\columnsep}{2em} % ... but more spacing instead.
44 \setcounter{unbalance}{4}
45 \setlength{\IndexMin}{100pt}
46 %%%%\OnlyDescription % uncomment this line to suppress printing the source code
47 \makeatletter
48 % don't show underfull hboxes in index/glossary:
49 \g@addto@macro{\IndexParms}{\hbadness=10000}
50 \g@addto@macro{\GlossaryParms}{\hbadness=10000}
51 \makeatother
52 \begin{document}
53 \DocInput{texdepends.dtx}
54 \PrintIndex
55 \PrintChanges
56 \end{document}
57 %</driver>
58 % \fi
59 %
60 % \GetFileInfo{texdepends.dtx}
61 %
62 % \DoNotIndex{\#,\$,\%,\&,\@,\\,\{,\},\^,\_,\~,\ }
63 % \DoNotIndex{\def,\long,\edef,\xdef,\gdef,\let,\global}
64 % \DoNotIndex{\if,\ifnum,\ifdim,\ifcat,\ifmmode,\ifvmode,\ifhmode,%
65 % \iftrue,\iffalse,\ifvoid,\ifx,\ifeof,\ifcase,\else,\or,\fi,\loop,\do}
66 % \DoNotIndex{\box,\copy,\setbox,\unvbox,\unhbox,\hbox,%
67 % \vbox,\vtop,\vcenter}
68 % \DoNotIndex{\@empty,\immediate,\write}
69 % \DoNotIndex{\egroup,\bgroup,\expandafter,\begingroup,\endgroup}
70 % \DoNotIndex{\divide,\advance,\multiply,\count,\dimen}
71 % \DoNotIndex{\relax,\space,\string}
72 % \DoNotIndex{\csname,\endcsname,\@spaces,\openin,\openout,%
73 % \closein,\closeout}
74 % \DoNotIndex{\catcode,\endinput}
75 % \DoNotIndex{\jobname,\message,\read,\the,\noexpand}
76 % \DoNotIndex{\hsize,\vsize,\hskip,\vskip,\kern,\hfil,\hfill,\hss}
77 % \DoNotIndex{\m@ne,\z@,\@m,\z@skip,\@ne,\tw@,\p@}
78 % \DoNotIndex{\DeclareRobustCommand,\DeclareOption,\newcommand,\newcommand*}
79 % \DoNotIndex{\newcount,\newif,\newlinechar,\newread,\newtoks,\newwrite}
80 % \DoNotIndex{\dp,\wd,\ht,\vss,\unskip,\ifthenelse}
81 %
82 % \DoNotIndex{\@filef@und,\@nameddef,\@tempa}
83 % \DoNotIndex{\define@key,\equal,\ExecuteOptions}
84 % \DoNotIndex{\filename@area,\filename@base,\filename@ext,\filename@parse}
85 % \DoNotIndex{\Gin@exclamation,\Gin@getbase,\Gin@scalex,\Gin@scaley}
86 % \DoNotIndex{\Gread@eps,\Gread@pdf,\Gscale@box}
87 % \DoNotIndex{\IfFileExists,\ifpdf,\input,\InputIfFileExists}
88 % \DoNotIndex{\MessageBreak,\PackageWarning,\PackageWarningNoLine}
89 % \DoNotIndex{\ProcessOptions,\RequirePackage,\typeout}
90 % \DoNotIndex{}
91 % \DoNotIndex{}
92 %
93 % \title{The \textsf{texdepends} package\thanks{This file
94 % has version number \fileversion, last
95 % revised \filedate.}}
96 % \author{Vincent \textsc{Danjean}}
97 % \date{\filedate}
98 % \maketitle
99 % \begin{abstract}
100 % This package allows \LaTeX\space to automatically generate
101 % dependencies while compiling documents.
102 % \end{abstract}
103 % \CheckSum{801}
104 %
105 % \changes{v1.0.1}{2005/03/22}{Version 1.0.1 at last}
106 % \changes{v1.0.2}{2005/10/22}{Add support for package index.sty}
107 % \changes{v1.1.0}{2005/11/05}{Manage index/glossary}
108 % \changes{v1.1.0}{2005/11/05}{Rewrite of the package}
109 % \changes{v1.2.0}{2008/01/28}{Better management of subfig files}
110 % \changes{v1.3.0}{2011/09/25}{Management of svg files}
111 % \changes{v2.2.5}{2018/09/04}{No changes in texdepends.dtx}
112 % \changes{v2.3.0}{2018/10/17}{ignore comment.cut file from the comment package}
113 % \changes{v2.4.1}{2020/07/10}{No changes in texdepends.dtx}
114 % \changes{v2.4.2}{2021/01/03}{Replace // by / in paths}
115 % \changes{v2.4.3}{2021/10/26}{No changes in texdepends.dtx}
116 %
117 % \makeatletter
118 % \def\SpecialOptionIndex#1{\@bsphack
119 % \index{#1\actualchar{\protect\ttfamily#1}
120 % (option)\encapchar usage}%
121 % \index{options:\levelchar{\protect\ttfamily#1}\encapchar
122 % usage}\@esphack}
123 % \def\SpecialFileIndex#1{\@bsphack
124 % \index{#1\actualchar{\protect\ttfamily#1}
125 % (file)\encapchar usage}%
126 % \index{files:\levelchar{\protect\ttfamily#1}\encapchar
127 % usage}\@esphack}
128 % \def\SpecialMainOptionIndex#1{\@bsphack\special@index{#1\actualchar
129 % {\string\ttfamily\space#1}
130 % (option)\encapchar main}%
131 % \special@index{options:\levelchar{%
132 % \string\ttfamily\space#1}\encapchar
133 % main}\@esphack}
134 % \def\option{\begingroup
135 % \catcode`\\12
136 % \MakePrivateLetters \mym@cro@ \iffalse}
137 % \long\def\mym@cro@#1#2{\endgroup \topsep\MacroTopsep \trivlist
138 % \edef\saved@macroname{\string#2}%
139 % \def\makelabel##1{\llap{##1}}%
140 % \if@inlabel
141 % \let\@tempa\@empty \count@\macro@cnt
142 % \loop \ifnum\count@>\z@
143 % \edef\@tempa{\@tempa\hbox{\strut}}\advance\count@\m@ne \repeat
144 % \edef\makelabel##1{\llap{\vtop to\baselineskip
145 % {\@tempa\hbox{##1}\vss}}}%
146 % \advance \macro@cnt \@ne
147 % \else \macro@cnt\@ne \fi
148 % \edef\@tempa{\noexpand\item[%
149 % #1%
150 % \noexpand\PrintMacroName
151 % \else
152 % \noexpand\PrintEnvName
153 % \fi
154 % {\string#2}]}%
155 % \@tempa
156 % \global\advance\c@CodelineNo\@ne
157 % #1%
158 % \SpecialMainIndex{#2}\nobreak
159 % \DoNotIndex{#2}%
160 % \else
161 % \SpecialMainOptionIndex{#2}\nobreak
162 % \fi
163 % \global\advance\c@CodelineNo\m@ne
164 % \ignorespaces}
165 % \let\endoption \endtrivlist
166 % \def\DescribeOption{\leavevmode\@bsphack\begingroup\MakePrivateLetters
167 % \Describe@Option}
168 % \def\Describe@Option#1{\endgroup
169 % \marginpar{\raggedleft\PrintDescribeEnv{#1}}%
170 % \SpecialOptionIndex{#1}\@esphack\ignorespaces}
171 % \def\DescribeFile{\leavevmode\@bsphack\begingroup\MakePrivateLetters
172 % \Describe@Option}
173 % \def\Describe@File#1{\endgroup
174 % \marginpar{\raggedleft\PrintDescribeEnv{#1}}%
175 % \SpecialFileIndex{#1}\@esphack\ignorespaces}
176 % \makeatother
177 % \MakeShortVerb{\|}
178 %
179 % \tableofcontents
180 % \section{Introduction}
181 % This package automatically generates dependancies on \LaTeX\ files and
182 % packages, figures, bibliography files, glossary and index files. The
183 % generated file is then used by a Makefile to handle dependancies.
184 % \StopEventually{
185 % }
186 % \section{Implementation of texdepends}
187 % \subsection{Options}
188 % \begin{macrocode}
189 %<*package>
190 % \end{macrocode}
191 % |texdepends| is easier to write with the |ifthen| package.
192 % \begin{macrocode}
193 \RequirePackage{ifthen}
194 % \end{macrocode}
195 % \begin{option}{debug}
196 % The debug option (enable debug messages, useful for debuging)
197 % \begin{macrocode}
198 \newboolean{TD@debug}
199 \newcommand{\TD@option@debug}[1][true]{%
200 %\PackageWarningNoLine{texdepends}{Setting debug to #1}
201 \setboolean{TD@debug}{#1}%
202 }%
203 % \end{macrocode}
204 % \end{option}
205 % \begin{option}{extension}
206 % The extension option. We can use it to let |texdepends|
207 % know whether we compile a dvi or a pdf file.
208 % \begin{macrocode}
209 \def\TD@option@extension[#1]{%
210 %\PackageWarningNoLine{texdepends}{Using extention #1}
211 \def\TD@extention{#1}%
212 }%
213 % \end{macrocode}
214 % \end{option}
215 % Managing options with specific code. Using the |keyval|
216 % package could be a solution, but this would add one more dependency.
217 % \begin{macrocode}
218 \def\TD@option@split#1=#2=#3\relax{%
219 \def\TD@option@name{#1}%
220 \ifx\TD@option@name\@empty\else
221 \expandafter\let\expandafter\TD@option@cmd
222 \csname TD@option@\TD@option@name\endcsname
223 %\PackageWarningNoLine{texdepends}{1: '#1', 2: '#2', 3: '#3'}
224 \ifx\TD@option@cmd\relax
225 \@unknownoptionerror%
226 \else
227 \ifx\@empty#3\@empty
228 \TD@option@cmd\relax%
229 \else
230 \def\TD@option@value{#2}%
231 \TD@option@cmd[\TD@option@value]%
232 \fi
233 \fi
234 \fi
235 }%
236 % \end{macrocode}
237 % All option are managed by the same code.
238 % \begin{macrocode}
239 \DeclareOption*{%
240 %\PackageWarningNoLine{texdepends}{Option \CurrentOption}%
241 \expandafter\TD@option@split\CurrentOption==\relax%
242 }%
243 % \end{macrocode}
244 % So lets process options
245 % \begin{macrocode}
246 \ProcessOptions
247 % \end{macrocode}
248 % If the |extension| option is not used, we try to find ourselves
249 % the good extension based on TeX engine or mode.
250 % \begin{macrocode}
251 \ifthenelse{\isundefined{\TD@extention}}{%
252 \PackageWarningNoLine{texdepends}{No extension given: detecting it}%
253 \RequirePackage{ifxetex,ifpdf}%
254 \ifxetex%
255 \PackageWarningNoLine{textdepends}{Detected XeTeX: using .pdf}%
256 \def\TD@extention{.pdf}%
257 \else\ifpdf%
258 \PackageWarningNoLine{texdepends}{Detected PDF mode: using .pdf}%
259 \def\TD@extention{.pdf}%
260 \else%
261 \PackageWarningNoLine{texdepends}{Detected DVI mode. Using .dvi}%
262 \def\TD@extention{.dvi}%
263 \fi\fi%
264 }{}%
265 % \end{macrocode}
266 %
267 % \subsection{Tools}
268 % Some macros to help development
269 % \subsubsection{Debug/info wrapper}
270 % \begin{macro}{\TD@warning}
271 % To write a warning
272 % \begin{macrocode}
273 \RequirePackage{xstring}%
274 \newcommand{\TD@warning}[1]{%
275 \PackageWarningNoLine{texdepends}{#1}%
276 }%
277 % \end{macrocode}
278 % \end{macro}
279 % \begin{macro}{\TD@warningLine}
280 % To write a warning with line info
281 % \begin{macrocode}
282 \newcommand{\TD@warningLine}[1]{%
283 \PackageWarning{texdepends}{#1}%
284 }%
285 % \end{macrocode}
286 % \end{macro}
287 % \begin{macro}{\TD@info}
288 % To write an info (as a warning if the |debug| option is set
289 % \begin{macrocode}
290 \newcommand{\TD@info}[1]{%
291 \ifthenelse{\boolean{TD@debug}}{%
292 \PackageWarningNoLine{texdepends}{#1}%
293 }{%
294 \PackageInfo{texdepends}{#1}%
295 }%
296 }%
297 % \end{macrocode}
298 % \end{macro}
299 % \begin{macro}{\TD@debug}
300 % To write a message if the |debug| option is set
301 % \begin{macrocode}
302 \newcommand{\TD@debug}[1]{%
303 \ifthenelse{\boolean{TD@debug}}{%
304 \PackageWarningNoLine{texdepends}{#1}%
305 }{%
306 }%
307 }%
308 % \end{macrocode}
309 % \end{macro}
310 % \subsubsection{Writing dependencies}
311 % We open the file where we will write dependencies and other infos.
312 % \begin{macrocode}
313 \newwrite\TD@write
314 \TD@info{Writing info in '\jobname\[email protected]'}
315 \immediate\openout\TD@write\jobname\[email protected]%
316 % \end{macrocode}
317 % And we define a few macro to write in this file
318 %
319 % \begin{macro}{\TD@print}
320 % We write something in the file
321 % \begin{macrocode}
322 \def\TD@print#1{%
323 {%
324 % TODO: fix pb when #1 contains '#'
325 %\noexpandarg%
326 \StrSubstitute{#1}{//}{/}[\TD@write@text]%
327 \immediate\write\TD@write{\TD@write@text}%
328 %\immediate\write\TD@write{#1}%
329 }
330 }%
331 % \end{macrocode}
332 % \end{macro}
333 % \begin{macro}{\TD@printClass}
334 % We need a class
335 % \begin{macrocode}
336 \def\TD@printClass#1{%
337 \TD@print{TD_\jobname\TD@extention _INPUTS\space += #1.cls}%
338 }%
339 % \end{macrocode}
340 % \end{macro}
341 % \begin{macro}{\TD@printPackage}
342 % We need a package
343 % \begin{macrocode}
344 \def\TD@printPackage#1{%
345 \TD@print{TD_\jobname\TD@extention _INPUTS\space += #1.sty}%
346 }%
347 % \end{macrocode}
348 % \end{macro}
349 % \begin{macro}{\TD@printInput}
350 % We need a (\LaTeX) file
351 % \begin{macrocode}
352 \def\TD@printInput#1{%
353 \TD@print{TD_\jobname\TD@extention _INPUTS\space += #1}%
354 }%
355 % \end{macrocode}
356 % \end{macro}
357 % \begin{macro}{\TD@printFig}
358 % We want to ignore a dependency
359 % \begin{macrocode}
360 \def\TD@printNoDependsFile#1{%
361 \TD@print{TD_\jobname\TD@extention _DEPENDS_EXCLUDE\space += #1}%
362 }%
363 % \end{macrocode}
364 % \end{macro}
365 % \begin{macro}{\TD@printFig}
366 % We need an |XFig| file
367 % \begin{macrocode}
368 \def\TD@printFig#1{%
369 \TD@print{TD_\jobname\TD@extention _FIGURES\space += #1}%
370 }%
371 % \end{macrocode}
372 % \end{macro}
373 % \begin{macro}{\TD@printSubfig}
374 % Web need a subfig file (see figlatex.dtx)
375 % \begin{macrocode}
376 \def\TD@printSubfig#1{%
377 \TD@print{TD_\jobname\TD@extention _SUBFIGS\space += #1}%
378 }%
379 % \end{macrocode}
380 % \end{macro}
381 % \begin{macro}{\TD@printRequiredFile}
382 % A file is missing. |texdepend| will try to skip it this time,
383 % but it will be needed at the next compilation
384 % \begin{macrocode}
385 \def\TD@printRequiredFile#1#2{%
386 \TD@print{TD_\jobname\TD@extention _REQUIRED\space += #1}%
387 }%
388 % \end{macrocode}
389 % \end{macro}
390 % \begin{macro}{\RequireFile}
391 % LaTeX users can directly declare a dependencie
392 % \begin{macrocode}
393 \def\RequireFile#1{%
394 \TD@printRequiredFile{#1}{User}%
395 }%
396 % \end{macrocode}
397 % \end{macro}
398 % \begin{macro}{\TD@printOut}
399 % We write in a file
400 % \begin{macrocode}
401 \def\TD@printOut#1{%
402 \TD@print{TD_\jobname\TD@extention _OUTPUTS\space += #1}%
403 }%
404 % \end{macrocode}
405 % \end{macro}
406 % \begin{macro}{\TD@printGraphicspath}
407 % We modify the graphicspath
408 % \begin{macrocode}
409 \def\TD@printGraphicspath#1{%
410 \TD@print{TD_\jobname\TD@extention _GRAPHICSPATH\space := #1}%
411 }%
412 % \end{macrocode}
413 % \end{macro}
414 % \begin{macro}{\TD@printBibfile}
415 % We use a bibfile (|*.bib|)
416 % \begin{macrocode}
417 \def\TD@printBibfile#1{%
418 \TD@print{TD_\jobname\TD@extention _BIBFILES\space += #1.bib}%
419 }%
420 % \end{macrocode}
421 % \end{macro}
422 % \begin{macro}{\TD@printBibstyle}
423 % We use a bibstyle file (|*.bst|)
424 % \begin{macrocode}
425 \def\TD@printBibstyle#1{%
426 \TD@print{TD_\jobname\TD@extention _BIBSTYLES\space += #1.bst}%
427 }%
428 % \end{macrocode}
429 % \end{macro}
430 % \begin{macro}{\TD@printBblfile}
431 % We use a bibliography file (|*.bbl|)
432 % \begin{macrocode}
433 \def\TD@printBblfile#1{%
434 \TD@print{TD_\jobname\TD@extention _BBLFILES\space += #1.bbl}%
435 }%
436 % \end{macrocode}
437 % \end{macro}
438 % \begin{macro}{\TD@printRebuildRule}
439 % We need a specific rule in the |Makefile| to check if a
440 % rebuild is needed
441 % \begin{macrocode}
442 \def\TD@printRebuildRule#1{%
443 \TD@print{TD_\jobname\TD@extention _REBUILD_RULES\space += #1}%
444 }%
445 % \end{macrocode}
446 % \end{macro}
447 % \begin{macro}{\TD@printIndex}
448 % We use a new index
449 % \begin{macrocode}
450 \def\TD@printIndex#1{%
451 \TD@print{TD_\jobname\TD@extention _INDEXES\space += INDEX}%
452 \TD@print{TD_\jobname\TD@extention _INDEXES_INDEX\space += #1}%
453 }%
454 % \end{macrocode}
455 % \end{macro}
456 % \begin{macro}{\TD@printIndexSource}
457 % The index file filled by \LaTeX
458 % \begin{macrocode}
459 \def\TD@printIndexSource#1#2{%
460 \TD@print{TD_\jobname\TD@extention _INDEX_#1_SRC\space = #2}%
461 }%
462 % \end{macrocode}
463 % \end{macro}
464 % \begin{macro}{\TD@printIndexTarget}
465 % And the index file read by \LaTeX{} after |makeindex|
466 % processing
467 % \begin{macrocode}
468 \def\TD@printIndexTarget#1#2{%
469 \TD@print{TD_\jobname\TD@extention _INDEX_#1_TARGET\space = #2}%
470 }%
471 % \end{macrocode}
472 % \end{macro}
473 % \begin{macro}{\TD@printIndexStyle}
474 % The index style to be used with |makeindex| (never
475 % called for now)
476 % \begin{macrocode}
477 \def\TD@printIndexStyle#1#2{%
478 \TD@print{TD_\jobname\TD@extention _INDEX_#1_STYLE\space = #2}%
479 }%
480 % \end{macrocode}
481 % \end{macro}
482 % \begin{macro}{\TD@printGlossary}
483 % And the same things for glossary. Its name
484 % \begin{macrocode}
485 \def\TD@printGlossary#1{%
486 \TD@print{TD_\jobname\TD@extention _INDEXES += GLOSS}%
487 \TD@print{TD_\jobname\TD@extention _INDEXES_GLOSS\space += #1}%
488 }%
489 % \end{macrocode}
490 % \end{macro}
491 % \begin{macro}{\TD@printGlossarySource}
492 % The glossary file filled by \LaTeX
493 % \begin{macrocode}
494 \def\TD@printGlossarySource#1#2{%
495 \TD@print{TD_\jobname\TD@extention _GLOSS_#1_SRC\space = #2}%
496 }%
497 % \end{macrocode}
498 % \end{macro}
499 % \begin{macro}{\TD@printGlossaryTarget}
500 % And the glossary file read by \LaTeX{} after |makeindex|
501 % processing
502 % \begin{macrocode}
503 \def\TD@printGlossaryTarget#1#2{%
504 \TD@print{TD_\jobname\TD@extention _GLOSS_#1_TARGET\space = #2}%
505 }%
506 % \end{macrocode}
507 % \end{macro}
508 % \begin{macro}{\TD@printGlossaryStyle}
509 % The glossary style to be used with |makeindex| (never
510 % called for now)
511 % \begin{macrocode}
512 \def\TD@printGlossaryStyle#1#2{%
513 \TD@print{TD_\jobname\TD@extention _GLOSS_#1_STYLE\space = #2}%
514 }%
515 % \end{macrocode}
516 % \end{macro}
517 %
518 % \subsubsection{Diverting a macro}
519 % \begin{macro}{\TD@switch}
520 % |\TD@switch| replace the macro |\#1| by the macro |\TD@#1|. The
521 % original macro is stored in the |\TD@orig@#1| macro. Nothing is done
522 % if |\#1| is already |\TD@#1| (that is if |\TD@switch| is called
523 % severall times with the same argument)
524 % \begin{macrocode}
525 \def\TD@switch#1{%
526 \expandafter\let\expandafter\TD@local@old\csname#1\endcsname%
527 \expandafter\let\expandafter\TD@local@new\csname TD@#1\endcsname%
528 \ifx\TD@local@old\TD@local@new
529 \PackageWarning{texdepends}{#1 already redefined. Skipping it.}%
530 \else
531 \ifx\TD@local@old\relax
532 \TD@warning{Diverting empty macro '#1' \MessageBreak%
533 Probably a bug in texdepends.sty}%
534 \else
535 \TD@info{Diverting macro '#1'}%
536 \fi
537 \expandafter\let\csname TD@orig@#1\endcsname\TD@local@old%
538 \expandafter\let\csname#1\endcsname\TD@local@new%
539 \fi
540 }%
541 % \end{macrocode}
542 % \end{macro}
543 % \begin{macro}{\TD@docswitch}
544 % Sometimes, we want the diversion to be delayed until the start of
545 % the document.
546 % \begin{macrocode}
547 \def\TD@docswitchlist{}%
548 \def\TD@docswitch#1{%
549 \TD@info{Registering macro '#1' for diversion}%
550 \ifx\TD@docswitchlist\@empty%
551 \xdef\TD@docswitchlist{#1}%
552 \else%
553 \xdef\TD@docswitchlist{\TD@docswitchlist,#1}%
554 \fi%
555 }%
556 \AtBeginDocument{%
557 \TD@info{Diverting registered macros...}%
558 \@for\TD@cmd:=\TD@docswitchlist\do{%
559 \TD@switch{\TD@cmd}%
560 }%
561 \TD@info{Divertions done}%
562 }%
563 % \end{macrocode}
564 % \end{macro}
565 %
566 % \begin{macro}{\TD@PackagePreDivert}
567 % \begin{macro}{\TD@PackagePostDivert}
568 % And then, two macros to insert command just before or after
569 % loading a package. The first argument is the name of the package
570 % we want to add an hook before or after, and then there is the
571 % definition of the hook that will be called. Four parameters (|#1|,
572 % \ldots, |#4|) are available (the same as the |@onefilewithoptions|
573 % \LaTeX{} macro, ie package name, options, and the two remaining ;-)).
574 % \begin{macrocode}
575 \def\TD@PackagePreDivert#1{%
576 \expandafter\def\csname TD@PackageStart@#1\endcsname ##1##2##3##4%
577 }%
578 \def\TD@PackagePostDivert#1{%
579 \expandafter\def\csname TD@PackageEnd@#1\endcsname ##1##2##3##4%
580 }%
581 % \end{macrocode}
582 % \end{macro}
583 % \end{macro}
584 %
585 % \subsubsection{Initialisation}
586 % We need to be loaded \emph{before} \string\documentclass
587 % \begin{macrocode}
588 \ifx\documentclass\@twoclasseserror
589 \PackageError{texdepends}{texdepends needs to be loaded BEFORE
590 \string\documentclass \MessageBreak
591 Use \string\RequirePackage\space instead of \string\usepackage
592 \MessageBreak as the later is not allowed before
593 \string\documentclass}
594 \fi
595 % \end{macrocode}
596 % And we write the first dependency (upon ourself)
597 % \begin{macrocode}
598 \TD@printPackage{texdepends}
599 % \end{macrocode}
600 % We write default graphicspath (is this really needed ?)
601 % \begin{macrocode}
602 \TD@printGraphicspath{{.}}
603 % \end{macrocode}
604 %
605 % \subsubsection{Warning upon missing figures}
606 % \begin{macro}{\TD@depends}
607 % \begin{macro}{\TD@dependsWarning}
608 % \begin{macro}{\TD@missingDepends}
609 % If some figures are missing, |\TD@missingDepends| will be called so
610 % that a warning will be displayed at the end of the
611 % compilation. Figures should be generated before the next run.
612 % \begin{macrocode}
613 \def\TD@depends{}%
614 \def\TD@dependsWarning{%
615 \PackageWarningNoLine{texdepends}{Figure(s) missing. Check
616 dependencies again}%
617 }%
618 \def\TD@missingDepends{%
619 \global\let\TD@depends\TD@dependsWarning%
620 }%
621 \AtEndDocument{%
622 \TD@depends%
623 }%
624 % \end{macrocode}
625 % \end{macro}
626 % \end{macro}
627 % \end{macro}
628 % \subsection{Diversion of \LaTeX{} macros}
629 %
630 % \subsubsection{Class and package loading}
631 % \begin{macro}{\TD@@fileswith@pti@ns}
632 % \begin{macro}{\TD@@@fileswith@pti@ns}
633 % Diverting |\@fileswith@pti@ns| and |@@fileswith@pti@ns| so that we
634 % can track class loading. Package are tracked with an other macro
635 % (see just after).
636 % \begin{macrocode}
637 \def\TD@@fileswith@pti@ns#1[#2]#3[#4]{%
638 \ifx#1\@clsextension
639 \TD@printClass{#3}
640 \fi
641 \TD@orig@@fileswith@pti@ns{#1}[#2]{#3}[#4]%
642 }%
643 \let\TD@@@fileswith@pti@ns\TD@@fileswith@pti@ns
644 \TD@switch{@fileswith@pti@ns}%
645 \TD@switch{@@fileswith@pti@ns}%
646 % \end{macrocode}
647 % \end{macro}
648 % \end{macro}
649 %
650 % \begin{macro}{\TD@@onefilewithoptions}
651 % By diverting |\@onefilewithoptions|, we can track all loaded
652 % packages. We write the dependency, and we look at the loaded package
653 % to see if we need some special requirements
654 % \begin{macrocode}
655 \def\TD@@onefilewithoptions#1[#2][#3]#4{%
656 \TD@printPackage{#1}%
657 \ifthenelse{\equal{#1}{texdepends}}{%
658 % \end{macrocode}
659 % The |texdepends| package is special : we know it has already been
660 % loaded (we are running code in it) but perhaps \LaTeX{} does not
661 % know it. So we try to honor the |debug| option.
662 % \begin{macrocode}
663 \TD@debug{Package '#1' detected}
664 \@for\TD@package@option:=#2\do{%
665 \ifthenelse{\expandafter\isundefined\csname TD@option@\TD@package@option\endcsname}{
666 \TD@warningLine{Ignoring unknown option '\TD@package@option'}
667 }{
668 \ifthenelse{%
669 \equal{\TD@package@option}{debug}%
670 %\OR\equal{\TD@package@option}{debug}%
671 }{
672 \csname TD@option@\TD@package@option\endcsname%
673 }{
674 \TD@warningLine{Ignoring option '\TD@package@option'
675 \MessageBreak #1 already loaded
676 }
677 }
678 }
679 }
680 }{%
681 \expandafter\let\expandafter\TD@divert
682 \csname TD@PackageStart@#1\endcsname
683 \ifx\TD@divert\relax
684 \TD@debug{No preamble for package #1}
685 \else
686 \TD@info{Preamble for package #1}
687 \TD@divert{#1}{#2}{#3}{#4}%
688 \fi
689 \TD@orig@@onefilewithoptions{#1}[#2][#3]{#4}%
690 \expandafter\let\expandafter\TD@divert
691 \csname TD@PackageEnd@#1\endcsname
692 \ifx\TD@divert\relax
693 \TD@debug{No postamble for package #1}
694 \else
695 \TD@info{Postamble for package #1}
696 \TD@divert{#1}{#2}{#3}{#4}%
697 \fi
698 }%
699 }%
700 \TD@switch{@onefilewithoptions}%
701 % \end{macrocode}
702 % \end{macro}
703 %
704 % \subsubsection{Tracking input files}
705 % \begin{macro}{\TD@@iinput}
706 % \begin{macro}{\TD@@input@}
707 % |\@iinput| and |\@input@| are diverted to track loaded files
708 % \begin{macrocode}
709 \def\TD@@iinput#1{%
710 \TD@printInput{#1}%
711 \TD@orig@@iinput{#1}}%
712 \def\TD@@input@#1{%
713 \IfFileExists{#1}{%
714 \TD@printInput{#1}%
715 }{}%
716 \TD@orig@@input@{#1}}%
717 \TD@switch{@iinput}%
718 \TD@switch{@input@}%
719 \def\TD@verbatiminput#1{%
720 \TD@printInput{#1}%
721 \TD@orig@verbatiminput{#1}}%
722 \TD@PackagePostDivert{verbatim}{%
723 \TD@switch{verbatiminput}}%
724 % \end{macrocode}
725 % \end{macro}
726 % \end{macro}
727 %
728 % \subsubsection{Tracking output files}
729 % \begin{macro}{\TD@openout}
730 % \begin{macro}{\TD@poenout@eq}
731 % \begin{macro}{\TD@poenout@noeq}
732 % Note: that does not work. Currently, we parse the log file instead
733 % of using this. If someone has ideas\ldots
734 % \begin{macrocode}
735 \let\TD@orig@openout\openout
736 \def\TD@openout#1{%
737 \@ifnextchar={\TD@openout@eq#1}{\TD@openout@noeq#1}}
738 \def\TD@openout@eq#1=#2.#3{%
739 \TD@printOut{#2.#3}%
740 \TD@orig@openout#1=#2.#3%
741 }%
742 \def\TD@openout@noeq#1#2.#3{%
743 \TD@printOut{#2.#3}%
744 \TD@orig@openout#1#2.#3%
745 }%
746 %\TD@switch{openout}
747 % \end{macrocode}
748 % \end{macro}
749 % \end{macro}
750 % \end{macro}
751 % \subsubsection{Tracking bibliography files}
752 % \begin{macrocode}
753 \def\TD@bibli@bbl{%
754 \TD@printBblfile{\jobname}%
755 \global\let\TD@bibli@bbl\relax%
756 }%
757 \def\TD@bibli@files#1{%
758 \TD@bibli@bbl%
759 \@for\TD@bibfile:=#1\do{%
760 \TD@printBibfile{\TD@bibfile}%
761 }%
762 }
763 \def\TD@bibli@style#1{%
764 \TD@bibli@bbl%
765 %\@for\TD@bibstyle:=#1\do{%
766 % \TD@printBibstyle{\TD@bibstyle}%
767 %}
768 \TD@printBibstyle{#1}%
769 }
770 \def\TD@bibliography#1{%
771 \TD@bibli@files{#1}%
772 \TD@orig@bibliography{#1}%
773 }%
774 \def\TD@bibliographystyle#1{%
775 \TD@bibli@style{#1}%
776 \TD@orig@bibliographystyle{#1}%
777 }%
778 \TD@docswitch{bibliography}%
779 \TD@switch{bibliographystyle}%
780 % \end{macrocode}
781 % \subsubsection{Glossary and index files}
782 % \begin{macrocode}
783 \def\TD@makeindex{%
784 \TD@printIndex{\jobname}%
785 \TD@printIndexSource{\jobname}{\jobname.idx}%
786 \TD@orig@makeindex%
787 }%
788 \def\TD@makeglossary{%
789 \TD@printGlossary{\jobname}%
790 \TD@printGlossarySource{\jobname}{\jobname.glo}%
791 \TD@orig@makeglossary%
792 }%
793 \TD@switch{makeindex}%
794 \TD@switch{makeglossary}%
795 % \end{macrocode}
796 % \subsection{Diversion of package's macros}
797 % \subsubsection{Package graphics}
798 % \begin{macrocode}
799 \def\TD@Gin@getbase#1{%
800 \TD@orig@Gin@getbase{#1}%
801 \ifx\Gin@ext\relax%
802 \else%
803 \TD@printFig{\Gin@base\Gin@ext}%
804 \fi%
805 }%
806 \def\TD@Ginclude@eps#1{%
807 \IfFileExists{#1}{%
808 \TD@orig@Ginclude@eps{#1}%
809 }{%
810 \PackageWarning{texdepends}{Figure '#1' needed\MessageBreak
811 Skipping it this time (the last one however)\MessageBreak}%
812 \TD@missingDepends%
813 \TD@printRequiredFile{#1}{eps}%
814 }%
815 }%
816 \def\TD@Ginclude@pdf#1{%
817 \IfFileExists{#1}{%
818 \TD@orig@Ginclude@pdf{#1}%
819 }{%
820 \PackageWarning{texdepends}{Figure '#1' needed\MessageBreak
821 Skipping it this time (the last one however)\MessageBreak}%
822 \TD@missingDepends%
823 \TD@printRequiredFile{#1}{pdf}%
824 }%
825 }%
826 \def\TD@graphicspath#1{%
827 \TD@printGraphicspath{#1}%
828 \TD@orig@graphicspath{#1}%
829 }%
830 \def\TD@Gread@eps#1{%
831 \IfFileExists{#1}{%
832 %\PackageWarning{texdepends}{Gread File '#1' exists}%
833 \TD@orig@Gread@eps{#1}%
834 }{%
835 \PackageWarning{texdepends}{No '#1' file \MessageBreak
836 using 1 for graphic dimensions}%
837 \setbox\@tempboxa\hbox{\relax}%
838 \def\Gin@llx{1}\let\Gin@lly\Gin@llx
839 \Gin@defaultbp\Gin@urx{\wd\@tempboxa}%
840 \Gin@defaultbp\Gin@ury{\ht\@tempboxa}%
841 }%
842 }%
843 \def\TD@Gread@pdf#1{%
844 \IfFileExists{#1}{%
845 %\PackageWarning{texdepends}{Gread File '#1' exists}%
846 \TD@orig@Gread@pdf{#1}%
847 }{%
848 \PackageWarning{texdepends}{No '#1' file \MessageBreak
849 using 1 for graphic dimensions}%
850 \setbox\@tempboxa\hbox{\relax}%
851 \def\Gin@llx{1}\let\Gin@lly\Gin@llx
852 \Gin@defaultbp\Gin@urx{\wd\@tempboxa}%
853 \Gin@defaultbp\Gin@ury{\ht\@tempboxa}%
854 }%
855 }%
856 \TD@PackagePostDivert{graphics}{%
857 \TD@switch{graphicspath}%
858 \TD@docswitch{Gin@getbase}%
859 \TD@docswitch{Ginclude@eps}%
860 \TD@docswitch{Ginclude@pdf}%
861 \TD@docswitch{Gread@eps}%
862 \TD@docswitch{Gread@pdf}%
863 }%
864 % \end{macrocode}
865 % \subsubsection{Package figlatex}
866 % \begin{macrocode}
867 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
868 % We do not want to fail when trying to load a missing subfig.
869 % \@Ginclude@rawtex
870 \def\TD@FL@includerawtexgraphics[#1]#2{%
871 \IfFileExists{#2}{%
872 \TD@orig@FL@includerawtexgraphics[#1]{#2}%
873 }{%
874 \PackageWarning{texdepends}{Figure '#2' needed\MessageBreak
875 Skipping it this time (the last one however)\MessageBreak}%
876 \TD@missingDepends%
877 \TD@printRequiredFile{#2}{rawtexgraphics}%
878 }%
879 }%
880
881 \def\TD@Ginclude@rawtex#1{%
882 \IfFileExists{#1}{%
883 \TD@orig@Ginclude@rawtex{#1}%
884 }{%
885 \PackageWarning{texdepends}{Figure '#1' needed\MessageBreak
886 Skipping it this time (the last one however)\MessageBreak}%
887 \TD@missingDepends%
888 \TD@printRequiredFile{#1}{rawtex}%
889 }%
890 }%
891
892 % \@Ginclude@figtex
893 \def\TD@Ginclude@figtex#1{%
894 \IfFileExists{#1}{%
895 %\PackageWarning{texdepends}{Ginclude File '#1' exists}%
896 \TD@orig@Ginclude@figtex{#1}%
897 }{%
898 \ifthenelse{\isundefined{\FL@subfig@mainfigname}}{%
899 \PackageWarning{texdepends}{Figure '#1' needed\MessageBreak
900 Skipping it this time (the last one however)\MessageBreak}%
901 }{%
902 \PackageWarning{texdepends}{SubFigure '#1' from
903 \FL@subfig@mainfigname needed\MessageBreak
904 Skipping it this time (the last one however)\MessageBreak}%
905 }
906 \TD@missingDepends%
907 \TD@printRequiredFile{#1}{figtex}%
908 }%
909 }%
910 % \@Ginclude@svgtex
911 \def\TD@Ginclude@svgtex#1{%
912 \IfFileExists{#1}{%
913 %\PackageWarning{texdepends}{Ginclude File '#1' exists}%
914 \TD@orig@Ginclude@svgtex{#1}%
915 }{%
916 \ifthenelse{\isundefined{\FL@subfig@mainfigname}}{%
917 \PackageWarning{texdepends}{Figure '#1' needed\MessageBreak
918 Skipping it this time (the last one however)\MessageBreak}%
919 }{%
920 \PackageWarning{texdepends}{SubFigure '#1' from
921 \FL@subfig@mainfigname needed\MessageBreak
922 Skipping it this time (the last one however)\MessageBreak}%
923 }
924 \TD@missingDepends%
925 \TD@printRequiredFile{#1}{svgtex}%
926 }%
927 }%
928
929
930 % \@Gread@figtex
931 \def\TD@Gread@figtex#1{%
932 \IfFileExists{#1}{%
933 %\PackageWarning{texdepends}{Gread File '#1' exists}%
934 \TD@orig@Gread@figtex{#1}%
935 }{%
936 \PackageWarning{texdepends}{No '#1' file \MessageBreak
937 using 1 for graphic dimensions}%
938 \setbox\@tempboxa\hbox{\relax}%
939 \def\Gin@llx{1}\let\Gin@lly\Gin@llx
940 \Gin@defaultbp\Gin@urx{\wd\@tempboxa}%
941 \Gin@defaultbp\Gin@ury{\ht\@tempboxa}%
942 }%
943 }%
944
945 % \@Gread@svgtex
946 \def\TD@Gread@svgtex#1{%
947 \IfFileExists{#1}{%
948 %\PackageWarning{texdepends}{Gread File '#1' exists}%
949 \TD@orig@Gread@svgtex{#1}%
950 }{%
951 \PackageWarning{texdepends}{No '#1' file \MessageBreak
952 using 1 for graphic dimensions}%
953 \setbox\@tempboxa\hbox{\relax}%
954 \def\Gin@llx{1}\let\Gin@lly\Gin@llx
955 \Gin@defaultbp\Gin@urx{\wd\@tempboxa}%
956 \Gin@defaultbp\Gin@ury{\ht\@tempboxa}%
957 }%
958 }%
959 % \FL@subfig@check
960 \def\TD@FL@subfig@check#1{%
961 \TD@printRequiredFile{#1}{subfigcheck}%
962 \TD@printSubfig{#1}%
963 }%
964 %
965 \TD@PackagePostDivert{figlatex}{%
966 \TD@docswitch{FL@includerawtexgraphics}%
967 \TD@docswitch{Ginclude@rawtex}%
968 \TD@docswitch{Ginclude@figtex}%
969 \TD@docswitch{Ginclude@svgtex}%
970 \TD@docswitch{Gread@figtex}%
971 \TD@docswitch{Gread@svgtex}%
972 \TD@docswitch{FL@subfig@check}%
973 }%
974 % \end{macrocode}
975 % \subsubsection{Package doc}
976 % \begin{macrocode}
977 \def\TD@PrintIndex{%
978 \TD@printIndexStyle{\jobname}{gind.ist}
979 \TD@printIndexTarget{\jobname}{\jobname.ind}
980 \TD@orig@PrintIndex%
981 }%
982 \def\TD@PrintChanges{%
983 \TD@printGlossaryStyle{\jobname}{gglo.ist}
984 \TD@printGlossaryTarget{\jobname}{\jobname.gls}
985 \TD@orig@PrintChanges%
986 }%
987 \TD@PackagePostDivert{doc}{%
988 \TD@docswitch{PrintIndex}%
989 \TD@docswitch{PrintChanges}%
990 }%
991 % \end{macrocode}
992 % \subsubsection{Package index}
993 % \begin{macrocode}
994 \def\TD@def@index#1#2#3#4{%
995 \TD@printIndex{#2}%
996 \TD@printIndexSource{#2}{\jobname.#3}%
997 \TD@printIndexTarget{#2}{\jobname.#4}
998 \TD@orig@def@index{#1}{#2}{#3}{#4}%
999 }%
1000 \TD@PackagePostDivert{index}{%
1001 \TD@switch{def@index}%
1002 }%
1003 % \end{macrocode}
1004 % \subsubsection{Package makeidx}
1005 % \begin{macrocode}
1006 \def\TD@printindex{%
1007 \TD@printIndexTarget{\jobname}{\jobname.ind}
1008 \TD@orig@printindex%
1009 }%
1010 \TD@PackagePostDivert{makeidx}{%
1011 \TD@docswitch{printindex}%
1012 }%
1013 % \end{macrocode}
1014 % \subsubsection{Package nomencl}
1015 % We divert |makeglossary| again after loading this package as its
1016 % redefines this macro (loosing our divertion). We also setup the
1017 % glossary style for this package.
1018 % \begin{macrocode}
1019 \def\TD@printglossary{%
1020 \TD@printGlossaryTarget{\jobname}{\jobname.gls}
1021 \TD@orig@printglossary%
1022 }%
1023 \TD@PackagePostDivert{nomencl}{%
1024 \TD@docswitch{printglossary}%
1025 \TD@switch{makeglossary}%
1026 \TD@printGlossaryStyle{\jobname}{nomencl.ist}
1027 }%
1028 % \end{macrocode}
1029 % \subsubsection{Package bibtopic}
1030 % \begin{macrocode}
1031 % For the bibtopic package
1032 \def\TD@btSect{%
1033 \@ifnextchar[{\TD@btSect@opt}{\TD@btSect@noopt}}
1034 \def\TD@btSect@opt[#1]#2{%
1035 \TD@bibli@files{#2}%
1036 \TD@bibli@style{#1}%
1037 \TD@orig@btSect[#1]{#2}}
1038 \def\TD@btSect@noopt#1{%
1039 \TD@bibli@files{#1}%
1040 \TD@orig@btSect{#1}}
1041
1042 \def\TD@@bt@write@auxfile{%
1043 \TD@printBblfile{\thebtauxfile}%
1044 \TD@orig@@bt@write@auxfile%
1045 }%
1046 \TD@PackagePostDivert{bibtopic}{%
1047 \global\let\TD@bibli@bbl\relax%
1048 \global\let\TD@biblio@rules@package\TD@biblio@rules@package@bibtopic%
1049 \TD@switch{@bt@write@auxfile}%
1050 \TD@printOut{btbbl.aux}%
1051 \TD@printRebuildRule{bibtopic}%
1052 \TD@docswitch{btSect}%
1053 }%
1054 % \end{macrocode}
1055 % \subsubsection{Package comment}
1056 % \begin{macrocode}
1057 % For the comment package, the |comment.cut| file must not be used as
1058 % a dependency: it is read and written several times during a compilation.
1059 \TD@PackagePostDivert{comment}{%
1060 \TD@printNoDependsFile{comment.cut}%
1061 }%
1062 % \end{macrocode}
1063 % \begin{macrocode}
1064 %</package>
1065 % \end{macrocode}
1066 % \Finale
1067 \endinput