]> git.lyx.org Git - lyx.git/blob - lib/configure
Use contains() instead of strchr().
[lyx.git] / lib / configure
1 #! /bin/sh
2 # This script is a hand-made configure script. It contains a lot of
3 # code stolen from GNU autoconf. I removed all the code that was not
4 # useful for configuring a LyX installation.
5
6
7
8
9
10 ####some configuration variables
11 lyx_check_config=yes
12 lyx_keep_temps=no
13 srcdir=
14
15 #### Parse the command line
16 for ac_option do
17   case "$ac_option" in
18     -help | --help | -h)
19       cat << EOF
20 Usage: configure [options] 
21 Options: 
22   --help                   show this help lines
23   --keep-temps             keep temporary files (for debug. purposes)
24   --without-latex-config   do not run LaTeX to determine configuration
25 EOF
26       exit 0;;
27     --without-latex-config)
28       lyx_check_config=no ;;
29     --keep-temps)
30       lyx_keep_temps=yes ;;
31   esac 
32 done
33
34
35 #### Checking for some echo oddities
36 if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
37   # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
38   if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
39     ac_n= ac_c='
40 ' ac_t='        '
41   else
42     ac_n=-n ac_c= ac_t=
43   fi
44 else
45   ac_n= ac_c='\c' ac_t=
46 fi
47
48
49 #### I do not really know why this is useful, but we might as well keep it.
50 # NLS nuisances.
51 # Only set these to C if already set.  These must not be set unconditionally
52 # because not all systems understand e.g. LANG=C (notably SCO).
53 # Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
54 # Non-C LC_CTYPE values break the ctype check.
55 if test "${LANG+set}"   = set; then LANG=C;   export LANG;   fi
56 if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
57 if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
58 if test "${LC_CTYPE+set}"    = set; then LC_CTYPE=C;    export LC_CTYPE;    fi
59
60
61 #### Guess the directory in which configure is located.
62 ac_prog=$0
63 srcdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` 
64 srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
65 test "x$srcdir" = "x$ac_prog" && srcdir=.
66 if test ! -r ${srcdir}/chkconfig.ltx ; then
67   echo "configure: error: cannot find chkconfig.ltx script"
68   exit 1
69 fi
70
71
72 #### Create the build directories if necessary
73 for dir in bind clipart doc examples images kbd layouts reLyX \
74     scripts templates ui ; do
75   test ! -d $dir && mkdir $dir
76 done
77
78
79 #### Searching some useful programs
80 # Search LaTeX2e
81 echo $ac_n "checking for a LaTeX2e program""... $ac_c"
82 echo "$ac_t""(latex latex2e)"
83 LATEX=
84 for ac_prog in latex latex2e
85 do
86 # Extract the first word of "$ac_prog", so it can be a program name with args.
87 set dummy $ac_prog ; ac_word=$2
88 if test -n "$ac_word"; then
89   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
90   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
91   for ac_dir in $PATH; do
92     test -z "$ac_dir" && ac_dir=.
93     if test -x $ac_dir/$ac_word; then
94       LATEX="$ac_prog"
95       break
96     fi
97   done
98   IFS="$ac_save_ifs"
99
100   if test -n "$LATEX"; then
101     ac_result=yes
102   else
103     ac_result=no
104   fi
105   
106 ## Check whether this is really LaTeX2e
107 rm -f chklatex.ltx
108 cat >chklatex.ltx <<EOF
109 \\nonstopmode\\makeatletter
110 \\ifx\\undefined\\documentclass\\else
111   \\message{ThisIsLaTeX2e}
112 \\fi
113 \\@@end
114 EOF
115 if eval ${LATEX} chklatex.ltx </dev/null 2>/dev/null \
116                        | grep 'ThisIsLaTeX2e' >/dev/null; then
117   :
118 else
119   LATEX=
120   ac_result="not useable"
121 fi
122 rm -f chklatex.ltx chklatex.log
123   echo "$ac_t""$ac_result"
124   test -n "$LATEX" && break
125 fi
126 done
127
128 if test -z "$LATEX" ; then
129   LATEX=none
130     lyx_check_config=no
131 fi
132
133 if test x$lyx_check_config != x ; then
134 echo $ac_n "checking for the pdflatex program""... $ac_c"
135 echo "$ac_t""(pdflatex)"
136 PDFLATEX=
137 for ac_prog in pdflatex
138 do
139 # Extract the first word of "$ac_prog", so it can be a program name with args.
140 set dummy $ac_prog ; ac_word=$2
141 if test -n "$ac_word"; then
142   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
143   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
144   for ac_dir in $PATH; do
145     test -z "$ac_dir" && ac_dir=.
146     if test -x $ac_dir/$ac_word; then
147       PDFLATEX="$ac_prog"
148       break
149     fi
150   done
151   IFS="$ac_save_ifs"
152
153   if test -n "$PDFLATEX"; then
154     ac_result=yes
155   else
156     ac_result=no
157   fi
158   
159 ## Check whether this is really LaTeX2e
160 rm -f chklatex.ltx
161 cat >chklatex.ltx <<EOF
162 \\nonstopmode\\makeatletter
163 \\ifx\\undefined\\documentclass\\else
164   \\message{ThisIsLaTeX2e}
165 \\fi
166 \\@@end
167 EOF
168 if eval ${LATEX} chklatex.ltx </dev/null 2>/dev/null \
169                        | grep 'ThisIsLaTeX2e' >/dev/null; then
170   :
171 else
172   LATEX=
173   ac_result="not useable"
174 fi
175 rm -f chklatex.ltx chklatex.log
176   echo "$ac_t""$ac_result"
177   test -n "$PDFLATEX" && break
178 fi
179 done
180
181 if test -z "$PDFLATEX" ; then
182   PDFLATEX=none
183 fi
184
185 fi
186
187 # Search for an installed reLyX or a ready-to-install one
188 save_PATH=${PATH}
189 PATH=${PATH}:./reLyX/
190 echo $ac_n "checking for a LaTeX -> LyX converter""... $ac_c"
191 echo "$ac_t""(reLyX)"
192 tex_to_lyx_command=
193 for ac_prog in reLyX
194 do
195 # Extract the first word of "$ac_prog", so it can be a program name with args.
196 set dummy $ac_prog ; ac_word=$2
197 if test -n "$ac_word"; then
198   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
199   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
200   for ac_dir in $PATH; do
201     test -z "$ac_dir" && ac_dir=.
202     if test -x $ac_dir/$ac_word; then
203       tex_to_lyx_command="$ac_prog"
204       break
205     fi
206   done
207   IFS="$ac_save_ifs"
208
209   if test -n "$tex_to_lyx_command"; then
210     ac_result=yes
211   else
212     ac_result=no
213   fi
214   
215   echo "$ac_t""$ac_result"
216   test -n "$tex_to_lyx_command" && break
217 fi
218 done
219
220 if test -z "$tex_to_lyx_command" ; then
221   tex_to_lyx_command=none
222 fi
223
224 PATH=${save_PATH}
225 test $tex_to_lyx_command = "reLyX" && tex_to_lyx_command="reLyX -f \$\$i"
226
227 echo $ac_n "checking for a Noweb -> LyX converter""... $ac_c"
228 echo "$ac_t""(noweb2lyx)"
229 literate_to_lyx_command=
230 for ac_prog in noweb2lyx
231 do
232 # Extract the first word of "$ac_prog", so it can be a program name with args.
233 set dummy $ac_prog ; ac_word=$2
234 if test -n "$ac_word"; then
235   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
236   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
237   for ac_dir in $PATH; do
238     test -z "$ac_dir" && ac_dir=.
239     if test -x $ac_dir/$ac_word; then
240       literate_to_lyx_command="$ac_prog"
241       break
242     fi
243   done
244   IFS="$ac_save_ifs"
245
246   if test -n "$literate_to_lyx_command"; then
247     ac_result=yes
248   else
249     ac_result=no
250   fi
251   
252   echo "$ac_t""$ac_result"
253   test -n "$literate_to_lyx_command" && break
254 fi
255 done
256
257 if test -z "$literate_to_lyx_command" ; then
258   literate_to_lyx_command=none
259 fi
260
261 test $literate_to_lyx_command = "noweb2lyx" && literate_to_lyx_command="noweb2lyx \$\$i \$\$o"
262
263 # Search something to process a literate document
264 echo $ac_n "checking for a Noweb -> LaTeX converter""... $ac_c"
265 echo "$ac_t""(noweave)"
266 literate_to_tex_command=
267 for ac_prog in noweave
268 do
269 # Extract the first word of "$ac_prog", so it can be a program name with args.
270 set dummy $ac_prog ; ac_word=$2
271 if test -n "$ac_word"; then
272   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
273   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
274   for ac_dir in $PATH; do
275     test -z "$ac_dir" && ac_dir=.
276     if test -x $ac_dir/$ac_word; then
277       literate_to_tex_command="$ac_prog"
278       break
279     fi
280   done
281   IFS="$ac_save_ifs"
282
283   if test -n "$literate_to_tex_command"; then
284     ac_result=yes
285   else
286     ac_result=no
287   fi
288   
289   echo "$ac_t""$ac_result"
290   test -n "$literate_to_tex_command" && break
291 fi
292 done
293
294 if test -z "$literate_to_tex_command" ; then
295   literate_to_tex_command=none
296 fi
297
298 test $literate_to_tex_command = "noweave" && literate_to_tex_command="noweave -delay -index \$\$i > \$\$o"
299
300 echo $ac_n "checking for a HTML -> Latex converter""... $ac_c"
301 echo "$ac_t""(html2latex)"
302 html_to_latex_command=
303 for ac_prog in html2latex
304 do
305 # Extract the first word of "$ac_prog", so it can be a program name with args.
306 set dummy $ac_prog ; ac_word=$2
307 if test -n "$ac_word"; then
308   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
309   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
310   for ac_dir in $PATH; do
311     test -z "$ac_dir" && ac_dir=.
312     if test -x $ac_dir/$ac_word; then
313       html_to_latex_command="$ac_prog"
314       break
315     fi
316   done
317   IFS="$ac_save_ifs"
318
319   if test -n "$html_to_latex_command"; then
320     ac_result=yes
321   else
322     ac_result=no
323   fi
324   
325   echo "$ac_t""$ac_result"
326   test -n "$html_to_latex_command" && break
327 fi
328 done
329
330 if test -z "$html_to_latex_command" ; then
331   html_to_latex_command=none
332 fi
333
334 test $html_to_latex_command = "html2latex" && html_to_latex_command="html2latex \$\$i"
335
336 echo $ac_n "checking for a MSWord -> Latex converter""... $ac_c"
337 echo "$ac_t""(wvCleanLatex word2x)"
338 word_to_latex_command=
339 for ac_prog in wvCleanLatex word2x
340 do
341 # Extract the first word of "$ac_prog", so it can be a program name with args.
342 set dummy $ac_prog ; ac_word=$2
343 if test -n "$ac_word"; then
344   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
345   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
346   for ac_dir in $PATH; do
347     test -z "$ac_dir" && ac_dir=.
348     if test -x $ac_dir/$ac_word; then
349       word_to_latex_command="$ac_prog"
350       break
351     fi
352   done
353   IFS="$ac_save_ifs"
354
355   if test -n "$word_to_latex_command"; then
356     ac_result=yes
357   else
358     ac_result=no
359   fi
360   
361   echo "$ac_t""$ac_result"
362   test -n "$word_to_latex_command" && break
363 fi
364 done
365
366 if test -z "$word_to_latex_command" ; then
367   word_to_latex_command=none
368 fi
369
370 test "$word_to_latex_command" = "wvCleanLatex" && word_to_latex_command="wvCleanLatex \$\$i \$\$o"
371 test "$word_to_latex_command" = "word2x" && word_to_latex_command="word2x -f latex \$\$i"
372
373 echo $ac_n "checking for Image converter""... $ac_c"
374 echo "$ac_t""(convert)"
375 image_command=
376 for ac_prog in convert
377 do
378 # Extract the first word of "$ac_prog", so it can be a program name with args.
379 set dummy $ac_prog ; ac_word=$2
380 if test -n "$ac_word"; then
381   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
382   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
383   for ac_dir in $PATH; do
384     test -z "$ac_dir" && ac_dir=.
385     if test -x $ac_dir/$ac_word; then
386       image_command="$ac_prog"
387       break
388     fi
389   done
390   IFS="$ac_save_ifs"
391
392   if test -n "$image_command"; then
393     ac_result=yes
394   else
395     ac_result=no
396   fi
397   
398   echo "$ac_t""$ac_result"
399   test -n "$image_command" && break
400 fi
401 done
402
403 if test -z "$image_command" ; then
404   image_command=none
405 fi
406
407 test $image_command = "convert" && image_command="convert \$\$i \$\$o"
408
409 # Search for a Postscript interpreter
410 echo $ac_n "checking for a Postscript interpreter""... $ac_c"
411 echo "$ac_t""(gs)"
412 GS=
413 for ac_prog in gs
414 do
415 # Extract the first word of "$ac_prog", so it can be a program name with args.
416 set dummy $ac_prog ; ac_word=$2
417 if test -n "$ac_word"; then
418   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
419   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
420   for ac_dir in $PATH; do
421     test -z "$ac_dir" && ac_dir=.
422     if test -x $ac_dir/$ac_word; then
423       GS="$ac_prog"
424       break
425     fi
426   done
427   IFS="$ac_save_ifs"
428
429   if test -n "$GS"; then
430     ac_result=yes
431   else
432     ac_result=no
433   fi
434   
435   echo "$ac_t""$ac_result"
436   test -n "$GS" && break
437 fi
438 done
439
440 if test -z "$GS" ; then
441   GS=none
442 fi
443
444
445 # Search something to preview postscript
446 echo $ac_n "checking for a Postscript previewer""... $ac_c"
447 echo "$ac_t""(gv ghostview)"
448 GHOSTVIEW=
449 for ac_prog in gv ghostview
450 do
451 # Extract the first word of "$ac_prog", so it can be a program name with args.
452 set dummy $ac_prog ; ac_word=$2
453 if test -n "$ac_word"; then
454   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
455   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
456   for ac_dir in $PATH; do
457     test -z "$ac_dir" && ac_dir=.
458     if test -x $ac_dir/$ac_word; then
459       GHOSTVIEW="$ac_prog"
460       break
461     fi
462   done
463   IFS="$ac_save_ifs"
464
465   if test -n "$GHOSTVIEW"; then
466     ac_result=yes
467   else
468     ac_result=no
469   fi
470   
471   echo "$ac_t""$ac_result"
472   test -n "$GHOSTVIEW" && break
473 fi
474 done
475
476 if test -z "$GHOSTVIEW" ; then
477   GHOSTVIEW=none
478 fi
479
480
481 # Search for a program to preview pdf
482 echo $ac_n "checking for a PDF preview""... $ac_c"
483 echo "$ac_t""(acroread gv ghostview xpdf)"
484 PDF_VIEWER=
485 for ac_prog in acroread gv ghostview xpdf
486 do
487 # Extract the first word of "$ac_prog", so it can be a program name with args.
488 set dummy $ac_prog ; ac_word=$2
489 if test -n "$ac_word"; then
490   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
491   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
492   for ac_dir in $PATH; do
493     test -z "$ac_dir" && ac_dir=.
494     if test -x $ac_dir/$ac_word; then
495       PDF_VIEWER="$ac_prog"
496       break
497     fi
498   done
499   IFS="$ac_save_ifs"
500
501   if test -n "$PDF_VIEWER"; then
502     ac_result=yes
503   else
504     ac_result=no
505   fi
506   
507   echo "$ac_t""$ac_result"
508   test -n "$PDF_VIEWER" && break
509 fi
510 done
511
512 if test -z "$PDF_VIEWER" ; then
513   PDF_VIEWER=none
514 fi
515
516
517 # Search something to preview dvi
518 echo $ac_n "checking for a DVI previewer""... $ac_c"
519 echo "$ac_t""(xdvi)"
520 DVI_VIEWER=
521 for ac_prog in xdvi
522 do
523 # Extract the first word of "$ac_prog", so it can be a program name with args.
524 set dummy $ac_prog ; ac_word=$2
525 if test -n "$ac_word"; then
526   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
527   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
528   for ac_dir in $PATH; do
529     test -z "$ac_dir" && ac_dir=.
530     if test -x $ac_dir/$ac_word; then
531       DVI_VIEWER="$ac_prog"
532       break
533     fi
534   done
535   IFS="$ac_save_ifs"
536
537   if test -n "$DVI_VIEWER"; then
538     ac_result=yes
539   else
540     ac_result=no
541   fi
542   
543   echo "$ac_t""$ac_result"
544   test -n "$DVI_VIEWER" && break
545 fi
546 done
547
548 if test -z "$DVI_VIEWER" ; then
549   DVI_VIEWER=none
550 fi
551
552
553 # Search something to preview html
554 echo $ac_n "checking for a HTML previewer""... $ac_c"
555 echo "$ac_t""(netscape)"
556 HTML_VIEWER=
557 for ac_prog in netscape
558 do
559 # Extract the first word of "$ac_prog", so it can be a program name with args.
560 set dummy $ac_prog ; ac_word=$2
561 if test -n "$ac_word"; then
562   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
563   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
564   for ac_dir in $PATH; do
565     test -z "$ac_dir" && ac_dir=.
566     if test -x $ac_dir/$ac_word; then
567       HTML_VIEWER="$ac_prog"
568       break
569     fi
570   done
571   IFS="$ac_save_ifs"
572
573   if test -n "$HTML_VIEWER"; then
574     ac_result=yes
575   else
576     ac_result=no
577   fi
578   
579   echo "$ac_t""$ac_result"
580   test -n "$HTML_VIEWER" && break
581 fi
582 done
583
584 if test -z "$HTML_VIEWER" ; then
585   HTML_VIEWER=none
586 fi
587
588
589 # Search for a program to convert ps to pdf
590 echo $ac_n "checking for a PS to PDF converter""... $ac_c"
591 echo "$ac_t""(ps2pdf)"
592 ps_to_pdf_command=
593 for ac_prog in ps2pdf
594 do
595 # Extract the first word of "$ac_prog", so it can be a program name with args.
596 set dummy $ac_prog ; ac_word=$2
597 if test -n "$ac_word"; then
598   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
599   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
600   for ac_dir in $PATH; do
601     test -z "$ac_dir" && ac_dir=.
602     if test -x $ac_dir/$ac_word; then
603       ps_to_pdf_command="$ac_prog"
604       break
605     fi
606   done
607   IFS="$ac_save_ifs"
608
609   if test -n "$ps_to_pdf_command"; then
610     ac_result=yes
611   else
612     ac_result=no
613   fi
614   
615   echo "$ac_t""$ac_result"
616   test -n "$ps_to_pdf_command" && break
617 fi
618 done
619
620 if test -z "$ps_to_pdf_command" ; then
621   ps_to_pdf_command=none
622 fi
623
624 test $ps_to_pdf_command = "ps2pdf" && ps_to_pdf_command="ps2pdf \$\$i"
625
626 # Search for a program to convert dvi to ps
627 echo $ac_n "checking for a DVI to PS converter""... $ac_c"
628 echo "$ac_t""(dvips)"
629 dvi_to_ps_command=
630 for ac_prog in dvips
631 do
632 # Extract the first word of "$ac_prog", so it can be a program name with args.
633 set dummy $ac_prog ; ac_word=$2
634 if test -n "$ac_word"; then
635   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
636   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
637   for ac_dir in $PATH; do
638     test -z "$ac_dir" && ac_dir=.
639     if test -x $ac_dir/$ac_word; then
640       dvi_to_ps_command="$ac_prog"
641       break
642     fi
643   done
644   IFS="$ac_save_ifs"
645
646   if test -n "$dvi_to_ps_command"; then
647     ac_result=yes
648   else
649     ac_result=no
650   fi
651   
652   echo "$ac_t""$ac_result"
653   test -n "$dvi_to_ps_command" && break
654 fi
655 done
656
657 if test -z "$dvi_to_ps_command" ; then
658   dvi_to_ps_command=none
659 fi
660
661 test $dvi_to_ps_command = "dvips" && dvi_to_ps_command="dvips -o \$\$o \$\$i"
662
663 # Search a *roff program (used to translate tables in ASCII export)
664 echo $ac_n "checking for a *roff formatter""... $ac_c"
665 echo "$ac_t""(groff nroff)"
666 ROFF=
667 for ac_prog in groff nroff
668 do
669 # Extract the first word of "$ac_prog", so it can be a program name with args.
670 set dummy $ac_prog ; ac_word=$2
671 if test -n "$ac_word"; then
672   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
673   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
674   for ac_dir in $PATH; do
675     test -z "$ac_dir" && ac_dir=.
676     if test -x $ac_dir/$ac_word; then
677       ROFF="$ac_prog"
678       break
679     fi
680   done
681   IFS="$ac_save_ifs"
682
683   if test -n "$ROFF"; then
684     ac_result=yes
685   else
686     ac_result=no
687   fi
688   
689   echo "$ac_t""$ac_result"
690   test -n "$ROFF" && break
691 fi
692 done
693
694 if test -z "$ROFF" ; then
695   ROFF=none
696 fi
697
698 ascii_roff_command=$ROFF
699 test $ROFF = "groff" && ascii_roff_command="groff -t -Tlatin1 \$\$FName"
700 test $ROFF = "nroff" && ascii_roff_command="tbl \$\$FName | nroff"
701
702 # Search the ChkTeX program
703 echo $ac_n "checking for ChkTeX""... $ac_c"
704 echo "$ac_t""(chktex)"
705 CHKTEX=
706 for ac_prog in chktex
707 do
708 # Extract the first word of "$ac_prog", so it can be a program name with args.
709 set dummy $ac_prog ; ac_word=$2
710 if test -n "$ac_word"; then
711   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
712   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
713   for ac_dir in $PATH; do
714     test -z "$ac_dir" && ac_dir=.
715     if test -x $ac_dir/$ac_word; then
716       CHKTEX="$ac_prog"
717       break
718     fi
719   done
720   IFS="$ac_save_ifs"
721
722   if test -n "$CHKTEX"; then
723     ac_result=yes
724   else
725     ac_result=no
726   fi
727   
728   echo "$ac_t""$ac_result"
729   test -n "$CHKTEX" && break
730 fi
731 done
732
733 if test -z "$CHKTEX" ; then
734   CHKTEX=none
735 fi
736
737 chktex_command=$CHKTEX
738 test $CHKTEX = "chktex" && chktex_command="$CHKTEX -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38"
739
740 # Search for a spellchecker
741 echo $ac_n "checking for a spell-checker""... $ac_c"
742 echo "$ac_t""(ispell)"
743 SPELL=
744 for ac_prog in ispell
745 do
746 # Extract the first word of "$ac_prog", so it can be a program name with args.
747 set dummy $ac_prog ; ac_word=$2
748 if test -n "$ac_word"; then
749   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
750   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
751   for ac_dir in $PATH; do
752     test -z "$ac_dir" && ac_dir=.
753     if test -x $ac_dir/$ac_word; then
754       SPELL="$ac_prog"
755       break
756     fi
757   done
758   IFS="$ac_save_ifs"
759
760   if test -n "$SPELL"; then
761     ac_result=yes
762   else
763     ac_result=no
764   fi
765   
766   echo "$ac_t""$ac_result"
767   test -n "$SPELL" && break
768 fi
769 done
770
771 if test -z "$SPELL" ; then
772   SPELL=none
773 fi
774
775
776
777 # Search a GUI Fax program
778 echo $ac_n "checking for a fax program""... $ac_c"
779 echo "$ac_t""(ksendfax)"
780 fax_command=
781 for ac_prog in ksendfax
782 do
783 # Extract the first word of "$ac_prog", so it can be a program name with args.
784 set dummy $ac_prog ; ac_word=$2
785 if test -n "$ac_word"; then
786   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
787   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
788   for ac_dir in $PATH; do
789     test -z "$ac_dir" && ac_dir=.
790     if test -x $ac_dir/$ac_word; then
791       fax_command="$ac_prog"
792       break
793     fi
794   done
795   IFS="$ac_save_ifs"
796
797   if test -n "$fax_command"; then
798     ac_result=yes
799   else
800     ac_result=no
801   fi
802   
803   echo "$ac_t""$ac_result"
804   test -n "$fax_command" && break
805 fi
806 done
807
808 if test -z "$fax_command" ; then
809   fax_command=none
810 fi
811
812 test $fax_command = "ksendfax" && fax_command="ksendfax \$\$i"
813
814 # Search for LinuxDoc support
815 echo $ac_n "checking for SGML-tools 1.x (LinuxDoc)""... $ac_c"
816 echo "$ac_t""(sgml2lyx)"
817 LINUXDOC=
818 for ac_prog in sgml2lyx
819 do
820 # Extract the first word of "$ac_prog", so it can be a program name with args.
821 set dummy $ac_prog ; ac_word=$2
822 if test -n "$ac_word"; then
823   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
824   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
825   for ac_dir in $PATH; do
826     test -z "$ac_dir" && ac_dir=.
827     if test -x $ac_dir/$ac_word; then
828       LINUXDOC="$ac_prog"
829       break
830     fi
831   done
832   IFS="$ac_save_ifs"
833
834   if test -n "$LINUXDOC"; then
835     ac_result=yes
836   else
837     ac_result=no
838   fi
839   
840   echo "$ac_t""$ac_result"
841   test -n "$LINUXDOC" && break
842 fi
843 done
844
845 if test -z "$LINUXDOC" ; then
846   LINUXDOC=none
847 fi
848
849 chk_linuxdoc=no
850 if test $LINUXDOC != none; then
851   chk_linuxdoc=yes
852   linuxdoc_cmd="\\def\\haslinuxdoc{yes}"
853 fi
854
855 case $LINUXDOC in
856   sgml2lyx)
857     linuxdoc_to_latex_command="sgml2latex \$\$i"
858     linuxdoc_to_dvi_command="sgml2latex -o dvi \$\$i"
859     linuxdoc_to_html_command="sgml2html \$\$i"
860     linuxdoc_to_lyx_command="sgml2lyx \$\$i";;
861   none)
862     linuxdoc_to_latex_command="none"
863     linuxdoc_to_dvi_command="none"
864     linuxdoc_to_html_command="none"
865     linuxdoc_to_lyx_command="none";;
866 esac
867
868 # Search for DocBook support
869 echo $ac_n "checking for SGML-tools 2.x (DocBook) or db2x scripts""... $ac_c"
870 echo "$ac_t""(sgmltools db2dvi)"
871 DOCBOOK=
872 for ac_prog in sgmltools db2dvi
873 do
874 # Extract the first word of "$ac_prog", so it can be a program name with args.
875 set dummy $ac_prog ; ac_word=$2
876 if test -n "$ac_word"; then
877   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
878   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
879   for ac_dir in $PATH; do
880     test -z "$ac_dir" && ac_dir=.
881     if test -x $ac_dir/$ac_word; then
882       DOCBOOK="$ac_prog"
883       break
884     fi
885   done
886   IFS="$ac_save_ifs"
887
888   if test -n "$DOCBOOK"; then
889     ac_result=yes
890   else
891     ac_result=no
892   fi
893   
894   echo "$ac_t""$ac_result"
895   test -n "$DOCBOOK" && break
896 fi
897 done
898
899 if test -z "$DOCBOOK" ; then
900   DOCBOOK=none
901 fi
902
903 chk_docbook=no
904 if test $DOCBOOK != none; then
905   chk_docbook=yes
906   docbook_cmd="\\def\\hasdocbook{yes}"
907 fi
908
909 case $DOCBOOK in
910   sgmltools)
911     docbook_to_dvi_command="sgmltools -b dvi \$\$i"
912     docbook_to_html_command="sgmltools -b html \$\$i";;
913   db2dvi)
914     docbook_to_dvi_command="db2dvi \$\$i"
915     docbook_to_html_command="db2html \$\$i";;
916   none)
917     docbook_to_dvi_command="none"
918     docbook_to_html_command="none";;
919 esac
920
921 # Search for a spool command
922 echo $ac_n "checking for a spool command""... $ac_c"
923 echo "$ac_t""(lp lpr)"
924 LPR=
925 for ac_prog in lp lpr
926 do
927 # Extract the first word of "$ac_prog", so it can be a program name with args.
928 set dummy $ac_prog ; ac_word=$2
929 if test -n "$ac_word"; then
930   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
931   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
932   for ac_dir in $PATH; do
933     test -z "$ac_dir" && ac_dir=.
934     if test -x $ac_dir/$ac_word; then
935       LPR="$ac_prog"
936       break
937     fi
938   done
939   IFS="$ac_save_ifs"
940
941   if test -n "$LPR"; then
942     ac_result=yes
943   else
944     ac_result=no
945   fi
946   
947   echo "$ac_t""$ac_result"
948   test -n "$LPR" && break
949 fi
950 done
951
952 if test -z "$LPR" ; then
953   LPR=none
954 fi
955
956 case $LPR in
957   lp) print_spool_command=lp
958       print_spool_printerprefix="-d ";;
959  lpr) print_spool_command=lpr
960       print_spool_printerprefix="-P";;
961    *) :;; # leave to empty values
962 esac
963
964 echo $ac_n "checking for a LaTeX -> HTML converter""... $ac_c"
965 echo "$ac_t""(tth latex2html hevea)"
966 TOHTML=
967 for ac_prog in tth latex2html hevea
968 do
969 # Extract the first word of "$ac_prog", so it can be a program name with args.
970 set dummy $ac_prog ; ac_word=$2
971 if test -n "$ac_word"; then
972   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
973   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
974   for ac_dir in $PATH; do
975     test -z "$ac_dir" && ac_dir=.
976     if test -x $ac_dir/$ac_word; then
977       TOHTML="$ac_prog"
978       break
979     fi
980   done
981   IFS="$ac_save_ifs"
982
983   if test -n "$TOHTML"; then
984     ac_result=yes
985   else
986     ac_result=no
987   fi
988   
989   echo "$ac_t""$ac_result"
990   test -n "$TOHTML" && break
991 fi
992 done
993
994 if test -z "$TOHTML" ; then
995   TOHTML=none
996 fi
997
998 latex_to_html_command=$TOHTML
999 case $TOHTML in
1000         tth) latex_to_html_command="tth -t -e2 -L\$\$b < \$\$i > \$\$o";;
1001  latex2html) latex_to_html_command="latex2html -no_subdir -split 0 -show_section_numbers \$\$i";;
1002       hevea) latex_to_html_command="hevea -s \$\$i";;
1003 esac
1004
1005 #### Explore the LaTeX configuration
1006 echo $ac_n "checking LaTeX configuration""... $ac_c"
1007 # First, remove the files that we want to re-create
1008 rm -f textclass.lst packages.lst chkconfig.sed
1009 if test ${lyx_check_config} = no ; then
1010   echo "$ac_t""default values"
1011 else
1012   echo "$ac_t""auto"
1013   rm -f wrap_chkconfig.ltx chkconfig.vars chkconfig.classes chklayouts.tex
1014   cat >wrap_chkconfig.ltx <<EOF
1015 \\newcommand\\srcdir{${srcdir}}
1016 ${linuxdoc_cmd}
1017 ${docbook_cmd}
1018 \\input{${srcdir}/chkconfig.ltx}
1019 EOF
1020   ## Construct the list of classes to test for.
1021   # build the list of available layout files and convert it to commands 
1022   # for chkconfig.ltx 
1023   for file in ./layouts/*.layout ${srcdir}/layouts/*.layout ; do 
1024     case $file in
1025       */\*.layout) ;;
1026       *) test -r "$file" && echo $file ;;
1027     esac
1028   done | sed -e 's%^.*layouts/\(.*\)\.layout$%\\TestDocClass{\1}%'\
1029              > chklayouts.tex
1030   eval ${LATEX} wrap_chkconfig.ltx 2>/dev/null | grep '^\+'
1031   eval `cat chkconfig.vars | sed 's/-/_/g'`
1032 fi
1033
1034 # Do we have all the files we need? Useful if latex did not run
1035 echo creating textclass.lst 
1036 # if textclass.lst does not exist (because LaTeX did not run), 
1037 # then provide a standard version.
1038 if test ! -f textclass.lst ; then
1039   cat >textclass.lst <<EOF
1040 # This file declares layouts and their associated definition files
1041 # (include dir. relative to the place where this file is).
1042 # It contains only default values, since chkconfig.ltx could not be run 
1043 # for some reason. Run ./configure if you need to update it after a
1044 # configuration change.  
1045 article article article
1046 report  report  report
1047 book    book    book
1048 linuxdoc        linuxdoc        linuxdoc
1049 letter  letter  letter
1050 EOF
1051 fi
1052
1053 # if chkconfig.sed does not exist (because LaTeX did not run), 
1054 # then provide a standard version.
1055 if test ! -f chkconfig.sed ; then
1056   cat >chkconfig.sed <<EOF
1057 s/@.*@/???/g
1058 EOF
1059 fi
1060
1061 echo creating packages.lst
1062 # if packages.lst does not exist (because LaTeX did not run), 
1063 # then provide a standard version.
1064 if test ! -f packages.lst ; then
1065   cat >packages.lst <<EOF
1066 # This file should contain the list of LaTeX packages that have been
1067 # recognized by LyX. Unfortunately, since configure could not find
1068 # your LaTeX2e program, the tests have not been run. Run ./configure
1069 # if you need to update it after a configuration change.
1070
1071 EOF
1072 fi
1073
1074 echo creating doc/LaTeXConfig.lyx
1075 echo "s/@chk_linuxdoc@/$chk_linuxdoc/g" >> chkconfig.sed
1076 echo "s/@chk_docbook@/$chk_docbook/g" >> chkconfig.sed
1077 sed -f chkconfig.sed ${srcdir}/doc/LaTeXConfig.lyx.in >doc/LaTeXConfig.lyx
1078
1079 echo creating lyxrc.defaults
1080 rm -f lyxrc.defaults
1081 cat >lyxrc.defaults <<EOF
1082 # This file has been automatically generated by LyX' lib/configure
1083 # script. It contains default settings that have been determined by
1084 # examining your system. PLEASE DO NOT MODIFY ANYTHING HERE! If you
1085 # want to customize LyX, make a copy of the file LYXDIR/lyxrc as
1086 # ~/.lyx/lyxrc and edit this file instead. Any setting in lyxrc will
1087 # override the values given here.
1088 \\Format text     txt   ASCII           A
1089 \\Format textparagraph txt ASCII(paragraphs)    ""
1090 \\Format docbook  sgml  DocBook         B
1091 \\Format dvi      dvi   DVI             D
1092 \\Format eps      eps   EPS             ""
1093 \\Format fax      ""    Fax             ""
1094 \\Format gif      gif   GIF             ""
1095 \\Format html     html  HTML            H
1096 \\Format jpg      jpg   JPEG            ""
1097 \\Format latex    tex   LaTeX           L
1098 \\Format linuxdoc sgml  LinuxDoc        x
1099 \\Format lyx      lyx   LyX             ""
1100 \\Format literate nw    NoWeb           N
1101 \\Format pdf      pdf   PDF             P
1102 \\Format pdf2     pdf  "PDF (pdflatex)" F
1103 \\Format png      png   PNG             ""
1104 \\Format ps       ps    Postscript      t
1105 \\Format program  ""    Program         ""
1106 \\Format word     doc   Word            W
1107
1108
1109 \\converter latex dvi "$LATEX \$\$i" "latex"
1110 \\converter latex pdf2 "$PDFLATEX \$\$i" "latex"
1111 \\converter latex html "$latex_to_html_command" "originaldir,needaux"
1112 \\converter literate latex "$literate_to_tex_command" ""
1113 \\converter dvi ps "$dvi_to_ps_command" ""
1114 \\converter ps pdf "$ps_to_pdf_command" ""
1115 \\converter ps fax "$fax_command" ""
1116 \\converter linuxdoc lyx "$linuxdoc_to_lyx_command" ""
1117 \\converter linuxdoc latex "$linuxdoc_to_latex_command" ""
1118 \\converter linuxdoc dvi "$linuxdoc_to_dvi_command" ""
1119 \\converter linuxdoc html "$linuxdoc_to_html_command" ""
1120 \\converter docbook dvi "$docbook_to_dvi_command" ""
1121 \\converter docbook html "$docbook_to_html_command" ""
1122
1123 \\converter latex lyx "$tex_to_lyx_command" ""
1124 \\converter literate lyx "$literate_to_lyx_command" ""
1125 \\converter html latex "$html_to_latex_command" ""
1126 \\converter word latex "$word_to_latex_command" ""
1127
1128 \converter gif eps "$image_command" ""
1129 \converter png eps "$image_command" ""
1130 \converter jpg eps "$image_command" ""
1131 \converter gif png "$image_command" ""
1132
1133 \\viewer dvi "$DVI_VIEWER"
1134 \\viewer html "$HTML_VIEWER"
1135 \\viewer pdf "$PDF_VIEWER"
1136 \\viewer ps "$GHOSTVIEW -swap"
1137 \\viewer eps "$GHOSTVIEW"
1138
1139 \\ps_command "$GS"
1140 \\ascii_roff_command "$ascii_roff_command"
1141 \\chktex_command "$chktex_command"
1142 \\spell_command "$SPELL"
1143 \\print_spool_command "$print_spool_command"
1144 \\print_spool_printerprefix "$print_spool_printerprefix"
1145 \\font_encoding "$chk_fontenc"
1146 EOF
1147
1148 # Remove superfluous files if we are not writing in the main lib
1149 # directory 
1150 for file in lyxrc.defaults textclass.lst packages.lst \
1151             doc/LaTeXConfig.lyx ; do
1152   # we rename the file first, so that we avoid comparing a file with itself
1153   mv $file $file.new
1154   if test -r $srcdir/$file && diff $file.new $srcdir/$file >/dev/null 2>/dev/null ; 
1155   then 
1156     echo "removing $file, which is identical to the system global version"
1157     rm -f $file.new
1158   else
1159     mv $file.new $file
1160   fi
1161 done
1162
1163
1164 # Final clean-up
1165 if test $lyx_keep_temps = no ; then
1166 rm -f chkconfig.sed chkconfig.vars wrap_chkconfig.* chklayouts.tex \
1167       missfont.log
1168 fi