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).
6 % This script should only be run from the configure script to update
7 % the files textclass.lst and doc/LyXConfig.lyx
9 % This script is in fact a complete rewrite of the original chkconfig
10 % script. Expect bugs.
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 :-)
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/LyXConfig.lyx.in,
23 %%% containing in particular a line like
24 %%% Found @chk_<name>@
25 %%% This line will be replaced at configure time by the proper text.
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 %%% LyXConfig.lyx.in, as described above.
32 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
33 %%%%%%%%%%%%%%%%%%%%%%% Initialization part (skip) %%%%%%%%%%%%%%%%%%%%%
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
36 % we do not want to stop on errors
37 \nonstopmode\makeatletter
38 % Have we been called from the configure script?
41 **** WARNING: For proper results, you should not run this script directly.^^J%
42 **** Please use the `configure' script.^^J}
43 \newcommand\srcdir{.}}
44 {\def\input@path{{\srcdir/}}}
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[<file>]{<name>} tests whether <name>.cls (or <file>,
52 % if it is provided) exists and creates a new entry with
53 % \AddLayout if this is the case. Note that you will probably not
54 % need to use this directly, since the configure script generates
55 % the needed macro calls automatically.
56 % \TestPackage[<file>]{<name>} tests whether <name>.sty (or <file>,
57 % if it is provided) exists.
58 % Both commands call \AddVariable to give value 'yes' or 'no' to
59 % the variable chk_<name>.
61 \newcommand{\prefix}{+} % the character used by grep to filter 'good' output
62 \newcommand{\AddLayout}[4][\default]{
64 \immediate\write\layouts{"#2" "#1" "#3" "#4"}}
65 \newcommand{\AddVariable}[2]{
66 \immediate\write\sed{s!@chk_#1@!#2!g}
67 \immediate\write\vars{chk_#1='#2'}}
68 \newcommand{\AddPackage}[1]{
69 \immediate\write\packages{#1}}
70 % Tests whether an item is present
71 % Syntax: \TestItem{<file>}{<name>}{<type>}{<ext>}{<iftrue>}{<iffalse>}
73 \newcommand{\TestItem}[6][\default]{
76 \message{^^J\prefix checking for #3 #2 [#1]...}
77 \let\firstelement\relax
79 \@for\file:=\files\do{
80 \ifx\firstelement\relax
81 \edef\firstelement{\file}
85 {\IfFileExists{\file.#4}{}{\existsfalse}}
96 \newcommand{\TestPackage}[2][\default]{
97 \TestItem[#1]{#2}{package}{sty}{\AddPackage{#2}}{}}
98 \newcommand{\TestDocClass}[1]{
99 \def\layoutname{#1} % remember the name of the layout file
100 \@ifundefined{layout@#1}
102 \catcode`\#=9 % consider # as a space
103 \input{layouts/#1.layout} % read the layout file
105 \global\@namedef{layout@#1}{}}
106 {} % we have already tried this one.
108 \newcommand{\DeclareLaTeXClass}[2][\default]{
109 \TestItem[#1]{\layoutname}{document class}{cls}
110 {\AddLayout[\firstelement]{\layoutname}{#2}{true}}
111 {\AddLayout[\firstelement]{\layoutname}{#2}{false}}
112 \expandafter\endinput
114 \newcommand{\DeclareLinuxDocClass}[2][\default]{
115 \message{^^J\prefix checking for linuxdoc class \layoutname... }
116 \@ifundefined{haslinuxdoc}
118 \AddLayout[#1]{\layoutname}{#2}{false}}
120 \AddLayout[#1]{\layoutname}{#2}{true}}
121 \expandafter\endinput
123 % Only for compatibility. Will be removed later.
124 \let\DeclareSGMLClass=\DeclareDocBookClass
126 \newcommand{\DeclareDocBookClass}[2][\default]{
127 \message{^^J\prefix checking for docbook\space\space class \layoutname... }
128 \@ifundefined{hasdocbook}
130 \AddLayout[#1]{\layoutname}{#2}{false}}
132 \AddLayout[#1]{\layoutname}{#2}{true}}
133 \expandafter\endinput
136 % Stolen from article.cls
137 \newcommand{\today}{\ifcase\month\or
138 January\or February\or March\or April\or May\or June\or
139 July\or August\or September\or October\or November\or December\fi
140 \space\number\day, \number\year}
142 % Initializes the files
143 \typeout{\prefix Inspecting your LaTeX configuration.}
144 \newwrite{\layouts} \immediate\openout \layouts = textclass.lst
145 \newwrite{\sed} \immediate\openout \sed = chkconfig.sed
146 \newwrite{\vars} \immediate\openout \vars = chkconfig.vars
147 \newwrite{\packages} \immediate\openout \packages = packages.lst
149 \immediate\write\layouts{%
150 # This file declares layouts and their associated definition files.^^J%
151 # It has been automatically generated by configure^^J%
152 # Use "Options/Reconfigure" if you need to update it after a^^J%
153 # configuration change. Run ./configure manually to update the^^J%
154 # system wide version of this file.}
156 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
157 %%%%% ACTUAL CONFIGURATION INSPECTION CODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%
158 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
160 %%% Add any new package or document class here.
162 %%% First, we want the day on which the test has been run.
163 \AddVariable{date}{\today}
165 %%% Then, the version of LaTeX we are using
166 \message{^^J\prefix checking for LaTeX version... \fmtversion}
167 \AddVariable{fmtversion}{\fmtversion}
169 %%% Check for ec fonts. Most of this code has been shamelessely stolen
170 %%% from the file ltxcheck.tex in the LaTeX distribution. In particular,
171 %%% don't ask me how the macro \ecrm works...
177 {\expandafter\string\csname ecrm\endcsname}%
178 {\expandafter\expandafter\expandafter
179 \string\csname T1/cmr/m/n\endcsname}}%
183 \message{^^J\prefix checking for default encoding (this may take a long time)^^J}
184 \font\test=ecrm1000\relax
186 \message{^^J\prefix\prefix checking for ec fonts... no^^J}
188 \AddVariable{fontenc}{default}
190 \message{^^J\prefix\space\space checking for ec fonts... yes^^J}
191 \message{^^J\prefix\space\space checking for ec support in LaTeX format...}
195 \AddVariable{ec}{yes}
196 \AddVariable{fontenc}{T1}
197 \message{^^J \prefix\space\space default encoding will be set to T1^^J}
201 \AddVariable{fontenc}{default}
207 % The list of layout files has been put in this file here by the
217 \TestPackage{color} % this one should be there if graphics.sty is there.
218 \TestPackage{fancyhdr}
219 \TestPackage{floatflt}
220 \TestPackage{setspace}
221 \TestPackage{subfigure}
222 \TestPackage{geometry}
223 \TestPackage{longtable}
224 \TestPackage{algorithm}
225 \TestPackage{rotating}
228 \TestPackage{varioref}
229 \TestPackage{prettyref}
231 \TestPackage{dvipost}
233 % The test for the graphics package is slightly more involved...
234 \newcommand\groption{dvips}
235 \TestItem{graphicx}{package}{sty}
236 % Let's do some clever things to guess the default driver for the
237 % graphicx package. The maintainer of the site might have declared it
238 % in the file 'graphics.cfg'. Let's hope there are no strange commands
240 {\renewcommand\ExecuteOptions[1]{\renewcommand\groption{default}}
241 \InputIfFileExists{graphics.cfg}{}{}
242 \AddPackage{graphicx}}
243 {\renewcommand{\groption}{none}}
244 \message{^^J\prefix checking for graphics driver... \groption^^J}
245 \AddVariable{graphicsdriver}{\groption}
247 % psnfss is in fact the name of a set of style files, among which
248 % times.sty. If times.sty is here, we will assume that everything is
250 \TestPackage[times.sty]{psnfss}
252 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
253 %%%%% END ACTUAL CONFIGURATION INSPECTION CODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%
254 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
256 % End of the LaTeX job
257 \immediate\closeout\layouts
258 \immediate\closeout\sed
259 \immediate\closeout\vars
260 \immediate\closeout\packages
261 \typeout{\prefix Inspection done.}
262 \typeout{\prefix Read the file doc/LaTeXConfig.lyx for more information.}
263 % Get the real \end command, that has been hidden by LaTeX