]> git.lyx.org Git - lyx.git/blob - lib/configure
985661d7902fdefad5b4cb511fc761e9cac9c86f
[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 doc kbd layouts templates reLyX ; do
74   test ! -d $dir && mkdir $dir
75 done
76
77
78 #### Searching some useful programs
79 # Search LaTeX2e
80 echo $ac_n "checking for a LaTeX2e program""... $ac_c"
81 echo "$ac_t"""
82 LATEX=
83 for ac_prog in latex latex2e
84 do
85 # Extract the first word of "$ac_prog", so it can be a program name with args.
86 set dummy $ac_prog ; ac_word=$2
87 if test -n "$ac_word"; then
88   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
89   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
90   for ac_dir in $PATH; do
91     test -z "$ac_dir" && ac_dir=.
92     if test -x $ac_dir/$ac_word; then
93       LATEX="$ac_prog"
94       break
95     fi
96   done
97   IFS="$ac_save_ifs"
98
99   if test -n "$LATEX"; then
100     ac_result=yes
101   else
102     ac_result=no
103   fi
104   
105 ## Check whether this is really LaTeX2e
106 rm -f chklatex.ltx
107 cat >chklatex.ltx <<EOF
108 \\nonstopmode\\makeatletter
109 \\ifx\\undefined\\documentclass\\else
110   \\message{ThisIsLaTeX2e}
111 \\fi
112 \\@@end
113 EOF
114 if eval ${LATEX} chklatex.ltx </dev/null 2>/dev/null \
115                        | grep 'ThisIsLaTeX2e' >/dev/null; then
116   :
117 else
118   LATEX=
119   ac_result="not useable"
120 fi
121 rm -f chklatex.ltx chklatex.log
122   echo "$ac_t""$ac_result"
123   test -n "$LATEX" && break
124 fi
125 done
126
127 if test -z "$LATEX" ; then
128   LATEX=none
129     lyx_check_config=no
130 fi
131
132
133 # Search for an installed reLyX or a ready-to-install one
134 save_PATH=${PATH}
135 PATH=${PATH}:./reLyX/
136 echo $ac_n "checking for reLyX LaTeX-to-LyX translator""... $ac_c"
137 echo "$ac_t"""
138 RELYX=
139 for ac_prog in reLyX
140 do
141 # Extract the first word of "$ac_prog", so it can be a program name with args.
142 set dummy $ac_prog ; ac_word=$2
143 if test -n "$ac_word"; then
144   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
145   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
146   for ac_dir in $PATH; do
147     test -z "$ac_dir" && ac_dir=.
148     if test -x $ac_dir/$ac_word; then
149       RELYX="$ac_prog"
150       break
151     fi
152   done
153   IFS="$ac_save_ifs"
154
155   if test -n "$RELYX"; then
156     ac_result=yes
157   else
158     ac_result=no
159   fi
160   
161   echo "$ac_t""$ac_result"
162   test -n "$RELYX" && break
163 fi
164 done
165
166 if test -z "$RELYX" ; then
167   RELYX=none
168 fi
169
170 PATH=${save_PATH}
171
172 # Search something to process a literate document
173 echo $ac_n "checking for a Literate programming processor""... $ac_c"
174 echo "$ac_t"""
175 LITERATE=
176 for ac_prog in "noweave -delay -index"
177 do
178 # Extract the first word of "$ac_prog", so it can be a program name with args.
179 set dummy $ac_prog ; ac_word=$2
180 if test -n "$ac_word"; then
181   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
182   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
183   for ac_dir in $PATH; do
184     test -z "$ac_dir" && ac_dir=.
185     if test -x $ac_dir/$ac_word; then
186       LITERATE="$ac_prog"
187       break
188     fi
189   done
190   IFS="$ac_save_ifs"
191
192   if test -n "$LITERATE"; then
193     ac_result=yes
194   else
195     ac_result=no
196   fi
197   
198   echo "$ac_t""$ac_result"
199   test -n "$LITERATE" && break
200 fi
201 done
202
203 if test -z "$LITERATE" ; then
204   LITERATE=none
205 fi
206
207 if test "$LITERATE" = "none"; then LITERATE_EXT="none"; else LITERATE_EXT=".nw"; fi
208
209 # Search for a Postscript interpreter
210 echo $ac_n "checking for a Postscript interpreter""... $ac_c"
211 echo "$ac_t"""
212 GS=
213 for ac_prog in gs
214 do
215 # Extract the first word of "$ac_prog", so it can be a program name with args.
216 set dummy $ac_prog ; ac_word=$2
217 if test -n "$ac_word"; then
218   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
219   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
220   for ac_dir in $PATH; do
221     test -z "$ac_dir" && ac_dir=.
222     if test -x $ac_dir/$ac_word; then
223       GS="$ac_prog"
224       break
225     fi
226   done
227   IFS="$ac_save_ifs"
228
229   if test -n "$GS"; then
230     ac_result=yes
231   else
232     ac_result=no
233   fi
234   
235   echo "$ac_t""$ac_result"
236   test -n "$GS" && break
237 fi
238 done
239
240 if test -z "$GS" ; then
241   GS=none
242 fi
243
244
245 # Search something to preview postscript
246 echo $ac_n "checking for a Postscript previewer""... $ac_c"
247 echo "$ac_t"""
248 GHOSTVIEW=
249 for ac_prog in gv ghostview
250 do
251 # Extract the first word of "$ac_prog", so it can be a program name with args.
252 set dummy $ac_prog ; ac_word=$2
253 if test -n "$ac_word"; then
254   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
255   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
256   for ac_dir in $PATH; do
257     test -z "$ac_dir" && ac_dir=.
258     if test -x $ac_dir/$ac_word; then
259       GHOSTVIEW="$ac_prog"
260       break
261     fi
262   done
263   IFS="$ac_save_ifs"
264
265   if test -n "$GHOSTVIEW"; then
266     ac_result=yes
267   else
268     ac_result=no
269   fi
270   
271   echo "$ac_t""$ac_result"
272   test -n "$GHOSTVIEW" && break
273 fi
274 done
275
276 if test -z "$GHOSTVIEW" ; then
277   GHOSTVIEW=none
278 fi
279
280
281 # Search a *roff program (used to translate tables in ASCII export)
282 echo $ac_n "checking for a *roff formatter""... $ac_c"
283 echo "$ac_t"""
284 ROFF=
285 for ac_prog in groff nroff
286 do
287 # Extract the first word of "$ac_prog", so it can be a program name with args.
288 set dummy $ac_prog ; ac_word=$2
289 if test -n "$ac_word"; then
290   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
291   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
292   for ac_dir in $PATH; do
293     test -z "$ac_dir" && ac_dir=.
294     if test -x $ac_dir/$ac_word; then
295       ROFF="$ac_prog"
296       break
297     fi
298   done
299   IFS="$ac_save_ifs"
300
301   if test -n "$ROFF"; then
302     ac_result=yes
303   else
304     ac_result=no
305   fi
306   
307   echo "$ac_t""$ac_result"
308   test -n "$ROFF" && break
309 fi
310 done
311
312 if test -z "$ROFF" ; then
313   ROFF=none
314 fi
315
316 ascii_roff_command=$ROFF
317 test $ROFF = "groff" && ascii_roff_command="groff -t -Tlatin1 \$\$FName"
318 test $ROFF = "nroff" && ascii_roff_command="tbl \$\$FName | nroff"
319
320 # Search the ChkTeX program
321 echo $ac_n "checking for ChkTeX""... $ac_c"
322 echo "$ac_t"""
323 CHKTEX=
324 for ac_prog in chktex
325 do
326 # Extract the first word of "$ac_prog", so it can be a program name with args.
327 set dummy $ac_prog ; ac_word=$2
328 if test -n "$ac_word"; then
329   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
330   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
331   for ac_dir in $PATH; do
332     test -z "$ac_dir" && ac_dir=.
333     if test -x $ac_dir/$ac_word; then
334       CHKTEX="$ac_prog"
335       break
336     fi
337   done
338   IFS="$ac_save_ifs"
339
340   if test -n "$CHKTEX"; then
341     ac_result=yes
342   else
343     ac_result=no
344   fi
345   
346   echo "$ac_t""$ac_result"
347   test -n "$CHKTEX" && break
348 fi
349 done
350
351 if test -z "$CHKTEX" ; then
352   CHKTEX=none
353 fi
354
355 chktex_command=$CHKTEX
356 test $CHKTEX = "chktex" && chktex_command="$CHKTEX -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38"
357
358 # Search for a spellchecker
359 echo $ac_n "checking for a spell-checker""... $ac_c"
360 echo "$ac_t"""
361 SPELL=
362 for ac_prog in ispell
363 do
364 # Extract the first word of "$ac_prog", so it can be a program name with args.
365 set dummy $ac_prog ; ac_word=$2
366 if test -n "$ac_word"; then
367   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
368   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
369   for ac_dir in $PATH; do
370     test -z "$ac_dir" && ac_dir=.
371     if test -x $ac_dir/$ac_word; then
372       SPELL="$ac_prog"
373       break
374     fi
375   done
376   IFS="$ac_save_ifs"
377
378   if test -n "$SPELL"; then
379     ac_result=yes
380   else
381     ac_result=no
382   fi
383   
384   echo "$ac_t""$ac_result"
385   test -n "$SPELL" && break
386 fi
387 done
388
389 if test -z "$SPELL" ; then
390   SPELL=none
391 fi
392
393
394 # Search a Fax handling program
395 echo $ac_n "checking for a fax driver""... $ac_c"
396 echo "$ac_t"""
397 FAX=
398 for ac_prog in sendfax faxsend fax
399 do
400 # Extract the first word of "$ac_prog", so it can be a program name with args.
401 set dummy $ac_prog ; ac_word=$2
402 if test -n "$ac_word"; then
403   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
404   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
405   for ac_dir in $PATH; do
406     test -z "$ac_dir" && ac_dir=.
407     if test -x $ac_dir/$ac_word; then
408       FAX="$ac_prog"
409       break
410     fi
411   done
412   IFS="$ac_save_ifs"
413
414   if test -n "$FAX"; then
415     ac_result=yes
416   else
417     ac_result=no
418   fi
419   
420   echo "$ac_t""$ac_result"
421   test -n "$FAX" && break
422 fi
423 done
424
425 if test -z "$FAX" ; then
426   FAX=none
427 fi
428
429 if test $FAX = sendfax ; then
430   fax_command="sendfax -n -h '\$\$Host' -c '\$\$Comment' -x '\$\$Enterprise' -d '\$\$Name'@'\$\$Phone' '\$\$FName'"
431 elif test $FAX = faxsend ; then
432   fax_command="faxsend '\$\$Phone' '\$\$FName'"
433 elif test $FAX = fax ; then
434   fax_command="fax send '\$\$Phone' '\$\$FName'"
435 else
436   fax_command="none"
437 fi
438
439 # Search for LinuxDoc support
440 echo $ac_n "checking for SGML-tools 1.x (LinuxDoc)""... $ac_c"
441 echo "$ac_t"""
442 LINUXDOC=
443 for ac_prog in sgml2lyx
444 do
445 # Extract the first word of "$ac_prog", so it can be a program name with args.
446 set dummy $ac_prog ; ac_word=$2
447 if test -n "$ac_word"; then
448   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
449   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
450   for ac_dir in $PATH; do
451     test -z "$ac_dir" && ac_dir=.
452     if test -x $ac_dir/$ac_word; then
453       LINUXDOC="$ac_prog"
454       break
455     fi
456   done
457   IFS="$ac_save_ifs"
458
459   if test -n "$LINUXDOC"; then
460     ac_result=yes
461   else
462     ac_result=no
463   fi
464   
465   echo "$ac_t""$ac_result"
466   test -n "$LINUXDOC" && break
467 fi
468 done
469
470 if test -z "$LINUXDOC" ; then
471   LINUXDOC=none
472 fi
473
474 chk_linuxdoc=no
475 if test $LINUXDOC != none; then
476   chk_linuxdoc=yes
477   linuxdoc_cmd="\\def\\haslinuxdoc{yes}"
478 fi
479
480 # Search for DocBook support
481 echo $ac_n "checking for SGML-tools 2.x (DocBook)""... $ac_c"
482 echo "$ac_t"""
483 DOCBOOK=
484 for ac_prog in sgmltools
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="${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       DOCBOOK="$ac_prog"
495       break
496     fi
497   done
498   IFS="$ac_save_ifs"
499
500   if test -n "$DOCBOOK"; then
501     ac_result=yes
502   else
503     ac_result=no
504   fi
505   
506   echo "$ac_t""$ac_result"
507   test -n "$DOCBOOK" && break
508 fi
509 done
510
511 if test -z "$DOCBOOK" ; then
512   DOCBOOK=none
513 fi
514
515 chk_docbook=no
516 if test $DOCBOOK != none; then
517   chk_docbook=yes
518   docbook_cmd="\\def\\hasdocbook{yes}"
519 fi
520
521
522 # Search for a spool command
523 echo $ac_n "checking for a spool command""... $ac_c"
524 echo "$ac_t"""
525 LPR=
526 for ac_prog in lp lpr
527 do
528 # Extract the first word of "$ac_prog", so it can be a program name with args.
529 set dummy $ac_prog ; ac_word=$2
530 if test -n "$ac_word"; then
531   echo $ac_n "+checking for \"$ac_word\"""... $ac_c"
532   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}:"
533   for ac_dir in $PATH; do
534     test -z "$ac_dir" && ac_dir=.
535     if test -x $ac_dir/$ac_word; then
536       LPR="$ac_prog"
537       break
538     fi
539   done
540   IFS="$ac_save_ifs"
541
542   if test -n "$LPR"; then
543     ac_result=yes
544   else
545     ac_result=no
546   fi
547   
548   echo "$ac_t""$ac_result"
549   test -n "$LPR" && break
550 fi
551 done
552
553 if test -z "$LPR" ; then
554   LPR=none
555 fi
556
557 case $LPR in
558   lp) print_spool_command=lp
559       print_spool_printerprefix="-d ";;
560  lpr) print_spool_command=lpr
561       print_spool_printerprefix="-P";;
562    *) :;; # leave to empty values
563 esac
564
565 #### Explore the LaTeX configuration
566 echo $ac_n "checking LaTeX configuration""... $ac_c"
567 # First, remove the files that we want to re-create
568 rm -f textclass.lst packages.lst chkconfig.sed
569 if test ${lyx_check_config} = no ; then
570   echo "$ac_t""default values"
571 else
572   echo "$ac_t""auto"
573   rm -f wrap_chkconfig.ltx chkconfig.vars chkconfig.classes chklayouts.tex
574   cat >wrap_chkconfig.ltx <<EOF
575 \\newcommand\\srcdir{${srcdir}}
576 ${linuxdoc_cmd}
577 ${docbook_cmd}
578 \\input{${srcdir}/chkconfig.ltx}
579 EOF
580   ## Construct the list of classes to test for.
581   # build the list of available layout files and convert it to commands 
582   # for chkconfig.ltx 
583   for file in ./layouts/*.layout ${srcdir}/layouts/*.layout ; do 
584     case $file in
585       */\*.layout) ;;
586       *) echo $file ;;
587     esac
588   done | sed -e 's%^.*layouts/\(.*\)\.layout$%\\TestDocClass{\1}%'\
589              > chklayouts.tex
590   eval ${LATEX} wrap_chkconfig.ltx 2>/dev/null | grep '^\+'
591   eval `cat chkconfig.vars | sed 's/-/_/g'`
592 fi
593
594 # Do we have all the files we need? Useful if latex did not run
595 echo creating textclass.lst 
596 # if textclass.lst does not exist (because LaTeX did not run), 
597 # then provide a standard version.
598 if test ! -f textclass.lst ; then
599   cat >textclass.lst <<EOF
600 # This file declares layouts and their associated definition files
601 # (include dir. relative to the place where this file is).
602 # It contains only default values, since chkconfig.ltx could not be run 
603 # for some reason. Run ./configure if you need to update it after a
604 # configuration change.  
605 article article article
606 report  report  report
607 book    book    book
608 linuxdoc        linuxdoc        linuxdoc
609 letter  letter  letter
610 EOF
611 fi
612
613 # if chkconfig.sed does not exist (because LaTeX did not run), 
614 # then provide a standard version.
615 if test ! -f chkconfig.sed ; then
616   cat >chkconfig.sed <<EOF
617 s/@.*@/???/g
618 EOF
619 fi
620
621 echo creating packages.lst
622 # if packages.lst does not exist (because LaTeX did not run), 
623 # then provide a standard version.
624 if test ! -f packages.lst ; then
625   cat >packages.lst <<EOF
626 # This file should contain the list of LaTeX packages that have been
627 # recognized by LyX. Unfortunately, since configure could not find
628 # your LaTeX2e program, the tests have not been run. Run ./configure
629 # if you need to update it after a configuration change.
630
631 EOF
632 fi
633
634 echo creating doc/LaTeXConfig.lyx
635 echo "s/@chk_linuxdoc@/$chk_linuxdoc/g" >> chkconfig.sed
636 echo "s/@chk_docbook@/$chk_docbook/g" >> chkconfig.sed
637 sed -f chkconfig.sed ${srcdir}/doc/LaTeXConfig.lyx.in >doc/LaTeXConfig.lyx
638
639 echo creating lyxrc.defaults
640 rm -f lyxrc.defaults
641 cat >lyxrc.defaults <<EOF
642 # This file has been automatically generated by LyX' lib/configure
643 # script. It contains default settings that have been determined by
644 # examining your system. PLEASE DO NOT MODIFY ANYTHING HERE! If you
645 # want to customize LyX, make a copy of the file LYXDIR/lyxrc as
646 # ~/.lyx/lyxrc and edit this file instead. Any setting in lyxrc will
647 # override the values given here.
648 \\latex_command "$LATEX"
649 \\relyx_command "$RELYX"
650 \\literate_command "$LITERATE"
651 \\literate_extension "$LITERATE_EXT"
652 \\ps_command "$GS"
653 \\view_ps_command "$GHOSTVIEW -swap"
654 \\view_pspic_command "$GHOSTVIEW"
655 \\ascii_roff_command "$ascii_roff_command"
656 \\chktex_command "$chktex_command"
657 \\spell_command "$SPELL"
658 \\fax_command "$fax_command"
659 \\print_spool_command "$print_spool_command"
660 \\print_spool_printerprefix "$print_spool_printerprefix"
661 \\font_encoding "$chk_fontenc"
662 EOF
663
664 # Remove superfluous files if we are not writing in the main lib
665 # directory 
666 for file in lyxrc.defaults textclass.lst packages.lst \
667             doc/LaTeXConfig.lyx ; do
668   # we rename the file first, so that we avoid comparing a file with itself
669   mv $file $file.new
670   if test -r $srcdir/$file && diff $file.new $srcdir/$file >/dev/null 2>/dev/null ; 
671   then 
672     echo "removing $file, which is identical to the system global version"
673     rm -f $file.new
674   else
675     mv $file.new $file
676   fi
677 done
678
679
680 # Final clean-up
681 if test $lyx_keep_temps = no ; then
682 rm -f chkconfig.sed chkconfig.vars wrap_chkconfig.* chklayouts.tex \
683       missfont.log
684 fi