| 1 |
% \iffalse meta-comment |
| 2 |
% |
| 3 |
%<*dtx> |
| 4 |
\ProvidesFile{latex-make.dtx} |
| 5 |
[2021/10/26 v2.4.3 Python 3 as default] |
| 6 |
%</dtx> |
| 7 |
% \fi |
| 8 |
% \iffalse |
| 9 |
%<*driver> |
| 10 |
\documentclass[a4paper]{ltxdoc} |
| 11 |
\usepackage{a4wide} |
| 12 |
\usepackage[utf8]{inputenc} |
| 13 |
\usepackage[T1]{fontenc} |
| 14 |
\usepackage{pdfswitch} |
| 15 |
\usepackage{lmodern} |
| 16 |
\usepackage{array} |
| 17 |
\usepackage{tabularx} |
| 18 |
\usepackage{boxedminipage} |
| 19 |
\EnableCrossrefs |
| 20 |
\CodelineIndex |
| 21 |
\RecordChanges |
| 22 |
\setcounter{IndexColumns}{2} % make a twocolumn index |
| 23 |
\setlength{\columnseprule}{0pt} % no rules between columns ... |
| 24 |
\setlength{\columnsep}{2em} % ... but more spacing instead. |
| 25 |
\setcounter{unbalance}{4} |
| 26 |
\setlength{\IndexMin}{100pt} |
| 27 |
%%%%\OnlyDescription % uncomment this line to suppress printing the source code |
| 28 |
\makeatletter |
| 29 |
% don't show underfull hboxes in index/glossary: |
| 30 |
\g@addto@macro{\IndexParms}{\hbadness=10000} |
| 31 |
\g@addto@macro{\GlossaryParms}{\hbadness=10000} |
| 32 |
\makeatother |
| 33 |
\newenvironment{source}[1][.9\linewidth]{% |
| 34 |
\begin{center}% |
| 35 |
\begin{boxedminipage}[c]{#1}\tt% |
| 36 |
\vspace{1em}% |
| 37 |
\hspace{2em}\begin{minipage}[c]{#1}\tt% |
| 38 |
}{% |
| 39 |
\end{minipage}% |
| 40 |
\vspace{1em}% |
| 41 |
\end{boxedminipage}% |
| 42 |
\end{center}% |
| 43 |
} |
| 44 |
\sloppy |
| 45 |
\begin{document} |
| 46 |
\DocInput{latex-make.dtx} |
| 47 |
\PrintIndex |
| 48 |
\PrintChanges |
| 49 |
\end{document} |
| 50 |
%</driver> |
| 51 |
% \fi |
| 52 |
% |
| 53 |
% \GetFileInfo{latex-make.dtx} |
| 54 |
% |
| 55 |
% \DoNotIndex{\#,\$,\%,\&,\@,\\,\{,\},\^,\_,\~,\ } |
| 56 |
% \DoNotIndex{\def,\long,\edef,\xdef,\gdef,\let,\global} |
| 57 |
% \DoNotIndex{\if,\ifnum,\ifdim,\ifcat,\ifmmode,\ifvmode,\ifhmode,% |
| 58 |
% \iftrue,\iffalse,\ifvoid,\ifx,\ifeof,\ifcase,\else,\or,\fi,\loop,\do} |
| 59 |
% \DoNotIndex{\box,\copy,\setbox,\unvbox,\unhbox,\hbox,% |
| 60 |
% \vbox,\vtop,\vcenter} |
| 61 |
% \DoNotIndex{\@empty,\immediate,\write} |
| 62 |
% \DoNotIndex{\egroup,\bgroup,\expandafter,\begingroup,\endgroup} |
| 63 |
% \DoNotIndex{\divide,\advance,\multiply,\count,\dimen} |
| 64 |
% \DoNotIndex{\relax,\space,\string} |
| 65 |
% \DoNotIndex{\csname,\endcsname,\@spaces,\openin,\openout,% |
| 66 |
% \closein,\closeout} |
| 67 |
% \DoNotIndex{\catcode,\endinput} |
| 68 |
% \DoNotIndex{\jobname,\message,\read,\the,\noexpand} |
| 69 |
% \DoNotIndex{\hsize,\vsize,\hskip,\vskip,\kern,\hfil,\hfill,\hss} |
| 70 |
% \DoNotIndex{\m@ne,\z@,\@m,\z@skip,\@ne,\tw@,\p@} |
| 71 |
% \DoNotIndex{\DeclareRobustCommand,\DeclareOption,\newcommand,\newcommand*} |
| 72 |
% \DoNotIndex{\newcount,\newif,\newlinechar,\newread,\newtoks,\newwrite} |
| 73 |
% \DoNotIndex{\dp,\wd,\ht,\vss,\unskip,\ifthenelse} |
| 74 |
% |
| 75 |
% \DoNotIndex{\@filef@und,\@nameddef,\@tempa} |
| 76 |
% \DoNotIndex{\define@key,\equal,\ExecuteOptions} |
| 77 |
% \DoNotIndex{\filename@area,\filename@base,\filename@ext,\filename@parse} |
| 78 |
% \DoNotIndex{\Gin@exclamation,\Gin@getbase,\Gin@scalex,\Gin@scaley} |
| 79 |
% \DoNotIndex{\Gread@eps,\Gread@pdf,\Gscale@box} |
| 80 |
% \DoNotIndex{\IfFileExists,\ifpdf,\input,\InputIfFileExists} |
| 81 |
% \DoNotIndex{\MessageBreak,\PackageWarning,\PackageWarningNoLine} |
| 82 |
% \DoNotIndex{\ProcessOptions,\RequirePackage,\typeout} |
| 83 |
% \DoNotIndex{\(,\),\.,\1,\t,\n,\^^J} |
| 84 |
% \catcode\endlinechar 12\DoNotIndex{\ |
| 85 |
% }\catcode\endlinechar 10{} |
| 86 |
% \catcode`\$=12 |
| 87 |
% \DoNotIndex{\$} |
| 88 |
% \catcode`\$=3 |
| 89 |
% \DoNotIndex{\DeclareGraphicsExtensions,\DeclareGraphicsRule} |
| 90 |
% |
| 91 |
% |
| 92 |
% \title{The \LaTeX.mk Makefile\\ |
| 93 |
% and related script tools\thanks{This file |
| 94 |
% has version number \fileversion, last |
| 95 |
% revised \filedate.}} |
| 96 |
% \author{Vincent \textsc{Danjean} \and Arnaud \textsc{Legrand}} |
| 97 |
% \date{\filedate} |
| 98 |
% \maketitle |
| 99 |
% \begin{abstract} |
| 100 |
% This package allows to compile all kind and complex \LaTeX\space |
| 101 |
% documents with the help of a Makefile. Dependencies are |
| 102 |
% automatically tracked with the help of the |texdepends.sty| package. |
| 103 |
% \end{abstract} |
| 104 |
% \CheckSum{346} |
| 105 |
% |
| 106 |
% \changes{v2.0.0}{2006/03/09}{First autocommented version} |
| 107 |
% \changes{v2.1.0}{2008/01/28}{That's the question} |
| 108 |
% \changes{v2.1.1}{2009/11/08}{Improve error message} |
| 109 |
% \changes{v2.1.2}{2012/03/17}{Switch from perl to python} |
| 110 |
% \changes{v2.2.0}{2016/02/08}{Support to install LaTeX-Make locally} |
| 111 |
% \changes{v2.2.1}{2016/02/09}{Improve configure} |
| 112 |
% \changes{v2.2.2}{2016/02/09}{Fix bugs} |
| 113 |
% \changes{v2.2.3}{2017/01/08}{Add LuaLaTeX support} |
| 114 |
% \changes{v2.2.4}{2018/05/29}{Fix directory permissions on install} |
| 115 |
% \changes{v2.2.5}{2018/09/04}{fix output format of figdepth.py} |
| 116 |
% \changes{v2.3.0}{2018/10/17}{Add DEPENDS-EXCLUDE, add doc and |
| 117 |
% support for local texmf tree} |
| 118 |
% \changes{v2.4.0}{2020/06/01}{Support inkscape version >= 1.0} |
| 119 |
% \changes{v2.4.1}{2020/07/10}{Fix encoding problem with latexfilter.pl} |
| 120 |
% \changes{v2.4.2}{2021/01/03}{No changes in latex-make.dtx} |
| 121 |
% \changes{v2.4.3}{2021/04/18}{Switch to T1 font encoding and lmodern font} |
| 122 |
% \changes{v2.4.3}{2021/04/18}{Use python3 instead of python} |
| 123 |
% |
| 124 |
% \makeatletter |
| 125 |
% \def\SpecialOptionIndex#1{\@bsphack |
| 126 |
% \index{#1\actualchar{\protect\ttfamily#1} |
| 127 |
% (option)\encapchar usage}% |
| 128 |
% \index{options:\levelchar{\protect\ttfamily#1}\encapchar |
| 129 |
% usage}\@esphack} |
| 130 |
% \def\SpecialFileIndex#1{\@bsphack |
| 131 |
% \index{#1\actualchar{\protect\ttfamily#1} |
| 132 |
% (file)\encapchar usage}% |
| 133 |
% \index{files:\levelchar{\protect\ttfamily#1}\encapchar |
| 134 |
% usage}\@esphack} |
| 135 |
% \def\SpecialMainOptionIndex#1{\@bsphack\special@index{#1\actualchar |
| 136 |
% {\string\ttfamily\space#1} |
| 137 |
% (option)\encapchar main}% |
| 138 |
% \special@index{options:\levelchar{% |
| 139 |
% \string\ttfamily\space#1}\encapchar |
| 140 |
% main}\@esphack} |
| 141 |
% \def\option{\begingroup |
| 142 |
% \catcode`\\12 |
| 143 |
% \MakePrivateLetters \mym@cro@ \iffalse} |
| 144 |
% \long\def\mym@cro@#1#2{\endgroup \topsep\MacroTopsep \trivlist |
| 145 |
% \edef\saved@macroname{\string#2}% |
| 146 |
% \def\makelabel##1{\llap{##1}}% |
| 147 |
% \if@inlabel |
| 148 |
% \let\@tempa\@empty \count@\macro@cnt |
| 149 |
% \loop \ifnum\count@>\z@ |
| 150 |
% \edef\@tempa{\@tempa\hbox{\strut}}\advance\count@\m@ne \repeat |
| 151 |
% \edef\makelabel##1{\llap{\vtop to\baselineskip |
| 152 |
% {\@tempa\hbox{##1}\vss}}}% |
| 153 |
% \advance \macro@cnt \@ne |
| 154 |
% \else \macro@cnt\@ne \fi |
| 155 |
% \edef\@tempa{\noexpand\item[% |
| 156 |
% #1% |
| 157 |
% \noexpand\PrintMacroName |
| 158 |
% \else |
| 159 |
% \noexpand\PrintEnvName |
| 160 |
% \fi |
| 161 |
% {\string#2}]}% |
| 162 |
% \@tempa |
| 163 |
% \global\advance\c@CodelineNo\@ne |
| 164 |
% #1% |
| 165 |
% \SpecialMainIndex{#2}\nobreak |
| 166 |
% \DoNotIndex{#2}% |
| 167 |
% \else |
| 168 |
% \SpecialMainOptionIndex{#2}\nobreak |
| 169 |
% \fi |
| 170 |
% \global\advance\c@CodelineNo\m@ne |
| 171 |
% \ignorespaces} |
| 172 |
% \let\endoption \endtrivlist |
| 173 |
% \def\DescribeOption{\leavevmode\@bsphack\begingroup\MakePrivateLetters |
| 174 |
% \Describe@Option} |
| 175 |
% \def\Describe@Option#1{\endgroup |
| 176 |
% \marginpar{\raggedleft\PrintDescribeEnv{#1}}% |
| 177 |
% \SpecialOptionIndex{#1}\@esphack\ignorespaces} |
| 178 |
% \def\DescribeFile{\leavevmode\@bsphack\begingroup\MakePrivateLetters |
| 179 |
% \Describe@Option} |
| 180 |
% \def\Describe@File#1{\endgroup |
| 181 |
% \marginpar{\raggedleft\PrintDescribeEnv{#1}}% |
| 182 |
% \SpecialFileIndex{#1}\@esphack\ignorespaces} |
| 183 |
% \makeatother |
| 184 |
% \MakeShortVerb{\|} |
| 185 |
% |
| 186 |
% \tableofcontents |
| 187 |
% \newpage |
| 188 |
% \section{Introduction} |
| 189 |
% |
| 190 |
% |latex-make| is a collection of \LaTeX{} packages, scripts and |
| 191 |
% Makefile fragments that allows to easily compile \LaTeX{} documents. |
| 192 |
% The best feature is that \textbf{\emph{dependencies are |
| 193 |
% automatically tracked}}\footnote{Dependencies are tracked with |
| 194 |
% the help of the |texdepend.sty| package that is automatically |
| 195 |
% loaded: no need to specify it with |\textbackslash usepackage\{\}| |
| 196 |
% in your documents.}. |
| 197 |
% \par |
| 198 |
% These tools can be used to compile small \LaTeX{} documents |
| 199 |
% as well as big ones (such as, for example, a thesis with summary, tables of |
| 200 |
% contents, list of figures, list of tabulars, multiple indexes and |
| 201 |
% multiple bibliographies). |
| 202 |
% |
| 203 |
% \section{Quick start} |
| 204 |
% |
| 205 |
% \subsection{First (and often last) step} |
| 206 |
% When you want to use |latex-make|, most of the time you have to |
| 207 |
% create a |Makefile| with the only line: \par |
| 208 |
% \begin{source} |
| 209 |
% include LaTeX.mk |
| 210 |
% \end{source} |
| 211 |
% % Then, the following targets are available: |dvi|, |ps|, |pdf|, |
| 212 |
% \emph{file}|.dvi|, \emph{file}|.ps|, \emph{file}|.pdf|, etc., |
| 213 |
% |clean| and |distclean|. |
| 214 |
% \par |
| 215 |
% |
| 216 |
% All \LaTeX{} documents of the current directory should be compilable |
| 217 |
% with respect to their dependencies. If something fails, please, |
| 218 |
% provide me the smallest example you can create to show me what is |
| 219 |
% wrong. |
| 220 |
% \par\medskip |
| 221 |
% |
| 222 |
% \paragraph{Tip:} |
| 223 |
% If you change the dependencies inside your document (for example, if |
| 224 |
% you change |\include{first}| into |\include{second}|), you may have |
| 225 |
% to type |make distclean| before being able to recompile your |
| 226 |
% document. Else, |make| can fail, trying to build or found the old |
| 227 |
% |first.tex| file. |
| 228 |
% \paragraph{Shared work} |
| 229 |
% If you work with other people that do not have installed (and do not |
| 230 |
% want to install) \LaTeX-Make, you can use the |
| 231 |
% |LaTeX-Make-local-install| target in |LaTeX.mk| to install required |
| 232 |
% files in a local TEXMF tree. You can them commit this |
| 233 |
% tree into your control version system. Then, in your |Makefile|, |
| 234 |
% replace the single line\par |
| 235 |
% \begin{source} |
| 236 |
% include LaTeX.mk |
| 237 |
% \end{source} |
| 238 |
% with something like\par |
| 239 |
% \begin{source}\small |
| 240 |
% export TEXMFHOME:=\$(CURDIR)/relpath/to/local/tree/texmf\\ |
| 241 |
% include \$(shell env TEXMFHOME=\$(TEXMFHOME) $\backslash$\\ |
| 242 |
% \hspace*{12ex}kpsewhich -format texmfscripts LaTeX.mk) |
| 243 |
% \end{source} |
| 244 |
% If you have a previous value for |TEXMFHOME| that you do not want to |
| 245 |
% override, you can use the following (more complexe) snipset\par |
| 246 |
% \begin{source}\small |
| 247 |
% \# Adapt the following line to find the local texmf tree\\ |
| 248 |
% LOCAL\_TEXMF:=\$(CURDIR)/\$(firstword \$(wildcard texmf $\backslash$\\ |
| 249 |
% \hspace*{16ex}../texmf ../../texmf ../../../texmf))\\ |
| 250 |
% \# Get the old TEXMFHOME value\\ |
| 251 |
% TEXMFHOME:=\$(shell kpsewhich -var-value TEXMFHOME)\\ |
| 252 |
% \# If the new tree is already in it, do nothing, else add it\\ |
| 253 |
% ifeq (\$(filter \$(LOCAL\_TEXMF)//%,\$(TEXMFHOME)),)\\ |
| 254 |
% TEXMFHOME := \$(LOCAL\_TEXMF)\$(addprefix :,\$(TEXMFHOME))\\ |
| 255 |
% \# display info so that users know what to define in order to\\ |
| 256 |
% \# compile documents directly with (pdf)latex\\ |
| 257 |
% \$(warning export TEXMFHOME=\$(TEXMFHOME))\\ |
| 258 |
% export TEXMFHOME\\ |
| 259 |
% endif\\ |
| 260 |
% ~\\ |
| 261 |
% include \$(shell env TEXMFHOME=\$(TEXMFHOME) $\backslash$\\ |
| 262 |
% \hspace*{12ex}kpsewhich -format texmfscripts LaTeX.mk) |
| 263 |
% \end{source} |
| 264 |
% Doing so, all co-authors will be able to use \LaTeX-Make without |
| 265 |
% installing it. However, note that: |
| 266 |
% \begin{itemize} |
| 267 |
% \item you wont beneficit of an update of \LaTeX-Make in your system |
| 268 |
% (you will continue to use the locally installed files) ; |
| 269 |
% \item there is no support for upgrading locally installed files (but |
| 270 |
% reexecuting the installation should do a correct upgrade most of |
| 271 |
% the time) ; |
| 272 |
% \item if a user tries to compile the \LaTeX{} source code directly |
| 273 |
% with |[pdf]latex|, he must before either have LaTeX-Make installed |
| 274 |
% or define and export |TEXMFHOME|. |
| 275 |
% \end{itemize} |
| 276 |
% |
| 277 |
% Another possibility is to install package files (|*.sty|) into a |
| 278 |
% directory pointed by |TEXINPUTS|, scripts files (|*.py|) into a |
| 279 |
% directory pointed bt |TEXMFSCRIPTS|, and to directly include |
| 280 |
% |LaTeX.mk|. For example: |
| 281 |
% \begin{source}\small |
| 282 |
% \# use local files by default\\ |
| 283 |
% \# packages in sty/ subdir and scripts in bin/\\ |
| 284 |
% TEXINPUTS:=sty\$(addprefix :,\$(TEXINPUTS))::\\ |
| 285 |
% TEXMFSCRIPTS:=bin\$(addprefix :,\$(TEXMFSCRIPTS))::\\ |
| 286 |
% export TEXINPUTS\\ |
| 287 |
% export TEXMFSCRIPTS\\ |
| 288 |
% \# Force using local LaTeX.mk and not system-wide LaTeX.mk if available\\ |
| 289 |
% include \$(CURDIR)/LaTeX.mk |
| 290 |
% \end{source} |
| 291 |
% \subsection{Customization} |
| 292 |
% Of course, lots of things can be customized. Here are the most |
| 293 |
% useful ones. Look at the section \ref{sec:reference} for more detailed |
| 294 |
% and complete possibilities. |
| 295 |
% \par |
| 296 |
% Customization is done through variables in the |Makefile| set |
| 297 |
% \emph{before} including |LaTeX.mk|. Setting them after can sometimes |
| 298 |
% work, but not always and it is not supported.\par |
| 299 |
% |
| 300 |
% \newcommand{\variable}[4][\texttt]{% |
| 301 |
% \paragraph*{#3}% |
| 302 |
% \addcontentsline{toc}{subsubsection}{#3}% |
| 303 |
% \hfill \hbox{#1{\textbf{#2}}}\par\medskip% |
| 304 |
% \textbf{Example:}\hspace{1em} |#4|\par\medskip } |
| 305 |
% |
| 306 |
% \variable{LU\_MASTERS}% |
| 307 |
% {Which \LaTeX{} documents to compile}% |
| 308 |
% {LU\_MASTERS=figlatex texdepends latex-make}% |
| 309 |
% This variable contains the basename of the \LaTeX{} documents to |
| 310 |
% compile. \par |
| 311 |
% If not set, |LaTeX.mk| looks for all |*.tex| files containing the |
| 312 |
% |\documentclass| command. |
| 313 |
% |
| 314 |
% \variable[]{\emph{master}\texttt{\_MAIN}}% |
| 315 |
% {Which \LaTeX{} main source for a document}% |
| 316 |
% {figlatex\_MAIN=figlatex.dtx}% |
| 317 |
% There is one such variable per documents declared in |LU_MASTERS|. |
| 318 |
% It contains the file against which the |latex| (or |pdflatex|, etc.) |
| 319 |
% program must be run. \par |
| 320 |
% If not set, \emph{master}|.tex| is used. |
| 321 |
% |
| 322 |
% \variable{LU\_FLAVORS}% |
| 323 |
% {Which flavors must be compiled}% |
| 324 |
% {LU\_FLAVORS=DVI DVIPDF}% |
| 325 |
% A flavor can be see as a kind of document (postscript, PDF, DVI, |
| 326 |
% etc.) and the way to create it. For example, a PDF document can be |
| 327 |
% created directly from the |.tex| file (with |pdflatex|), from a |
| 328 |
% |.dvi| file (with |dvipdfm|) or from a postscript file (with |
| 329 |
% |ps2pdf|). This would be three different flavors. |
| 330 |
% \par |
| 331 |
% Some flavors are already defined in |LaTeX.mk|. Other flavors can be |
| 332 |
% defined by the user (see section~\ref{sec:def_flavors}). The list of |
| 333 |
% predefined flavors can be see in the table~\ref{tab:flavors}. A |
| 334 |
% flavor can depend on another. For example, the flavor creating a |
| 335 |
% postscript file from a DVI file depends on the flavor creating a DVI |
| 336 |
% file from a \LaTeX{} file. This is automatically handled. |
| 337 |
% \par |
| 338 |
% If not set, |PS| and |PDF| are used (and |DVI| due to |PS|). |
| 339 |
%\def\extrarowheight{2pt} |
| 340 |
% \begin{table}[htbp] |
| 341 |
% \centering |
| 342 |
% |
| 343 |
% \begin{tabular}{|c|c|l|l|} |
| 344 |
% \hline |
| 345 |
% Flavor & dependency & program variable & Transformation \\ |
| 346 |
% \hline \hline |
| 347 |
% DVI & & LATEX & |.tex| $\Rightarrow$ |.dvi| \\ |
| 348 |
% \hline |
| 349 |
% PS & DVI & DVIPS & |.dvi| $\Rightarrow$ |.ps| \\ |
| 350 |
% \hline |
| 351 |
% PDF & & PDFLATEX & |.tex| $\Rightarrow$ |.pdf| \\ |
| 352 |
% \hline |
| 353 |
% LUALATEX & & LUALATEX & |.tex| $\Rightarrow$ |.pdf| \\ |
| 354 |
% \hline |
| 355 |
% DVIPDF & DVI & DVIPDFM & |.dvi| $\Rightarrow$ |.pdf| \\ |
| 356 |
% \hline |
| 357 |
% \end{tabular} |
| 358 |
% \par\smallskip |
| 359 |
% \begin{minipage}[t]{0.8\linewidth} |
| 360 |
% \em For example, the |DVI| flavor transforms a |*.tex| file into |
| 361 |
% a |*.dvi| file with the |Makefile| command |
| 362 |
% |$(LATEX) $(LATEX_OPTIONS)| |
| 363 |
% \end{minipage} |
| 364 |
% % \caption{Predefined flavors} |
| 365 |
% \label{tab:flavors} |
| 366 |
% |
| 367 |
% \end{table} |
| 368 |
% |
| 369 |
% \variable[]{\emph{prog}/\emph{prog}\texttt{\_OPTIONS}} |
| 370 |
% {Which programs are called and with which options}% |
| 371 |
% { |
| 372 |
% \begin{minipage}[t]{0.5\linewidth} |
| 373 |
% DVIPS=dvips\\DVIPS\_OPTIONS=-t a4 |
| 374 |
% \end{minipage} |
| 375 |
% } |
| 376 |
% Each flavor has a program variable name that is used by |LaTeX.mk| |
| 377 |
% to run the program. Another variable with the suffix |\_OPTIONS| is |
| 378 |
% also provided if needed. See the table~\ref{tab:flavors} the look |
| 379 |
% for the program variable name associated to the predefined flavors. |
| 380 |
% \par |
| 381 |
% Other programs are also run in the same manner. For example, the |
| 382 |
% |makeindex| program is run from |LaTeX.mk| with the help of the |
| 383 |
% variables |MAKEINDEX| and |MAKEINDEX_OPTIONS|. |
| 384 |
% |
| 385 |
% \variable[]{\emph{master}\texttt{\_}\emph{prog}/\emph{master}\texttt{\_}\emph{prog}\texttt{\_OPTIONS}} |
| 386 |
% {Per target programs and options}% |
| 387 |
% { |
| 388 |
% \begin{minipage}[t]{0.5\linewidth} |
| 389 |
% figlatex\_DVIPS=dvips\\ |
| 390 |
% figlatex\_DVIPS\_OPTIONS=-t a4 |
| 391 |
% \end{minipage} |
| 392 |
% } |
| 393 |
% Note that, if defined, \emph{master}\texttt{\_}\emph{prog} will |
| 394 |
% \textbf{\emph{replace}} \emph{prog} whereas |
| 395 |
% \emph{master}\texttt{\_}\emph{prog}\texttt{\_OPTIONS} will |
| 396 |
% \textbf{\emph{be added to}} \emph{prog}\texttt{\_OPTIONS} (see |
| 397 |
% section \ref{sec:variables} for more details). |
| 398 |
% |
| 399 |
% \variable[]{\texttt{DEPENDS}/\emph{master}\texttt{\_DEPENDS}} |
| 400 |
% {Global and per target dependencies}% |
| 401 |
% { |
| 402 |
% \begin{minipage}[t]{0.5\linewidth} |
| 403 |
% DEPENDS=texdepends.sty\\ |
| 404 |
% figlatex\_DEPENDS=figlatex.tex |
| 405 |
% \end{minipage} |
| 406 |
% } |
| 407 |
% All flavor targets will depend to theses files. This should not be |
| 408 |
% used as dependencies are automatically tracked. |
| 409 |
% |
| 410 |
%\section{Reference manual} |
| 411 |
%\label{sec:reference} |
| 412 |
% |
| 413 |
% \subsection{Flavors} |
| 414 |
% \subsubsection{What is a flavor ?} |
| 415 |
% A flavor can be see as a kind of document (postscript, PDF, DVI, |
| 416 |
% etc.) and the way to create it. Several property are attached to |
| 417 |
% each flavor. Currently, there exists two kinds of flavors: |
| 418 |
% \begin{description} |
| 419 |
% \item[TEX-flavors:] these flavors are used to compile a |
| 420 |
% \texttt{*.tex} file into a target. A \LaTeX{} compiler |
| 421 |
% (\texttt{latex}, \texttt{pdflatex}, etc.) is used; |
| 422 |
% \item[DVI-flavors:] these flavors are used to compile a file |
| 423 |
% produced by a TEX-flavors into an other file. Examples of such |
| 424 |
% flavors are all the ones converting a DVI file into another format |
| 425 |
% (postscript, PDF, etc.). |
| 426 |
% \end{description} |
| 427 |
% Several properties are attached to each flavors. Most are common, a |
| 428 |
% few a specific to the kind of the flavor. |
| 429 |
% \begin{description} |
| 430 |
% \item[Name:] the name of the flavor. It is used to declare dependencies |
| 431 |
% between flavors (see below). It also used to tell which flavor |
| 432 |
% should be compiled for each document (see the \texttt{FLAVORS} |
| 433 |
% variables); |
| 434 |
% \item[Program variable name:] name of the variable that will be used |
| 435 |
% to run the program of this flavor. This name is used for the |
| 436 |
% program and also for the options (variable with the |
| 437 |
% \texttt{\_OPTIONS} suffix); |
| 438 |
% \item[Target extension:] extension of the target of the flavor. The |
| 439 |
% dot must be added if wanted; |
| 440 |
% \item[Master target:] if not empty, all documents registered for the |
| 441 |
% flavor will be built when this master target is called; |
| 442 |
% \item[XFig extensions to clean (\emph{TEX-flavor only}):] files |
| 443 |
% extensions of figures that will be cleaned for the \texttt{clean} |
| 444 |
% target. Generally, there is \texttt{.pstex\_t .pstex} when using |
| 445 |
% \texttt{latex} and \texttt{.pdftex\_t .pdftex} when using |
| 446 |
% \texttt{pdflatex}; |
| 447 |
% \item[Dependency \emph{DVI-flavor only}:] name of the TEX-flavor the |
| 448 |
% one depends upon. |
| 449 |
% \end{description} |
| 450 |
% |
| 451 |
% \subsubsection{Defining a new flavor} |
| 452 |
% \label{sec:def_flavors} |
| 453 |
% To define a new flavor named \texttt{NAME}, one just have to declare |
| 454 |
% a \texttt{lu-define-flavor-NAME} that calls and evaluates the |
| 455 |
% \texttt{lu-create-flavor} with the right parameters, ie: |
| 456 |
% \begin{itemize} |
| 457 |
% \item name of the flavor; |
| 458 |
% \item kind of flavor (\texttt{tex} or \texttt{dvi}); |
| 459 |
% \item program variable name; |
| 460 |
% \item target extension; |
| 461 |
% \item master target; |
| 462 |
% \item XFig extensions to clean \emph{or} TEX-flavor to depend upon. |
| 463 |
% \end{itemize} |
| 464 |
% |
| 465 |
% \par |
| 466 |
% |
| 467 |
% For example, \texttt{LaTeX.mk} already defines: |
| 468 |
% \paragraph{DVI flavor} |
| 469 |
% \begin{source}[0.9\linewidth] |
| 470 |
% define lu-define-flavor-DVI\\ |
| 471 |
% \hspace*{2ex}\$\$(eval \$\$(call lu-create-flavor,DVI,tex,LATEX,.dvi,dvi,\textbackslash\\ |
| 472 |
% \hspace*{4ex}.pstex\_t .pstex))\\ |
| 473 |
% endef |
| 474 |
% \end{source} |
| 475 |
% \subparagraph{Tip:} the \texttt{LATEX} program variable name means |
| 476 |
% that the program called will be the one in the \texttt{LATEX} |
| 477 |
% variable and that options in the \texttt{LATEX\_OPTIONS} variable |
| 478 |
% will be used. |
| 479 |
% |
| 480 |
% \paragraph{PDF flavor} |
| 481 |
% \begin{source}[0.9\linewidth] |
| 482 |
% define lu-define-flavor-PDF\\ |
| 483 |
% \hspace*{2ex}\$\$(eval \$\$(call lu-create-flavor,PDF,tex,PDFLATEX,.pdf,pdf,\textbackslash\\ |
| 484 |
% \hspace*{4ex}.pdftex\_t .\$\$(\_LU\_PDFTEX\_EXT)))\\ |
| 485 |
% endef |
| 486 |
% \end{source} |
| 487 |
% |
| 488 |
% \paragraph{LuaLaTeX flavor} |
| 489 |
% \begin{source}[0.9\linewidth] |
| 490 |
% define lu-define-flavor-LUALATEX\\ |
| 491 |
% \hspace*{2ex}\$\$(eval \$\$(call lu-create-flavor,LUALATEX,tex,LUALATEX,.pdf,pdf,\textbackslash\\ |
| 492 |
% \hspace*{4ex}.pdftex\_t .\$\$(\_LU\_PDFTEX\_EXT)))\\ |
| 493 |
% endef |
| 494 |
% \end{source} |
| 495 |
% |
| 496 |
% \paragraph{PS flavor} |
| 497 |
% \begin{source}[0.9\linewidth] |
| 498 |
% define lu-define-flavor-PS\\ |
| 499 |
% \hspace*{2ex}\$\$(eval \$\$(call lu-create-flavor,PS,dvi,DVIPS,.ps,ps,DVI))\\ |
| 500 |
% endef |
| 501 |
% \end{source} |
| 502 |
% \subparagraph{Tip:} for DVI-flavors, the program will be invoked with |
| 503 |
% with the option \texttt{-o \emph{target}} and with the name of the |
| 504 |
% file source in argument. |
| 505 |
% |
| 506 |
% \paragraph{DVIPDF flavor} |
| 507 |
% \begin{source}[0.9\linewidth] |
| 508 |
% define lu-define-flavor-DVIPDF\\ |
| 509 |
% \hspace*{2ex}\$\$(eval \$\$(call lu-create-flavor,DVIPDF,dvi,DVIPDFM,.pdf,pdf,DVI))\\ |
| 510 |
% endef |
| 511 |
% \end{source} |
| 512 |
% |
| 513 |
% |
| 514 |
% \subsection{Variables} |
| 515 |
% \label{sec:variables} |
| 516 |
% \texttt{LaTeX.mk} use a generic mechanism to manage variables, so |
| 517 |
% that lots of thing can easily be customized per document and/or per |
| 518 |
% flavor. |
| 519 |
% \subsubsection{Two kind of variables} |
| 520 |
% \texttt{LaTeX.mk} distinguish two kind of variables. The first one |
| 521 |
% (called SET-variable) is for variables where only \emph{one} value |
| 522 |
% can be set. For example, this is the case for a variable that |
| 523 |
% contain the name of a program to launch. The second one (called |
| 524 |
% ADD-variable) is for variables where values can be cumulative. For |
| 525 |
% example, this will be the case for the options of a program. |
| 526 |
% \par |
| 527 |
% |
| 528 |
% For each variable used by \texttt{LaTeX.mk}, there exists several |
| 529 |
% variables that can be set in the Makefile so that the value will be |
| 530 |
% used for all documents, only for one document, only for one flavor, |
| 531 |
% etc. |
| 532 |
% |
| 533 |
% \newcounter{nbvars}% |
| 534 |
% \newenvironment{descvars}{% |
| 535 |
% \par |
| 536 |
% \noindent% |
| 537 |
% \bgroup% |
| 538 |
% \setcounter{nbvars}{0}% |
| 539 |
% \renewcommand{\emph}[1]{{\it ##1}} |
| 540 |
% \renewcommand{\variable}[3][;]{% |
| 541 |
% \stepcounter{nbvars}% |
| 542 |
% \arabic{nbvars}&\textbf{##2}&##3##1\\% |
| 543 |
% } |
| 544 |
% \begin{tabular}{clp{0.5\linewidth}} |
| 545 |
% }{% |
| 546 |
% \end{tabular} |
| 547 |
% \egroup |
| 548 |
% \par\medskip |
| 549 |
% } |
| 550 |
% |
| 551 |
% \paragraph{SET-variable.} For each SET-variable \texttt{\emph{NAME}}, we |
| 552 |
% can find in the Makfile: |
| 553 |
% \begin{descvars} |
| 554 |
% \variable{\texttt{LU\_\emph{target}\_\emph{NAME}}}{per document |
| 555 |
% and per flavor value}% |
| 556 |
% \variable{\texttt{TD\_\emph{target}\_\emph{NAME}}}{per document |
| 557 |
% and per flavor value filled by the \texttt{texdepends} \LaTeX{} |
| 558 |
% package}% |
| 559 |
% \variable{\texttt{LU\_\emph{master}\_\emph{NAME}}}{per document |
| 560 |
% value}% |
| 561 |
% \variable{\texttt{\emph{master}\_\emph{NAME}}}{per document |
| 562 |
% value}% |
| 563 |
% \variable{\texttt{LU\_FLAVOR\_\emph{flavor}\_\emph{NAME}}}{per |
| 564 |
% flavor value}% |
| 565 |
% \variable{\texttt{LU\_\emph{NAME}}}{global value}% |
| 566 |
% \variable{\texttt{\emph{NAME}}}{global value}% |
| 567 |
% \variable[.]{\texttt{\_LU\_\ldots\emph{NAME}}}{internal |
| 568 |
% \texttt{LaTeX.mk} default values}% |
| 569 |
% \end{descvars} |
| 570 |
% The first set variable will be used. |
| 571 |
% |
| 572 |
% \subparagraph{Tip:} in case of flavor context or document context, |
| 573 |
% only relevant variables will be checked. For example, the |
| 574 |
% SET-variable \texttt{MAIN} that give the main source of the document |
| 575 |
% will be evaluated in document context, so only 4, 5, 6, 7 and 8 will |
| 576 |
% be used (and I cannot see any real interest in using 6 or 7 for this |
| 577 |
% variable). |
| 578 |
% |
| 579 |
% \subparagraph{Tip2:} in case of context of index (when building |
| 580 |
% indexes or glossary), there exists several other variables per index |
| 581 |
% to add to this list (mainly ending with \texttt{\_{\it kind}\_{\it |
| 582 |
% indexname}\_{\it NAME}} or \texttt{\_{\it kind}\_{\it NAME}}). |
| 583 |
% Refer to the sources if you really need them. |
| 584 |
% |
| 585 |
% \paragraph{ADD-variable.} An ADD-variable is cumulative. The user |
| 586 |
% can replace or add any values per document, per flavor, etc. |
| 587 |
% \begin{descvars} |
| 588 |
% \variable{\texttt{LU\_\emph{target}\_\emph{NAME}}}{replacing per |
| 589 |
% document and per flavor values}% |
| 590 |
% \variable{\texttt{\emph{target}\_\emph{NAME}}}{cumulative per |
| 591 |
% document and per flavor values}% |
| 592 |
% \variable{\texttt{LU\_\emph{master}\_\emph{NAME}}}{replacing per |
| 593 |
% document values}% |
| 594 |
% \variable{\texttt{\emph{master}\_\emph{NAME}}}{cumulative per |
| 595 |
% document values}% |
| 596 |
% \variable{\texttt{LU\_FLAVOR\_\emph{flavor}\_\emph{NAME}}}{replacing |
| 597 |
% per flavor values}% |
| 598 |
% \variable{\texttt{FLAVOR\_\emph{flavor}\_\emph{NAME}}}{cumulative |
| 599 |
% per flavor values}% |
| 600 |
% \variable{\texttt{LU\_\emph{NAME}}}{replacing global values}% |
| 601 |
% \variable{\texttt{\emph{NAME}}}{cumulative global values}% |
| 602 |
% \end{descvars} |
| 603 |
% \subparagraph{Tip:} if not defined, \texttt{LU\_\emph{variable}} |
| 604 |
% defaults to ``\texttt{\$(\emph{variable}) |
| 605 |
% \$(\_LU\_\emph{variable})}'' and \texttt{\_LU\_\emph{variable}} |
| 606 |
% contains default values managed by \texttt{LaTeX.mk} and the |
| 607 |
% \texttt{texdepends} \LaTeX{} package. |
| 608 |
% \subparagraph{Example:} the ADD-variable \texttt{FLAVORS} is invoked |
| 609 |
% in document context to know which flavors needs to be build for each |
| 610 |
% document. This means that \texttt{LU\_{\it master}\_FLAVORS} will be |
| 611 |
% used. |
| 612 |
% \begin{source} |
| 613 |
% \# We override default value for MASTERS\\ |
| 614 |
% LU\_MASTERS=foo bar baz\\ |
| 615 |
% \# By default, only the DVIPDF flavor will be build\\ |
| 616 |
% FLAVORS=DVIPDF\\ |
| 617 |
% ~\\ |
| 618 |
% bar\_FLAVORS=PS\\ |
| 619 |
% LU\_baz\_FLAVORS=PDF\\ |
| 620 |
% \# there will be rules to build\\ |
| 621 |
% \# * foo.dvi and foo.pdf\\ |
| 622 |
% \# ~ (the DVIPDF flavor depends on the DVI flavor)\\ |
| 623 |
% \# * bar.dvi, bar.pdf and bar.ps\\ |
| 624 |
% \# ~ (the PS flavor is added to global flavors)\\ |
| 625 |
% \# * baz.pdf\\ |
| 626 |
% \# ~ (the PDF flavor will be the only one for baz) |
| 627 |
% include LaTeX.mk |
| 628 |
% \end{source} |
| 629 |
% \subsubsection{List of used variables} |
| 630 |
% Here are most of the variables used by \texttt{LaTeX.mk}. Users |
| 631 |
% should only have to sometimes managed the first ones. The latter are |
| 632 |
% described here for information only (and are subject to |
| 633 |
% modifications). Please, report a bug if some of them are not |
| 634 |
% correctly pickup by the \texttt{texdepends} \LaTeX{} package and |
| 635 |
% \texttt{LaTeX.mk}. |
| 636 |
% |
| 637 |
% \newenvironment{describevars}{% |
| 638 |
% \par |
| 639 |
% \noindent% |
| 640 |
% \bgroup% |
| 641 |
% \renewcommand{\emph}[1]{{\it ##1}}% |
| 642 |
% \newcommand{\default}[1]{\newline\textbf{Default: }##1} |
| 643 |
% \renewcommand{\variable}[4]{% |
| 644 |
% \textbf{\texttt{##1}}&##2&##3&##4\\% |
| 645 |
% } |
| 646 |
% \begin{tabular}{cccp{0.5\linewidth}} |
| 647 |
% Name & Kind &% |
| 648 |
% \multicolumn{1}{m{4em}}{\begin{center}Context of |
| 649 |
% use\end{center}} & |
| 650 |
% \multicolumn{1}{c}{Description} \\ |
| 651 |
% \hline |
| 652 |
% \hline |
| 653 |
% }{% |
| 654 |
% \end{tabular} |
| 655 |
% \egroup |
| 656 |
% \par\medskip |
| 657 |
% } |
| 658 |
% |
| 659 |
% \begin{describevars} |
| 660 |
% \variable{MASTERS}{ADD}{Global}{List of documents to compile. |
| 661 |
% These values will be used as jobname. \default{basename of |
| 662 |
% \texttt{*.tex} files containing the \texttt{\textbackslash |
| 663 |
% documentclass} pattern}}% |
| 664 |
% \variable{FLAVORS}{ADD}{Document}{List of flavors for each |
| 665 |
% document. \default{\texttt{PS PDF}}}% |
| 666 |
% \variable{MAIN}{SET}{Document}{Master \texttt{tex} source |
| 667 |
% file\default{\texttt{\emph{master}.tex}}}% |
| 668 |
% \variable{DEPENDS}{ADD}{Target}{List of dependencies}% |
| 669 |
% \variable{DEPENDS\_EXCLUDE}{ADD}{Target}{Dependencies to |
| 670 |
% forget. Useful when LaTeX Make wrongly auto-detect false dependencies}% |
| 671 |
% \variable{\emph{progvarname}}{SET}{Target}{Program to launch for |
| 672 |
% the corresponding flavor}% |
| 673 |
% \variable{\emph{progvarname}\_OPTIONS}{ADD}{Target}{Options to use |
| 674 |
% when building the target}% |
| 675 |
% \variable{STYLE}{SET}{Index}{Name of the index/glossary style file |
| 676 |
% to use (\texttt{.ist}, etc.)}% |
| 677 |
% \hline |
| 678 |
% \variable{TARGET}{SET}{Index}{Name of the index/glossary file to |
| 679 |
% produce (\texttt{.ind}, \texttt{.gls}, etc.)}% |
| 680 |
% \variable{SRC}{SET}{Index}{Name of the index/glossary file source |
| 681 |
% (\texttt{.idx}, \texttt{.glo}, etc.)}% |
| 682 |
% \variable{FIGURES}{ADD}{Target}{Lists of figures included}% |
| 683 |
% \variable{BIBFILES}{ADD}{Target}{Lists of bibliography files used |
| 684 |
% (\texttt{.bib})}% |
| 685 |
% \variable{BIBSTYLES}{ADD}{Target}{Lists of bibliography style |
| 686 |
% files used (\texttt{.bst})}% |
| 687 |
% \variable{BBLFILES}{ADD}{Target}{Lists of built bibliography files |
| 688 |
% (\texttt{.bbl})}% |
| 689 |
% \variable{INPUT}{ADD}{Target}{Lists of input files (\texttt{.cls}, |
| 690 |
% \texttt{.sty}, \texttt{.tex}, etc.)}% |
| 691 |
% \variable{OUTPUTS}{ADD}{Target}{Lists of output files |
| 692 |
% (\texttt{.aux}, etc.)}% |
| 693 |
% \variable{GRAPHICSPATH}{ADD}{Target}{\texttt{\textbackslash |
| 694 |
% graphicspath\{\}} arguments}% |
| 695 |
% \variable{GPATH}{ADD}{Target}{List of directories from |
| 696 |
% \texttt{GRAPHICSPATH} without \texttt{\{} and \texttt{\}}, |
| 697 |
% separated by spaces}% |
| 698 |
% \variable{INDEXES}{ADD}{Target}{Kinds of index (\texttt{INDEX}, |
| 699 |
% \texttt{GLOSS}, etc.)}% |
| 700 |
% \variable{INDEXES\_\emph{kind}}{ADD}{Target}{List of indexes or |
| 701 |
% glossaries}% |
| 702 |
% \variable{WATCHFILES}{ADD}{Target}{List of files that trigger a |
| 703 |
% rebuild if modified (\texttt{.aux}, etc.)}% |
| 704 |
% \variable{REQUIRED}{ADD}{Target}{List of new dependencies found by |
| 705 |
% the \texttt{texdepends} \LaTeX{} package}% |
| 706 |
% \variable{MAX\_REC}{SET}{Target}{Maximum level of recursion |
| 707 |
% authorized}% |
| 708 |
% \variable{REBUILD\_RULES}{ADD}{Target}{List of rebuild rules to |
| 709 |
% use (can be modified by the \texttt{texdepends} \LaTeX{} |
| 710 |
% package}% |
| 711 |
% \variable{EXT}{SET}{Flavor}{Target file extension of the flavor}% |
| 712 |
% \variable{DEPFLAVOR}{SET}{Flavor}{TEX-flavor a DVI-flavor depend |
| 713 |
% upon}% |
| 714 |
% \variable{CLEANFIGEXT}{ADD}{Flavor}{Extensions of figure files to |
| 715 |
% remove on clean}% |
| 716 |
% \end{describevars} |
| 717 |
% |
| 718 |
% \newpage |
| 719 |
% \section{FAQ} |
| 720 |
% |
| 721 |
% \newenvironment{question}[2]{ |
| 722 |
% \subsection{#1} |
| 723 |
% \texttt{}\llap{$\Rightarrow$ \quad }\emph{#2}\par\bigskip}{ |
| 724 |
% } |
| 725 |
% |
| 726 |
% \begin{question}{No rule to make target `LU\_WATCH\_FILES\_SAVE'}{When |
| 727 |
% using |LaTeX.mk|, I got the error:\\ |
| 728 |
% |make[1]: *** No rule to make target `LU\_WATCH\_FILES\_SAVE'. Stop.|} |
| 729 |
% |
| 730 |
% |make| is called in such a way that does not allow correct recursive |
| 731 |
% calls. As one can not know by advance how many times \LaTeX{}, |
| 732 |
% bib\TeX{}, etc. will need to be run, |latex-make| use recursive |
| 733 |
% invocations of |make|. This means that in the |LaTeX.mk| makefile, |
| 734 |
% there exist rules such as: |
| 735 |
% \begin{source} |
| 736 |
% \$(MAKE) INTERNAL\_VARIABLE=value internal\_target |
| 737 |
% \end{source} |
| 738 |
% In order |latex-make| to work, this invocation of |make| must read |
| 739 |
% the same rules and variable definitions as the main one. This means |
| 740 |
% that calling "|make -f LaTeX.mk foo.pdf|" in a directory with only |
| 741 |
% |foo.tex| will not work. Recursive invocations of make will not load |
| 742 |
% |LaTeX.mk|, will search for a |Makefile| in the current directory |
| 743 |
% and will complain about being unable to build the |
| 744 |
% |LU_WATCH_FILES_SAVE| internal target. |
| 745 |
% |
| 746 |
% \par\medskip |
| 747 |
% The solution is to call |make| so that recursive invocations will |
| 748 |
% read the same variables and rules. For example:\\ |
| 749 |
% |make -f LaTeX.mk MAKE="make -f LaTeX.mk" foo.pdf|\\ |
| 750 |
% or (if there is no |Makefile| in the directory):\\ |
| 751 |
% |env MAKEFILES=LaTeX.mk make foo.pdf|\\ |
| 752 |
% |
| 753 |
% \end{question} |
| 754 |
% |
| 755 |
% \StopEventually{ |
| 756 |
% } |
| 757 |
% \newpage |
| 758 |
% \section{Implementation} |
| 759 |
% |
| 760 |
% \subsection{LaTeX.mk} |
| 761 |
% \begin{macrocode} |
| 762 |
%<*makefile> |
| 763 |
|
| 764 |
####[ Check Software ]################################################ |
| 765 |
|
| 766 |
ifeq ($(filter else-if,$(.FEATURES)),) |
| 767 |
$(error GNU Make 3.81 needed. Please, update your software.) |
| 768 |
exit 1 |
| 769 |
endif |
| 770 |
|
| 771 |
# Some people want to call our Makefile snippet with |
| 772 |
# make -f LaTeX.mk |
| 773 |
# This should not work as $(MAKE) is call recursively and will not read |
| 774 |
# LaTeX.mk again. We cannot just add LaTeX.mk to MAKEFILES as LaTeX.mk |
| 775 |
# should be read AFTER a standard Makefile (if any) that can define some |
| 776 |
# variables (LU_MASTERS, ...) that LaTeX.mk must see. |
| 777 |
# So I introduce an HACK here that try to workaround the situation. Keep in |
| 778 |
# mind that this hack is not perfect and does not handle all cases |
| 779 |
# (for example, "make -f my_latex_config.mk -f LaTeX.mk" will not recurse |
| 780 |
# correctly) |
| 781 |
ifeq ($(foreach m,$(MAKEFILES), $(m)) $(lastword $(MAKEFILE_LIST)),$(MAKEFILE_LIST)) |
| 782 |
# We are the first file read after the ones from MAKEFILES |
| 783 |
# So we assume we are read due to "-f LaTeX.mk" |
| 784 |
LU_LaTeX.mk_NAME := $(lastword $(MAKEFILE_LIST)) |
| 785 |
# Is this Makefile correctly read for recursive calls ? |
| 786 |
ifeq ($(findstring -f $(LU_LaTeX.mk_NAME),$(MAKE)),) |
| 787 |
$(info ********************************************************************************) |
| 788 |
$(info Warning: $(LU_LaTeX.mk_NAME) called directly. I suppose that you run:) |
| 789 |
$(info Warning: $(MAKE) -f $(LU_LaTeX.mk_NAME) $(MAKECMDGOALS)) |
| 790 |
$(info Warning: or something similar that does not allow recursive invocation of make) |
| 791 |
$(info Warning: ) |
| 792 |
$(info Warning: Trying to enable a workaround. This ACK will be disabled in a future) |
| 793 |
$(info Warning: release. Consider using another syntax, for example:) |
| 794 |
$(info Warning: $(MAKE) -f $(LU_LaTeX.mk_NAME) MAKE="$(MAKE) -f $(LU_LaTeX.mk_NAME)" $(MAKECMDGOALS)) |
| 795 |
$(info ********************************************************************************) |
| 796 |
MAKE+= -f $(LU_LaTeX.mk_NAME) |
| 797 |
endif |
| 798 |
endif |
| 799 |
|
| 800 |
####[ Configuration ]################################################ |
| 801 |
|
| 802 |
# list of messages categories to display |
| 803 |
LU_SHOW ?= warning #info debug debug-vars |
| 804 |
|
| 805 |
# Select GNU/BSD/MACOSX utils (cp, rm, mv, ...) |
| 806 |
LU_UTILS ?= $(shell ( /bin/cp --heelp > /dev/null 2>&1 && echo GNU ) || echo BSD ) |
| 807 |
export LU_UTILS |
| 808 |
|
| 809 |
####[ End of configuration ]################################################ |
| 810 |
# Modifying the remaining of this document may endanger you life!!! ;) |
| 811 |
|
| 812 |
#--------------------------------------------------------------------- |
| 813 |
# Controling verbosity |
| 814 |
ifdef VERB |
| 815 |
MAK_VERB := $(VERB) |
| 816 |
else |
| 817 |
#MAK_VERB := debug |
| 818 |
#MAK_VERB := verbose |
| 819 |
#MAK_VERB := normal |
| 820 |
MAK_VERB := quiet |
| 821 |
#MAK_VERB := silent |
| 822 |
endif |
| 823 |
|
| 824 |
#--------------------------------------------------------------------- |
| 825 |
# MAK_VERB -> verbosity |
| 826 |
ifeq ($(MAK_VERB),debug) |
| 827 |
COMMON_PREFIX = echo " ======> building " $@ "<======" ; \ |
| 828 |
printf "%s $(@F) due to:$(foreach file,$?,\n * $(file))\n" $1; set -x; |
| 829 |
# |
| 830 |
COMMON_HIDE := set -x; |
| 831 |
COMMON_CLEAN := set -x; |
| 832 |
SHOW_LATEX:=true |
| 833 |
else |
| 834 |
ifeq ($(MAK_VERB),verbose) |
| 835 |
COMMON_PREFIX = echo " ======> building " $@ "<======" ; \ |
| 836 |
printf "%s $(@F) due to:$(foreach file,$?,\n * $(file))\n" $1; |
| 837 |
# |
| 838 |
COMMON_HIDE :=# |
| 839 |
COMMON_CLEAN :=# |
| 840 |
SHOW_LATEX:=true |
| 841 |
else |
| 842 |
ifeq ($(MAK_VERB),normal) |
| 843 |
COMMON_PREFIX =# |
| 844 |
COMMON_HIDE := @ |
| 845 |
COMMON_CLEAN :=# |
| 846 |
SHOW_LATEX:=true |
| 847 |
else |
| 848 |
ifeq ($(MAK_VERB),quiet) |
| 849 |
COMMON_PREFIX = @ echo " ======> building " $@ "<======" ; |
| 850 |
# echo "due to $?" ; |
| 851 |
COMMON_HIDE := @ |
| 852 |
COMMON_CLEAN :=# |
| 853 |
SHOW_LATEX:= |
| 854 |
else # silent |
| 855 |
COMMON_PREFIX = @ |
| 856 |
COMMON_HIDE := @ |
| 857 |
COMMON_CLEAN := @ |
| 858 |
SHOW_LATEX:= |
| 859 |
endif |
| 860 |
endif |
| 861 |
endif |
| 862 |
endif |
| 863 |
|
| 864 |
#--------------------------------------------------------------------- |
| 865 |
# Old LaTeX have limitations |
| 866 |
_LU_PDFTEX_EXT ?= pdftex |
| 867 |
|
| 868 |
######################################################################### |
| 869 |
# Utilities |
| 870 |
LU_CP=$(LU_CP_$(LU_UTILS)) |
| 871 |
LU_MV=$(LU_MV_$(LU_UTILS)) |
| 872 |
LU_RM=$(LU_RM_$(LU_UTILS)) |
| 873 |
LU_CP_GNU ?= cp -a -- |
| 874 |
LU_MV_GNU ?= mv -- |
| 875 |
LU_RM_GNU ?= rm -f -- |
| 876 |
LU_CP_BSD ?= cp -p |
| 877 |
LU_MV_BSD ?= mv |
| 878 |
LU_RM_BSD ?= rm -f |
| 879 |
LU_CP_MACOSX ?= /bin/cp -p |
| 880 |
LU_MV_MACOSX ?= /bin/mv |
| 881 |
LU_RM_MACOSX ?= /bin/rm -f |
| 882 |
|
| 883 |
lu-show=\ |
| 884 |
$(if $(filter $(LU_SHOW),$(1)), \ |
| 885 |
$(if $(2), \ |
| 886 |
$(if $(filter-out $(2),$(MAKELEVEL)),,$(3)), \ |
| 887 |
$(3))) |
| 888 |
lu-show-infos=\ |
| 889 |
$(if $(filter $(LU_SHOW),$(1)), \ |
| 890 |
$(if $(2), \ |
| 891 |
$(if $(filter-out $(2),$(MAKELEVEL)),,$(warning $(3))), \ |
| 892 |
$(warning $(3)))) |
| 893 |
lu-show-rules=$(call lu-show-infos,info,0,$(1)) |
| 894 |
lu-show-flavors=$(call lu-show-infos,info,0,$(1)) |
| 895 |
lu-show-var=$(call lu-show-infos,debug-vars,, * Set $(1)=$($(1))) |
| 896 |
lu-show-read-var=$(eval $(call lu-show-infos,debug-vars,, Reading $(1) in $(2) ctx: $(3)))$(3) |
| 897 |
lu-show-readone-var=$(eval $(call lu-show-infos,debug-vars,, Reading $(1) for $(2) [one value]: $(3)))$(3) |
| 898 |
lu-show-set-var=$(call lu-show-infos,debug-vars,, * Setting $(1) for $(2) to value: $(3)) |
| 899 |
lu-show-add-var=$(call lu-show-infos,debug-vars,, * Adding to $(1) for $(2) values: $(value 3)) |
| 900 |
lu-show-add-var2=$(call lu-show-infos,warning,, * Adding to $(1) for $(2) values: $(value 3)) |
| 901 |
|
| 902 |
lu-save-file=$(call lu-show,debug,,echo "saving $1" ;) \ |
| 903 |
if [ -f "$1" ];then $(LU_CP) "$1" "$2" ;else $(LU_RM) "$2" ;fi |
| 904 |
lu-cmprestaure-file=\ |
| 905 |
if cmp -s "$1" "$2"; then \ |
| 906 |
$(LU_MV) "$2" "$1" ; \ |
| 907 |
$(call lu-show,debug,,echo "$1" not modified ;) \ |
| 908 |
else \ |
| 909 |
$(call lu-show,debug,,echo "$1" modified ;) \ |
| 910 |
if [ -f "$2" -o -f "$1" ]; then \ |
| 911 |
$(RM) -- "$2" ; \ |
| 912 |
$3 \ |
| 913 |
fi ; \ |
| 914 |
fi |
| 915 |
|
| 916 |
lu-clean=$(if $(strip $(1)),$(RM) $(1)) |
| 917 |
|
| 918 |
define lu-bug # description |
| 919 |
$$(warning Internal error: $(1)) |
| 920 |
$$(error You probably found a bug. Please, report it.) |
| 921 |
endef |
| 922 |
|
| 923 |
######################################################################### |
| 924 |
######################################################################### |
| 925 |
######################################################################### |
| 926 |
######################################################################### |
| 927 |
################## ######################### |
| 928 |
################## Variables ######################### |
| 929 |
################## ######################### |
| 930 |
######################################################################### |
| 931 |
######################################################################### |
| 932 |
######################################################################### |
| 933 |
######################################################################### |
| 934 |
######################################################################### |
| 935 |
# |
| 936 |
# _LU_FLAVORS_DEFINED : list of available flavors |
| 937 |
# _LU_FLAV_*_'flavname' : per flavor variables |
| 938 |
# where * can be : |
| 939 |
# PROGNAME : variable name for programme (and .._OPTIONS for options) |
| 940 |
# EXT : extension of created file |
| 941 |
# TARGETNAME : global target |
| 942 |
# DEPFLAVOR : flavor to depend upon |
| 943 |
# CLEANFIGEXT : extensions to clean for fig figures |
| 944 |
_LU_FLAVORS_DEFINED = $(_LU_FLAVORS_DEFINED_TEX) $(_LU_FLAVORS_DEFINED_DVI) |
| 945 |
|
| 946 |
# INDEXES_TYPES = GLOSS INDEX |
| 947 |
# INDEXES_INDEX = name1 ... |
| 948 |
# INDEXES_GLOSS = name2 ... |
| 949 |
# INDEX_name1_SRC |
| 950 |
# GLOSS_name2_SRC |
| 951 |
|
| 952 |
define _lu-getvalues# 1:VAR 2:CTX (no inheritage) |
| 953 |
$(if $(filter-out undefined,$(origin LU_$2$1)),$(LU_$2$1),$($2$1) $(_LU_$2$1_MK) $(TD_$2$1)) |
| 954 |
endef |
| 955 |
define lu-define-addvar # 1:suffix_fnname 2:CTX 3:disp-debug 4:nb_args 5:inherited_ctx 6:ctx-build-depend |
| 956 |
define lu-addtovar$1 # 1:VAR 2:... $4: value |
| 957 |
_LU_$2$$1_MK+=$$($4) |
| 958 |
$$(call lu-show-add-var,$$1,$3,$$(value $4)) |
| 959 |
endef |
| 960 |
define lu-def-addvar-inherited-ctx$1 # 1:VAR 2:... |
| 961 |
$6 |
| 962 |
_LU_$2$$1_INHERITED_CTX=$$(sort \ |
| 963 |
$$(foreach ctx,$5,$$(ctx) $$(if $$(filter-out undefined,$$(origin \ |
| 964 |
LU_$$(ctx)$$1)),,\ |
| 965 |
$$(_LU_$$(ctx)$$1_INHERITED_CTX)))) |
| 966 |
$$$$(call lu-show-var,_LU_$2$$1_INHERITED_CTX) |
| 967 |
endef |
| 968 |
define lu-getvalues$1# 1:VAR 2:... |
| 969 |
$$(if $$(filter-out undefined,$$(origin _LU_$2$$1_INHERITED_CTX)),,$$(eval \ |
| 970 |
$$(call lu-def-addvar-inherited-ctx$1,$$1,$$2,$$3,$$4,$$5,$$6)\ |
| 971 |
))$$(call lu-show-read-var,$$1,$3,$$(foreach ctx,\ |
| 972 |
$(if $2,$2,GLOBAL) $$(if $$(filter-out undefined,$$(origin LU_$2$$1)),,\ |
| 973 |
$$(_LU_$2$$1_INHERITED_CTX))\ |
| 974 |
,$$(call _lu-getvalues,$$1,$$(filter-out GLOBAL,$$(ctx))))) |
| 975 |
endef |
| 976 |
endef |
| 977 |
|
| 978 |
# Global variable |
| 979 |
# VAR (DEPENDS) |
| 980 |
$(eval $(call lu-define-addvar,-global,,global,2)) |
| 981 |
|
| 982 |
# Per flavor variable |
| 983 |
# FLAVOR_$2_VAR (FLAVOR_DVI_DEPENDS) |
| 984 |
# 2: flavor name |
| 985 |
# Inherit from VAR (DEPENDS) |
| 986 |
$(eval $(call lu-define-addvar,-flavor,FLAVOR_$$2_,flavor $$2,3,\ |
| 987 |
GLOBAL,\ |
| 988 |
$$(eval $$(call lu-def-addvar-inherited-ctx-global,$$1)) \ |
| 989 |
)) |
| 990 |
|
| 991 |
# Per master variable |
| 992 |
# $2_VAR (source_DEPENDS) |
| 993 |
# 2: master name |
| 994 |
# Inherit from VAR (DEPENDS) |
| 995 |
$(eval $(call lu-define-addvar,-master,$$2_,master $$2,3,\ |
| 996 |
GLOBAL,\ |
| 997 |
$$(eval $$(call lu-def-addvar-inherited-ctx-global,$$1)) \ |
| 998 |
)) |
| 999 |
|
| 1000 |
# Per target variable |
| 1001 |
# $2$(EXT of $3)_VAR (source.dvi_DEPENDS) |
| 1002 |
# 2: master name |
| 1003 |
# 3: flavor name |
| 1004 |
# Inherit from $2_VAR FLAVOR_$3_VAR (source_DEPENDS FLAVOR_DVI_DEPENDS) |
| 1005 |
$(eval $(call lu-define-addvar,,$$2$$(call lu-getvalue-flavor,EXT,$$3)_,target $$2$$(call lu-getvalue-flavor,EXT,$$3),4,\ |
| 1006 |
$$2_ FLAVOR_$$3_,\ |
| 1007 |
$$(eval $$(call lu-def-addvar-inherited-ctx-master,$$1,$$2)) \ |
| 1008 |
$$(eval $$(call lu-def-addvar-inherited-ctx-flavor,$$1,$$3)) \ |
| 1009 |
)) |
| 1010 |
|
| 1011 |
# Per index/glossary variable |
| 1012 |
# $(2)_$(3)_VAR (INDEX_source_DEPENDS) |
| 1013 |
# 2: type (INDEX, GLOSS, ...) |
| 1014 |
# 3: index name |
| 1015 |
# Inherit from VAR (DEPENDS) |
| 1016 |
$(eval $(call lu-define-addvar,-global-index,$$2_$$3_,index $$3[$$2],4,\ |
| 1017 |
GLOBAL,\ |
| 1018 |
$$(eval $$(call lu-def-addvar-inherited-ctx-global,$$1)) \ |
| 1019 |
)) |
| 1020 |
|
| 1021 |
# Per master and per index/glossary variable |
| 1022 |
# $(2)_$(3)_$(4)_VAR (source_INDEX_source_DEPENDS) |
| 1023 |
# 2: master name |
| 1024 |
# 3: type (INDEX, GLOSS, ...) |
| 1025 |
# 4: index name |
| 1026 |
# Inherit from $2_VAR $3_$4_VAR (source_DEPENDS INDEX_source_DEPENDS) |
| 1027 |
$(eval $(call lu-define-addvar,-master-index,$$2_$$3_$$4_,index $$2/$$4[$$3],5,\ |
| 1028 |
$$2_ $$3_$$4_,\ |
| 1029 |
$$(eval $$(call lu-def-addvar-inherited-ctx-master,$$1,$$2)) \ |
| 1030 |
$$(eval $$(call lu-def-addvar-inherited-ctx-global-index,$$1,$$3,$$4)) \ |
| 1031 |
)) |
| 1032 |
|
| 1033 |
# Per target and per index/glossary variable |
| 1034 |
# $(2)$(EXT of $3)_$(4)_$(5)_VAR (source.dvi_INDEX_source_DEPENDS) |
| 1035 |
# 2: master name |
| 1036 |
# 3: flavor name |
| 1037 |
# 4: type (INDEX, GLOSS, ...) |
| 1038 |
# 5: index name |
| 1039 |
# Inherit from $2$(EXT of $3)_VAR $(2)_$(3)_$(4)_VAR |
| 1040 |
# (source.dvi_DEPENDS source_INDEX_source_DEPENDS) |
| 1041 |
$(eval $(call lu-define-addvar,-index,$$2$$(call lu-getvalue-flavor,EXT,$$3)_$$4_$$5_,index $$2$$(call lu-getvalue-flavor,EXT,$$3)/$$5[$$4],6,\ |
| 1042 |
$$2$$(call lu-getvalue-flavor,EXT,$$3)_ $$2_$$4_$$5_,\ |
| 1043 |
$$(eval $$(call lu-def-addvar-inherited-ctx,$$1,$$2,$$3)) \ |
| 1044 |
$$(eval $$(call lu-def-addvar-inherited-ctx-master-index,$$1,$$2,$$4,$$5)) \ |
| 1045 |
)) |
| 1046 |
|
| 1047 |
|
| 1048 |
|
| 1049 |
|
| 1050 |
|
| 1051 |
|
| 1052 |
define lu-setvar-global # 1:name 2:value |
| 1053 |
_LU_$(1) ?= $(2) |
| 1054 |
$$(eval $$(call lu-show-set-var,$(1),global,$(2))) |
| 1055 |
endef |
| 1056 |
|
| 1057 |
define lu-setvar-flavor # 1:name 2:flavor 3:value |
| 1058 |
_LU_FLAVOR_$(2)_$(1) ?= $(3) |
| 1059 |
$$(eval $$(call lu-show-set-var,$(1),flavor $(2),$(3))) |
| 1060 |
endef |
| 1061 |
|
| 1062 |
define lu-setvar-master # 1:name 2:master 3:value |
| 1063 |
_LU_$(2)_$(1) ?= $(3) |
| 1064 |
$$(eval $$(call lu-show-set-var,$(1),master $(2),$(3))) |
| 1065 |
endef |
| 1066 |
|
| 1067 |
define lu-setvar # 1:name 2:master 3:flavor 4:value |
| 1068 |
_LU_$(2)$$(call lu-getvalue-flavor,EXT,$(3))_$(1)=$(4) |
| 1069 |
$$(eval $$(call lu-show-set-var,$(1),master/flavor $(2)/$(3),$(4))) |
| 1070 |
endef |
| 1071 |
|
| 1072 |
define lu-getvalue # 1:name 2:master 3:flavor |
| 1073 |
$(call lu-show-readone-var,$(1),master/flavor $(2)/$(3),$(or \ |
| 1074 |
$(LU_$(2)$(call lu-getvalue-flavor,EXT,$(3))_$(1)), \ |
| 1075 |
$(TD_$(2)$(call lu-getvalue-flavor,EXT,$(3))_$(1)), \ |
| 1076 |
$(LU_$(2)_$(1)), \ |
| 1077 |
$($(2)_$(1)), \ |
| 1078 |
$(LU_FLAVOR_$(3)_$(1)), \ |
| 1079 |
$(LU_$(1)), \ |
| 1080 |
$($(1)), \ |
| 1081 |
$(_LU_$(2)$(call lu-getvalue-flavor,EXT,$(3))_$(1)), \ |
| 1082 |
$(_LU_$(2)_$(1)), \ |
| 1083 |
$(_LU_FLAVOR_$(3)_$(1)), \ |
| 1084 |
$(_LU_$(1))\ |
| 1085 |
)) |
| 1086 |
endef |
| 1087 |
|
| 1088 |
define lu-getvalue-flavor # 1:name 2:flavor |
| 1089 |
$(call lu-show-readone-var,$(1),flavor $(2),$(or \ |
| 1090 |
$(LU_FLAVOR_$(2)_$(1)), \ |
| 1091 |
$(LU_$(1)), \ |
| 1092 |
$($(1)), \ |
| 1093 |
$(_LU_FLAVOR_$(2)_$(1)), \ |
| 1094 |
$(_LU_$(1))\ |
| 1095 |
)) |
| 1096 |
endef |
| 1097 |
|
| 1098 |
define lu-getvalue-master # 1:name 2:master |
| 1099 |
$(call lu-show-readone-var,$(1),master $(2),$(or \ |
| 1100 |
$(LU_$(2)_$(1)), \ |
| 1101 |
$($(2)_$(1)), \ |
| 1102 |
$(LU_$(1)), \ |
| 1103 |
$($(1)), \ |
| 1104 |
$(_LU_$(2)_$(1)), \ |
| 1105 |
$(_LU_$(1))\ |
| 1106 |
)) |
| 1107 |
endef |
| 1108 |
|
| 1109 |
define lu-getvalue-index # 1:name 2:master 3:flavor 4:type 5:indexname |
| 1110 |
$(call lu-show-readone-var,$(1),master/flavor/index $(2)/$(3)/[$(4)]$(5),$(or \ |
| 1111 |
$(LU_$(2)$(call lu-getvalue-flavor,EXT,$(3))_$(4)_$(5)_$(1)), \ |
| 1112 |
$(LU_$(2)_$(4)_$(5)_$(1)), \ |
| 1113 |
$(TD_$(2)$(call lu-getvalue-flavor,EXT,$(3))_$(4)_$(5)_$(1)), \ |
| 1114 |
$($(2)_$(4)_$(5)_$(1)), \ |
| 1115 |
$(LU_$(4)_$(5)_$(1)), \ |
| 1116 |
$($(4)_$(5)_$(1)), \ |
| 1117 |
$(LU_$(2)$(call lu-getvalue-flavor,EXT,$(3))_$(4)_$(1)), \ |
| 1118 |
$(LU_$(2)_$(4)_$(1)), \ |
| 1119 |
$($(2)_$(4)_$(1)), \ |
| 1120 |
$(LU_$(4)_$(1)), \ |
| 1121 |
$($(4)_$(1)), \ |
| 1122 |
$(LU_$(2)_$(1)), \ |
| 1123 |
$($(2)_$(1)), \ |
| 1124 |
$(LU_FLAVOR_$(3)_$(1)), \ |
| 1125 |
$(LU_$(1)), \ |
| 1126 |
$($(1)), \ |
| 1127 |
$(_LU_$(2)$(call lu-getvalue-flavor,EXT,$(3))_$(4)_$(5)_$(1)), \ |
| 1128 |
$(_LU_$(2)_$(4)_$(5)_$(1)), \ |
| 1129 |
$(_LU_$(4)_$(5)_$(1)), \ |
| 1130 |
$(_LU_$(2)$(call lu-getvalue-flavor,EXT,$(3))_$(4)_$(1)), \ |
| 1131 |
$(_LU_$(2)_$(4)_$(1)), \ |
| 1132 |
$(_LU_FLAVOR_$(3)_$(4)_$(1)), \ |
| 1133 |
$(_LU_$(4)_$(1)), \ |
| 1134 |
$(_LU_$(2)$(call lu-getvalue-flavor,EXT,$(3))_$(1)), \ |
| 1135 |
$(_LU_$(2)_$(1)), \ |
| 1136 |
$(_LU_FLAVOR_$(3)_$(1)), \ |
| 1137 |
$(_LU_$(1))\ |
| 1138 |
)) |
| 1139 |
endef |
| 1140 |
|
| 1141 |
define lu-call-prog # 1:varname 2:master 3:flavor [4:index] |
| 1142 |
$(call lu-getvalue,$(1),$(2),$(3)) $(call lu-getvalues,$(1)_OPTIONS,$(2),$(3)) |
| 1143 |
endef |
| 1144 |
|
| 1145 |
define lu-call-prog-index # 1:varname 2:master 3:flavor 4:type 5:indexname |
| 1146 |
$(call lu-getvalue$(if $(4),-index),$(1),$(2),$(3),$(4),$(5)) \ |
| 1147 |
$(call lu-getvalues$(if $(4),-index),$(1)_OPTIONS,$(2),$(3),$(4),$(5)) |
| 1148 |
endef |
| 1149 |
|
| 1150 |
define lu-call-prog-flavor # 1:master 2:flavor |
| 1151 |
$(call lu-call-prog,$(call lu-getvalue,VARPROG,$(1),$(2)),$(1),$(2)) |
| 1152 |
endef |
| 1153 |
|
| 1154 |
######################################################################### |
| 1155 |
######################################################################### |
| 1156 |
######################################################################### |
| 1157 |
######################################################################### |
| 1158 |
################## ######################### |
| 1159 |
################## Global variables ######################### |
| 1160 |
################## ######################### |
| 1161 |
######################################################################### |
| 1162 |
######################################################################### |
| 1163 |
######################################################################### |
| 1164 |
######################################################################### |
| 1165 |
######################################################################### |
| 1166 |
|
| 1167 |
# Globals variables |
| 1168 |
$(eval $(call lu-setvar-global,LATEX,latex)) |
| 1169 |
$(eval $(call lu-setvar-global,PDFLATEX,pdflatex)) |
| 1170 |
$(eval $(call lu-setvar-global,LUALATEX,lualatex)) |
| 1171 |
$(eval $(call lu-setvar-global,DVIPS,dvips)) |
| 1172 |
$(eval $(call lu-setvar-global,DVIPDFM,dvipdfm)) |
| 1173 |
$(eval $(call lu-setvar-global,BIBTEX,bibtex)) |
| 1174 |
#$(eval $(call lu-setvar-global,MPOST,TEX="$(LATEX)" mpost)) |
| 1175 |
$(eval $(call lu-setvar-global,FIG2DEV,fig2dev)) |
| 1176 |
#$(eval $(call lu-setvar-global,SVG2DEV,svg2dev)) |
| 1177 |
$(eval $(call lu-setvar-global,EPSTOPDF,epstopdf)) |
| 1178 |
$(eval $(call lu-setvar-global,MAKEINDEX,makeindex)) |
| 1179 |
|
| 1180 |
# workaround the fact that $(shell ...) ignore locally exported variables |
| 1181 |
# get only the variables with plain names |
| 1182 |
_LU_MAKE_ENV := $(shell echo '$(.VARIABLES)' | awk -v RS=' ' '/^[a-zA-Z0-9]+$$/') |
| 1183 |
_LU_SHELL_EXPORT := $(foreach v,$(_LU_MAKE_ENV),$(v)='$($(v))') |
| 1184 |
_lu_run_kpsewhich=$(shell $(_LU_SHELL_EXPORT) kpsewhich -format $1 $2) |
| 1185 |
|
| 1186 |
# Look first into the TDS (texmfscripts), then in PATH for our program |
| 1187 |
# At each location, we prefer with suffix than without |
| 1188 |
define _lu_which # VARNAME progname |
| 1189 |
ifeq ($(origin _LU_$(1)_DEFAULT), undefined) |
| 1190 |
_LU_$(1)_DEFAULT := $$(firstword $$(wildcard \ |
| 1191 |
$$(call _lu_run_kpsewhich,texmfscripts,$(2)) \ |
| 1192 |
$$(call _lu_run_kpsewhich,texmfscripts,$$(basename $(2))) \ |
| 1193 |
$$(foreach dir,$$(subst :, ,$$(PATH)), \ |
| 1194 |
$$(dir)/$(2) $$(dir)/$$(basename $(2))) \ |
| 1195 |
) $(2)) |
| 1196 |
export _LU_$(1)_DEFAULT |
| 1197 |
_LU_$(1)_DEFAULT_OLD := $$(firstword $$(wildcard \ |
| 1198 |
$$(addprefix bin/,$(2) $$(basename $(2))) \ |
| 1199 |
$$(addprefix ./,$(2) $$(basename $(2))))) |
| 1200 |
$$(if $$(filter-out $$(_LU_$(1)_DEFAULT), $$(_LU_$(1)_DEFAULT_OLD)),\ |
| 1201 |
$$(if $$(_lu_scripts_warnings),, \ |
| 1202 |
$$(eval _lu_scripts_warnings:=done) \ |
| 1203 |
$$(warning By default, this version of LaTeX-Make do not use \ |
| 1204 |
scripts in $$(dir $$(_LU_$(1)_DEFAULT_OLD)) anymore.) \ |
| 1205 |
$$(warning For example $$(_LU_$(1)_DEFAULT) is used instead of $$(_LU_$(1)_DEFAULT_OLD))\ |
| 1206 |
$$(warning If you want to keep the old behavior, add into your \ |
| 1207 |
Makefile something like:)\ |
| 1208 |
$$(warning export TEXMFSCRIPTS:=$$(dir $$(_LU_$(1)_DEFAULT_OLD))$$$$(addprefix :,$$$$(TEXMFSCRIPTS))::))) |
| 1209 |
#$$(warning _LU_$(1)_DEFAULT=$$(_LU_$(1)_DEFAULT)) |
| 1210 |
endif |
| 1211 |
$$(eval $$(call lu-setvar-global,$(1),$$(_LU_$(1)_DEFAULT))) |
| 1212 |
endef |
| 1213 |
|
| 1214 |
$(eval $(call _lu_which,GENSUBFIG,gensubfig.py)) |
| 1215 |
$(eval $(call _lu_which,FIGDEPTH,figdepth.py)) |
| 1216 |
$(eval $(call _lu_which,GENSUBSVG,gensubfig.py)) |
| 1217 |
$(eval $(call _lu_which,SVGDEPTH,svgdepth.py)) |
| 1218 |
$(eval $(call _lu_which,SVG2DEV,svg2dev.py)) |
| 1219 |
$(eval $(call _lu_which,LATEXFILTER,latexfilter.py)) |
| 1220 |
|
| 1221 |
# Rules to use to check if the build document (dvi or pdf) is up-to-date |
| 1222 |
# This can be overruled per document manually and/or automatically |
| 1223 |
#REBUILD_RULES ?= latex texdepends bibtopic bibtopic_undefined_references |
| 1224 |
$(eval $(call lu-addtovar-global,REBUILD_RULES,latex texdepends)) |
| 1225 |
|
| 1226 |
# Default maximum recursion level |
| 1227 |
$(eval $(call lu-setvar-global,MAX_REC,6)) |
| 1228 |
|
| 1229 |
######################################################################### |
| 1230 |
######################################################################### |
| 1231 |
######################################################################### |
| 1232 |
######################################################################### |
| 1233 |
################## ######################### |
| 1234 |
################## Flavors ######################### |
| 1235 |
################## ######################### |
| 1236 |
######################################################################### |
| 1237 |
######################################################################### |
| 1238 |
######################################################################### |
| 1239 |
######################################################################### |
| 1240 |
######################################################################### |
| 1241 |
|
| 1242 |
define lu-create-texflavor # 1:name 2:tex_prog 3:file_ext |
| 1243 |
# 4:master_cible 5:fig_extention_to_clean |
| 1244 |
_LU_FLAVORS_DEFINED_TEX += $(1) |
| 1245 |
$(eval $(call lu-setvar-flavor,VARPROG,$(1),$(2))) |
| 1246 |
$(eval $(call lu-setvar-flavor,EXT,$(1),$(3))) |
| 1247 |
$(eval $(call lu-setvar-flavor,TARGETNAME,$(1),$(4))) |
| 1248 |
$(eval $(call lu-addtovar-flavor,CLEANFIGEXT,$(1),$(5))) |
| 1249 |
$(eval $(call lu-addtovar-flavor,CLEANSVGEXT,$(1),$(5))) |
| 1250 |
endef |
| 1251 |
|
| 1252 |
define lu-create-dviflavor # 1:name 2:dvi_prog 3:file_ext |
| 1253 |
# 4:master_cible 5:tex_flavor_depend |
| 1254 |
$$(eval $$(call lu-define-flavor,$(5))) |
| 1255 |
_LU_FLAVORS_DEFINED_DVI += $(1) |
| 1256 |
$(eval $(call lu-setvar-flavor,VARPROG,$(1),$(2))) |
| 1257 |
$(eval $(call lu-setvar-flavor,EXT,$(1),$(3))) |
| 1258 |
$(eval $(call lu-setvar-flavor,TARGETNAME,$(1),$(4))) |
| 1259 |
$(eval $(call lu-setvar-flavor,DEPFLAVOR,$(1),$(5))) |
| 1260 |
endef |
| 1261 |
|
| 1262 |
define lu-create-flavor # 1:name 2:type 3..7:options |
| 1263 |
$$(if $$(filter $(1),$(_LU_FLAVORS_DEFINED)), \ |
| 1264 |
$$(call lu-show-flavors,Flavor $(1) already defined), \ |
| 1265 |
$$(call lu-show-flavors,Creating flavor $(1) ($(2))) \ |
| 1266 |
$$(eval $$(call lu-create-$(2)flavor,$(1),$(3),$(4),$(5),$(6),$(7)))) |
| 1267 |
endef |
| 1268 |
|
| 1269 |
define lu-define-flavor # 1:name |
| 1270 |
$$(eval $$(call lu-define-flavor-$(1))) |
| 1271 |
endef |
| 1272 |
|
| 1273 |
define lu-flavor-rules # 1:name |
| 1274 |
$$(call lu-show-flavors,Defining rules for flavor $(1)) |
| 1275 |
$$(if $$(call lu-getvalue-flavor,TARGETNAME,$(1)), \ |
| 1276 |
$$(call lu-getvalue-flavor,TARGETNAME,$(1)): \ |
| 1277 |
$$(call lu-getvalues-flavor,TARGETS,$(1))) |
| 1278 |
$$(if $$(call lu-getvalue-flavor,TARGETNAME,$(1)), \ |
| 1279 |
.PHONY: $$(call lu-getvalue-flavor,TARGETNAME,$(1))) |
| 1280 |
endef |
| 1281 |
|
| 1282 |
define lu-define-flavor-DVI # |
| 1283 |
$$(eval $$(call lu-create-flavor,DVI,tex,LATEX,.dvi,dvi,\ |
| 1284 |
.pstex_t .pstex)) |
| 1285 |
endef |
| 1286 |
|
| 1287 |
define lu-define-flavor-PDF # |
| 1288 |
$$(eval $$(call lu-create-flavor,PDF,tex,PDFLATEX,.pdf,pdf,\ |
| 1289 |
.pdftex_t .$$(_LU_PDFTEX_EXT))) |
| 1290 |
endef |
| 1291 |
|
| 1292 |
define lu-define-flavor-LUALATEX # |
| 1293 |
$$(eval $$(call lu-create-flavor,LUALATEX,tex,LUALATEX,.pdf,pdf,\ |
| 1294 |
.pdftex_t .$$(_LU_PDFTEX_EXT))) |
| 1295 |
endef |
| 1296 |
|
| 1297 |
define lu-define-flavor-PS # |
| 1298 |
$$(eval $$(call lu-create-flavor,PS,dvi,DVIPS,.ps,ps,DVI)) |
| 1299 |
endef |
| 1300 |
|
| 1301 |
define lu-define-flavor-DVIPDF # |
| 1302 |
$$(eval $$(call lu-create-flavor,DVIPDF,dvi,DVIPDFM,.pdf,pdf,DVI)) |
| 1303 |
endef |
| 1304 |
|
| 1305 |
$(eval $(call lu-addtovar-global,FLAVORS,PDF PS)) |
| 1306 |
|
| 1307 |
######################################################################### |
| 1308 |
######################################################################### |
| 1309 |
######################################################################### |
| 1310 |
######################################################################### |
| 1311 |
################## ######################### |
| 1312 |
################## Masters ######################### |
| 1313 |
################## ######################### |
| 1314 |
######################################################################### |
| 1315 |
######################################################################### |
| 1316 |
######################################################################### |
| 1317 |
######################################################################### |
| 1318 |
######################################################################### |
| 1319 |
|
| 1320 |
define _lu-do-latex # 1:master 2:flavor 3:source.tex 4:ext(.dvi/.pdf) |
| 1321 |
exec 3>&1; \ |
| 1322 |
run() { \ |
| 1323 |
printf "Running:" 1>&3 ; \ |
| 1324 |
for arg; do \ |
| 1325 |
printf "%s" " '$$arg'" 1>&3 ; \ |
| 1326 |
done ; echo 1>&3 ; \ |
| 1327 |
"$$@" ; \ |
| 1328 |
}; \ |
| 1329 |
doit() { \ |
| 1330 |
$(RM) -v "$(1)$(4)_FAILED" \ |
| 1331 |
"$(1)$(4)_NEED_REBUILD" \ |
| 1332 |
"$(1)$(4).mk" ;\ |
| 1333 |
( echo X | \ |
| 1334 |
run $(call lu-call-prog-flavor,$(1),$(2)) \ |
| 1335 |
--interaction errorstopmode \ |
| 1336 |
--jobname "$(1)" \ |
| 1337 |
'\RequirePackage[extension='"$(4)"']{texdepends}\input'"{$(3)}" || \ |
| 1338 |
touch "$(1)$(4)_FAILED" ; \ |
| 1339 |
if grep -sq '^! LaTeX Error:' "$(1).log" ; then \ |
| 1340 |
touch "$(1)$(4)_FAILED" ; \ |
| 1341 |
fi \ |
| 1342 |
) | $(call lu-call-prog,LATEXFILTER,$(1),$(2)) ; \ |
| 1343 |
NO_TEXDEPENDS_FILE=0 ;\ |
| 1344 |
if [ ! -f "$(1)$(4).mk" ]; then \ |
| 1345 |
NO_TEXDEPENDS_FILE=1 ;\ |
| 1346 |
fi ;\ |
| 1347 |
sed -e 's,\\openout[0-9]* = \([^`].*\),TD_$(1)$(4)_OUTPUTS += \1,p;s,\\openout[0-9]* = `\(.*\)'"'.,TD_$(1)$(4)_OUTPUTS += \1,p;d" \ |
| 1348 |
"$(1).log" >> "$(1)$(4).mk" ;\ |
| 1349 |
if [ -f "$(1)$(4)_FAILED" ]; then \ |
| 1350 |
echo "*************************************" ;\ |
| 1351 |
echo "Building $(1)$(4) fails" ;\ |
| 1352 |
echo "*************************************" ;\ |
| 1353 |
echo "Here are the last lines of the log file" ;\ |
| 1354 |
echo "If this is not enought, try to" ;\ |
| 1355 |
echo "call 'make' with 'VERB=verbose' option" ;\ |
| 1356 |
echo "*************************************" ;\ |
| 1357 |
echo "==> Last lines in $(1).log <==" ; \ |
| 1358 |
sed -e '/^[?] X$$/,$$d' \ |
| 1359 |
-e '/^Here is how much of TeX'"'"'s memory you used:$$/,$$d' \ |
| 1360 |
< "$(1).log" | tail -n 20; \ |
| 1361 |
return 1; \ |
| 1362 |
fi; \ |
| 1363 |
if [ "$$NO_TEXDEPENDS_FILE" = 1 ]; then \ |
| 1364 |
echo "*************************************" ;\ |
| 1365 |
echo "texdepends does not seems be loaded" ;\ |
| 1366 |
echo "Either your (La)TeX installation is wrong or you found a bug." ;\ |
| 1367 |
echo "If so, please, report it (with the result of shell command 'kpsepath tex')";\ |
| 1368 |
echo "Aborting compilation" ;\ |
| 1369 |
echo "*************************************" ;\ |
| 1370 |
touch "$(1)$(4)_FAILED" ; \ |
| 1371 |
return 1 ;\ |
| 1372 |
fi ;\ |
| 1373 |
}; doit |
| 1374 |
endef |
| 1375 |
|
| 1376 |
.PHONY: clean-build-fig |
| 1377 |
|
| 1378 |
########################################################## |
| 1379 |
define lu-master-texflavor-index-vars # MASTER FLAVOR TYPE INDEX ext(.dvi/.pdf) |
| 1380 |
$$(call lu-show-rules,Setting flavor index vars for $(1)/$(2)/[$(3)]$(4)) |
| 1381 |
$$(eval $$(call lu-addtovar,DEPENDS,$(1),$(2), \ |
| 1382 |
$$(call lu-getvalue-index,TARGET,$(1),$(2),$(3),$(4)))) |
| 1383 |
$$(eval $$(call lu-addtovar,WATCHFILES,$(1),$(2), \ |
| 1384 |
$$(call lu-getvalue-index,SRC,$(1),$(2),$(3),$(4)))) |
| 1385 |
endef #################################################### |
| 1386 |
define lu-master-texflavor-index-rules # MASTER FLAVOR TYPE INDEX ext(.dvi/.pdf) |
| 1387 |
$$(call lu-show-rules,Setting flavor index rules for $(1)/$(2)/[$(3)]$(4)) |
| 1388 |
$$(if $$(_LU_DEF_IND_$$(call lu-getvalue-index,TARGET,$(1),$(2),$(3),$(4))), \ |
| 1389 |
$$(call lu-show-rules,=> Skipping: already defined in flavor $$(_LU_DEF_IND_$$(call lu-getvalue-index,TARGET,$(1),$(2),$(3),$(4)))), \ |
| 1390 |
$$(eval $$(call _lu-master-texflavor-index-rules\ |
| 1391 |
,$(1),$(2),$(3),$(4),$(5),$$(call lu-getvalue-index,TARGET,$(1),$(2),$(3),$(4))))) |
| 1392 |
endef |
| 1393 |
define _lu-master-texflavor-index-rules # MASTER FLAVOR TYPE INDEX ext TARGET |
| 1394 |
$(6): \ |
| 1395 |
$$(call lu-getvalue-index,SRC,$(1),$(2),$(3),$(4)) \ |
| 1396 |
$$(wildcard $$(call lu-getvalue-index,STYLE,$(1),$(2),$(3),$(4))) |
| 1397 |
$$(COMMON_PREFIX)$$(call lu-call-prog-index,MAKEINDEX,$(1),$(2),$(3),$(4)) \ |
| 1398 |
$$(addprefix -s ,$$(call lu-getvalue-index,STYLE,$(1),$(2),$(3),$(4))) \ |
| 1399 |
-o $$@ $$< |
| 1400 |
_LU_DEF_IND_$(6)=$(2) |
| 1401 |
clean:: |
| 1402 |
$$(call lu-clean,$$(call lu-getvalue-index,TARGET,$(1),$(2),$(3),$(4)) \ |
| 1403 |
$$(addsuffix .ilg,$$(basename \ |
| 1404 |
$$(call lu-getvalue-index,SRC,$(1),$(2),$(3),$(4))))) |
| 1405 |
endef #################################################### |
| 1406 |
define lu-master-texflavor-index # MASTER FLAVOR INDEX ext(.dvi/.pdf) |
| 1407 |
$$(eval $$(call lu-master-texflavor-index-vars,$(1),$(2),$(3),$(4))) |
| 1408 |
$$(eval $$(call lu-master-texflavor-index-rules,$(1),$(2),$(3),$(4))) |
| 1409 |
endef |
| 1410 |
########################################################## |
| 1411 |
|
| 1412 |
########################################################## |
| 1413 |
define lu-master-texflavor-vars # MASTER FLAVOR ext(.dvi/.pdf) |
| 1414 |
$$(call lu-show-rules,Setting flavor vars for $(1)/$(2)) |
| 1415 |
-include $(1)$(3).mk |
| 1416 |
$$(eval $$(call lu-addtovar,DEPENDS,$(1),$(2), \ |
| 1417 |
$$(call lu-getvalues,FIGURES,$(1),$(2)) \ |
| 1418 |
$$(call lu-getvalues,BIBFILES,$(1),$(2)) \ |
| 1419 |
$$(wildcard $$(call lu-getvalues,INPUTS,$(1),$(2))) \ |
| 1420 |
$$(wildcard $$(call lu-getvalues,BIBSTYLES,$(1),$(2))) \ |
| 1421 |
$$(call lu-getvalues,BBLFILES,$(1),$(2))\ |
| 1422 |
)) |
| 1423 |
|
| 1424 |
$$(eval $$(call lu-addtovar-flavor,TARGETS,$(2),$(1)$(3))) |
| 1425 |
|
| 1426 |
$$(eval $$(call lu-addtovar,GPATH,$(1),$(2), \ |
| 1427 |
$$(subst },,$$(subst {,,$$(subst }{, ,\ |
| 1428 |
$$(call lu-getvalue,GRAPHICSPATH,$(1),$(2))))))) |
| 1429 |
|
| 1430 |
$$(if $$(sort $$(call lu-getvalues,SUBFIGS,$(1),$(2))), \ |
| 1431 |
$$(eval include $$(addsuffix .mk,$$(sort \ |
| 1432 |
$$(call lu-getvalues,SUBFIGS,$(1),$(2)))))) |
| 1433 |
|
| 1434 |
$$(eval $$(call lu-addtovar,WATCHFILES,$(1),$(2), \ |
| 1435 |
$$(filter %.aux, $$(call lu-getvalues,OUTPUTS,$(1),$(2))))) |
| 1436 |
|
| 1437 |
$$(foreach type,$$(call lu-getvalues,INDEXES,$(1),$(2)), \ |
| 1438 |
$$(foreach index,$$(call lu-getvalues,INDEXES_$$(type),$(1),$(2)), \ |
| 1439 |
$$(eval $$(call lu-master-texflavor-index-vars,$(1),$(2),$$(type),$$(index),$(3))))) |
| 1440 |
endef #################################################### |
| 1441 |
define lu-master-texflavor-rules # MASTER FLAVOR ext(.dvi/.pdf) |
| 1442 |
$$(call lu-show-rules,Defining flavor rules for $(1)/$(2)) |
| 1443 |
$$(call lu-getvalues,BBLFILES,$(1),$(2)): \ |
| 1444 |
$$(sort $$(call lu-getvalues,BIBFILES,$(1),$(2)) \ |
| 1445 |
$$(wildcard $$(call lu-getvalues,BIBSTYLES,$(1),$(2)))) |
| 1446 |
$(1)$(3): %$(3): \ |
| 1447 |
$$(filter-out $$(call lu-getvalues,DEPENDS_EXCLUDE,$(1),$(2)), \ |
| 1448 |
$$(call lu-getvalues,DEPENDS,$(1),$(2)) \ |
| 1449 |
$$(call lu-getvalues,REQUIRED,$(1),$(2))) \ |
| 1450 |
$$(if $$(wildcard $(1)$(3)_FAILED),LU_FORCE,) \ |
| 1451 |
$$(if $$(wildcard $(1)$(3)_NEED_REBUILD),LU_FORCE,) \ |
| 1452 |
$$(if $$(wildcard $(1)$(3)_NEED_REBUILD_IN_PROGRESS),LU_FORCE,) |
| 1453 |
$$(if $$(filter-out $$(LU_REC_LEVEL),$$(call lu-getvalue,MAX_REC,$(1),$(2))),, \ |
| 1454 |
$$(warning *********************************) \ |
| 1455 |
$$(warning *********************************) \ |
| 1456 |
$$(warning *********************************) \ |
| 1457 |
$$(warning Stopping generation of $$@) \ |
| 1458 |
$$(warning I got max recursion level $$(call lu-getvalue,MAX_REC,$(1),$(2))) \ |
| 1459 |
$$(warning Set LU_$(1)_$(2)_MAX_REC, LU_MAX_REC_$(1) or LU_MAX_REC if you need it) \ |
| 1460 |
$$(warning *********************************) \ |
| 1461 |
$$(warning *********************************) \ |
| 1462 |
$$(warning *********************************) \ |
| 1463 |
$$(error Aborting generation of $$@)) |
| 1464 |
$$(MAKE) LU_REC_MASTER="$(1)" LU_REC_FLAVOR="$(2)" LU_REC_TARGET="$$@"\ |
| 1465 |
LU_WATCH_FILES_SAVE |
| 1466 |
$$(COMMON_PREFIX)$$(call _lu-do-latex\ |
| 1467 |
,$(1),$(2),$$(call lu-getvalue-master,MAIN,$(1)),$(3)) |
| 1468 |
$$(MAKE) LU_REC_MASTER="$(1)" LU_REC_FLAVOR="$(2)" LU_REC_TARGET="$$@"\ |
| 1469 |
LU_WATCH_FILES_RESTORE |
| 1470 |
$$(MAKE) LU_REC_MASTER="$(1)" LU_REC_FLAVOR="$(2)" LU_REC_TARGET="$$@"\ |
| 1471 |
$(1)$(3)_NEED_REBUILD |
| 1472 |
ifneq ($(LU_REC_TARGET),) |
| 1473 |
$(1)$(3)_NEED_REBUILD_IN_PROGRESS: |
| 1474 |
$$(COMMON_HIDE)touch $(1)$(3)_NEED_REBUILD_IN_PROGRESS |
| 1475 |
$$(addprefix LU_rebuild_,$$(call lu-getvalues,REBUILD_RULES,$(1),$(2))): \ |
| 1476 |
$(1)$(3)_NEED_REBUILD_IN_PROGRESS |
| 1477 |
.PHONY: $(1)$(3)_NEED_REBUILD |
| 1478 |
$(1)$(3)_NEED_REBUILD: \ |
| 1479 |
$(1)$(3)_NEED_REBUILD_IN_PROGRESS \ |
| 1480 |
$$(addprefix LU_rebuild_,$$(call lu-getvalues,REBUILD_RULES,$(1),$(2))) |
| 1481 |
$$(COMMON_HIDE)$(RM) $(1)$(3)_NEED_REBUILD_IN_PROGRESS |
| 1482 |
$$(COMMON_HIDE)if [ -f "$(1)$(3)_NEED_REBUILD" ];then\ |
| 1483 |
echo "********************************************" ;\ |
| 1484 |
echo "*********** New build needed ***************" ;\ |
| 1485 |
echo "********************************************" ;\ |
| 1486 |
cat "$(1)$(3)_NEED_REBUILD" ; \ |
| 1487 |
echo "********************************************" ;\ |
| 1488 |
fi |
| 1489 |
$$(MAKE) LU_REC_LEVEL=$$(shell expr $$(LU_REC_LEVEL) + 1) \ |
| 1490 |
$$(LU_REC_TARGET) |
| 1491 |
endif |
| 1492 |
clean-build-fig:: |
| 1493 |
$$(call lu-clean,$$(foreach fig, \ |
| 1494 |
$$(basename $$(wildcard $$(filter %.fig, \ |
| 1495 |
$$(call lu-getvalues,FIGURES,$(1),$(2))))), \ |
| 1496 |
$$(addprefix $$(fig),$$(call lu-getvalues-flavor,CLEANFIGEXT,$(2))))) |
| 1497 |
$$(call lu-clean,$$(foreach svg, \ |
| 1498 |
$$(basename $$(wildcard $$(filter %.svg, \ |
| 1499 |
$$(call lu-getvalues,FIGURES,$(1),$(2))))), \ |
| 1500 |
$$(addprefix $$(svg),$$(call lu-getvalues-flavor,CLEANSVGEXT,$(2))))) |
| 1501 |
clean:: clean-build-fig |
| 1502 |
$$(call lu-clean,$$(call lu-getvalues,OUTPUTS,$(1),$(2)) \ |
| 1503 |
$$(call lu-getvalues,BBLFILES,$(1),$(2)) \ |
| 1504 |
$$(addsuffix .mk,$$(call lu-getvalues,SUBFIGS,$(1),$(2))) \ |
| 1505 |
$$(patsubst %.bbl,%.blg,$$(call lu-getvalues,BBLFILES,$(1),$(2)))) |
| 1506 |
$$(call lu-clean,$$(wildcard $(1).log)) |
| 1507 |
distclean:: |
| 1508 |
$$(call lu-clean,$$(wildcard $(1)$(3) $(1)$(3)_FAILED \ |
| 1509 |
$(1)$(3)_NEED_REBUILD $(1)$(3)_NEED_REBUILD_IN_PROGRESS)) |
| 1510 |
$$(foreach type,$$(call lu-getvalues,INDEXES,$(1),$(2)), \ |
| 1511 |
$$(foreach index,$$(call lu-getvalues,INDEXES_$$(type),$(1),$(2)), \ |
| 1512 |
$$(eval $$(call lu-master-texflavor-index-rules,$(1),$(2),$$(type),$$(index),$(3))))) |
| 1513 |
endef #################################################### |
| 1514 |
define lu-master-texflavor # MASTER FLAVOR ext(.dvi/.pdf) |
| 1515 |
$$(eval $$(call lu-master-texflavor-vars,$(1),$(2),$(3))) |
| 1516 |
$$(eval $$(call lu-master-texflavor-rules,$(1),$(2),$(3))) |
| 1517 |
endef |
| 1518 |
########################################################## |
| 1519 |
|
| 1520 |
########################################################## |
| 1521 |
define lu-master-dviflavor-vars # MASTER FLAVOR ext(.ps) |
| 1522 |
$$(call lu-show-rules,Setting flavor vars for \ |
| 1523 |
$(1)/$(2)/$$(call lu-getvalue-flavor,DEPFLAVOR,$(2))) |
| 1524 |
# $$(eval $$(call lu-addvar,VARPROG,$(1),$(2))) |
| 1525 |
# $$(eval $$(call lu-addvar,$$(call lu-getvalue,VARPROG,$(1),$(2)),$(1),$(2))) |
| 1526 |
$$(eval $$(call lu-addtovar-flavor,TARGETS,$(2),$(1)$(3))) |
| 1527 |
endef #################################################### |
| 1528 |
define lu-master-dviflavor-rules # MASTER FLAVOR ext(.ps) |
| 1529 |
$$(call lu-show-rules,Defining flavor rules for \ |
| 1530 |
$(1)/$(2)/$$(call lu-getvalue-flavor,DEPFLAVOR,$(2))) |
| 1531 |
$(1)$(3): %$(3): %$$(call lu-getvalue-flavor,EXT,$$(call lu-getvalue-flavor,DEPFLAVOR,$(2))) |
| 1532 |
$$(call lu-call-prog-flavor,$(1),$(2)) -o $$@ $$< |
| 1533 |
distclean:: |
| 1534 |
$$(call lu-clean,$$(wildcard $(1)$(3))) |
| 1535 |
endef #################################################### |
| 1536 |
define lu-master-dviflavor # MASTER FLAVOR ext(.ps) |
| 1537 |
$$(eval $$(call lu-master-dviflavor-vars,$(1),$(2),$(3))) |
| 1538 |
$$(eval $$(call lu-master-dviflavor-rules,$(1),$(2),$(3))) |
| 1539 |
endef |
| 1540 |
########################################################## |
| 1541 |
|
| 1542 |
########################################################## |
| 1543 |
define lu-master-vars # MASTER |
| 1544 |
$$(call lu-show-rules,Setting vars for $(1)) |
| 1545 |
$$(eval $$(call lu-setvar-master,MAIN,$(1),$(1).tex)) |
| 1546 |
$$(eval $$(call lu-addtovar-master,DEPENDS,$(1),\ |
| 1547 |
$$(call lu-getvalue-master,MAIN,$(1)))) |
| 1548 |
_LU_$(1)_DVI_FLAVORS=$$(filter $$(_LU_FLAVORS_DEFINED_DVI),\ |
| 1549 |
$$(sort $$(call lu-getvalues-master,FLAVORS,$(1)))) |
| 1550 |
_LU_$(1)_TEX_FLAVORS=$$(filter $$(_LU_FLAVORS_DEFINED_TEX),\ |
| 1551 |
$$(sort $$(call lu-getvalues-master,FLAVORS,$(1)) \ |
| 1552 |
$$(LU_REC_FLAVOR) \ |
| 1553 |
$$(foreach dvi,$$(call lu-getvalues-master,FLAVORS,$(1)), \ |
| 1554 |
$$(call lu-getvalue-flavor,DEPFLAVOR,$$(dvi))))) |
| 1555 |
$$(foreach flav,$$(_LU_$(1)_TEX_FLAVORS), $$(eval $$(call \ |
| 1556 |
lu-master-texflavor-vars,$(1),$$(flav),$$(call lu-getvalue-flavor,EXT,$$(flav))))) |
| 1557 |
$$(foreach flav,$$(_LU_$(1)_DVI_FLAVORS), $$(eval $$(call \ |
| 1558 |
lu-master-dviflavor-vars,$(1),$$(flav),$$(call lu-getvalue-flavor,EXT,$$(flav))))) |
| 1559 |
endef #################################################### |
| 1560 |
define lu-master-rules # MASTER |
| 1561 |
$$(call lu-show-rules,Defining rules for $(1)) |
| 1562 |
$$(foreach flav,$$(_LU_$(1)_TEX_FLAVORS), $$(eval $$(call \ |
| 1563 |
lu-master-texflavor-rules,$(1),$$(flav),$$(call lu-getvalue-flavor,EXT,$$(flav))))) |
| 1564 |
$$(foreach flav,$$(_LU_$(1)_DVI_FLAVORS), $$(eval $$(call \ |
| 1565 |
lu-master-dviflavor-rules,$(1),$$(flav),$$(call lu-getvalue-flavor,EXT,$$(flav))))) |
| 1566 |
endef #################################################### |
| 1567 |
define lu-master # MASTER |
| 1568 |
$$(eval $$(call lu-master-vars,$(1))) |
| 1569 |
$$(eval $$(call lu-master-rules,$(1))) |
| 1570 |
endef |
| 1571 |
########################################################## |
| 1572 |
|
| 1573 |
#$(warning $(call LU_RULES,example)) |
| 1574 |
$(eval $(call lu-addtovar-global,MASTERS,\ |
| 1575 |
$$(shell grep -l '\\documentclass' *.tex 2>/dev/null | sed -e 's/\.tex$$$$//'))) |
| 1576 |
ifneq ($(LU_REC_TARGET),) |
| 1577 |
_LU_DEF_MASTERS = $(LU_REC_MASTER) |
| 1578 |
_LU_DEF_FLAVORS = $(LU_REC_FLAVOR) $(FLAV_DEPFLAVOR_$(LU_REC_FLAVOR)) |
| 1579 |
else |
| 1580 |
_LU_DEF_MASTERS = $(call lu-getvalues-global,MASTERS) |
| 1581 |
_LU_DEF_FLAVORS = $(sort $(foreach master,$(_LU_DEF_MASTERS),\ |
| 1582 |
$(call lu-getvalues-master,FLAVORS,$(master)))) |
| 1583 |
endif |
| 1584 |
|
| 1585 |
$(foreach flav, $(_LU_DEF_FLAVORS), $(eval $(call lu-define-flavor,$(flav)))) |
| 1586 |
$(foreach master, $(_LU_DEF_MASTERS), $(eval $(call lu-master-vars,$(master)))) |
| 1587 |
$(foreach flav, $(_LU_FLAVORS_DEFINED), $(eval $(call lu-flavor-rules,$(flav)))) |
| 1588 |
$(foreach master, $(_LU_DEF_MASTERS), $(eval $(call lu-master-rules,$(master)))) |
| 1589 |
|
| 1590 |
##################################################################"" |
| 1591 |
# Gestion des subfigs |
| 1592 |
|
| 1593 |
%<<MAKEFILE |
| 1594 |
%.subfig.mk: %.subfig %.fig |
| 1595 |
$(COMMON_PREFIX)$(call lu-call-prog,GENSUBFIG) \ |
| 1596 |
-p '$$(COMMON_PREFIX)$(call lu-call-prog,FIGDEPTH) < $$< > $$@' \ |
| 1597 |
-s $*.subfig $*.fig < $^ > $@ |
| 1598 |
%MAKEFILE |
| 1599 |
|
| 1600 |
%<<MAKEFILE |
| 1601 |
%.subfig.mk: %.subfig %.svg |
| 1602 |
$(COMMON_PREFIX)$(call lu-call-prog,GENSUBSVG) \ |
| 1603 |
-p '$$(COMMON_PREFIX)$(call lu-call-prog,SVGDEPTH) < $$< > $$@' \ |
| 1604 |
-s $*.subfig $*.svg < $^ > $@ |
| 1605 |
%MAKEFILE |
| 1606 |
|
| 1607 |
clean:: |
| 1608 |
$(call lu-clean,$(FIGS2CREATE_LIST)) |
| 1609 |
$(call lu-clean,$(FIGS2CREATE_LIST:%.fig=%.pstex)) |
| 1610 |
$(call lu-clean,$(FIGS2CREATE_LIST:%.fig=%.pstex_t)) |
| 1611 |
$(call lu-clean,$(FIGS2CREATE_LIST:%.fig=%.$(_LU_PDFTEX_EXT))) |
| 1612 |
$(call lu-clean,$(FIGS2CREATE_LIST:%.fig=%.pdftex_t)) |
| 1613 |
$(call lu-clean,$(FIGS2CREATE_LIST:%.svg=%.pstex)) |
| 1614 |
$(call lu-clean,$(FIGS2CREATE_LIST:%.svg=%.pstex_t)) |
| 1615 |
$(call lu-clean,$(FIGS2CREATE_LIST:%.svg=%.$(_LU_PDFTEX_EXT))) |
| 1616 |
$(call lu-clean,$(FIGS2CREATE_LIST:%.svg=%.pdftex_t)) |
| 1617 |
|
| 1618 |
.PHONY: LU_FORCE clean distclean |
| 1619 |
LU_FORCE: |
| 1620 |
@echo "Previous compilation failed. Rerun needed" |
| 1621 |
|
| 1622 |
#$(warning $(MAKEFILE)) |
| 1623 |
|
| 1624 |
distclean:: clean |
| 1625 |
|
| 1626 |
%<<MAKEFILE |
| 1627 |
%.eps: %.fig |
| 1628 |
$(COMMON_PREFIX)$(call lu-call-prog,FIG2DEV) -L eps $< $@ |
| 1629 |
|
| 1630 |
%.pdf: %.fig |
| 1631 |
$(COMMON_PREFIX)$(call lu-call-prog,FIG2DEV) -L pdf $< $@ |
| 1632 |
|
| 1633 |
%.pstex: %.fig |
| 1634 |
$(COMMON_PREFIX)$(call lu-call-prog,FIG2DEV) -L pstex $< $@ |
| 1635 |
|
| 1636 |
%.pstex: %.svg |
| 1637 |
$(COMMON_PREFIX)$(call lu-call-prog,SVG2DEV) -L pstex $< $@ |
| 1638 |
|
| 1639 |
|
| 1640 |
.PRECIOUS: %.pstex |
| 1641 |
%.pstex_t: %.fig %.pstex |
| 1642 |
$(COMMON_PREFIX)$(call lu-call-prog,FIG2DEV) -L pstex_t -p $*.pstex $< $@ |
| 1643 |
|
| 1644 |
%.pstex_t: %.svg %.pstex |
| 1645 |
$(COMMON_PREFIX)$(call lu-call-prog,SVG2DEV) -L pstex_t -p $*.pstex $< $@ |
| 1646 |
|
| 1647 |
|
| 1648 |
%.$(_LU_PDFTEX_EXT): %.fig |
| 1649 |
$(COMMON_PREFIX)$(call lu-call-prog,FIG2DEV) -L pdftex $< $@ |
| 1650 |
|
| 1651 |
%.$(_LU_PDFTEX_EXT): %.svg |
| 1652 |
$(COMMON_PREFIX)$(call lu-call-prog,SVG2DEV) -L pdftex $< $@ |
| 1653 |
|
| 1654 |
.PRECIOUS: %.$(_LU_PDFTEX_EXT) |
| 1655 |
%.pdftex_t: %.fig %.$(_LU_PDFTEX_EXT) |
| 1656 |
$(COMMON_PREFIX)$(call lu-call-prog,FIG2DEV) -L pdftex_t -p $*.$(_LU_PDFTEX_EXT) $< $@ |
| 1657 |
|
| 1658 |
%.pdftex_t: %.svg %.$(_LU_PDFTEX_EXT) |
| 1659 |
$(COMMON_PREFIX)$(call lu-call-prog,SVG2DEV) -L pdftex_t -p $*.$(_LU_PDFTEX_EXT) $< $@ |
| 1660 |
|
| 1661 |
%.pdf: %.eps |
| 1662 |
$(COMMON_PREFIX)$(call lu-call-prog,EPSTOPDF) --filter < $< > $@ |
| 1663 |
%MAKEFILE |
| 1664 |
|
| 1665 |
######################################################################### |
| 1666 |
# Les flavors |
| 1667 |
LU_REC_LEVEL ?= 1 |
| 1668 |
ifneq ($(LU_REC_TARGET),) |
| 1669 |
export LU_REC_FLAVOR |
| 1670 |
export LU_REC_MASTER |
| 1671 |
export LU_REC_TARGET |
| 1672 |
export LU_REC_LEVEL |
| 1673 |
LU_REC_LOGFILE=$(LU_REC_MASTER).log |
| 1674 |
LU_REC_GENFILE=$(LU_REC_MASTER)$(call lu-getvalue-flavor,EXT,$(LU_REC_FLAVOR)) |
| 1675 |
|
| 1676 |
lu-rebuild-head=$(info *** Checking rebuild with rule '$(subst LU_rebuild_,,$@)') |
| 1677 |
lu-rebuild-needed=echo $(1) >> "$(LU_REC_GENFILE)_NEED_REBUILD" ; |
| 1678 |
|
| 1679 |
.PHONY: $(addprefix LU_rebuild_,latex texdepends bibtex) |
| 1680 |
LU_rebuild_latex: |
| 1681 |
$(call lu-rebuild-head) |
| 1682 |
$(COMMON_HIDE)if grep -sq 'Rerun to get'\ |
| 1683 |
"$(LU_REC_LOGFILE)" ; then \ |
| 1684 |
$(call lu-rebuild-needed\ |
| 1685 |
,"$@: new run needed (LaTeX message 'Rerun to get...')") \ |
| 1686 |
fi |
| 1687 |
|
| 1688 |
LU_rebuild_texdepends: |
| 1689 |
$(call lu-rebuild-head) |
| 1690 |
$(COMMON_HIDE)if grep -sq '^Package texdepends Warning: .* Check dependencies again.$$'\ |
| 1691 |
"$(LU_REC_LOGFILE)" ; then \ |
| 1692 |
$(call lu-rebuild-needed,"$@: new depends required") \ |
| 1693 |
fi |
| 1694 |
|
| 1695 |
LU_rebuild_bibtopic: |
| 1696 |
$(call lu-rebuild-head) |
| 1697 |
%</makefile> |
| 1698 |
% \end{macrocode} |
| 1699 |
% This part is not needed: already checked with the |lu_rebuild_latex| rule |
| 1700 |
% \begin{macrocode} |
| 1701 |
%<*notused> |
| 1702 |
$(COMMON_HIDE)if grep -sq 'Rerun to get indentation of bibitems right'\ |
| 1703 |
"$(LU_REC_LOGFILE)" ; then \ |
| 1704 |
$(call lu-rebuild-needed,"$@: new run needed") \ |
| 1705 |
fi |
| 1706 |
$(COMMON_HIDE)if grep -sq 'Rerun to get cross-references right'\ |
| 1707 |
"$(LU_REC_LOGFILE)" ; then \ |
| 1708 |
$(call lu-rebuild-needed,"$@: new run needed") \ |
| 1709 |
fi |
| 1710 |
%</notused> |
| 1711 |
%<*makefile> |
| 1712 |
$(COMMON_HIDE)sed -e '/^Package bibtopic Warning: Please (re)run BibTeX on the file(s):$$/,/^(bibtopic) *and after that rerun LaTeX./{s/^(bibtopic) *\([^ ]*\)$$/\1/p};d' \ |
| 1713 |
"$(LU_REC_LOGFILE)" | while read file ; do \ |
| 1714 |
touch $$file.aux ; \ |
| 1715 |
$(call lu-rebuild-needed,"bibtopic: $$file.bbl outdated") \ |
| 1716 |
done |
| 1717 |
|
| 1718 |
LU_rebuild_bibtopic_undefined_references: |
| 1719 |
$(call lu-rebuild-head) |
| 1720 |
$(COMMON_HIDE)if grep -sq 'There were undefined references'\ |
| 1721 |
"$(MASTER_$(LU_REC_MASTER)).log" ; then \ |
| 1722 |
$(call lu-rebuild-needed,"$@: new run needed") \ |
| 1723 |
fi |
| 1724 |
|
| 1725 |
.PHONY: LU_WATCH_FILES_SAVE LU_WATCH_FILES_RESTORE |
| 1726 |
LU_WATCH_FILES_SAVE: |
| 1727 |
$(COMMON_HIDE)$(foreach file, $(sort \ |
| 1728 |
$(call lu-getvalues,WATCHFILES,$(LU_REC_MASTER),$(LU_REC_FLAVOR))), \ |
| 1729 |
$(call lu-save-file,$(file),$(file).orig);) |
| 1730 |
|
| 1731 |
LU_WATCH_FILES_RESTORE: |
| 1732 |
$(COMMON_HIDE)$(foreach file, $(sort \ |
| 1733 |
$(call lu-getvalues,WATCHFILES,$(LU_REC_MASTER),$(LU_REC_FLAVOR))), \ |
| 1734 |
$(call lu-cmprestaure-file,"$(file)","$(file).orig",\ |
| 1735 |
echo "New $(file) file" >> $(LU_REC_GENFILE)_NEED_REBUILD;\ |
| 1736 |
);) |
| 1737 |
|
| 1738 |
endif |
| 1739 |
|
| 1740 |
%<<MAKEFILE |
| 1741 |
%.bbl: %.aux |
| 1742 |
$(COMMON_PREFIX)$(call lu-call-prog,BIBTEX) $* |
| 1743 |
%MAKEFILE |
| 1744 |
|
| 1745 |
_LaTeX_Make_GROUPS=texmfscripts tex |
| 1746 |
_LaTeX_Make_texmfscripts = LaTeX.mk figdepth.py gensubfig.py svg2dev.py svgdepth.py latexfilter.py |
| 1747 |
_LaTeX_Make_texmfscripts_DIR = scripts/latex-make |
| 1748 |
_LaTeX_Make_tex = figlatex.sty pdfswitch.sty texdepends.sty texgraphicx.sty |
| 1749 |
_LaTeX_Make_tex_DIR = tex/latex/latex-make |
| 1750 |
|
| 1751 |
.PHONY: LaTeX-Make-local-install LaTeX-Make-local-uninstall |
| 1752 |
|
| 1753 |
LaTeX-Make-local-uninstall:: |
| 1754 |
$(if $(TEXMF_INSTALL_ROOT_DIR),,\ |
| 1755 |
$(error TEXMF_INSTALL_ROOT_DIR must be set when calling LaTeX-Make-local-uninstall)) |
| 1756 |
$(foreach g,$(_LaTeX_Make_GROUPS),\ |
| 1757 |
$(foreach f,$(_LaTeX_Make_$(g)), \ |
| 1758 |
$(LU_RM) $(TEXMF_INSTALL_ROOT_DIR)/$(_LaTeX_Make_$(g)_DIR)/$f && \ |
| 1759 |
) (rmdir $(TEXMF_INSTALL_ROOT_DIR)/$(_LaTeX_Make_$(g)_DIR) || true) && \ |
| 1760 |
) $(LU_RM) LaTeX.mk |
| 1761 |
|
| 1762 |
LU_INSTALL_PKSEWHICH?=env -u TEXMFHOME kpsewhich |
| 1763 |
LaTeX-Make-local-install:: |
| 1764 |
$(if $(TEXMF_INSTALL_ROOT_DIR),,\ |
| 1765 |
$(error TEXMF_INSTALL_ROOT_DIR must be set when calling LaTeX-Make-local-install)) |
| 1766 |
$(if $(filter texmf,$(notdir $(TEXMF_INSTALL_ROOT_DIR))),,\ |
| 1767 |
$(if $(FORCE),,\ |
| 1768 |
$(warning TEXMF_INSTALL_ROOT_DIR does not end with 'texmf')\ |
| 1769 |
$(error Use FORCE=1 if you really want to use this value of TEXMF_INSTALL_ROOT_DIR))) |
| 1770 |
$(foreach g,$(_LaTeX_Make_GROUPS),\ |
| 1771 |
mkdir -p $(TEXMF_INSTALL_ROOT_DIR)/$(_LaTeX_Make_$(g)_DIR) && \ |
| 1772 |
$(foreach f,$(_LaTeX_Make_$(g)), \ |
| 1773 |
$(LU_CP) -v $$($(LU_INSTALL_PKSEWHICH) -format $g $f) $(TEXMF_INSTALL_ROOT_DIR)/$(_LaTeX_Make_$(g)_DIR) && \ |
| 1774 |
)) echo "Installation into $(TEXMF_INSTALL_ROOT_DIR) done." |
| 1775 |
@echo "==> You must ensure your TEXMFHOME contains this path <==" |
| 1776 |
|
| 1777 |
%</makefile> |
| 1778 |
% \end{macrocode} |
| 1779 |
% \subsection{figdepth} |
| 1780 |
% |
| 1781 |
% \begin{macrocode} |
| 1782 |
%<*figdepth> |
| 1783 |
#!/usr/bin/env python3 |
| 1784 |
#coding=utf8 |
| 1785 |
|
| 1786 |
""" |
| 1787 |
|
| 1788 |
stdin : the original xfig file |
| 1789 |
stdout : the output xfig file |
| 1790 |
args : all depths we want to keep |
| 1791 |
|
| 1792 |
""" |
| 1793 |
|
| 1794 |
from __future__ import print_function |
| 1795 |
import optparse |
| 1796 |
import os.path |
| 1797 |
import sys |
| 1798 |
|
| 1799 |
def main(): |
| 1800 |
parser = optparse.OptionParser() |
| 1801 |
(options, args) = parser.parse_args() |
| 1802 |
|
| 1803 |
depths_to_keep = set() |
| 1804 |
for arg in args: |
| 1805 |
depths_to_keep.add(arg) |
| 1806 |
|
| 1807 |
comment = '' |
| 1808 |
display = True |
| 1809 |
def show(depth, line): |
| 1810 |
if depth in depths_to_keep: |
| 1811 |
print(comment+line, end='') |
| 1812 |
return True |
| 1813 |
else: |
| 1814 |
return False |
| 1815 |
for line in sys.stdin: |
| 1816 |
if line[0] == '#': |
| 1817 |
comment += line |
| 1818 |
continue |
| 1819 |
if line[0] in "\t ": |
| 1820 |
if display: |
| 1821 |
print(line, end='') |
| 1822 |
else: |
| 1823 |
Fld = line.split(' ', 9999) |
| 1824 |
if not Fld[0] or Fld[0] not in ('1', '2', '3', '4', '5'): |
| 1825 |
print(comment+line, end='') |
| 1826 |
display = True |
| 1827 |
elif Fld[0] == '4': |
| 1828 |
display = show(Fld[3], line) |
| 1829 |
else: |
| 1830 |
display = show(Fld[6], line) |
| 1831 |
comment = '' |
| 1832 |
|
| 1833 |
if __name__ == "__main__": |
| 1834 |
main() |
| 1835 |
%</figdepth> |
| 1836 |
% \end{macrocode} |
| 1837 |
% \subsection{gensubfig} |
| 1838 |
% \begin{macrocode} |
| 1839 |
%<*gensubfig> |
| 1840 |
#!/usr/bin/env python3 |
| 1841 |
#coding=utf8 |
| 1842 |
|
| 1843 |
""" |
| 1844 |
|
| 1845 |
Arguments passes : |
| 1846 |
- fichier image (image.fig ou image.svg) |
| 1847 |
- -s fichier subfig (image.subfig) |
| 1848 |
- -p chemin du script pour generer les sous-images (svgdepth.py ou figdepth.py) |
| 1849 |
|
| 1850 |
Sortie standard : |
| 1851 |
- makefile pour creer les sous-images (au format .fig ou .svg), et pour les supprimer |
| 1852 |
|
| 1853 |
""" |
| 1854 |
|
| 1855 |
from __future__ import print_function |
| 1856 |
from optparse import OptionParser |
| 1857 |
import os.path |
| 1858 |
|
| 1859 |
def main(): |
| 1860 |
parser = OptionParser(usage='usage: %prog [options] svg file', description='Creates a\ |
| 1861 |
Makefile generating subfigures using figdepth.py or svgdepth.py') |
| 1862 |
parser.add_option("-s", "--subfig", dest="subfig", help="subfig file") |
| 1863 |
parser.add_option("-p", "--depth", dest="depth", help="full path of depth script") |
| 1864 |
(options, args) = parser.parse_args() |
| 1865 |
if len(args) < 1: |
| 1866 |
parser.error("incorrect number of arguments") |
| 1867 |
if not options.subfig: |
| 1868 |
parser.error("no subfig file specified") |
| 1869 |
if not options.depth: |
| 1870 |
parser.error("no depth script specified") |
| 1871 |
|
| 1872 |
(root, ext) = os.path.splitext(args[0]) |
| 1873 |
sf_name = options.subfig |
| 1874 |
ds_name = options.depth |
| 1875 |
varname = '%s_FIGS' % root.upper() |
| 1876 |
|
| 1877 |
subfigs = [] |
| 1878 |
for line in open(options.subfig, 'r'): |
| 1879 |
t = line.find('#') # looking for comments |
| 1880 |
if t > -1: line = line[0:t] # remove comments... |
| 1881 |
line = line.strip() #remove blank chars |
| 1882 |
if line == '': continue |
| 1883 |
subfigs.append(line) |
| 1884 |
|
| 1885 |
count = 1 |
| 1886 |
for subfig in subfigs: |
| 1887 |
print("%s_%d%s: %s%s %s" % (root, count, ext, root, ext, sf_name)) |
| 1888 |
print("\t%s %s" % (ds_name, subfig)) |
| 1889 |
print("") |
| 1890 |
count += 1 |
| 1891 |
print("%s := $(foreach n, " % varname, end='') |
| 1892 |
count = 1 |
| 1893 |
for subfig in subfigs: |
| 1894 |
print('%d ' % count, end='') |
| 1895 |
count += 1 |
| 1896 |
print(", %s_$(n)%s)" % (root, ext)) |
| 1897 |
print("FILES_TO_DISTCLEAN += $(%s)" % varname) |
| 1898 |
print("FIGS2CREATE_LIST += $(%s)" % varname) |
| 1899 |
print("$(TEMPORAIRE): $(%s)" % varname) |
| 1900 |
|
| 1901 |
if __name__ == "__main__": |
| 1902 |
main() |
| 1903 |
%</gensubfig> |
| 1904 |
% \end{macrocode} |
| 1905 |
% \subsection{svg2dev} |
| 1906 |
% \begin{macrocode} |
| 1907 |
%<*svg2dev> |
| 1908 |
#!/usr/bin/env python3 |
| 1909 |
#coding=utf8 |
| 1910 |
|
| 1911 |
from optparse import OptionParser |
| 1912 |
import shutil |
| 1913 |
import os |
| 1914 |
import subprocess |
| 1915 |
|
| 1916 |
svg2eps = 'inkscape %s -C --export-filename=%s.eps --export-type=eps --export-latex' |
| 1917 |
svg2pdf = 'inkscape %s -C --export-filename=%s.pdf --export-type=pdf --export-latex' |
| 1918 |
|
| 1919 |
def create_image(input_filename, output_filename, mode, ext): |
| 1920 |
subprocess.Popen(mode % (input_filename, output_filename), |
| 1921 |
stdout=subprocess.PIPE, shell=True).communicate()[0] |
| 1922 |
|
| 1923 |
o_ext = output_filename + '.' + ext |
| 1924 |
o = output_filename |
| 1925 |
o_ext_tex = output_filename + '.' + ext + '_tex' |
| 1926 |
o_t = output_filename + '_t' |
| 1927 |
|
| 1928 |
shutil.move(o_ext, o) |
| 1929 |
|
| 1930 |
fin = open(o_ext_tex, 'r') |
| 1931 |
fout = open(o_t, 'w') |
| 1932 |
|
| 1933 |
#\includegraphics[width=\unitlength,page=1]{logo.pdftex} |
| 1934 |
for line in fin: |
| 1935 |
# FIXME: be more conservative in the replacement |
| 1936 |
# (in case '{'+o_ext+'}' appeares somewhere else) |
| 1937 |
out = line.replace('{'+os.path.basename(o_ext)+'}', '{'+os.path.basename(o)+'}') |
| 1938 |
fout.write(out) |
| 1939 |
|
| 1940 |
fin.close() |
| 1941 |
fout.close() |
| 1942 |
os.remove(o_ext_tex) |
| 1943 |
|
| 1944 |
def main(): |
| 1945 |
parser = OptionParser() |
| 1946 |
parser.add_option("-L", "--format", dest="outputFormat", |
| 1947 |
metavar="FORMAT", help="output format", default="spstex") |
| 1948 |
parser.add_option("-p", "--portrait", dest="portrait", help="dummy arg") |
| 1949 |
(options, args) = parser.parse_args() |
| 1950 |
if len(args) != 2: return |
| 1951 |
(input_filename, output_filename) = args |
| 1952 |
fmt = options.outputFormat |
| 1953 |
portrait = options.portrait |
| 1954 |
|
| 1955 |
if fmt == 'eps': |
| 1956 |
create_image(input_filename, output_filename, svg2eps, 'eps') |
| 1957 |
elif fmt == 'spstex' or fmt == 'pstex': |
| 1958 |
create_image(input_filename, output_filename, svg2eps, 'eps') |
| 1959 |
elif fmt == 'spstex_t' or fmt == 'pstex_t': |
| 1960 |
pass |
| 1961 |
elif fmt == 'spdftex' or fmt == 'pdftex': |
| 1962 |
create_image(input_filename, output_filename, svg2pdf, 'pdf') |
| 1963 |
elif fmt == 'spdftex_t' or fmt == 'pdftex_t': |
| 1964 |
pass |
| 1965 |
|
| 1966 |
if __name__ == "__main__": |
| 1967 |
main() |
| 1968 |
|
| 1969 |
%</svg2dev> |
| 1970 |
% \end{macrocode} |
| 1971 |
% \subsection{latexfilter} |
| 1972 |
% |latexfilter.py| is a small python program that hides most of the output |
| 1973 |
% of \TeX/\LaTeX{} output. It only display info, warnings, errors |
| 1974 |
% and underfull/overfull hbox/vbox. |
| 1975 |
% \begin{macrocode} |
| 1976 |
%<*latexfilter> |
| 1977 |
#!/usr/bin/env python3 |
| 1978 |
#coding=utf8 |
| 1979 |
|
| 1980 |
""" |
| 1981 |
|
| 1982 |
stdin : the original LaTeX log file |
| 1983 |
stdout : the output filtered log file |
| 1984 |
|
| 1985 |
""" |
| 1986 |
|
| 1987 |
from __future__ import print_function |
| 1988 |
import optparse |
| 1989 |
import os.path |
| 1990 |
import re |
| 1991 |
import sys |
| 1992 |
import io |
| 1993 |
|
| 1994 |
def main(): |
| 1995 |
parser = optparse.OptionParser() |
| 1996 |
(options, args) = parser.parse_args() |
| 1997 |
|
| 1998 |
display = 0 |
| 1999 |
in_display = 0 |
| 2000 |
start_line = '' |
| 2001 |
warnerror_re = re.compile(r"^(LaTeX|Package|Class)( (.*))? (Warning:|Error:)") |
| 2002 |
fullbox_re = re.compile(r"^(Underfull|Overfull) \\[hv]box") |
| 2003 |
accu = '' |
| 2004 |
# PDFLaTeX log file is not really in latin-1 (in T1 more exactly) |
| 2005 |
# but all bytes are corrects in latin-1, so python won't stop |
| 2006 |
# while parsing log. |
| 2007 |
# Without specifying this encoding (ie using default utf-8), we |
| 2008 |
# can get decode errors (UnicodeDecodeError: 'utf-8' codec can't decode byte...) |
| 2009 |
with io.open(sys.stdin.fileno(),'r',encoding='latin-1') as sin: |
| 2010 |
for line in sin: |
| 2011 |
if display > 0: |
| 2012 |
display -= 1 |
| 2013 |
if line[0:4].lower() in ('info', 'warn') or line[0:5].lower() == 'error': |
| 2014 |
display = 0 |
| 2015 |
line_groups = warnerror_re.match(line) |
| 2016 |
if line_groups: |
| 2017 |
start_line = line_groups.group(3) |
| 2018 |
if not start_line: |
| 2019 |
start_line = '' |
| 2020 |
if line_groups.group(2): |
| 2021 |
start_line = "(" + start_line + ")" |
| 2022 |
display = 1 |
| 2023 |
in_display = 1 |
| 2024 |
elif (start_line != '') and (line[0:len(start_line)] == start_line): |
| 2025 |
display = 1 |
| 2026 |
elif line == "\n": |
| 2027 |
in_display = 0 |
| 2028 |
elif line[0:4] == 'Chap': |
| 2029 |
display = 1 |
| 2030 |
elif fullbox_re.match(line): |
| 2031 |
display = 2 |
| 2032 |
if display: |
| 2033 |
print(accu, end="") |
| 2034 |
accu = line |
| 2035 |
elif in_display: |
| 2036 |
print(accu[0:-1], end="") |
| 2037 |
accu = line |
| 2038 |
|
| 2039 |
if __name__ == "__main__": |
| 2040 |
main() |
| 2041 |
|
| 2042 |
%</latexfilter> |
| 2043 |
% \end{macrocode} |
| 2044 |
% \subsection{svgdepth} |
| 2045 |
% \begin{macrocode} |
| 2046 |
%<*svgdepth> |
| 2047 |
#!/usr/bin/env python3 |
| 2048 |
#coding=utf8 |
| 2049 |
|
| 2050 |
import sys |
| 2051 |
import xml.parsers.expat |
| 2052 |
|
| 2053 |
|
| 2054 |
layers = [] |
| 2055 |
for arg in sys.argv: |
| 2056 |
layers.append(arg) |
| 2057 |
|
| 2058 |
parser = xml.parsers.expat.ParserCreate() |
| 2059 |
class XmlParser(object): |
| 2060 |
def __init__(self, layers): |
| 2061 |
self.state_stack = [True] |
| 2062 |
self.last_state = True |
| 2063 |
self.layers = layers |
| 2064 |
def XmlDeclHandler(self, version, encoding, standalone): |
| 2065 |
sys.stdout.write("<?xml version='%s' encoding='%s'?>\n" % (version, encoding)) |
| 2066 |
def StartDoctypeDeclHandler(self, doctypeName, systemId, publicId, has_internal_subset): |
| 2067 |
if publicId != None: sys.stdout.write("<!DOCTYPE %s PUBLIC \"%s\" \"%s\">\n" %\ |
| 2068 |
(doctypeName, publicId, systemId)) |
| 2069 |
else: sys.stdout.write("<!DOCTYPE %s \"%s\">\n" % (doctypeName, systemId)) |
| 2070 |
def StartElementHandler(self, name, attributes): |
| 2071 |
if name.lower() == 'g': |
| 2072 |
r = self.last_state and ('id' not in attributes or \ |
| 2073 |
attributes['id'] in self.layers) |
| 2074 |
self.last_state = r |
| 2075 |
self.state_stack.append(r) |
| 2076 |
if not self.last_state: return |
| 2077 |
s = "" |
| 2078 |
for k, v in attributes.items(): s += ' %s="%s"' % (k, v) |
| 2079 |
sys.stdout.write("<%s%s>" % (name, s)) |
| 2080 |
def EndElementHandler(self, name): |
| 2081 |
r = self.last_state |
| 2082 |
if name.lower() == 'g': |
| 2083 |
self.state_stack = self.state_stack[0:-1] |
| 2084 |
self.last_state = self.state_stack[-1] |
| 2085 |
if not r: return |
| 2086 |
sys.stdout.write("</%s>" % (name)) |
| 2087 |
def CharacterDataHandler(self, data): |
| 2088 |
if not self.last_state: return |
| 2089 |
sys.stdout.write(data) |
| 2090 |
|
| 2091 |
my_parser = XmlParser(layers) |
| 2092 |
|
| 2093 |
parser.XmlDeclHandler = my_parser.XmlDeclHandler |
| 2094 |
parser.StartDoctypeDeclHandler = my_parser.StartDoctypeDeclHandler |
| 2095 |
parser.StartElementHandler = my_parser.StartElementHandler |
| 2096 |
parser.EndElementHandler = my_parser.EndElementHandler |
| 2097 |
parser.CharacterDataHandler = my_parser.CharacterDataHandler |
| 2098 |
|
| 2099 |
for line in sys.stdin: |
| 2100 |
parser.Parse(line, False) |
| 2101 |
parser.Parse('', True) |
| 2102 |
|
| 2103 |
|
| 2104 |
%</svgdepth> |
| 2105 |
% \end{macrocode} |
| 2106 |
% \Finale |
| 2107 |
\endinput |