]> git.lyx.org Git - lyx.git/blob - lib/configure
small changes and two patches from Dekel
[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 reLyX LaTeX-to-LyX translator""... $ac_c"
191 echo "$ac_t""(reLyX)"
192 RELYX=
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       RELYX="$ac_prog"
204       break
205     fi
206   done
207   IFS="$ac_save_ifs"
208
209   if test -n "$RELYX"; then
210     ac_result=yes
211   else
212     ac_result=no
213   fi
214   
215   echo "$ac_t""$ac_result"
216   test -n "$RELYX" && break
217 fi
218 done
219
220 if test -z "$RELYX" ; then
221   RELYX=none
222 fi
223
224 PATH=${save_PATH}
225
226 # Search something to process a literate document
227 echo $ac_n "checking for a Literate programming processor""... $ac_c"
228 echo "$ac_t""(noweave)"
229 LITERATE=
230 for ac_prog in noweave
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="$ac_prog"
241       break
242     fi
243   done
244   IFS="$ac_save_ifs"
245
246   if test -n "$LITERATE"; then
247     ac_result=yes
248   else
249     ac_result=no
250   fi
251   
252   echo "$ac_t""$ac_result"
253   test -n "$LITERATE" && break
254 fi
255 done
256
257 if test -z "$LITERATE" ; then
258   LITERATE=none
259 fi
260
261 test $LITERATE = "noweave" && LITERATE="noweave -delay -index \$\$FName > \$\$OutName"
262 LITERATE_EXT="nw"
263
264 # Search for a Postscript interpreter
265 echo $ac_n "checking for a Postscript interpreter""... $ac_c"
266 echo "$ac_t""(gs)"
267 GS=
268 for ac_prog in gs
269 do
270 # Extract the first word of "$ac_prog", so it can be a program name with args.
271 set dummy $ac_prog ; ac_word=$2
272 if test -n "$ac_word"; then
273   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
274   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
275   for ac_dir in $PATH; do
276     test -z "$ac_dir" && ac_dir=.
277     if test -x $ac_dir/$ac_word; then
278       GS="$ac_prog"
279       break
280     fi
281   done
282   IFS="$ac_save_ifs"
283
284   if test -n "$GS"; then
285     ac_result=yes
286   else
287     ac_result=no
288   fi
289   
290   echo "$ac_t""$ac_result"
291   test -n "$GS" && break
292 fi
293 done
294
295 if test -z "$GS" ; then
296   GS=none
297 fi
298
299
300 # Search something to preview postscript
301 echo $ac_n "checking for a Postscript previewer""... $ac_c"
302 echo "$ac_t""(gv ghostview)"
303 GHOSTVIEW=
304 for ac_prog in gv ghostview
305 do
306 # Extract the first word of "$ac_prog", so it can be a program name with args.
307 set dummy $ac_prog ; ac_word=$2
308 if test -n "$ac_word"; then
309   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
310   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
311   for ac_dir in $PATH; do
312     test -z "$ac_dir" && ac_dir=.
313     if test -x $ac_dir/$ac_word; then
314       GHOSTVIEW="$ac_prog"
315       break
316     fi
317   done
318   IFS="$ac_save_ifs"
319
320   if test -n "$GHOSTVIEW"; then
321     ac_result=yes
322   else
323     ac_result=no
324   fi
325   
326   echo "$ac_t""$ac_result"
327   test -n "$GHOSTVIEW" && break
328 fi
329 done
330
331 if test -z "$GHOSTVIEW" ; then
332   GHOSTVIEW=none
333 fi
334
335
336 # Search for a program to preview pdf
337 echo $ac_n "checking for a PDF preview""... $ac_c"
338 echo "$ac_t""(xpdf acroread gv ghostview)"
339 PDF_VIEWER=
340 for ac_prog in xpdf acroread gv ghostview
341 do
342 # Extract the first word of "$ac_prog", so it can be a program name with args.
343 set dummy $ac_prog ; ac_word=$2
344 if test -n "$ac_word"; then
345   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
346   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
347   for ac_dir in $PATH; do
348     test -z "$ac_dir" && ac_dir=.
349     if test -x $ac_dir/$ac_word; then
350       PDF_VIEWER="$ac_prog"
351       break
352     fi
353   done
354   IFS="$ac_save_ifs"
355
356   if test -n "$PDF_VIEWER"; then
357     ac_result=yes
358   else
359     ac_result=no
360   fi
361   
362   echo "$ac_t""$ac_result"
363   test -n "$PDF_VIEWER" && break
364 fi
365 done
366
367 if test -z "$PDF_VIEWER" ; then
368   PDF_VIEWER=none
369 fi
370
371
372 # Search something to preview dvi
373 echo $ac_n "checking for a DVI previewer""... $ac_c"
374 echo "$ac_t""(xdvi)"
375 DVI_VIEWER=
376 for ac_prog in xdvi
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       DVI_VIEWER="$ac_prog"
387       break
388     fi
389   done
390   IFS="$ac_save_ifs"
391
392   if test -n "$DVI_VIEWER"; then
393     ac_result=yes
394   else
395     ac_result=no
396   fi
397   
398   echo "$ac_t""$ac_result"
399   test -n "$DVI_VIEWER" && break
400 fi
401 done
402
403 if test -z "$DVI_VIEWER" ; then
404   DVI_VIEWER=none
405 fi
406
407
408 # Search something to preview html
409 echo $ac_n "checking for a HTML previewer""... $ac_c"
410 echo "$ac_t""(netscape)"
411 HTML_VIEWER=
412 for ac_prog in netscape
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       HTML_VIEWER="$ac_prog"
423       break
424     fi
425   done
426   IFS="$ac_save_ifs"
427
428   if test -n "$HTML_VIEWER"; then
429     ac_result=yes
430   else
431     ac_result=no
432   fi
433   
434   echo "$ac_t""$ac_result"
435   test -n "$HTML_VIEWER" && break
436 fi
437 done
438
439 if test -z "$HTML_VIEWER" ; then
440   HTML_VIEWER=none
441 fi
442
443
444 # Search for a program to convert ps to pdf
445 echo $ac_n "checking for a PS to PDF converter""... $ac_c"
446 echo "$ac_t""(ps2pdf)"
447 ps_to_pdf_command=
448 for ac_prog in ps2pdf
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       ps_to_pdf_command="$ac_prog"
459       break
460     fi
461   done
462   IFS="$ac_save_ifs"
463
464   if test -n "$ps_to_pdf_command"; then
465     ac_result=yes
466   else
467     ac_result=no
468   fi
469   
470   echo "$ac_t""$ac_result"
471   test -n "$ps_to_pdf_command" && break
472 fi
473 done
474
475 if test -z "$ps_to_pdf_command" ; then
476   ps_to_pdf_command=none
477 fi
478
479 test $ps_to_pdf_command = "ps2pdf" && ps_to_pdf_command="ps2pdf \$\$FName"
480
481 # Search for a program to convert dvi to ps
482 echo $ac_n "checking for a DVI to PS converter""... $ac_c"
483 echo "$ac_t""(dvips)"
484 dvi_to_ps_command=
485 for ac_prog in dvips
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       dvi_to_ps_command="$ac_prog"
496       break
497     fi
498   done
499   IFS="$ac_save_ifs"
500
501   if test -n "$dvi_to_ps_command"; then
502     ac_result=yes
503   else
504     ac_result=no
505   fi
506   
507   echo "$ac_t""$ac_result"
508   test -n "$dvi_to_ps_command" && break
509 fi
510 done
511
512 if test -z "$dvi_to_ps_command" ; then
513   dvi_to_ps_command=none
514 fi
515
516 test $dvi_to_ps_command = "dvips" && dvi_to_ps_command="dvips -o \$\$OutName \$\$FName"
517
518 # Search a *roff program (used to translate tables in ASCII export)
519 echo $ac_n "checking for a *roff formatter""... $ac_c"
520 echo "$ac_t""(groff nroff)"
521 ROFF=
522 for ac_prog in groff nroff
523 do
524 # Extract the first word of "$ac_prog", so it can be a program name with args.
525 set dummy $ac_prog ; ac_word=$2
526 if test -n "$ac_word"; then
527   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
528   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
529   for ac_dir in $PATH; do
530     test -z "$ac_dir" && ac_dir=.
531     if test -x $ac_dir/$ac_word; then
532       ROFF="$ac_prog"
533       break
534     fi
535   done
536   IFS="$ac_save_ifs"
537
538   if test -n "$ROFF"; then
539     ac_result=yes
540   else
541     ac_result=no
542   fi
543   
544   echo "$ac_t""$ac_result"
545   test -n "$ROFF" && break
546 fi
547 done
548
549 if test -z "$ROFF" ; then
550   ROFF=none
551 fi
552
553 ascii_roff_command=$ROFF
554 test $ROFF = "groff" && ascii_roff_command="groff -t -Tlatin1 \$\$FName"
555 test $ROFF = "nroff" && ascii_roff_command="tbl \$\$FName | nroff"
556
557 # Search the ChkTeX program
558 echo $ac_n "checking for ChkTeX""... $ac_c"
559 echo "$ac_t""(chktex)"
560 CHKTEX=
561 for ac_prog in chktex
562 do
563 # Extract the first word of "$ac_prog", so it can be a program name with args.
564 set dummy $ac_prog ; ac_word=$2
565 if test -n "$ac_word"; then
566   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
567   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
568   for ac_dir in $PATH; do
569     test -z "$ac_dir" && ac_dir=.
570     if test -x $ac_dir/$ac_word; then
571       CHKTEX="$ac_prog"
572       break
573     fi
574   done
575   IFS="$ac_save_ifs"
576
577   if test -n "$CHKTEX"; then
578     ac_result=yes
579   else
580     ac_result=no
581   fi
582   
583   echo "$ac_t""$ac_result"
584   test -n "$CHKTEX" && break
585 fi
586 done
587
588 if test -z "$CHKTEX" ; then
589   CHKTEX=none
590 fi
591
592 chktex_command=$CHKTEX
593 test $CHKTEX = "chktex" && chktex_command="$CHKTEX -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38"
594
595 # Search for a spellchecker
596 echo $ac_n "checking for a spell-checker""... $ac_c"
597 echo "$ac_t""(ispell)"
598 SPELL=
599 for ac_prog in ispell
600 do
601 # Extract the first word of "$ac_prog", so it can be a program name with args.
602 set dummy $ac_prog ; ac_word=$2
603 if test -n "$ac_word"; then
604   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
605   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
606   for ac_dir in $PATH; do
607     test -z "$ac_dir" && ac_dir=.
608     if test -x $ac_dir/$ac_word; then
609       SPELL="$ac_prog"
610       break
611     fi
612   done
613   IFS="$ac_save_ifs"
614
615   if test -n "$SPELL"; then
616     ac_result=yes
617   else
618     ac_result=no
619   fi
620   
621   echo "$ac_t""$ac_result"
622   test -n "$SPELL" && break
623 fi
624 done
625
626 if test -z "$SPELL" ; then
627   SPELL=none
628 fi
629
630
631 # Search a Fax handling program
632 echo $ac_n "checking for a fax driver""... $ac_c"
633 echo "$ac_t""(sendfax faxsend fax)"
634 FAX=
635 for ac_prog in sendfax faxsend fax
636 do
637 # Extract the first word of "$ac_prog", so it can be a program name with args.
638 set dummy $ac_prog ; ac_word=$2
639 if test -n "$ac_word"; then
640   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
641   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
642   for ac_dir in $PATH; do
643     test -z "$ac_dir" && ac_dir=.
644     if test -x $ac_dir/$ac_word; then
645       FAX="$ac_prog"
646       break
647     fi
648   done
649   IFS="$ac_save_ifs"
650
651   if test -n "$FAX"; then
652     ac_result=yes
653   else
654     ac_result=no
655   fi
656   
657   echo "$ac_t""$ac_result"
658   test -n "$FAX" && break
659 fi
660 done
661
662 if test -z "$FAX" ; then
663   FAX=none
664 fi
665
666 if test $FAX = sendfax ; then
667   fax_command="sendfax -n -h '\$\$Host' -c '\$\$Comment' -x '\$\$Enterprise' -d '\$\$Name'@'\$\$Phone' '\$\$FName'"
668 elif test $FAX = faxsend ; then
669   fax_command="faxsend '\$\$Phone' '\$\$FName'"
670 elif test $FAX = fax ; then
671   fax_command="fax send '\$\$Phone' '\$\$FName'"
672 else
673   fax_command="none"
674 fi
675
676 # Search for LinuxDoc support
677 echo $ac_n "checking for SGML-tools 1.x (LinuxDoc)""... $ac_c"
678 echo "$ac_t""(sgml2lyx)"
679 LINUXDOC=
680 for ac_prog in sgml2lyx
681 do
682 # Extract the first word of "$ac_prog", so it can be a program name with args.
683 set dummy $ac_prog ; ac_word=$2
684 if test -n "$ac_word"; then
685   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
686   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
687   for ac_dir in $PATH; do
688     test -z "$ac_dir" && ac_dir=.
689     if test -x $ac_dir/$ac_word; then
690       LINUXDOC="$ac_prog"
691       break
692     fi
693   done
694   IFS="$ac_save_ifs"
695
696   if test -n "$LINUXDOC"; then
697     ac_result=yes
698   else
699     ac_result=no
700   fi
701   
702   echo "$ac_t""$ac_result"
703   test -n "$LINUXDOC" && break
704 fi
705 done
706
707 if test -z "$LINUXDOC" ; then
708   LINUXDOC=none
709 fi
710
711 chk_linuxdoc=no
712 if test $LINUXDOC != none; then
713   chk_linuxdoc=yes
714   linuxdoc_cmd="\\def\\haslinuxdoc{yes}"
715 fi
716
717 case $LINUXDOC in
718   sgml2lyx)
719     linuxdoc_to_latex_command="sgml2latex \$\$FName"
720     linuxdoc_to_dvi_command="sgml2latex -o dvi \$\$FName"
721     linuxdoc_to_html_command="sgml2html \$\$FName"
722     linuxdoc_to_lyx_command="sgml2lyx";;
723   none)
724     linuxdoc_to_latex_command="none"
725     linuxdoc_to_dvi_command="none"
726     linuxdoc_to_html_command="none"
727     linuxdoc_to_lyx_command="none";;
728 esac
729
730 # Search for DocBook support
731 echo $ac_n "checking for SGML-tools 2.x (DocBook) or db2x scripts""... $ac_c"
732 echo "$ac_t""(sgmltools db2dvi)"
733 DOCBOOK=
734 for ac_prog in sgmltools db2dvi
735 do
736 # Extract the first word of "$ac_prog", so it can be a program name with args.
737 set dummy $ac_prog ; ac_word=$2
738 if test -n "$ac_word"; then
739   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
740   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
741   for ac_dir in $PATH; do
742     test -z "$ac_dir" && ac_dir=.
743     if test -x $ac_dir/$ac_word; then
744       DOCBOOK="$ac_prog"
745       break
746     fi
747   done
748   IFS="$ac_save_ifs"
749
750   if test -n "$DOCBOOK"; then
751     ac_result=yes
752   else
753     ac_result=no
754   fi
755   
756   echo "$ac_t""$ac_result"
757   test -n "$DOCBOOK" && break
758 fi
759 done
760
761 if test -z "$DOCBOOK" ; then
762   DOCBOOK=none
763 fi
764
765 chk_docbook=no
766 if test $DOCBOOK != none; then
767   chk_docbook=yes
768   docbook_cmd="\\def\\hasdocbook{yes}"
769 fi
770
771 case $DOCBOOK in
772   sgmltools)
773     docbook_to_dvi_command="sgmltools -b dvi \$\$FName"
774     docbook_to_html_command="sgmltools -b html \$\$FName";;
775   db2dvi)
776     docbook_to_dvi_command="db2dvi \$\$FName"
777     docbook_to_html_command="db2html \$\$FName";;
778   none)
779     docbook_to_dvi_command="none"
780     docbook_to_html_command="none";;
781 esac
782
783 # Search for a spool command
784 echo $ac_n "checking for a spool command""... $ac_c"
785 echo "$ac_t""(lp lpr)"
786 LPR=
787 for ac_prog in lp lpr
788 do
789 # Extract the first word of "$ac_prog", so it can be a program name with args.
790 set dummy $ac_prog ; ac_word=$2
791 if test -n "$ac_word"; then
792   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
793   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
794   for ac_dir in $PATH; do
795     test -z "$ac_dir" && ac_dir=.
796     if test -x $ac_dir/$ac_word; then
797       LPR="$ac_prog"
798       break
799     fi
800   done
801   IFS="$ac_save_ifs"
802
803   if test -n "$LPR"; then
804     ac_result=yes
805   else
806     ac_result=no
807   fi
808   
809   echo "$ac_t""$ac_result"
810   test -n "$LPR" && break
811 fi
812 done
813
814 if test -z "$LPR" ; then
815   LPR=none
816 fi
817
818 case $LPR in
819   lp) print_spool_command=lp
820       print_spool_printerprefix="-d ";;
821  lpr) print_spool_command=lpr
822       print_spool_printerprefix="-P";;
823    *) :;; # leave to empty values
824 esac
825
826 # Search for a latex to html converter
827 echo $ac_n "checking for an HTML converter""... $ac_c"
828 echo "$ac_t""(tth latex2html hevea)"
829 TOHTML=
830 for ac_prog in tth latex2html hevea
831 do
832 # Extract the first word of "$ac_prog", so it can be a program name with args.
833 set dummy $ac_prog ; ac_word=$2
834 if test -n "$ac_word"; then
835   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
836   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
837   for ac_dir in $PATH; do
838     test -z "$ac_dir" && ac_dir=.
839     if test -x $ac_dir/$ac_word; then
840       TOHTML="$ac_prog"
841       break
842     fi
843   done
844   IFS="$ac_save_ifs"
845
846   if test -n "$TOHTML"; then
847     ac_result=yes
848   else
849     ac_result=no
850   fi
851   
852   echo "$ac_t""$ac_result"
853   test -n "$TOHTML" && break
854 fi
855 done
856
857 if test -z "$TOHTML" ; then
858   TOHTML=none
859 fi
860
861 latex_to_html_command = $TOHTML
862 case $TOHTML in
863         tth) latex_to_html_command="tth -t -e2 -L\$\$BaseName < \$\$FName > \$\$OutName";;
864  latex2html) latex_to_html_command="latex2html -no_subdir -split 0 -show_section_numbers \$\$FName";;
865       hevea) latex_to_html_command="hevea -s \$\$FName";;
866 esac
867
868 #### Explore the LaTeX configuration
869 echo $ac_n "checking LaTeX configuration""... $ac_c"
870 # First, remove the files that we want to re-create
871 rm -f textclass.lst packages.lst chkconfig.sed
872 if test ${lyx_check_config} = no ; then
873   echo "$ac_t""default values"
874 else
875   echo "$ac_t""auto"
876   rm -f wrap_chkconfig.ltx chkconfig.vars chkconfig.classes chklayouts.tex
877   cat >wrap_chkconfig.ltx <<EOF
878 \\newcommand\\srcdir{${srcdir}}
879 ${linuxdoc_cmd}
880 ${docbook_cmd}
881 \\input{${srcdir}/chkconfig.ltx}
882 EOF
883   ## Construct the list of classes to test for.
884   # build the list of available layout files and convert it to commands 
885   # for chkconfig.ltx 
886   for file in ./layouts/*.layout ${srcdir}/layouts/*.layout ; do 
887     case $file in
888       */\*.layout) ;;
889       *) test -r "$file" && echo $file ;;
890     esac
891   done | sed -e 's%^.*layouts/\(.*\)\.layout$%\\TestDocClass{\1}%'\
892              > chklayouts.tex
893   eval ${LATEX} wrap_chkconfig.ltx 2>/dev/null | grep '^\+'
894   eval `cat chkconfig.vars | sed 's/-/_/g'`
895 fi
896
897 # Do we have all the files we need? Useful if latex did not run
898 echo creating textclass.lst 
899 # if textclass.lst does not exist (because LaTeX did not run), 
900 # then provide a standard version.
901 if test ! -f textclass.lst ; then
902   cat >textclass.lst <<EOF
903 # This file declares layouts and their associated definition files
904 # (include dir. relative to the place where this file is).
905 # It contains only default values, since chkconfig.ltx could not be run 
906 # for some reason. Run ./configure if you need to update it after a
907 # configuration change.  
908 article article article
909 report  report  report
910 book    book    book
911 linuxdoc        linuxdoc        linuxdoc
912 letter  letter  letter
913 EOF
914 fi
915
916 # if chkconfig.sed does not exist (because LaTeX did not run), 
917 # then provide a standard version.
918 if test ! -f chkconfig.sed ; then
919   cat >chkconfig.sed <<EOF
920 s/@.*@/???/g
921 EOF
922 fi
923
924 echo creating packages.lst
925 # if packages.lst does not exist (because LaTeX did not run), 
926 # then provide a standard version.
927 if test ! -f packages.lst ; then
928   cat >packages.lst <<EOF
929 # This file should contain the list of LaTeX packages that have been
930 # recognized by LyX. Unfortunately, since configure could not find
931 # your LaTeX2e program, the tests have not been run. Run ./configure
932 # if you need to update it after a configuration change.
933
934 EOF
935 fi
936
937 echo creating doc/LaTeXConfig.lyx
938 echo "s/@chk_linuxdoc@/$chk_linuxdoc/g" >> chkconfig.sed
939 echo "s/@chk_docbook@/$chk_docbook/g" >> chkconfig.sed
940 sed -f chkconfig.sed ${srcdir}/doc/LaTeXConfig.lyx.in >doc/LaTeXConfig.lyx
941
942 echo creating lyxrc.defaults
943 rm -f lyxrc.defaults
944 cat >lyxrc.defaults <<EOF
945 # This file has been automatically generated by LyX' lib/configure
946 # script. It contains default settings that have been determined by
947 # examining your system. PLEASE DO NOT MODIFY ANYTHING HERE! If you
948 # want to customize LyX, make a copy of the file LYXDIR/lyxrc as
949 # ~/.lyx/lyxrc and edit this file instead. Any setting in lyxrc will
950 # override the values given here.
951 \\converter tex dvi "$LATEX" ""
952 \\converter tex pdf "$PDFLATEX" ""
953 \\converter dvi ps "$dvi_to_ps_command" ""
954 \\converter ps pdf "$ps_to_pdf_command" ""
955 \\converter sgml tex "$linuxdoc_to_latex_command" ""
956 \\converter sgml dvi "$linuxdoc_to_dvi_command" ""
957 \\converter sgml html "$linuxdoc_to_html_command" ""
958 \\converter docbook dvi "$docbook_to_dvi_command" ""
959 \\converter docbook html "$docbook_to_html_command" ""
960 \\converter tex html "$latex_to_html_command"
961         "originaldir,needaux"
962 \\converter $LITERATE_EXT tex "$LITERATE" ""
963
964 \\viewer dvi "$DVI_VIEWER"
965 \\viewer html "$HTML_VIEWER"
966 \\viewer pdf "$PDF_VIEWER"
967 \\viewer ps "$GHOSTVIEW -swap"
968 \\viewer eps "$GHOSTVIEW"
969
970 \\relyx_command "$RELYX"
971 \\linuxdoc_to_lyx_command "$linuxdoc_to_lyx_command"
972 \\literate_extension "$LITERATE_EXT"
973 \\ps_command "$GS"
974 \\ascii_roff_command "$ascii_roff_command"
975 \\chktex_command "$chktex_command"
976 \\spell_command "$SPELL"
977 \\fax_command "$fax_command"
978 \\print_spool_command "$print_spool_command"
979 \\print_spool_printerprefix "$print_spool_printerprefix"
980 \\font_encoding "$chk_fontenc"
981 EOF
982
983 # Remove superfluous files if we are not writing in the main lib
984 # directory 
985 for file in lyxrc.defaults textclass.lst packages.lst \
986             doc/LaTeXConfig.lyx ; do
987   # we rename the file first, so that we avoid comparing a file with itself
988   mv $file $file.new
989   if test -r $srcdir/$file && diff $file.new $srcdir/$file >/dev/null 2>/dev/null ; 
990   then 
991     echo "removing $file, which is identical to the system global version"
992     rm -f $file.new
993   else
994     mv $file.new $file
995   fi
996 done
997
998
999 # Final clean-up
1000 if test $lyx_keep_temps = no ; then
1001 rm -f chkconfig.sed chkconfig.vars wrap_chkconfig.* chklayouts.tex \
1002       missfont.log
1003 fi