]> git.lyx.org Git - lyx.git/blob - lib/chkconfig.ltx
less fingerpainting involved now. and no warnings...
[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/documentclasses 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   @chk_<name>@
25 %%%    This line will be replaced at configure time by the proper text.
26 %%%
27 %%% For document classes, things are even simpler, since you do not
28 %%% need to edit this file. Just put your layout file in some place
29 %%% where LyX can find it and add if you wish a description in
30 %%% LaTeXConfig.lyx, as described above.
31
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
33 %%%%%%%%%%%%%%%%%%%%%%% Initialization part (skip) %%%%%%%%%%%%%%%%%%%%%
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35
36 % we do not want to stop on errors
37 \nonstopmode\makeatletter
38
39 %%% Some useful macros.
40 %   Several commands are defined to test for packages:
41 %    \AddLayout{<layout>} adds an entry for <layout> in textclass.lst
42 %    \AddVariable{<name>}{<value>} creates a new variable chk_<name>,
43 %      and gives it the value <value>.
44 %    \TestDocClass{<name>}{<command>} if layout <name> has not already
45 %      been tested for, execute <command>. Note that you will
46 %      probably not need to use this directly, since the configure
47 %      script generates the needed macro calls automatically.
48 %    \TestPackage[<file>]{<name>} tests whether <name>.sty (or <file>,
49 %      if it is provided) exists.
50 %   Both commands call \AddVariable to give value 'yes' or 'no' to
51 %   the variable chk_<name>.
52 %%%
53
54 \newcommand{\prefix}{+} % the character used by grep to filter 'good' output
55
56 \newcommand{\AddLayout}[4][\default]{
57   \def\default{#2}
58   \immediate\write\layouts{"#2"   "#1"   "#3"   "#4"}}
59
60 \newcommand{\AddVariable}[2]{
61   \immediate\write\vars{chk_#1='#2'}}
62
63 \newcommand{\AddPackage}[1]{
64   \immediate\write\packages{#1}}
65
66 % Tests whether an item is present
67 % Syntax: \TestItem{<file>}{<name>}{<type>}{<ext>}{<iftrue>}{<iffalse>}
68 \newif\ifexists
69
70 \newcommand{\TestItem}[6][\default]{
71   \def\default{#2}
72   \def\files{#1}
73   \message{^^J\prefix checking for #3 #2 [#1]...}
74   \let\firstelement\relax
75   \existstrue
76   \@for\file:=\files\do{
77     \ifx\firstelement\relax
78        \edef\firstelement{\file}
79     \fi
80     \IfFileExists{\file}
81       {}
82       {\IfFileExists{\file.#4}{}{\existsfalse}}
83   }
84   \ifexists
85     \message{yes^^J}
86     \AddVariable{#2}{yes}
87     #5
88   \else
89     \message{no^^J}
90     \AddVariable{#2}{no}
91     #6
92   \fi}
93
94 \newcommand{\TestPackage}[2][\default]{
95   \TestItem[#1]{#2}{package}{sty}{\AddPackage{#2}}{}}
96
97 \newcommand{\TestDocClass}[2]{
98    \def\layoutname{#1}  % remember the name of the layout file
99    \@ifundefined{layout@#1}
100      {#2  % execute the command
101       \global\@namedef{layout@#1}{}}
102      {} % we have already tried this one.
103 }
104
105 \newcommand{\DeclareLaTeXClass}[2][\default]{
106   \TestItem[#1]{\layoutname}{document class}{cls}
107            {\AddLayout[\firstelement]{\layoutname}{#2}{true}}
108            {\AddLayout[\firstelement]{\layoutname}{#2}{false}}
109 }
110
111 % Only for compatibility. Will be removed later.
112 \let\DeclareSGMLClass=\DeclareDocBookClass
113
114 \newcommand{\DeclareDocBookClass}[2][\default]{
115   \message{^^J\prefix checking for docbook\space\space class \layoutname... }
116   \@ifundefined{hasdocbook}
117     {\message{no^^J}
118      \AddLayout[#1]{\layoutname}{#2}{false}}
119     {\message{yes^^J}
120      \AddLayout[#1]{\layoutname}{#2}{true}}
121 }
122
123 % Stolen from article.cls
124 \newcommand{\today}{\ifcase\month\or
125   January\or February\or March\or April\or May\or June\or
126   July\or August\or September\or October\or November\or December\fi
127   \space\number\day, \number\year}
128
129 % Initializes the files
130 \typeout{\prefix Inspecting your LaTeX configuration.}
131 \newwrite{\layouts} \immediate\openout \layouts = textclass.lst.tmp
132 \newwrite{\vars} \immediate\openout \vars = chkconfig.vars
133 \newwrite{\packages} \immediate\openout \packages = packages.lst.tmp
134
135 \immediate\write\layouts{%
136 # This file declares layouts and their associated definition files.^^J%
137 # It has been automatically generated by configure^^J%
138 # Use "Options/Reconfigure" if you need to update it after a^^J%
139 # configuration change. Run ./configure manually to update the^^J%
140 # system wide version of this file.}
141
142 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
143 %%%%% ACTUAL CONFIGURATION INSPECTION CODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
144 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
145
146 %%% Add any new package or document class here.
147
148 %%% First, we want the day on which the test has been run.
149 \AddVariable{date}{\today}
150
151 %%% Then, the version of LaTeX we are using
152 \message{^^J\prefix checking for LaTeX version... \fmtversion}
153 \AddVariable{fmtversion}{\fmtversion}
154
155 %%% And now, the list of available languages
156 % The trick is to know that \the\everyjob contains something like
157 %  \typeout{LaTeX2e <2001/06/01>}
158 %  \typeout{Babel <v3.7h> and hyphenation patterns for american, french, german, ngerman, nohyphenation, loaded.}
159 % All we have to do is to extract the list from there:
160 % (1) concatenate all the messages that are displayed everytime the
161 % format is loaded. The is done by redefining locally \typeout to
162 % append its argument to the macro \mesg.
163 \def\mesg{}
164 {\def\typeout#1{\xdef\mesg{\mesg #1}}
165  \the\everyjob}
166
167 % (2) strip the useless parts from \mesg. This uses the fact that TeX
168 % allows to define macros with parameters delimited by arbitrary text.
169 \def\platexname{pLaTeX2e}
170 \ifx\pfmtname\platexname
171   \def\langs{japanese}
172 \else
173   \def\strip#1patterns for #2, loaded.#3\endmark{\def\langs{#2}}
174   \expandafter\strip\mesg\endmark
175 \fi
176
177 % (3) handle the result
178 \message{^^J\prefix checking for available hyphenation patterns... \langs}
179 \AddVariable{languages}{\langs}
180
181 %%% Check for ec fonts. Most of this code has been shamelessely stolen
182 %%% from the file ltxcheck.tex in the LaTeX distribution. In particular,
183 %%% don't ask me how the macro \ecrm works...
184 \def\ecrm{%
185   \begingroup
186     \escapechar-1
187     \xdef\reserved@a{%
188       \noexpand\in@
189         {\expandafter\string\csname ecrm\endcsname}%
190         {\expandafter\expandafter\expandafter
191            \string\csname T1/cmr/m/n\endcsname}}%
192   \endgroup
193   \reserved@a}
194
195 \message{^^J\prefix checking for default encoding (this may take a long time)^^J}
196 \font\test=ecrm1000\relax
197
198 \ifx\test\nullfont
199   \message{^^J\prefix\prefix checking for ec fonts... no^^J}
200   \AddVariable{ec}{no}
201   \AddVariable{fontenc}{default}
202 \else
203   \message{^^J\prefix\space\space checking for ec fonts... yes^^J}
204   \message{^^J\prefix\space\space checking for ec support in LaTeX format...}
205   \ecrm
206   \ifin@
207     \message{yes^^J}
208     \AddVariable{ec}{yes}
209     \AddVariable{fontenc}{T1}
210     \message{^^J \prefix\space\space default encoding will be set to T1^^J}
211   \else
212     \message{no^^J}
213     \AddVariable{ec}{no}
214     \AddVariable{fontenc}{default}
215   \fi
216 \fi
217
218
219 %%% Document classes
220 % The list of layout files has been put in this file here by the
221 % configure script.
222 \input{chklayouts}
223
224
225 %%% Packages
226 \TestPackage{algorithm}
227 \TestPackage{array}
228 \TestPackage{babel}
229 \TestPackage{bibtopic}
230 \TestPackage{bm}
231 \TestPackage{booktabs}
232 \TestPackage{braille}
233 \TestPackage{color} % this one should be there if graphics.sty is there.
234 \TestPackage{covington}
235 \TestPackage{csquotes}
236 \TestPackage{dvipost}
237 \TestPackage{endnotes}
238 \TestPackage{enumitem}
239 \TestPackage{esint}
240 \TestPackage{ifthen}
241 \TestPackage{fancybox}
242 \TestPackage{fancyhdr}
243 \TestPackage{framed}
244 \TestPackage{geometry}
245 \TestPackage{hyperref}
246 \TestPackage{jurabib}
247 \TestPackage{latex8}
248 \TestPackage{listings}
249 \TestPackage{longtable}
250 \TestPackage{natbib}
251 \TestPackage{nicefrac}
252 \TestPackage{nomencl}
253 \TestPackage{pdfcolmk}
254 \TestPackage{pdfpages}
255 \TestPackage{prettyref}
256 \TestPackage{preview}
257 \TestPackage{relsize}
258 \TestPackage{rotating}
259 \TestPackage{rotfloat}
260 \TestPackage{setspace}
261 \TestPackage{soul}
262 \TestPackage{subfig}
263 \TestPackage{textcomp}
264 \TestPackage{units}
265 \TestPackage{url}
266 \TestPackage{varioref}
267 \TestPackage{wrapfig}
268 \TestPackage{xargs}
269 \TestPackage{xcolor}
270
271
272 % The test for the graphics package is slightly more involved...
273 \newcommand\groption{dvips}
274 \TestItem{graphicx}{package}{sty}
275
276 %  Let's do some clever things to guess the default driver for the
277 %  graphicx package. The maintainer of the site might have declared it
278 %  in the file 'graphics.cfg'. Let's hope there are no strange commands
279 %  in there...
280   {\renewcommand\ExecuteOptions[1]{\renewcommand\groption{default}}
281    \InputIfFileExists{graphics.cfg}{}{}
282    \AddPackage{graphicx}}
283   {\renewcommand{\groption}{none}}
284
285 \message{^^J\prefix checking for graphics driver... \groption^^J}
286 \AddVariable{graphicsdriver}{\groption}
287
288 % psnfss is in fact the name of a set of style files, among which
289 % times.sty. If times.sty is here, we will assume that everything is
290 % fine.
291 \TestPackage[times.sty]{psnfss}
292 % not sure if these are in all versions of psnfss
293 \TestPackage{avant}
294 \TestPackage{bookman}
295 \TestPackage{chancery}
296 \TestPackage{charter}
297 \TestPackage{mathpazo}
298 \TestPackage{mathpple}
299 \TestPackage{mathptm}
300 \TestPackage{mathptmx}
301 \TestPackage{newcent}
302 \TestPackage{utopia}
303 % Other font packages
304 \TestPackage{ae}
305 \TestPackage{bera}
306 \TestPackage{ccfonts}
307 \TestPackage{cmbright}
308 \TestPackage{eco}
309 \TestPackage{fourier}
310 \TestPackage{lmodern}
311 \TestPackage{luximono}
312 \TestPackage{tipa}
313
314
315 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
316 %%%%% END ACTUAL CONFIGURATION INSPECTION CODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%
317 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
318
319 % End of the LaTeX job
320 \immediate\closeout\layouts
321 \immediate\closeout\vars
322 \immediate\closeout\packages
323 \typeout{\prefix Inspection done.}
324 \typeout{\prefix Read the file doc/LaTeXConfig.lyx for more information.}
325
326 % Get the real \end command, that has been hidden by LaTeX
327 \@@end