]> git.lyx.org Git - lyx.git/blob - lib/chkconfig.ltx
3af74b9df1ef5fea0757f71225925bef8e35571b
[lyx.git] / lib / chkconfig.ltx
1 % This is chkconfig.ltx, a script which tries to autodetect and
2 %    document your LaTeX configuration.
3 % Author: Jean-Marc Lasgouttes (Jean-Marc.Lasgouttes@inria.fr)
4 % with minimal changes by Asger Alstrup (alstrup@diku.dk).
5 %
6 % This script should only be run from the configure script to update
7 % the files textclass.lst and doc/LaTeXConfig.lyx
8 %
9 % This script is in fact a complete rewrite of the original chkconfig
10 % script. Expect bugs.
11
12 %%% If you want to add new packages/document classes to be recognized,
13 %%% read the explanation that follow and jump to the section 'Actual
14 %%% inspection code' below. You do not need to understand the ugly
15 %%% LaTeX code below to help improving chkconfig.ltx :-)
16 %%%
17 %%% If you want to add the new package <name>, all you need most of
18 %%% the times is a two-steps work:
19 %%% 1- Add the command \TestPackage{<name>}. The syntax is:
20 %%%    \TestPackage[<file>]{<name>}, which  tests whether <name>.sty
21 %%%    (or <file>, if this optional parameter is provided) exists.
22 %%% 2- Add a description for <name> in doc/LaTeXConfig.lyx,
23 %%%    containing in particular a line like
24 %%%         Found: [InsetInfo]
25 %%%    where [InsetInfo] is obtained by entering in the minibuffer (Alt+X)
26 %%%    info-insert package <name>
27 %%%    This inset will automatically display a boxed "yes" or "no"
28 %%%    depending on the availability of the package.
29 %%%
30 %%% Since \TestPackage does not find font metric (tfm) files, there's an
31 %%% additional test \TestFont[<file>]{<name>} for this purpose.
32 %%%
33 %%% For document classes, things are even simpler, since you do not
34 %%% need to edit this file. Just put your layout file in some place
35 %%% where LyX can find it and add if you wish a description in
36 %%% LaTeXConfig.lyx, as described above but using
37 %%% "info-insert textclass <name>" instead of "info-insert package <name>".
38
39 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
40 %%%%%%%%%%%%%%%%%%%%%%% Initialization part (skip) %%%%%%%%%%%%%%%%%%%%%
41 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42
43 % we do not want to stop on errors
44 \nonstopmode\makeatletter
45
46 %%% Some useful macros.
47 %   Several commands are defined to test for packages:
48 %    \AddLayout{<layout>} adds an entry for <layout> in textclass.lst
49 %    \AddVariable{<name>}{<value>} creates a new variable chk_<name>,
50 %      and gives it the value <value>.
51 %    \TestDocClass{<name>}{<command>} if layout <name> has not already
52 %      been tested for, execute <command>. Note that you will
53 %      probably not need to use this directly, since the configure
54 %      script generates the needed macro calls automatically.
55 %    \TestPackage[<file>]{<name>} tests whether <name>.sty (or <file>,
56 %      if it is provided) exists.
57 %    \TestFont[<file>]{<name>} test whether <name>.tfm (or <file>.tfm,
58 %      if provided) exists.
59 %   These three commands call \AddVariable to give value 'yes' or 'no' to
60 %   the variable chk_<name>.
61 %%%
62
63 \newcommand{\prefix}{+} % the character used by grep to filter 'good' output
64
65 \newcommand{\AddLayout}[5][\default]{
66   \def\default{#2}
67   \immediate\write\layouts{"#2"   "#1"   "#3"   "#4"   "#5"}}
68
69 \newcommand{\AddVariable}[2]{
70   \immediate\write\vars{chk_#1='#2'}}
71
72 \newcommand{\AddPackage}[1]{
73   \immediate\write\packages{#1}}
74
75 % Tests whether an item is present
76 % Syntax: \TestItem[<file>]{<name>}{<type>}{<ext>}{<iftrue>}{<iffalse>}
77 \newif\ifexists
78
79 \newcommand{\TestItem}[6][\default]{
80   \def\default{#2}
81   \def\files{#1}
82   \message{^^J\prefix checking for #3 #2 [#1]...}
83   \let\firstelement\relax
84   \let\missingelements\empty
85   \existstrue
86   \@for\file:=\files\do{
87     \ifx\firstelement\relax
88        \edef\firstelement{\file}
89     \fi
90     \@expandtwoargs\in@{.}{\file}
91     \ifin@
92       \def\myfile{\file}
93     \else
94       \def\myfile{\file.#4}
95     \fi
96     \IfFileExists{\myfile}
97       {}
98       {
99         \existsfalse
100         \ifx\missingelements\empty
101           \edef\missingelements{\myfile}
102         \else
103           \edef\missingelements{\missingelements,\myfile}
104         \fi
105       }
106   }
107   \ifexists
108     \message{yes^^J}
109     \AddVariable{#2}{yes}
110     #5
111   \else
112     \message{no^^J}
113     \AddVariable{#2}{no}
114     #6
115   \fi}
116
117 % Adapted from ltxcheck.tex
118 \newcommand{\TestFont}[2][\default]{
119   \def\default{#2}
120   \batchmode
121   \font\test=#1\relax
122   \nonstopmode
123   \message{^^J\prefix checking for font #2 [#1]...}
124   \ifx\test\nullfont
125     \message{no^^J}
126     \AddVariable{#2}{no}
127     \@tempswatrue
128   \else
129     \message{yes^^J}
130     \AddVariable{#2}{yes}
131     \AddPackage{#2}
132   \fi}
133
134 \newcommand{\TestPackage}[2][\default]{
135   \TestItem[#1]{#2}{package}{sty}{\AddPackage{#2}}{}}
136
137 \newcommand{\TestDocClass}[2]{
138    \def\layoutname{#1}  % remember the name of the layout file
139    \@ifundefined{layout@#1}
140      {#2  % execute the command
141       \global\@namedef{layout@#1}{}}
142      {} % we have already tried this one.
143 }
144
145 \newcommand{\DeclareLaTeXClass}[2][\default]{
146   \TestItem[#1]{\layoutname}{document class}{cls}
147            {\AddLayout[\firstelement]{\layoutname}{#2}{true}{\missingelements}}
148            {\AddLayout[\firstelement]{\layoutname}{#2}{false}{\missingelements}}
149 }
150
151 % Only for compatibility. Will be removed later.
152 \let\DeclareSGMLClass=\DeclareDocBookClass
153
154 \newcommand{\DeclareDocBookClass}[2][\default]{
155   \message{^^J\prefix checking for docbook\space\space class \layoutname... }
156   \@ifundefined{hasdocbook}
157     {\message{no^^J}
158      \AddLayout[#1]{\layoutname}{#2}{false}{docbook}}
159     {\message{yes^^J}
160      \AddLayout[#1]{\layoutname}{#2}{true}{}}
161 }
162
163 % Stolen from article.cls
164 \newcommand{\today}{\ifcase\month\or
165   January\or February\or March\or April\or May\or June\or
166   July\or August\or September\or October\or November\or December\fi
167   \space\number\day, \number\year}
168
169 % Initializes the files
170 \typeout{\prefix Inspecting your LaTeX configuration.}
171 \newwrite{\layouts} \immediate\openout \layouts = textclass.lst.tmp
172 \newwrite{\vars} \immediate\openout \vars = chkconfig.vars
173 \newwrite{\packages} \immediate\openout \packages = packages.lst.tmp
174
175 \immediate\write\layouts{%
176 # This file declares layouts and their associated definition files.^^J%
177 # It has been automatically generated by configure^^J%
178 # Use "Tools/Reconfigure" if you need to update it after a^^J%
179 # configuration change. Run ./configure manually to update the^^J%
180 # system wide version of this file.}
181
182 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
183 %%%%% ACTUAL CONFIGURATION INSPECTION CODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
184 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
185
186 %%% Add any new package or document class here.
187
188 %%% First, we want the day on which the test has been run.
189 \AddVariable{date}{\today}
190
191 %%% Then, the version of LaTeX we are using
192 \message{^^J\prefix checking for LaTeX version... \fmtversion}
193 \AddVariable{fmtversion}{\fmtversion}
194
195 %%% And now, the list of available languages
196 % The trick is to know that \the\everyjob contains something like
197 %  \typeout{LaTeX2e <2001/06/01>}
198 %  \typeout{Babel <v3.7h> and hyphenation patterns for american, french, german, ngerman, nohyphenation, loaded.}
199 % All we have to do is to extract the list from there:
200 % (1) concatenate all the messages that are displayed everytime the
201 % format is loaded. The is done by redefining locally \typeout to
202 % append its argument to the macro \mesg.
203 \def\mesg{}
204 {\def\typeout#1{\xdef\mesg{\mesg #1}}
205  \the\everyjob}
206
207 % (2) strip the useless parts from \mesg. This uses the fact that TeX
208 % allows to define macros with parameters delimited by arbitrary text.
209 \def\platexname{pLaTeX2e}
210 \ifx\pfmtname\platexname
211   \def\langs{japanese}
212 \else
213   \def\strip#1patterns for #2, loaded.#3\endmark{\def\langs{#2}}
214   \expandafter\strip\mesg\endmark
215 \fi
216
217 % (3) handle the result
218 \message{^^J\prefix checking for available hyphenation patterns... \langs}
219 \AddVariable{languages}{\langs}
220
221 %%% Check for ec fonts. Most of this code has been shamelessely stolen
222 %%% from the file ltxcheck.tex in the LaTeX distribution. In particular,
223 %%% don't ask me how the macro \ecrm works...
224 \def\ecrm{%
225   \begingroup
226     \escapechar-1
227     \xdef\reserved@a{%
228       \noexpand\in@
229         {\expandafter\string\csname ecrm\endcsname}%
230         {\expandafter\expandafter\expandafter
231            \string\csname T1/cmr/m/n\endcsname}}%
232   \endgroup
233   \reserved@a}
234
235 \message{^^J\prefix checking for default encoding (this may take a long time)^^J}
236 \font\test=ecrm1000\relax
237
238 \ifx\test\nullfont
239   \message{^^J\prefix\prefix checking for ec fonts... no^^J}
240   \AddVariable{ec}{no}
241   \AddVariable{fontenc}{default}
242 \else
243   \message{^^J\prefix\space\space checking for ec fonts... yes^^J}
244   \message{^^J\prefix\space\space checking for ec support in LaTeX format...}
245   \ecrm
246   \ifin@
247     \message{yes^^J}
248     \AddPackage{ec}
249     \AddVariable{fontenc}{T1}
250     \message{^^J\prefix\space\space default encoding will be set to T1^^J}
251   \else
252     \message{no^^J}
253     \AddVariable{fontenc}{default}
254   \fi
255 \fi
256
257
258 %%% Document classes
259 % The list of layout files has been put in this file here by the
260 % configure script.
261 \input{chklayouts}
262 \input{chkmodules}
263
264
265 %%% Packages
266 \TestPackage{accents}
267 \TestPackage{algorithm}
268 \TestPackage{amstext}
269 \TestPackage[arabic.ldf]{arabi}
270 \TestPackage{array}
271 \TestPackage{babel}
272 \TestPackage{bibtopic}
273 \TestPackage{bidi}
274 \TestPackage{bm}
275 \TestPackage{booktabs}
276 \TestPackage{braille}
277 \TestPackage{breakurl}
278 \TestPackage{CJKutf8}
279 \TestPackage{calc}
280 \TestPackage{cancel}
281 \TestPackage{color} % this one should be there if graphics.sty is there.
282 \TestPackage{covington}
283 \TestPackage{csquotes}
284 \TestPackage{dvipost}
285 \TestPackage{endnotes}
286 \TestPackage{enumitem}
287 \TestPackage{esint}
288 \TestPackage{eso-pic}
289 \TestPackage{fontspec}
290 \TestPackage{hhline}
291 \TestPackage{ifthen}
292 \TestPackage{iftex}
293 \TestPackage{fancybox}
294 \TestPackage{fancyhdr}
295 \TestPackage{fixltx2e}
296 \TestPackage{fix-cm}
297 \TestPackage{float}
298 \TestPackage{framed}
299 \TestPackage{geometry}
300 \TestPackage{graphicx}
301 \TestPackage{hyperref}
302 \TestPackage{hyphenat}
303 \TestPackage[japanese.ldf]{japanese}
304 \TestPackage{jurabib}
305 \TestPackage{latex8}
306 \TestPackage{lettrine}
307 \TestPackage{listings}
308 \TestPackage[lithuanian.ldf]{lithuanian}
309 \TestPackage{longtable}
310 \TestPackage{luainputenc}
311 \TestPackage{mathdots}
312 \TestPackage{mathrsfs}
313 \TestPackage{mathtools}
314 \TestPackage{mhchem}
315 \TestPackage[mongolian.ldf]{mongolian}
316 \TestPackage{multirow}
317 \TestPackage{natbib}
318 \TestPackage{nicefrac}
319 \TestPackage{nomencl}
320 \TestPackage{pdfcolmk}
321 \TestPackage{polyglossia}
322 \TestPackage{pdfpages}
323 \TestPackage{prettyref}
324 \TestPackage{preview}
325 \TestPackage{refstyle}
326 \TestPackage{rotating}
327 \TestPackage{rotfloat}
328 \TestPackage{setspace}
329 \TestPackage{slashed}
330 \TestPackage{soul}
331 \TestPackage{splitidx}
332 \TestPackage{subfig}
333 \TestPackage{Sweave}
334 \TestPackage{textcomp}
335 \TestPackage{subscript}
336 \TestPackage[turkmen.ldf]{turkmen}
337 \TestPackage{ulem}
338 \TestPackage{undertilde}
339 \TestPackage{unicode-math}
340 \TestPackage{units}
341 \TestPackage{url}
342 \TestPackage{varioref}
343 \TestPackage{wasy}
344 \TestPackage{wrapfig}
345 \TestPackage{xargs}
346 \TestPackage{xcolor}
347 \TestPackage{xkeyval}
348
349 % Packages used by LyX's documentation files
350 \TestPackage{arydshln}
351 \TestPackage{braket}
352 \TestPackage{cancel}
353 \TestPackage{colortbl}
354 \TestPackage{eurosym}
355 \TestPackage{marginnote}
356 \TestPackage{picinpar}
357 \TestPackage{sidecap}
358 \TestPackage{was}
359
360 % psnfss is in fact the name of a set of style files, among which
361 % times.sty. If times.sty is here, we will assume that everything is fine.
362 \TestPackage[times.sty]{psnfss}
363 % test the following fonts in case they are not in all versions of psnfss
364 \TestPackage{avant}
365 \TestPackage{bookman}
366 \TestPackage{chancery}
367 \TestPackage{charter}
368 \TestPackage{courier}
369 \TestPackage{helvet}
370 \TestPackage{mathpazo}
371 \TestPackage{mathpple}
372 \TestPackage{mathptm}
373 \TestPackage{mathptmx}
374 \TestPackage{newcent}
375 \TestPackage{pifont}
376 \TestPackage{utopia}
377 % Other font packages
378 \TestPackage{ae}
379 \TestPackage{bera}
380 \TestPackage{biolinum-type1}
381 \TestPackage{ccfonts}
382 \TestPackage{cmbright}
383 \TestPackage{eco}
384 \TestPackage{eulervm}
385 \TestPackage{feyn}
386 \TestPackage{fourier}
387 \TestPackage{libertine}
388 \TestPackage{libertine-type1}
389 \TestPackage{lmodern}
390 \TestPackage{luximono}
391 \TestPackage{mathdesign}% For Roman fonts
392 \TestPackage{mdbch}
393 \TestPackage{mdput}
394 \TestPackage{mdugm}
395 \TestPackage{MinionPro}
396 \TestFont[rzmnr]{minion2newtx}
397 \TestPackage{newtxmath}
398 \TestPackage{tgadventor}
399 \TestPackage{tgbonum}
400 \TestPackage{tgchorus}
401 \TestPackage{tgcursor}
402 \TestPackage{tgheros}
403 \TestPackage{tgpagella}
404 \TestPackage{tgschola}
405 \TestPackage{tgtermes}
406 \TestPackage{tipa}
407 \TestPackage{tipx}
408 \TestPackage{tone}
409 \TestPackage{txfonts}% For the txtt monospaced font
410 % necessary to get correct size for InstantPreview images created by dvipng
411 \TestPackage[c70fs.fd]{zhmetrics}
412 % symbol packakges supported by LyX for items and the special character dialog
413 % see the unicodesymbols file
414 \TestPackage{ascii}
415 \TestPackage{bbding}
416 \TestPackage{ifsym}
417 \TestPackage{marvosym}
418 \TestPackage{pmboxdraw}
419 \TestPackage{textgreek}
420 \TestPackage{wasysym}
421 % These packages are disabled in the unicodesymbols file
422 % see comment there
423 %\TestPackage{txfonts}% But see above!
424 %\TestPackage{pxfonts}
425 %\TestPackage{mathabx}
426 %\TestPackage{mathdesign}% But see above!
427
428
429 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
430 %%%%% END ACTUAL CONFIGURATION INSPECTION CODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%
431 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
432
433 % End of the LaTeX job
434 \immediate\closeout\layouts
435 \immediate\closeout\vars
436 \immediate\closeout\packages
437 \typeout{\prefix Inspection done.}
438 \typeout{\prefix Read the file doc/LaTeXConfig.lyx for more information.}
439
440 % Get the real \end command, that has been hidden by LaTeX
441 \@@end