]> git.lyx.org Git - lyx.git/blob - lib/configure
Angus latest patch + some tweaks
[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 \$\$FName"
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 \$\$FName \$\$OutName"
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 \$\$FName > \$\$OutName"
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 \$\$FName"
335
336 echo $ac_n "checking for Image converter""... $ac_c"
337 echo "$ac_t""(convert)"
338 image_command=
339 for ac_prog in convert
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       image_command="$ac_prog"
350       break
351     fi
352   done
353   IFS="$ac_save_ifs"
354
355   if test -n "$image_command"; then
356     ac_result=yes
357   else
358     ac_result=no
359   fi
360   
361   echo "$ac_t""$ac_result"
362   test -n "$image_command" && break
363 fi
364 done
365
366 if test -z "$image_command" ; then
367   image_command=none
368 fi
369
370 test $image_command = "convert" && image_command="convert \$\$FName \$\$OutName"
371
372 # Search for a Postscript interpreter
373 echo $ac_n "checking for a Postscript interpreter""... $ac_c"
374 echo "$ac_t""(gs)"
375 GS=
376 for ac_prog in gs
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       GS="$ac_prog"
387       break
388     fi
389   done
390   IFS="$ac_save_ifs"
391
392   if test -n "$GS"; then
393     ac_result=yes
394   else
395     ac_result=no
396   fi
397   
398   echo "$ac_t""$ac_result"
399   test -n "$GS" && break
400 fi
401 done
402
403 if test -z "$GS" ; then
404   GS=none
405 fi
406
407
408 # Search something to preview postscript
409 echo $ac_n "checking for a Postscript previewer""... $ac_c"
410 echo "$ac_t""(gv ghostview)"
411 GHOSTVIEW=
412 for ac_prog in gv ghostview
413 do
414 # Extract the first word of "$ac_prog", so it can be a program name with args.
415 set dummy $ac_prog ; ac_word=$2
416 if test -n "$ac_word"; then
417   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
418   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
419   for ac_dir in $PATH; do
420     test -z "$ac_dir" && ac_dir=.
421     if test -x $ac_dir/$ac_word; then
422       GHOSTVIEW="$ac_prog"
423       break
424     fi
425   done
426   IFS="$ac_save_ifs"
427
428   if test -n "$GHOSTVIEW"; then
429     ac_result=yes
430   else
431     ac_result=no
432   fi
433   
434   echo "$ac_t""$ac_result"
435   test -n "$GHOSTVIEW" && break
436 fi
437 done
438
439 if test -z "$GHOSTVIEW" ; then
440   GHOSTVIEW=none
441 fi
442
443
444 # Search for a program to preview pdf
445 echo $ac_n "checking for a PDF preview""... $ac_c"
446 echo "$ac_t""(acroread gv ghostview xpdf)"
447 PDF_VIEWER=
448 for ac_prog in acroread gv ghostview xpdf
449 do
450 # Extract the first word of "$ac_prog", so it can be a program name with args.
451 set dummy $ac_prog ; ac_word=$2
452 if test -n "$ac_word"; then
453   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
454   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
455   for ac_dir in $PATH; do
456     test -z "$ac_dir" && ac_dir=.
457     if test -x $ac_dir/$ac_word; then
458       PDF_VIEWER="$ac_prog"
459       break
460     fi
461   done
462   IFS="$ac_save_ifs"
463
464   if test -n "$PDF_VIEWER"; then
465     ac_result=yes
466   else
467     ac_result=no
468   fi
469   
470   echo "$ac_t""$ac_result"
471   test -n "$PDF_VIEWER" && break
472 fi
473 done
474
475 if test -z "$PDF_VIEWER" ; then
476   PDF_VIEWER=none
477 fi
478
479
480 # Search something to preview dvi
481 echo $ac_n "checking for a DVI previewer""... $ac_c"
482 echo "$ac_t""(xdvi)"
483 DVI_VIEWER=
484 for ac_prog in xdvi
485 do
486 # Extract the first word of "$ac_prog", so it can be a program name with args.
487 set dummy $ac_prog ; ac_word=$2
488 if test -n "$ac_word"; then
489   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
490   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
491   for ac_dir in $PATH; do
492     test -z "$ac_dir" && ac_dir=.
493     if test -x $ac_dir/$ac_word; then
494       DVI_VIEWER="$ac_prog"
495       break
496     fi
497   done
498   IFS="$ac_save_ifs"
499
500   if test -n "$DVI_VIEWER"; then
501     ac_result=yes
502   else
503     ac_result=no
504   fi
505   
506   echo "$ac_t""$ac_result"
507   test -n "$DVI_VIEWER" && break
508 fi
509 done
510
511 if test -z "$DVI_VIEWER" ; then
512   DVI_VIEWER=none
513 fi
514
515
516 # Search something to preview html
517 echo $ac_n "checking for a HTML previewer""... $ac_c"
518 echo "$ac_t""(netscape)"
519 HTML_VIEWER=
520 for ac_prog in netscape
521 do
522 # Extract the first word of "$ac_prog", so it can be a program name with args.
523 set dummy $ac_prog ; ac_word=$2
524 if test -n "$ac_word"; then
525   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
526   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
527   for ac_dir in $PATH; do
528     test -z "$ac_dir" && ac_dir=.
529     if test -x $ac_dir/$ac_word; then
530       HTML_VIEWER="$ac_prog"
531       break
532     fi
533   done
534   IFS="$ac_save_ifs"
535
536   if test -n "$HTML_VIEWER"; then
537     ac_result=yes
538   else
539     ac_result=no
540   fi
541   
542   echo "$ac_t""$ac_result"
543   test -n "$HTML_VIEWER" && break
544 fi
545 done
546
547 if test -z "$HTML_VIEWER" ; then
548   HTML_VIEWER=none
549 fi
550
551
552 # Search for a program to convert ps to pdf
553 echo $ac_n "checking for a PS to PDF converter""... $ac_c"
554 echo "$ac_t""(ps2pdf)"
555 ps_to_pdf_command=
556 for ac_prog in ps2pdf
557 do
558 # Extract the first word of "$ac_prog", so it can be a program name with args.
559 set dummy $ac_prog ; ac_word=$2
560 if test -n "$ac_word"; then
561   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
562   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
563   for ac_dir in $PATH; do
564     test -z "$ac_dir" && ac_dir=.
565     if test -x $ac_dir/$ac_word; then
566       ps_to_pdf_command="$ac_prog"
567       break
568     fi
569   done
570   IFS="$ac_save_ifs"
571
572   if test -n "$ps_to_pdf_command"; then
573     ac_result=yes
574   else
575     ac_result=no
576   fi
577   
578   echo "$ac_t""$ac_result"
579   test -n "$ps_to_pdf_command" && break
580 fi
581 done
582
583 if test -z "$ps_to_pdf_command" ; then
584   ps_to_pdf_command=none
585 fi
586
587 test $ps_to_pdf_command = "ps2pdf" && ps_to_pdf_command="ps2pdf \$\$FName"
588
589 # Search for a program to convert dvi to ps
590 echo $ac_n "checking for a DVI to PS converter""... $ac_c"
591 echo "$ac_t""(dvips)"
592 dvi_to_ps_command=
593 for ac_prog in dvips
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       dvi_to_ps_command="$ac_prog"
604       break
605     fi
606   done
607   IFS="$ac_save_ifs"
608
609   if test -n "$dvi_to_ps_command"; then
610     ac_result=yes
611   else
612     ac_result=no
613   fi
614   
615   echo "$ac_t""$ac_result"
616   test -n "$dvi_to_ps_command" && break
617 fi
618 done
619
620 if test -z "$dvi_to_ps_command" ; then
621   dvi_to_ps_command=none
622 fi
623
624 test $dvi_to_ps_command = "dvips" && dvi_to_ps_command="dvips -o \$\$OutName \$\$FName"
625
626 # Search a *roff program (used to translate tables in ASCII export)
627 echo $ac_n "checking for a *roff formatter""... $ac_c"
628 echo "$ac_t""(groff nroff)"
629 ROFF=
630 for ac_prog in groff nroff
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       ROFF="$ac_prog"
641       break
642     fi
643   done
644   IFS="$ac_save_ifs"
645
646   if test -n "$ROFF"; then
647     ac_result=yes
648   else
649     ac_result=no
650   fi
651   
652   echo "$ac_t""$ac_result"
653   test -n "$ROFF" && break
654 fi
655 done
656
657 if test -z "$ROFF" ; then
658   ROFF=none
659 fi
660
661 ascii_roff_command=$ROFF
662 test $ROFF = "groff" && ascii_roff_command="groff -t -Tlatin1 \$\$FName"
663 test $ROFF = "nroff" && ascii_roff_command="tbl \$\$FName | nroff"
664
665 # Search the ChkTeX program
666 echo $ac_n "checking for ChkTeX""... $ac_c"
667 echo "$ac_t""(chktex)"
668 CHKTEX=
669 for ac_prog in chktex
670 do
671 # Extract the first word of "$ac_prog", so it can be a program name with args.
672 set dummy $ac_prog ; ac_word=$2
673 if test -n "$ac_word"; then
674   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
675   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
676   for ac_dir in $PATH; do
677     test -z "$ac_dir" && ac_dir=.
678     if test -x $ac_dir/$ac_word; then
679       CHKTEX="$ac_prog"
680       break
681     fi
682   done
683   IFS="$ac_save_ifs"
684
685   if test -n "$CHKTEX"; then
686     ac_result=yes
687   else
688     ac_result=no
689   fi
690   
691   echo "$ac_t""$ac_result"
692   test -n "$CHKTEX" && break
693 fi
694 done
695
696 if test -z "$CHKTEX" ; then
697   CHKTEX=none
698 fi
699
700 chktex_command=$CHKTEX
701 test $CHKTEX = "chktex" && chktex_command="$CHKTEX -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38"
702
703 # Search for a spellchecker
704 echo $ac_n "checking for a spell-checker""... $ac_c"
705 echo "$ac_t""(ispell)"
706 SPELL=
707 for ac_prog in ispell
708 do
709 # Extract the first word of "$ac_prog", so it can be a program name with args.
710 set dummy $ac_prog ; ac_word=$2
711 if test -n "$ac_word"; then
712   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
713   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
714   for ac_dir in $PATH; do
715     test -z "$ac_dir" && ac_dir=.
716     if test -x $ac_dir/$ac_word; then
717       SPELL="$ac_prog"
718       break
719     fi
720   done
721   IFS="$ac_save_ifs"
722
723   if test -n "$SPELL"; then
724     ac_result=yes
725   else
726     ac_result=no
727   fi
728   
729   echo "$ac_t""$ac_result"
730   test -n "$SPELL" && break
731 fi
732 done
733
734 if test -z "$SPELL" ; then
735   SPELL=none
736 fi
737
738
739
740 # Search for LinuxDoc support
741 echo $ac_n "checking for SGML-tools 1.x (LinuxDoc)""... $ac_c"
742 echo "$ac_t""(sgml2lyx)"
743 LINUXDOC=
744 for ac_prog in sgml2lyx
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       LINUXDOC="$ac_prog"
755       break
756     fi
757   done
758   IFS="$ac_save_ifs"
759
760   if test -n "$LINUXDOC"; then
761     ac_result=yes
762   else
763     ac_result=no
764   fi
765   
766   echo "$ac_t""$ac_result"
767   test -n "$LINUXDOC" && break
768 fi
769 done
770
771 if test -z "$LINUXDOC" ; then
772   LINUXDOC=none
773 fi
774
775 chk_linuxdoc=no
776 if test $LINUXDOC != none; then
777   chk_linuxdoc=yes
778   linuxdoc_cmd="\\def\\haslinuxdoc{yes}"
779 fi
780
781 case $LINUXDOC in
782   sgml2lyx)
783     linuxdoc_to_latex_command="sgml2latex \$\$FName"
784     linuxdoc_to_dvi_command="sgml2latex -o dvi \$\$FName"
785     linuxdoc_to_html_command="sgml2html \$\$FName"
786     linuxdoc_to_lyx_command="sgml2lyx \$\$FName";;
787   none)
788     linuxdoc_to_latex_command="none"
789     linuxdoc_to_dvi_command="none"
790     linuxdoc_to_html_command="none"
791     linuxdoc_to_lyx_command="none";;
792 esac
793
794 # Search for DocBook support
795 echo $ac_n "checking for SGML-tools 2.x (DocBook) or db2x scripts""... $ac_c"
796 echo "$ac_t""(sgmltools db2dvi)"
797 DOCBOOK=
798 for ac_prog in sgmltools db2dvi
799 do
800 # Extract the first word of "$ac_prog", so it can be a program name with args.
801 set dummy $ac_prog ; ac_word=$2
802 if test -n "$ac_word"; then
803   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
804   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
805   for ac_dir in $PATH; do
806     test -z "$ac_dir" && ac_dir=.
807     if test -x $ac_dir/$ac_word; then
808       DOCBOOK="$ac_prog"
809       break
810     fi
811   done
812   IFS="$ac_save_ifs"
813
814   if test -n "$DOCBOOK"; then
815     ac_result=yes
816   else
817     ac_result=no
818   fi
819   
820   echo "$ac_t""$ac_result"
821   test -n "$DOCBOOK" && break
822 fi
823 done
824
825 if test -z "$DOCBOOK" ; then
826   DOCBOOK=none
827 fi
828
829 chk_docbook=no
830 if test $DOCBOOK != none; then
831   chk_docbook=yes
832   docbook_cmd="\\def\\hasdocbook{yes}"
833 fi
834
835 case $DOCBOOK in
836   sgmltools)
837     docbook_to_dvi_command="sgmltools -b dvi \$\$FName"
838     docbook_to_html_command="sgmltools -b html \$\$FName";;
839   db2dvi)
840     docbook_to_dvi_command="db2dvi \$\$FName"
841     docbook_to_html_command="db2html \$\$FName";;
842   none)
843     docbook_to_dvi_command="none"
844     docbook_to_html_command="none";;
845 esac
846
847 # Search for a spool command
848 echo $ac_n "checking for a spool command""... $ac_c"
849 echo "$ac_t""(lp lpr)"
850 LPR=
851 for ac_prog in lp lpr
852 do
853 # Extract the first word of "$ac_prog", so it can be a program name with args.
854 set dummy $ac_prog ; ac_word=$2
855 if test -n "$ac_word"; then
856   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
857   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
858   for ac_dir in $PATH; do
859     test -z "$ac_dir" && ac_dir=.
860     if test -x $ac_dir/$ac_word; then
861       LPR="$ac_prog"
862       break
863     fi
864   done
865   IFS="$ac_save_ifs"
866
867   if test -n "$LPR"; then
868     ac_result=yes
869   else
870     ac_result=no
871   fi
872   
873   echo "$ac_t""$ac_result"
874   test -n "$LPR" && break
875 fi
876 done
877
878 if test -z "$LPR" ; then
879   LPR=none
880 fi
881
882 case $LPR in
883   lp) print_spool_command=lp
884       print_spool_printerprefix="-d ";;
885  lpr) print_spool_command=lpr
886       print_spool_printerprefix="-P";;
887    *) :;; # leave to empty values
888 esac
889
890 echo $ac_n "checking for a LaTeX -> HTML converter""... $ac_c"
891 echo "$ac_t""(tth latex2html hevea)"
892 TOHTML=
893 for ac_prog in tth latex2html hevea
894 do
895 # Extract the first word of "$ac_prog", so it can be a program name with args.
896 set dummy $ac_prog ; ac_word=$2
897 if test -n "$ac_word"; then
898   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
899   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
900   for ac_dir in $PATH; do
901     test -z "$ac_dir" && ac_dir=.
902     if test -x $ac_dir/$ac_word; then
903       TOHTML="$ac_prog"
904       break
905     fi
906   done
907   IFS="$ac_save_ifs"
908
909   if test -n "$TOHTML"; then
910     ac_result=yes
911   else
912     ac_result=no
913   fi
914   
915   echo "$ac_t""$ac_result"
916   test -n "$TOHTML" && break
917 fi
918 done
919
920 if test -z "$TOHTML" ; then
921   TOHTML=none
922 fi
923
924 latex_to_html_command = $TOHTML
925 case $TOHTML in
926         tth) latex_to_html_command="tth -t -e2 -L\$\$BaseName < \$\$FName > \$\$OutName";;
927  latex2html) latex_to_html_command="latex2html -no_subdir -split 0 -show_section_numbers \$\$FName";;
928       hevea) latex_to_html_command="hevea -s \$\$FName";;
929 esac
930
931 #### Explore the LaTeX configuration
932 echo $ac_n "checking LaTeX configuration""... $ac_c"
933 # First, remove the files that we want to re-create
934 rm -f textclass.lst packages.lst chkconfig.sed
935 if test ${lyx_check_config} = no ; then
936   echo "$ac_t""default values"
937 else
938   echo "$ac_t""auto"
939   rm -f wrap_chkconfig.ltx chkconfig.vars chkconfig.classes chklayouts.tex
940   cat >wrap_chkconfig.ltx <<EOF
941 \\newcommand\\srcdir{${srcdir}}
942 ${linuxdoc_cmd}
943 ${docbook_cmd}
944 \\input{${srcdir}/chkconfig.ltx}
945 EOF
946   ## Construct the list of classes to test for.
947   # build the list of available layout files and convert it to commands 
948   # for chkconfig.ltx 
949   for file in ./layouts/*.layout ${srcdir}/layouts/*.layout ; do 
950     case $file in
951       */\*.layout) ;;
952       *) test -r "$file" && echo $file ;;
953     esac
954   done | sed -e 's%^.*layouts/\(.*\)\.layout$%\\TestDocClass{\1}%'\
955              > chklayouts.tex
956   eval ${LATEX} wrap_chkconfig.ltx 2>/dev/null | grep '^\+'
957   eval `cat chkconfig.vars | sed 's/-/_/g'`
958 fi
959
960 # Do we have all the files we need? Useful if latex did not run
961 echo creating textclass.lst 
962 # if textclass.lst does not exist (because LaTeX did not run), 
963 # then provide a standard version.
964 if test ! -f textclass.lst ; then
965   cat >textclass.lst <<EOF
966 # This file declares layouts and their associated definition files
967 # (include dir. relative to the place where this file is).
968 # It contains only default values, since chkconfig.ltx could not be run 
969 # for some reason. Run ./configure if you need to update it after a
970 # configuration change.  
971 article article article
972 report  report  report
973 book    book    book
974 linuxdoc        linuxdoc        linuxdoc
975 letter  letter  letter
976 EOF
977 fi
978
979 # if chkconfig.sed does not exist (because LaTeX did not run), 
980 # then provide a standard version.
981 if test ! -f chkconfig.sed ; then
982   cat >chkconfig.sed <<EOF
983 s/@.*@/???/g
984 EOF
985 fi
986
987 echo creating packages.lst
988 # if packages.lst does not exist (because LaTeX did not run), 
989 # then provide a standard version.
990 if test ! -f packages.lst ; then
991   cat >packages.lst <<EOF
992 # This file should contain the list of LaTeX packages that have been
993 # recognized by LyX. Unfortunately, since configure could not find
994 # your LaTeX2e program, the tests have not been run. Run ./configure
995 # if you need to update it after a configuration change.
996
997 EOF
998 fi
999
1000 echo creating doc/LaTeXConfig.lyx
1001 echo "s/@chk_linuxdoc@/$chk_linuxdoc/g" >> chkconfig.sed
1002 echo "s/@chk_docbook@/$chk_docbook/g" >> chkconfig.sed
1003 sed -f chkconfig.sed ${srcdir}/doc/LaTeXConfig.lyx.in >doc/LaTeXConfig.lyx
1004
1005 echo creating lyxrc.defaults
1006 rm -f lyxrc.defaults
1007 cat >lyxrc.defaults <<EOF
1008 # This file has been automatically generated by LyX' lib/configure
1009 # script. It contains default settings that have been determined by
1010 # examining your system. PLEASE DO NOT MODIFY ANYTHING HERE! If you
1011 # want to customize LyX, make a copy of the file LYXDIR/lyxrc as
1012 # ~/.lyx/lyxrc and edit this file instead. Any setting in lyxrc will
1013 # override the values given here.
1014 \\Format latex  tex     LaTeX           L
1015 \\Format dvi    dvi     DVI             D
1016 \\Format ps     ps      Postscript      t
1017 \\Format pdf    pdf     PDF             P
1018 \\Format html   html    HTML            H
1019 \\Format text   txt     ASCII           A
1020 \\Format literate nw    NoWeb           W
1021 \\Format linuxdoc sgml  LinuxDoc        x
1022 \\Format docbook  sgml  DocBook         B
1023 \\Format program  run   Program         r
1024
1025 \\converter latex lyx "$tex_to_lyx_command" ""
1026 \\converter latex dvi "$LATEX" "latex,disable=linuxdoc&docbook"
1027 \\converter latex pdf "$PDFLATEX" "latex,disable=linuxdoc&docbook"
1028 \\converter latex html "$latex_to_html_command"
1029         "originaldir,needaux,disable=linuxdoc&docbook"
1030 \\converter literate lyx "$literate_to_lyx_command" ""
1031 \\converter literate latex "$literate_to_tex_command" ""
1032 \\converter dvi ps "$dvi_to_ps_command" ""
1033 \\converter ps pdf "$ps_to_pdf_command" ""
1034 \\converter linuxdoc lyx "$linuxdoc_to_lyx_command" ""
1035 \\converter linuxdoc latex "$linuxdoc_to_latex_command" ""
1036 \\converter linuxdoc dvi "$linuxdoc_to_dvi_command" ""
1037 \\converter linuxdoc html "$linuxdoc_to_html_command" ""
1038 \\converter docbook dvi "$docbook_to_dvi_command" ""
1039 \\converter docbook html "$docbook_to_html_command" ""
1040 \\converter html latex "$html_to_latex_command"
1041                        "disable=latex&literate&linuxdoc&docbook"
1042
1043 \converter gif eps "$image_command" ""
1044 \converter png eps "$image_command" ""
1045 \converter jpg eps "$image_command" ""
1046 \converter gif png "$image_command" ""
1047
1048 \\viewer dvi "$DVI_VIEWER"
1049 \\viewer html "$HTML_VIEWER"
1050 \\viewer pdf "$PDF_VIEWER"
1051 \\viewer ps "$GHOSTVIEW -swap"
1052 \\viewer eps "$GHOSTVIEW"
1053
1054 \\ps_command "$GS"
1055 \\ascii_roff_command "$ascii_roff_command"
1056 \\chktex_command "$chktex_command"
1057 \\spell_command "$SPELL"
1058 \\print_spool_command "$print_spool_command"
1059 \\print_spool_printerprefix "$print_spool_printerprefix"
1060 \\font_encoding "$chk_fontenc"
1061 EOF
1062
1063 # Remove superfluous files if we are not writing in the main lib
1064 # directory 
1065 for file in lyxrc.defaults textclass.lst packages.lst \
1066             doc/LaTeXConfig.lyx ; do
1067   # we rename the file first, so that we avoid comparing a file with itself
1068   mv $file $file.new
1069   if test -r $srcdir/$file && diff $file.new $srcdir/$file >/dev/null 2>/dev/null ; 
1070   then 
1071     echo "removing $file, which is identical to the system global version"
1072     rm -f $file.new
1073   else
1074     mv $file.new $file
1075   fi
1076 done
1077
1078
1079 # Final clean-up
1080 if test $lyx_keep_temps = no ; then
1081 rm -f chkconfig.sed chkconfig.vars wrap_chkconfig.* chklayouts.tex \
1082       missfont.log
1083 fi