]> git.lyx.org Git - lyx.git/blob - lib/configure
Oops! Forgot to commit a few files.
[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 \$\$FName > \$\$OutName")"
229 LITERATE=
230 for ac_prog in "noweave -delay -index \$\$FName > \$\$OutName"
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_dvi_command="sgml2latex -o dvi \$\$FName"
720     linuxdoc_to_html_command="sgml2html \$\$FName"
721     linuxdoc_to_lyx_command="sgml2lyx";;
722   none)
723     linuxdoc_to_latex_command="none"
724     linuxdoc_to_dvi_command="none"
725     linuxdoc_to_html_command="none"
726     linuxdoc_to_lyx_command="none";;
727 esac
728
729 # Search for DocBook support
730 echo $ac_n "checking for SGML-tools 2.x (DocBook) or db2x scripts""... $ac_c"
731 echo "$ac_t""(sgmltools db2dvi)"
732 DOCBOOK=
733 for ac_prog in sgmltools db2dvi
734 do
735 # Extract the first word of "$ac_prog", so it can be a program name with args.
736 set dummy $ac_prog ; ac_word=$2
737 if test -n "$ac_word"; then
738   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
739   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
740   for ac_dir in $PATH; do
741     test -z "$ac_dir" && ac_dir=.
742     if test -x $ac_dir/$ac_word; then
743       DOCBOOK="$ac_prog"
744       break
745     fi
746   done
747   IFS="$ac_save_ifs"
748
749   if test -n "$DOCBOOK"; then
750     ac_result=yes
751   else
752     ac_result=no
753   fi
754   
755   echo "$ac_t""$ac_result"
756   test -n "$DOCBOOK" && break
757 fi
758 done
759
760 if test -z "$DOCBOOK" ; then
761   DOCBOOK=none
762 fi
763
764 chk_docbook=no
765 if test $DOCBOOK != none; then
766   chk_docbook=yes
767   docbook_cmd="\\def\\hasdocbook{yes}"
768 fi
769
770 case $DOCBOOK in
771   sgmltools)
772     docbook_to_dvi_command="sgmltools -b dvi \$\$FName"
773     docbook_to_html_command="sgmltools -b html \$\$FName";;
774   db2dvi)
775     docbook_to_dvi_command="db2dvi \$\$FName"
776     docbook_to_html_command="db2html \$\$FName";;
777   none)
778     docbook_to_dvi_command="none"
779     docbook_to_html_command="none";;
780 esac
781
782 # Search for a spool command
783 echo $ac_n "checking for a spool command""... $ac_c"
784 echo "$ac_t""(lp lpr)"
785 LPR=
786 for ac_prog in lp lpr
787 do
788 # Extract the first word of "$ac_prog", so it can be a program name with args.
789 set dummy $ac_prog ; ac_word=$2
790 if test -n "$ac_word"; then
791   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
792   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
793   for ac_dir in $PATH; do
794     test -z "$ac_dir" && ac_dir=.
795     if test -x $ac_dir/$ac_word; then
796       LPR="$ac_prog"
797       break
798     fi
799   done
800   IFS="$ac_save_ifs"
801
802   if test -n "$LPR"; then
803     ac_result=yes
804   else
805     ac_result=no
806   fi
807   
808   echo "$ac_t""$ac_result"
809   test -n "$LPR" && break
810 fi
811 done
812
813 if test -z "$LPR" ; then
814   LPR=none
815 fi
816
817 case $LPR in
818   lp) print_spool_command=lp
819       print_spool_printerprefix="-d ";;
820  lpr) print_spool_command=lpr
821       print_spool_printerprefix="-P";;
822    *) :;; # leave to empty values
823 esac
824
825 # Search for a latex to html converter
826 echo $ac_n "checking for an HTML converter""... $ac_c"
827 echo "$ac_t""(tth latex2html hevea)"
828 TOHTML=
829 for ac_prog in tth latex2html hevea
830 do
831 # Extract the first word of "$ac_prog", so it can be a program name with args.
832 set dummy $ac_prog ; ac_word=$2
833 if test -n "$ac_word"; then
834   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
835   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
836   for ac_dir in $PATH; do
837     test -z "$ac_dir" && ac_dir=.
838     if test -x $ac_dir/$ac_word; then
839       TOHTML="$ac_prog"
840       break
841     fi
842   done
843   IFS="$ac_save_ifs"
844
845   if test -n "$TOHTML"; then
846     ac_result=yes
847   else
848     ac_result=no
849   fi
850   
851   echo "$ac_t""$ac_result"
852   test -n "$TOHTML" && break
853 fi
854 done
855
856 if test -z "$TOHTML" ; then
857   TOHTML=none
858 fi
859
860 latex_to_html_command = $TOHTML
861 case $TOHTML in
862         tth) latex_to_html_command="tth -t -e2 -L\$\$BaseName < \$\$FName > \$\$OutName";;
863  latex2html) latex_to_html_command="latex2html -no_subdir -split 0 -show_section_numbers \$\$FName";;
864       hevea) latex_to_html_command="hevea -s \$\$FName";;
865 esac
866
867 #### Explore the LaTeX configuration
868 echo $ac_n "checking LaTeX configuration""... $ac_c"
869 # First, remove the files that we want to re-create
870 rm -f textclass.lst packages.lst chkconfig.sed
871 if test ${lyx_check_config} = no ; then
872   echo "$ac_t""default values"
873 else
874   echo "$ac_t""auto"
875   rm -f wrap_chkconfig.ltx chkconfig.vars chkconfig.classes chklayouts.tex
876   cat >wrap_chkconfig.ltx <<EOF
877 \\newcommand\\srcdir{${srcdir}}
878 ${linuxdoc_cmd}
879 ${docbook_cmd}
880 \\input{${srcdir}/chkconfig.ltx}
881 EOF
882   ## Construct the list of classes to test for.
883   # build the list of available layout files and convert it to commands 
884   # for chkconfig.ltx 
885   for file in ./layouts/*.layout ${srcdir}/layouts/*.layout ; do 
886     case $file in
887       */\*.layout) ;;
888       *) test -r "$file" && echo $file ;;
889     esac
890   done | sed -e 's%^.*layouts/\(.*\)\.layout$%\\TestDocClass{\1}%'\
891              > chklayouts.tex
892   eval ${LATEX} wrap_chkconfig.ltx 2>/dev/null | grep '^\+'
893   eval `cat chkconfig.vars | sed 's/-/_/g'`
894 fi
895
896 # Do we have all the files we need? Useful if latex did not run
897 echo creating textclass.lst 
898 # if textclass.lst does not exist (because LaTeX did not run), 
899 # then provide a standard version.
900 if test ! -f textclass.lst ; then
901   cat >textclass.lst <<EOF
902 # This file declares layouts and their associated definition files
903 # (include dir. relative to the place where this file is).
904 # It contains only default values, since chkconfig.ltx could not be run 
905 # for some reason. Run ./configure if you need to update it after a
906 # configuration change.  
907 article article article
908 report  report  report
909 book    book    book
910 linuxdoc        linuxdoc        linuxdoc
911 letter  letter  letter
912 EOF
913 fi
914
915 # if chkconfig.sed does not exist (because LaTeX did not run), 
916 # then provide a standard version.
917 if test ! -f chkconfig.sed ; then
918   cat >chkconfig.sed <<EOF
919 s/@.*@/???/g
920 EOF
921 fi
922
923 echo creating packages.lst
924 # if packages.lst does not exist (because LaTeX did not run), 
925 # then provide a standard version.
926 if test ! -f packages.lst ; then
927   cat >packages.lst <<EOF
928 # This file should contain the list of LaTeX packages that have been
929 # recognized by LyX. Unfortunately, since configure could not find
930 # your LaTeX2e program, the tests have not been run. Run ./configure
931 # if you need to update it after a configuration change.
932
933 EOF
934 fi
935
936 echo creating doc/LaTeXConfig.lyx
937 echo "s/@chk_linuxdoc@/$chk_linuxdoc/g" >> chkconfig.sed
938 echo "s/@chk_docbook@/$chk_docbook/g" >> chkconfig.sed
939 sed -f chkconfig.sed ${srcdir}/doc/LaTeXConfig.lyx.in >doc/LaTeXConfig.lyx
940
941 echo creating lyxrc.defaults
942 rm -f lyxrc.defaults
943 cat >lyxrc.defaults <<EOF
944 # This file has been automatically generated by LyX' lib/configure
945 # script. It contains default settings that have been determined by
946 # examining your system. PLEASE DO NOT MODIFY ANYTHING HERE! If you
947 # want to customize LyX, make a copy of the file LYXDIR/lyxrc as
948 # ~/.lyx/lyxrc and edit this file instead. Any setting in lyxrc will
949 # override the values given here.
950 \\converter tex dvi "$LATEX" ""
951 \\converter tex pdf "$PDFLATEX" ""
952 \\converter dvi ps "$dvi_to_ps_command" ""
953 \\converter ps pdf "$ps_to_pdf_command" ""
954 \\converter sgml tex "$linuxdoc_to_latex_command" ""
955 \\converter sgml dvi "$linuxdoc_to_dvi_command" ""
956 \\converter sgml html "$linuxdoc_to_html_command" ""
957 \\converter docbook dvi "$docbook_to_dvi_command" ""
958 \\converter docbook html "$docbook_to_html_command" ""
959 \\converter tex html "$latex_to_html_command"
960         "originaldir,needaux"
961 \\converter $LITERATE_EXT tex "$LITERATE" ""
962
963 \\viewer dvi "$DVI_VIEWER"
964 \\viewer html "$HTML_VIEWER"
965 \\viewer pdf "$PDF_VIEWER"
966 \\viewer ps "$GHOSTVIEW -swap"
967 \\viewer eps "$GHOSTVIEW"
968
969 \\relyx_command "$RELYX"
970 \\linuxdoc_to_lyx_command "$linuxdoc_to_lyx_command"
971 \\literate_extension "$LITERATE_EXT"
972 \\ps_command "$GS"
973 \\ascii_roff_command "$ascii_roff_command"
974 \\chktex_command "$chktex_command"
975 \\spell_command "$SPELL"
976 \\fax_command "$fax_command"
977 \\print_spool_command "$print_spool_command"
978 \\print_spool_printerprefix "$print_spool_printerprefix"
979 \\font_encoding "$chk_fontenc"
980 EOF
981
982 # Remove superfluous files if we are not writing in the main lib
983 # directory 
984 for file in lyxrc.defaults textclass.lst packages.lst \
985             doc/LaTeXConfig.lyx ; do
986   # we rename the file first, so that we avoid comparing a file with itself
987   mv $file $file.new
988   if test -r $srcdir/$file && diff $file.new $srcdir/$file >/dev/null 2>/dev/null ; 
989   then 
990     echo "removing $file, which is identical to the system global version"
991     rm -f $file.new
992   else
993     mv $file.new $file
994   fi
995 done
996
997
998 # Final clean-up
999 if test $lyx_keep_temps = no ; then
1000 rm -f chkconfig.sed chkconfig.vars wrap_chkconfig.* chklayouts.tex \
1001       missfont.log
1002 fi