]> git.lyx.org Git - lyx.git/blob - lib/chkconfig.ltx
Remove SGML paragraph type. (docbook)
[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/LyXConfig.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/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.
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 %%% LyXConfig.lyx.in, 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 \newcommand{\prefix}{+} % the character used by grep to filter 'good' output
54 \newcommand{\AddLayout}[4][\default]{
55   \def\default{#2}
56   \immediate\write\layouts{"#2"   "#1"   "#3"   "#4"}}
57 \newcommand{\AddVariable}[2]{
58   \immediate\write\sed{s!@chk_#1@!#2!g}
59   \immediate\write\vars{chk_#1='#2'}}
60 \newcommand{\AddPackage}[1]{
61   \immediate\write\packages{#1}}
62 % Tests whether an item is present
63 % Syntax: \TestItem{<file>}{<name>}{<type>}{<ext>}{<iftrue>}{<iffalse>}
64 \newif\ifexists
65 \newcommand{\TestItem}[6][\default]{
66   \def\default{#2}
67   \def\files{#1}
68   \message{^^J\prefix checking for #3 #2 [#1]...}
69   \let\firstelement\relax
70   \existstrue
71   \@for\file:=\files\do{
72     \ifx\firstelement\relax
73        \edef\firstelement{\file}
74     \fi
75     \IfFileExists{\file}
76       {}
77       {\IfFileExists{\file.#4}{}{\existsfalse}}
78   }
79   \ifexists
80     \message{yes^^J}
81     \AddVariable{#2}{yes}
82     #5
83   \else
84     \message{no^^J}
85     \AddVariable{#2}{no}
86     #6
87   \fi}
88 \newcommand{\TestPackage}[2][\default]{
89   \TestItem[#1]{#2}{package}{sty}{\AddPackage{#2}}{}}
90 \newcommand{\TestDocClass}[2]{
91    \def\layoutname{#1}  % remember the name of the layout file
92    \@ifundefined{layout@#1}
93      {#2  % execute the command
94       \global\@namedef{layout@#1}{}}
95      {} % we have already tried this one.
96 }
97 \newcommand{\DeclareLaTeXClass}[2][\default]{
98   \TestItem[#1]{\layoutname}{document class}{cls}
99            {\AddLayout[\firstelement]{\layoutname}{#2}{true}}
100            {\AddLayout[\firstelement]{\layoutname}{#2}{false}}
101 }
102 \newcommand{\DeclareLinuxDocClass}[2][\default]{
103   \message{^^J\prefix checking for linuxdoc class \layoutname... }
104   \@ifundefined{haslinuxdoc}
105     {\message{no^^J}
106      \AddLayout[#1]{\layoutname}{#2}{false}}
107     {\message{yes^^J}
108      \AddLayout[#1]{\layoutname}{#2}{true}}
109 }
110 % Only for compatibility. Will be removed later.
111 \let\DeclareSGMLClass=\DeclareDocBookClass
112
113 \newcommand{\DeclareDocBookClass}[2][\default]{
114   \message{^^J\prefix checking for docbook\space\space class \layoutname... }
115   \@ifundefined{hasdocbook}
116     {\message{no^^J}
117      \AddLayout[#1]{\layoutname}{#2}{false}}
118     {\message{yes^^J}
119      \AddLayout[#1]{\layoutname}{#2}{true}}
120 }
121
122 % Stolen from article.cls
123 \newcommand{\today}{\ifcase\month\or
124   January\or February\or March\or April\or May\or June\or
125   July\or August\or September\or October\or November\or December\fi
126   \space\number\day, \number\year}
127
128 % Initializes the files
129 \typeout{\prefix Inspecting your LaTeX configuration.}
130 \newwrite{\layouts} \immediate\openout \layouts = textclass.lst
131 \newwrite{\sed} \immediate\openout \sed  = chkconfig.sed
132 \newwrite{\vars} \immediate\openout \vars = chkconfig.vars
133 \newwrite{\packages} \immediate\openout \packages = packages.lst
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 %%% Check for ec fonts. Most of this code has been shamelessely stolen
156 %%% from the file ltxcheck.tex in the LaTeX distribution. In particular,
157 %%% don't ask me how the macro \ecrm works...
158 \def\ecrm{%
159   \begingroup
160     \escapechar-1
161     \xdef\reserved@a{%
162       \noexpand\in@
163         {\expandafter\string\csname ecrm\endcsname}%
164         {\expandafter\expandafter\expandafter
165            \string\csname T1/cmr/m/n\endcsname}}%
166   \endgroup
167   \reserved@a}
168
169 \message{^^J\prefix checking for default encoding (this may take a long time)^^J}
170 \font\test=ecrm1000\relax
171 \ifx\test\nullfont
172   \message{^^J\prefix\prefix checking for ec fonts... no^^J}
173   \AddVariable{ec}{no}
174   \AddVariable{fontenc}{default}
175 \else
176   \message{^^J\prefix\space\space checking for ec fonts... yes^^J}
177   \message{^^J\prefix\space\space checking for ec support in LaTeX format...}
178   \ecrm
179   \ifin@
180     \message{yes^^J}
181     \AddVariable{ec}{yes}
182     \AddVariable{fontenc}{T1}
183     \message{^^J \prefix\space\space default encoding will be set to T1^^J}
184   \else
185     \message{no^^J}
186     \AddVariable{ec}{no}
187     \AddVariable{fontenc}{default}
188   \fi
189 \fi
190
191
192 %%% Document classes
193 % The list of layout files has been put in this file here by the
194 % configure script.
195 \input{chklayouts}
196
197
198 %%% Packages
199 \TestPackage{a4}
200 \TestPackage{a4wide}
201 \TestPackage{array}
202 \TestPackage{babel}
203 \TestPackage{color} % this one should be there if graphics.sty is there.
204 \TestPackage{fancyhdr}
205 \TestPackage{floatflt}
206 \TestPackage{setspace}
207 \TestPackage{subfigure}
208 \TestPackage{geometry}
209 \TestPackage{longtable}
210 \TestPackage{algorithm}
211 \TestPackage{rotating}
212 \TestPackage{latex8}
213 \TestPackage{url}
214 \TestPackage{varioref}
215 \TestPackage{prettyref}
216 \TestPackage{natbib}
217 \TestPackage{dvipost}
218
219 % The test for the graphics package is slightly more involved...
220 \newcommand\groption{dvips}
221 \TestItem{graphicx}{package}{sty}
222 %  Let's do some clever things to guess the default driver for the
223 %  graphicx package. The maintainer of the site might have declared it
224 %  in the file 'graphics.cfg'. Let's hope there are no strange commands
225 %  in there...
226   {\renewcommand\ExecuteOptions[1]{\renewcommand\groption{default}}
227    \InputIfFileExists{graphics.cfg}{}{}
228    \AddPackage{graphicx}}
229   {\renewcommand{\groption}{none}}
230 \message{^^J\prefix checking for graphics driver... \groption^^J}
231 \AddVariable{graphicsdriver}{\groption}
232
233 % psnfss is in fact the name of a set of style files, among which
234 % times.sty. If times.sty is here, we will assume that everything is
235 % fine.
236 \TestPackage[times.sty]{psnfss}
237
238 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
239 %%%%% END ACTUAL CONFIGURATION INSPECTION CODE %%%%%%%%%%%%%%%%%%%%%%%%%%%%
240 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
241
242 % End of the LaTeX job
243 \immediate\closeout\layouts
244 \immediate\closeout\sed
245 \immediate\closeout\vars
246 \immediate\closeout\packages
247 \typeout{\prefix Inspection done.}
248 \typeout{\prefix Read the file doc/LaTeXConfig.lyx for more information.}
249 % Get the real \end command, that has been hidden by LaTeX
250 \@@end