simplify index (string drunkness corrected)
[lyx.git] / lib / configure.cmd
blobee9c95ad45c462e0bf42fdef41bfb4762d23583e
1 /* OS/2 REXX : The lib/configure.cmd; Don't delete this comment. */
2 call RxFuncAdd 'SysLoadFuncs','RexxUtil','SysLoadFuncs'
3 call SysLoadFuncs
4 env='OS2ENVIRONMENT'
5 X11ROOT=value('X11ROOT',,env)
6 latex_script='chkconfig.ltx'
7 lyxrc_defaults='lyxrc.defaults'
8 lyx_check_config='yes'
9 rc_fontenc='default'
11 parse arg option '=' srcdir
12 select
13 when option='-h'|option='-help'|option='--help' then do
14 say 'Usage: configure [options]'
15 say 'Options:'
16 say ' --help show this help lines'
17 say ' --without-latex-config do not run LaTeX to determine configuration'
18 exit
19 end
20 when option='--without-latex-config' then
21 lyx_check_config='no'
22 when option='--srcdir' then
23 srcdir=translate(srcdir,'\','/')
24 otherwise
25 nop
26 end /* select */
27 if srcdir='' then do
28 parse source 'OS/2 COMMAND ' script
29 say 'script =' script
30 srcdir=filespec('drive',script)strip(filespec('path',script),'T','\')
31 end
33 rc=SysFileTree(srcdir'\'latex_script,found,'F')
34 if found.0 = 0 then do
35 say "configure: error: cannot find "srcdir'\'latex_script" script"
36 exit 1
37 end
38 curdir=directory()
39 if \(curdir=srcdir) then do
40 call SysFileTree 'layouts', 'found', 'D'
41 if found.0 = 0 then do
42 call SysMkDir 'bind'
43 call SysMkDir 'clipart'
44 call SysMkDir 'doc'
45 call SysMkDir 'examples'
46 call SysMkDir 'images'
47 call SysMkDir 'kbd'
48 call SysMkDir 'layouts'
49 call SysMkDir 'reLyX'
50 call SysMkDir 'scripts'
51 call SysMkDir 'templates'
52 call SysMkDir 'ui'
53 end
54 'cmd /c copy /v' srcdir'\layouts\*.layout layouts'
55 if \(rc=0) then
56 say 'Error! copying layout files.'
57 end
58 curdir=translate(curdir,'/','\')
59 srcdir=translate(srcdir,'/','\')
60 A_.0=0
61 call SEARCH_PROG 'converter latex dvi%latex $$i|latex2e $$i%"latex"'
62 call SEARCH_PROG 'converter latex pdf2%pdflatex $$i|pdflatex2e $$i%"latex"'
63 call SEARCH_PROG 'converter latex html%tth -t -e2 -L$$BaseName < $$i > $$o|latex2html -no_subdir -split 0 -show_section_numbers $$i|hevea -s $$i%"originaldir,needaux"'
64 call SEARCH_PROG 'converter literate latex%noweave -delay -index $$i > $$o%""'
65 call SEARCH_PROG 'converter dvi ps%dvips -o $$o $$i%""'
66 call SEARCH_PROG 'converter ps pdf%ps2pdf $$i%""'
67 call SEARCH_PROG 'converter ps fax%ksendfax $$i%""'
68 /* call SEARCH_PROG 'converter ps tiff%gs -sDEVICE=tiffg3 -sOutputFile=$$o -dNOPAUSE $$i -c quit|gsos2 -sDEVICE=tiffg3 -sOutputFile=$$o -dNOPAUSE $$i -c quit%""' */
69 call SEARCH_PROG 'converter linuxdoc lyx%sgml2lyx $$i%""'
70 call SEARCH_PROG 'converter linuxdoc latex%sgml2latex $$i%""'
71 call SEARCH_PROG 'converter linuxdoc dvi%sgml2latex -o dvi $$i%""'
72 call SEARCH_PROG 'converter linuxdoc html%sgml2html $$i%""'
73 call SEARCH_PROG 'converter docbook dvi%sgmltools -b dvi $$i|db2dvi $$i%""'
74 call SEARCH_PROG 'converter docbook html%sgmltools -b html $$i|db2html $$i%""'
75 A_.0=A_.0+1;i=A_.0
76 A_.i=''
77 call SEARCH_PROG 'converter latex lyx%reLyX -f $$i%""'
78 call SEARCH_PROG 'converter literate lyx%noweb2lyx $$i $$o%""'
79 call SEARCH_PROG 'converter html latex%html2latex $$i%""'
80 call SEARCH_PROG 'converter word latex%wvCleanLatex $$i $$o|word2x -f latex $$i%""'
81 A_.0=A_.0+1;i=A_.0
82 A_.i=''
83 call SEARCH_PROG 'converter gif eps%convert $$i $$o%""'
84 call SEARCH_PROG 'converter png eps%convert $$i $$o%""'
85 call SEARCH_PROG 'converter jpg eps%convert $$i $$o%""'
86 call SEARCH_PROG 'converter gif png%convert $$i $$o%""'
87 A_.0=A_.0+1;i=A_.0
88 A_.i=''
89 call SEARCH_PROG 'viewer dvi%xdvi'
90 call SEARCH_PROG 'viewer html%netscape'
91 call SEARCH_PROG 'viewer pdf%xpdf gv ghostview acroread'
92 call SEARCH_PROG 'viewer ps%gv -swap|ghostview -swap|gvpm -swap'
93 call SEARCH_PROG 'viewer eps%gv|ghostview|gvpm'
94 A_.0=A_.0+1;i=A_.0
95 A_.i=''
96 call SEARCH_PROG 'ps_command%gs|gsos2'
97 call SEARCH_PROG 'ascii_roff_command%groff -t -Tlatin1 $$i'
98 call SEARCH_PROG 'chktex_command%chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38'
99 call SEARCH_PROG 'spell_command%ispell'
100 /* call SEARCH_PROG 'fax_command%fsend -p$$Phone -i$$i -d$$Name -m$$Comment' */
101 call SEARCH_PROG 'print_spool_command%lp|lpr'
102 i=A_.0;A_.0=A_.0+1
103 if pos('lpr',A_.i)>0 then
105 i=i+1
106 A_.i='print_spool_printerprefix "-P"'
108 else
110 i=i+1
111 A_.i='print_spool_printerprefix "-d "'
113 /* call SysFileTree 'reLyX\reLyX.cmd', 'found', 'F' */
114 /* $ChkLaTeX
115 \nonstopmode\makeatletter
116 \ifx\undefined\documentclass\else
117 \message{ThisIsLaTeX2e}
119 \@@end
120 EOF */
121 call WRITE_FILE 'chklatex.ltx' '$ChkLaTeX'
122 'cmd /c 'LATEX' chklatex.ltx>nul'
123 call SysFileSearch 'NotLaTeX2e', 'chklatex.log', chklatex
124 if chklatex.0 > 0 then LATEX=''
126 rc=SysFileDelete('textclass.lst')
127 rc=SysFileDelete('packages.lst')
128 rc=SysFileDelete('chkconfig.sed')
129 if \(lyx_check_config='no') then
131 rc=SysFileTree(srcdir'\layouts\*.layout',found,'FO')
132 rc=SysFileDelete('chklayouts.tex')
133 rc=SysFileDelete('chkconfig.vars')
134 if found.0>0 then
135 do num=1 to found.0
136 parse value filespec('name',found.num) with DocClass '.layout'
137 parse value DocClass with mainClass '_' subClass
138 if ''=subClass then
139 rc=lineout('chklayouts.tex','\TestDocClass{'DocClass'}')
140 else /* Not used, or must be empty? */
141 rc=lineout('chklayouts.tex','\TestDocClass['mainClass'.cls]{'DocClass'}')
143 rc=lineout('chklayouts.tex')
144 sgmltools_cmd=''
145 chk_sgmltools='no'
146 if SGMLTOOLS='sgml2lyx' then
148 chk_sgmltools='yes'
149 sgmltools_cmd='\def\hassgmltools{}'
151 rc=SysFileDelete('wrap_chkconfig.ltx')
152 rc=lineout('wrap_chkconfig.ltx','\newcommand\srcdir{'srcdir'}')
153 rc=lineout('wrap_chkconfig.ltx',sgmltools_cmd)
154 rc=lineout('wrap_chkconfig.ltx','\input{'srcdir'/chkconfig.ltx}')
155 rc=lineout('wrap_chkconfig.ltx')
156 'cmd /c 'LATEX' wrap_chkconfig.ltx'
157 size=stream('chkconfig.sed','c','query size')
158 rc=stream('chkconfig.sed','c','open')
159 if rxfuncquery(SysAddRexxMacro) then
160 rc=stream('chkconfig.sed','c','seek +'size)
161 else
162 rc=stream('chkconfig.sed','c','seek + 'size' write')
163 rc=lineout('chkconfig.sed','s/@chk_sgmltools@/'chk_sgmltools'/g')
164 rc=lineout('chkconfig.sed')
165 call SysFileSearch 'chk_fontenc=', 'chkconfig.vars', fontenc
166 if fontenc.0 > 0 then parse var fontenc.1 chk"='"rc_fontenc"'"
169 call SysFileTree 'textclass.lst', 'file', 'FO'
170 if file.0=0 then
172 /* $TextClass
173 # This file declares layouts and their associated definition files
174 # (include dir. relative to the place where this file is).
175 # It contains only default values, since chkconfig.ltx could not be run
176 # for some reason. Run ./configure if you need to update it after a
177 # configuration change.
178 "article" "article" "article"
179 "report" "report" "report"
180 "book" "book" "book"
181 "linuxdoc" "linuxdoc" "linuxdoc"
182 "letter" "letter" "letter"
183 EOF */
184 call WRITE_FILE 'textclass.lst' '$TextClass'
185 rc=lineout('chkconfig.sed','s/@.*@/???/g')
186 rc=lineout('chkconfig.sed')
187 rc_graphics='none'
190 call SysFileTree 'chkconfig.sed', 'file', 'FO'
191 if file.0=0 then
193 rc=lineout('chkconfig.sed','s/@.*@/???/g')
194 rc=lineout('chkconfig.sed')
197 call SysFileTree 'packages.lst', 'file', 'FO'
198 if file.0=0 then
200 /* $Packages
201 # This file should contain the list of LaTeX packages that have been
202 # recognized by LyX. Unfortunately, since configure could not find
203 # your LaTeX2e program, the tests have not been run. Run configure
204 # if you need to update it after a configuration change.
205 EOF */
206 call WRITE_FILE 'packages.lst' '$Packages'
209 say 'creating doc/LaTeXConfig.lyx'
210 'sed -f chkconfig.sed 'srcdir'/doc/LaTeXConfig.lyx.in >doc\LaTeXConfig.lyx'
211 call SysFileDelete 'chkconfig.sed'
212 call SysFileDelete 'chkconfig.vars'
213 call SysFileDelete 'wrap_chkconfig.ltx'
214 call SysFileDelete 'wrap_chkconfig.log'
215 call SysFileDelete 'chklatex.ltx'
216 call SysFileDelete 'chklatex.log'
217 call SysFileDelete 'chklayouts.tex'
218 call SysFileDelete 'missfont.log'
220 say 'creating 'lyxrc_defaults
221 if rxfuncquery(SysAddRexxMacro) then
222 rc=stream(lyxrc_defaults,'c','seek =0')
223 rc=SysFileDelete(X11ROOT'\XFree86\bin\fsend2.cmd')
224 /* $LyXRC_Default
225 # This file has been automatically generated by LyX' lib/configure
226 # script. It contains default settings that have been determined by
227 # examining your system. PLEASE DO NOT MODIFY ANYTHING HERE! If you
228 # want to customize LyX, make a copy of the file LYXDIR/lyxrc as
229 # ~/.lyx/lyxrc and edit this file instead. Any setting in lyxrc will
230 # override the values given here.
231 \Format text txt ASCII A
232 \Format textparagraph txt ASCII(paragraphs) ""
233 \Format docbook sgml DocBook B
234 \Format dvi dvi DVI D
235 \Format eps eps EPS ""
236 \Format fax "" Fax ""
237 \Format gif gif GIF ""
238 \Format html html HTML H
239 \Format jpg jpg JPEG ""
240 \Format latex tex LaTeX L
241 \Format linuxdoc sgml LinuxDoc x
242 \Format lyx lyx LyX ""
243 \Format literate nw NoWeb N
244 \Format pdf pdf PDF P
245 \Format pdf2 pdf "PDF (pdflatex)" F
246 \Format png png PNG ""
247 \Format ps ps Postscript t
248 \Format program "" Program ""
249 \Format word doc Word W
252 EOF */
253 call WRITE_FILE lyxrc_defaults '$LyXRC_Default'
254 A_.0=A_.0+1;i=A_.0
255 A_.i='font_encoding "'||rc_fontenc||'"'
256 do i=1 to A_.0
257 if A_.i\='' then A_.i='\'||A_.i
258 call lineout lyxrc_defaults,A_.i
260 call lineout lyxrc_defaults
261 call lineout script
262 exit
264 SEARCH_PROG: procedure expose A_.
265 parse arg LABEL '%' COMMANDS '%' ROUTE
266 i=A_.0+1
267 A_.0=i
268 A_.i=LABEL||' "none" '||ROUTE
269 do while COMMANDS\=''
270 parse value COMMANDS with COMMAND '|' COMMANDS
271 parse upper value COMMAND with CMD ARGV
272 if (\(''=SysSearchPath('PATH',CMD||'.EXE'))|\(''=SysSearchPath('PATH',CMD||'.CMD'))) then
274 A_.i=LABEL||' "'||COMMAND||'" '||ROUTE
275 COMMANDS=''
278 return
280 WRITE_FILE: procedure expose script
281 parse arg FILE TAG
282 call SysFileDelete FILE
283 C_=''
284 do while pos(TAG,C_)=0
285 C_=linein(script)
287 C_=linein(script)
288 do while pos('EOF',C_)=0
289 call lineout FILE,C_
290 C_=linein(script)
292 call lineout FILE
293 /*call lineout script*/
294 return