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