]> git.lyx.org Git - lyx.git/blob - lib/configure.m4
get John Spray into the Hall of Fame
[lyx.git] / lib / configure.m4
1 #! /bin/sh
2 dnl Use 'make' to create configure from this m4 script.
3 # This script is a hand-made configure script. It contains a lot of
4 # code stolen from GNU autoconf. I removed all the code that was not
5 # useful for configuring a LyX installation.
6
7
8 dnl ######### Begin M4 macros #########################################
9 dnl This is a template for my stripped-down configure script.
10 dnl First, a few convenient macros.
11 changequote([,])dnl
12 dnl
13 dnl
14 dnl MSG_CHECKING(FEATURE-DESCRIPTION,PREFIX)
15 dnl
16 define(MSG_CHECKING,
17 [echo $ac_n "$2checking $1""... $ac_c"])dnl
18 dnl
19 dnl
20 dnl MSG_RESULT(RESULT-DESCRIPTION)
21 dnl
22 define(MSG_RESULT,
23 [echo "$ac_t""$1"])dnl
24 dnl
25 dnl
26 dnl SEARCH_PROG(FEATURE-DESCRIPTION,VARIABLE-NAME,PROGRAMS-LIST,
27 dnl             ACTION-IF-FOUND,ACTION-IF-NOT-FOUND)
28 dnl
29 define(SEARCH_PROG,[dnl
30 changequote([,])dnl
31 MSG_CHECKING($1)
32 MSG_RESULT(($3))
33 $2=
34 for ac_prog in $3
35 do
36 # Extract the first word of "$ac_prog", so it can be a program name with args.
37 set dummy $ac_prog ; ac_word=$[2]
38 if test -n "$ac_word"; then
39   MSG_CHECKING([for \"$ac_word\"],[+])
40   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS=":"
41   for ac_dir in $PATH; do
42     test -z "$ac_dir" && ac_dir=.
43     if test -x [$ac_dir/$ac_word]; then
44       $2="$ac_prog"
45       break
46     fi
47   done
48   IFS="$ac_save_ifs"
49
50   if test -n "[$]$2"; then
51     ac_result=yes
52     ifelse($4,,,[$4])
53   else
54     ac_result=no
55   fi
56   MSG_RESULT($ac_result)
57   test -n "[$]$2" && break
58 fi
59 done
60
61 if test -z "[$]$2" ; then
62   $2=none
63 ifelse($5,,,[  $5
64 ])dnl
65 fi
66 changequote(,)dnl
67 ])dnl
68 dnl
69 dnl
70 dnl LYXRC_VAR(VARIABLE_NAME, VALUE)
71 define(LYXRC_VAR,[dnl
72 rc_entries="$rc_entries
73 $1 \"$2\""])
74 dnl
75 dnl
76 dnl LYXRC_PROG(FEATURE-DESCRIPTION,VARIABLE-NAME,PROGRAMS-LIST,
77 dnl             ACTION-IF-FOUND,ACTION-IF-NOT-FOUND)
78 define(LYXRC_PROG,[dnl
79 SEARCH_PROG($1,prog,$3,$4,$5)
80 LYXRC_VAR($2,$prog)])
81 dnl
82 dnl
83 dnl PROVIDE_DEFAULT_FILE(FILE, DEFAULT-VALUE)
84 dnl
85 define(PROVIDE_DEFAULT_FILE,[dnl
86 # if $1 does not exist (because LaTeX did not run),
87 # then provide a standard version.
88 if test ! -f $1 ; then
89   cat >$1 <<EOF
90 $2
91 EOF
92 fi])
93 changequote(,)dnl
94 dnl ######### End M4 macros #############################################
95
96
97 # Be Bourne compatible (taken from autoconf 2.53)
98 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
99   emulate sh
100   NULLCMD=:
101 elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
102   set -o posix
103 fi
104
105
106
107 ####some configuration variables
108 outfile=lyxrc.defaults
109 rc_entries=
110 lyx_check_config=yes
111 lyx_keep_temps=no
112 srcdir=
113 version_suffix=
114
115 #### Parse the command line
116 for ac_option do
117   case "$ac_option" in
118     -help | --help | -h)
119       cat << EOF
120 Usage: configure [options]
121 Options:
122   --help                   show this help lines
123   --keep-temps             keep temporary files (for debug. purposes)
124   --without-latex-config   do not run LaTeX to determine configuration
125   --with-version-suffix=suffix suffix of binary installed files
126 EOF
127       exit 0;;
128     --without-latex-config)
129       lyx_check_config=no ;;
130     --keep-temps)
131       lyx_keep_temps=yes ;;
132     --with-version-suffix*)
133       version_suffix=`echo "$ac_option" | sed 's,--with-version-suffix=,,'`
134   esac
135 done
136
137
138 #### Checking for some echo oddities
139 if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
140   # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
141   if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
142     ac_n= ac_c='
143 ' ac_t='        '
144   else
145     ac_n=-n ac_c= ac_t=
146   fi
147 else
148   ac_n= ac_c='\c' ac_t=
149 fi
150
151
152 #### I do not really know why this is useful, but we might as well keep it.
153 # NLS nuisances.
154 # Only set these to C if already set.  These must not be set unconditionally
155 # because not all systems understand e.g. LANG=C (notably SCO).
156 # Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
157 # Non-C LC_CTYPE values break the ctype check.
158 if test "${LANG+set}"   = set; then LANG=C;   export LANG;   fi
159 if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
160 if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
161 if test "${LC_CTYPE+set}"    = set; then LC_CTYPE=C;    export LC_CTYPE;    fi
162
163
164 #### Guess the directory in which configure is located.
165 changequote([,])dnl
166 ac_prog=[$]0
167 changequote(,)dnl
168 srcdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
169 srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
170 test "x${srcdir}" = "x$ac_prog" && srcdir=.
171 if test ! -r "${srcdir}"/chkconfig.ltx ; then
172   echo "configure: error: cannot find chkconfig.ltx script"
173   exit 1
174 fi
175
176 #### Adjust PATH for Win32 (Cygwin)
177 case `uname -s` in
178    CYGWIN*)
179      tmpfname="/tmp/x$$.ltx";
180      echo "\\documentstyle{article}" > $tmpfname
181      echo "\\begin{document}\\end{document}" >> $tmpfname
182      inpname=`cygpath -w $tmpfname | tr '\\\\' /`
183      echo "\\input{$inpname}" > wrap_temp$$.ltx
184      check_err=`latex wrap_temp$$.ltx 2>&1 < /dev/null | grep Error`
185      rm -f wrap_temp$$.* /tmp/x$$.*
186      if [ x"$check_err" = "x" ]
187      then
188        echo "configure: cygwin detected; path correction"
189        srcdir=`cygpath -w "${srcdir}" | tr '\\\\' /`
190        echo "srcdir=${srcdir}"
191      else
192        echo "configure: cygwin detected; path correction is not needed"
193      fi
194      ;;
195 esac
196
197 #### Create the build directories if necessary
198 for dir in bind clipart doc examples help images kbd layouts reLyX \
199     scripts templates ui xfonts; do
200   test ! -d $dir && mkdir $dir
201 done
202
203
204 #### Searching some useful programs
205 define(CHECKLATEX2E,[
206 ## Check whether this is really LaTeX2e
207 rm -f chklatex.ltx
208 cat >chklatex.ltx <<EOF
209 \\nonstopmode\\makeatletter
210 \\ifx\\undefined\\documentclass\\else
211   \\message{ThisIsLaTeX2e}
212 \\fi
213 \\@@end
214 EOF
215 if eval ${LATEX} chklatex.ltx </dev/null 2>/dev/null \
216                        | grep 'ThisIsLaTeX2e' >/dev/null; then
217   :
218 else
219   LATEX=
220   ac_result="not useable"
221 fi
222 # Grab the list of languages avaliable to LaTeX by parsing the LaTeX log file, chklatex.log.
223 LANGUAGES=`sed -n '/hyphenation patterns/{
224 :loop
225 /loaded\.$/!{
226 $!{
227 N
228 s/\n//
229 s/^.*for\ //
230 tloop
231 }
232 }
233 /loaded\.$/p
234 }' chklatex.log`
235 rm -f chklatex.ltx chklatex.log])dnl
236 dnl
237 # Search LaTeX2e
238 SEARCH_PROG([for a LaTeX2e program],LATEX,pplatex latex2e latex,CHECKLATEX2E,dnl
239   [lyx_check_config=no])
240 latex_to_dvi=$LATEX
241 test -z "$latex_to_dvi" && latex_to_dvi="none"
242
243 # Search for pdflatex
244 if test ${lyx_check_config} = no ; then
245   latex_to_pdf=none
246 else
247   SEARCH_PROG([for the pdflatex program],latex_to_pdf,pdflatex)
248 fi
249
250 test $latex_to_dvi != "none" && latex_to_dvi="$latex_to_dvi \$\$i"
251 test $latex_to_pdf != "none" && latex_to_pdf="$latex_to_pdf \$\$i"
252
253 SEARCH_PROG([for a TGIF viewer and editor], TGIF_EDITOR, tgif)
254 TGIF_VIEWER="$TGIF_EDITOR"
255
256 SEARCH_PROG([for a FIG viewer and editor], FIG_EDITOR, xfig)
257 FIG_VIEWER="$FIG_EDITOR"
258
259 SEARCH_PROG([for a GRACE viewer and editor], GRACE_EDITOR, xmgrace)
260 GRACE_VIEWER="$GRACE_EDITOR"
261
262 SEARCH_PROG([for a FEN viewer and editor], FEN_EDITOR, xboard)
263 test "$FEN" = "xboard" && FEN_EDITOR="xboard -lpf \$\$i -mode EditPosition"
264 FEN_VIEWER="$FEN_EDITOR"
265
266 SEARCH_PROG([for a raster image viewer], RASTERIMAGE_VIEWER, xv kview gimp)
267
268 SEARCH_PROG([for a raster image editor], RASTERIMAGE_EDITOR, gimp)
269
270 SEARCH_PROG([for a text editor], TEXT_EDITOR, xemacs gvim kedit kwrite kate nedit gedit)
271
272 # Search for an installed reLyX or a ready-to-install one
273 save_PATH=${PATH}
274 PATH=${PATH}:./reLyX/
275 SEARCH_PROG([for a LaTeX -> LyX converter],tex_to_lyx_command,reLyX)
276 PATH=${save_PATH}
277 test $tex_to_lyx_command = "reLyX" && tex_to_lyx_command="reLyX -f \$\$i"
278 tex_to_lyx_command=`echo $tex_to_lyx_command | sed "s,reLyX,reLyX$version_suffix,"`
279
280 SEARCH_PROG([for a Noweb -> LyX converter],literate_to_lyx_command,noweb2lyx)
281 test $literate_to_lyx_command = "noweb2lyx" && literate_to_lyx_command="noweb2lyx \$\$i \$\$o"
282 literate_to_lyx_command=`echo $literate_to_lyx_command | sed "s,noweb2lyx,noweb2lyx$version_suffix,"`
283
284 # Search something to process a literate document
285 SEARCH_PROG([for a Noweb -> LaTeX converter],literate_to_tex_command,noweave)
286 test $literate_to_tex_command = "noweave" && literate_to_tex_command="noweave -delay -index \$\$i > \$\$o"
287
288 SEARCH_PROG([for a HTML -> Latex converter],html_to_latex_command,html2latex)
289 test $html_to_latex_command = "html2latex" && html_to_latex_command="html2latex \$\$i"
290
291 SEARCH_PROG([for a MSWord -> Latex converter],word_to_latex_command,wvCleanLatex word2x)
292 test "$word_to_latex_command" = "wvCleanLatex" && word_to_latex_command="wvCleanLatex \$\$i \$\$o"
293 test "$word_to_latex_command" = "word2x" && word_to_latex_command="word2x -f latex \$\$i"
294
295 SEARCH_PROG([for Image converter],image_command,convert)
296 test $image_command = "convert" && image_command="convert \$\$i \$\$o"
297
298 SEARCH_PROG([for an OpenOffice.org -> Latex converter],sxw_to_latex_command,w2l)
299 test "$sxw_to_latex_command" = "w2l" && sxw_to_latex_command="w2l -clean \$\$i"
300
301 # oolatex is the original name, SuSE has oolatex.sh
302 SEARCH_PROG([for an Latex -> OpenOffice.org converter],latex_to_sxw_command,oolatex oolatex.sh)
303 test "$latex_to_sxw_command" != "none" && latex_to_sxw_command="$latex_to_sxw_command \$\$i"
304
305 # Search something to preview postscript
306 SEARCH_PROG([for a Postscript previewer],GHOSTVIEW,gsview32 gv ghostview kghostview)
307 case $GHOSTVIEW in
308   gv|ghostview) PS_VIEWER="$GHOSTVIEW -swap" ;;
309   *) PS_VIEWER="$GHOSTVIEW";;
310 esac
311 EPS_VIEWER=$GHOSTVIEW
312
313 # Search for a program to preview pdf
314 SEARCH_PROG([for a PDF preview],PDF_VIEWER, acrobat acrord32 gsview32 acroread gv ghostview xpdf kpdf kghostview)
315
316 # Search something to preview dvi
317 SEARCH_PROG([for a DVI previewer],DVI_VIEWER, xdvi windvi yap kdvi)
318
319 # Search something to preview html
320 SEARCH_PROG([for a HTML previewer],HTML_VIEWER, "mozilla file://\$\$p\$\$i" netscape)
321
322 # Search for a program to convert ps to pdf
323 SEARCH_PROG([for a PS to PDF converter],ps_to_pdf_command,ps2pdf)
324 test $ps_to_pdf_command = "ps2pdf" && ps_to_pdf_command="ps2pdf -dCompatibilityLevel=1.3 \$\$i"
325
326 # Search for a program to convert dvi to ps
327 SEARCH_PROG([for a DVI to PS converter],dvi_to_ps_command,dvips)
328 test $dvi_to_ps_command = "dvips" && dvi_to_ps_command="dvips -o \$\$o \$\$i"
329
330 # Search for a program to convert dvi to pdf
331 SEARCH_PROG([for a DVI to PDF converter],dvi_to_pdf_command,dvipdfm)
332 test $dvi_to_pdf_command = "dvipdfm" && dvi_to_pdf_command="dvipdfm \$\$i"
333
334 # We have a script to convert previewlyx to ppm or to png
335 lyxpreview_to_bitmap_command='python $$s/lyxpreview2bitmap.py'
336
337 # Search for 'dvipng'. Only enable the conversion from lyxpreview -> png
338 # if dvipng is found.
339 SEARCH_PROG([for dvipng],DVIPNG,dvipng)
340
341 test "$DVIPNG" = "dvipng" && \
342         lyxpreview_to_png_command=$lyxpreview_to_bitmap_command
343
344 # Search a *roff program (used to translate tables in ASCII export)
345 LYXRC_PROG([for a *roff formatter], \ascii_roff_command, dnl
346   'groff -t -Tlatin1 $$FName' nroff,dnl
347   test "$prog" = "nroff" && prog='tbl $$FName | nroff')
348
349 # Search the ChkTeX program
350 LYXRC_PROG([for ChkTeX], \chktex_command,dnl
351    "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38")
352
353 # Search for a spellchecker
354 LYXRC_PROG([for a spell-checker], \spell_command, ispell)
355
356 # Search for computer algebra systems
357 SEARCH_PROG([for Octave],OCTAVE,octave)
358 SEARCH_PROG([for Maple],MAPLE,maple)
359
360 dnl # Search a Fax handling program
361 dnl SEARCH_PROG([for a fax driver], FAX, sendfax faxsend fax)
362 dnl if test $FAX = sendfax ; then
363 dnl   fax_command="sendfax -n -h '\$\$Host' -c '\$\$Comment' -x '\$\$Enterprise' -d '\$\$Name'@'\$\$Phone' '\$\$FName'"
364 dnl elif test $FAX = faxsend ; then
365 dnl   fax_command="faxsend '\$\$Phone' '\$\$FName'"
366 dnl elif test $FAX = fax ; then
367 dnl   fax_command="fax send '\$\$Phone' '\$\$FName'"
368 dnl else
369 dnl   fax_command="none"
370 dnl fi
371
372 # Search a GUI Fax program
373 SEARCH_PROG([for a fax program], fax_command, kdeprintfax ksendfax)
374 test $fax_command != "none" && fax_command="$fax_command \$\$i"
375
376 # Search for LinuxDoc support
377 SEARCH_PROG([for SGML-tools 1.x (LinuxDoc)], LINUXDOC, sgml2lyx)
378 if test $LINUXDOC != none; then
379   chk_linuxdoc=yes
380   bool_linuxdoc=true
381   linuxdoc_cmd="\\def\\haslinuxdoc{yes}"
382 else
383   chk_linuxdoc=no
384   bool_linuxdoc=false
385 fi
386
387 case $LINUXDOC in
388   sgml2lyx)
389     linuxdoc_to_latex_command="sgml2latex \$\$i"
390     linuxdoc_to_dvi_command="sgml2latex -o dvi \$\$i"
391     linuxdoc_to_html_command="sgml2html \$\$i"
392     linuxdoc_to_lyx_command="sgml2lyx \$\$i";;
393   none)
394     linuxdoc_to_latex_command="none"
395     linuxdoc_to_dvi_command="none"
396     linuxdoc_to_html_command="none"
397     linuxdoc_to_lyx_command="none";;
398 esac
399
400 # Search for DocBook support
401 SEARCH_PROG([for SGML-tools 2.x (DocBook) or db2x scripts], DOCBOOK, sgmltools db2dvi)
402 if test $DOCBOOK != none; then
403   chk_docbook=yes
404   bool_docbook=true
405   docbook_cmd="\\def\\hasdocbook{yes}"
406 else
407   chk_docbook=no
408   bool_docbook=false
409 fi
410
411 case $DOCBOOK in
412   sgmltools)
413     docbook_to_dvi_command="sgmltools -b dvi \$\$i"
414     docbook_to_html_command="sgmltools -b html \$\$i";;
415   db2dvi)
416     docbook_to_dvi_command="db2dvi \$\$i"
417     docbook_to_html_command="db2html \$\$i";;
418   none)
419     docbook_to_dvi_command="none"
420     docbook_to_html_command="none";;
421 esac
422
423 # Search for a spool command
424 LYXRC_PROG([for a spool command], \print_spool_command, lp lpr)
425 case $prog in
426   lp) print_spool_printerprefix="-d ";;
427  lpr) print_spool_printerprefix="-P";;
428    *) :;; # leave to empty values
429 esac
430 LYXRC_VAR(\print_spool_printerprefix, $print_spool_printerprefix)
431
432 SEARCH_PROG([for a LaTeX -> HTML converter], TOHTML, tth latex2html hevea)
433 latex_to_html_command=$TOHTML
434 case $TOHTML in
435         tth) latex_to_html_command="tth -t -e2 -L\$\$b < \$\$i > \$\$o";;
436  latex2html) latex_to_html_command="latex2html -no_subdir -split 0 -show_section_numbers \$\$i";;
437       hevea) latex_to_html_command="hevea -s \$\$i";;
438 esac
439
440 #### Explore the LaTeX configuration
441 MSG_CHECKING(LaTeX configuration)
442 # First, remove the files that we want to re-create
443 rm -f textclass.lst packages.lst chkconfig.sed
444 if test ${lyx_check_config} = no ; then
445   MSG_RESULT(default values)
446   MSG_CHECKING(list of textclasses,+)
447   cat >textclass.lst <<EOF
448 # This file declares layouts and their associated definition files
449 # (include dir. relative to the place where this file is).
450 # It contains only default values, since chkconfig.ltx could not be run
451 # for some reason. Run ./configure if you need to update it after a
452 # configuration change.
453 EOF
454   # build the list of available layout files and convert it to entries
455   # for the default textclass.lst file
456   for file in ./layouts/*.layout "${srcdir}"/layouts/*.layout ; do
457     case $file in
458       */\*.layout) ;;
459       *) if test -r "$file" ; then
460            class=`echo $file | sed -e 's%^.*layouts/\(.*\)\.layout$%\1%'`
461            cleanclass=`echo $class | tr ' -' '__'`
462 changequote([,])dnl
463            # make sure the same class is not considered twice
464            if test  x`[eval] echo $ac_n '${found_'$cleanclass'}'` = x ; then
465              [eval] "found_$cleanclass=yes"
466 changequote(,)dnl
467              # The sed commands below are a bit scary. Here is what they do:
468              # 1-3: remove the \DeclareFOO macro and add the correct boolean
469              #      at the end of the line telling whether the class is
470              #      available
471              # 4: if the macro had an optional argument with several
472              #    parameters, only keep the first one
473              # 5: if the macro did not have an optional argument, provide one
474              #    (equal to the class name)
475              # 6: remove brackets and replace with correctly quoted entries
476              grep '\\Declare\(LaTeX\|DocBook\|LinuxDoc\)Class' "$file" \
477               | sed -e 's/^.*\DeclareLaTeXClass *\(.*\)/\1 "false"/' \
478                     -e 's/^.*\DeclareDocBookClass *\(.*\)/\1 "'$bool_docbook'"/' \
479                     -e 's/^.*\DeclareLinuxDocClass *\(.*\)/\1 "'$bool_linuxdoc'"/' \
480                     -e 's/\[\([^,]*\),[^]]*\]/[\1]/' \
481                     -e 's/^{/['$class']{/' \
482                     -e 's/\[\([^]]*\)\] *{\([^}]*\)}/"'$class'" "\1" "\2"/' \
483                     >>textclass.lst
484            fi
485          fi ;;
486     esac
487   done
488   MSG_RESULT(done)
489 else
490   MSG_RESULT(auto)
491   rm -f wrap_chkconfig.ltx chkconfig.vars chkconfig.classes chklayouts.tex
492   if ! test -r "chkconfig.ltx" ; then
493     ln -s "${srcdir}"/chkconfig.ltx .
494     rmlink=true
495   fi
496   cat >wrap_chkconfig.ltx <<EOF
497 ${linuxdoc_cmd}
498 ${docbook_cmd}
499 \\input{chkconfig.ltx}
500 EOF
501   ## Construct the list of classes to test for.
502   # build the list of available layout files and convert it to commands
503   # for chkconfig.ltx
504   for file in ./layouts/*.layout "${srcdir}"/layouts/*.layout ; do
505     case $file in
506       */\*.layout) ;;
507       *) if test -r "$file" ; then
508            class=`echo $file | sed -e 's%^.*layouts/\(.*\)\.layout$%\1%'`
509            # Generate the proper TestDocClass command for this layout
510            grep '\\Declare\(LaTeX\|DocBook\|LinuxDoc\)Class' "$file" \
511               | sed -e 's/^\# *\(.*\)$/\\TestDocClass{'${class}'}{\1}/'
512          fi ;;
513     esac
514   done > chklayouts.tex
515 changequote([,])dnl
516   [eval] ${LATEX} wrap_chkconfig.ltx 2>/dev/null | grep '^\+'
517   [eval] `cat chkconfig.vars | sed 's/-/_/g'`
518 changequote(,)dnl
519   test -n "${rmlink}" && rm -f chkconfig.ltx
520 fi
521
522 # Do we have all the files we need? Useful if latex did not run
523 changequote([,])dnl
524
525 PROVIDE_DEFAULT_FILE(chkconfig.sed,[s/@.*@/???/g])
526
527 echo "creating packages.lst"
528 PROVIDE_DEFAULT_FILE(packages.lst,dnl
529 [# This file should contain the list of LaTeX packages that have been
530 # recognized by LyX. Unfortunately, since configure could not find
531 # your LaTeX2e program, the tests have not been run. Run ./configure
532 # if you need to update it after a configuration change.
533 ])
534 changequote(,)dnl
535
536 echo "creating doc/LaTeXConfig.lyx"
537 echo "s/@chk_linuxdoc@/$chk_linuxdoc/g" >> chkconfig.sed
538 echo "s/@chk_docbook@/$chk_docbook/g" >> chkconfig.sed
539 # Add a line to chkconfig.sed so that the placeholder in
540 # LaTeXConfig.lyx.in will be replaced by the list of available
541 # languages.
542 test "${LANGUAGES}" != "" && \
543         echo "s/@chk_languages@/${LANGUAGES}/g" >> chkconfig.sed
544 sed -f chkconfig.sed "${srcdir}"/doc/LaTeXConfig.lyx.in >doc/LaTeXConfig.lyx
545
546 echo "creating $outfile"
547 cat >$outfile <<EOF
548 # This file has been automatically generated by LyX' lib/configure
549 # script. It contains default settings that have been determined by
550 # examining your system. PLEASE DO NOT MODIFY ANYTHING HERE! If you
551 # want to customize LyX, make a copy of the file LYXDIR/lyxrc as
552 # ~/.lyx/lyxrc and edit this file instead. Any setting in lyxrc will
553 # override the values given here.
554 \\Format asciichess asc    "ASCII (chess output)"  "" ""        "$TEXT_EDITOR"
555 \\Format asciiimage asc    "ASCII (image)"         "" ""        "$TEXT_EDITOR"
556 \\Format asciixfig  asc    "ASCII (xfig output)"   "" ""        "$TEXT_EDITOR"
557 \\Format agr        agr     GRACE                  "" "$GRACE_VIEWER"   "$GRACE_EDITOR"
558 \\Format bmp        bmp     BMP                    "" "$RASTERIMAGE_VIEWER"     "$RASTERIMAGE_EDITOR"
559 \\Format date       ""     "date command"          "" ""        ""
560 \\Format dateout    tmp    "date (output)"         "" ""        "$TEXT_EDITOR"
561 \\Format docbook    sgml    DocBook                B  ""        "$TEXT_EDITOR"
562 \\Format docbook-xml xml   "Docbook (xml)"         "" ""        "$TEXT_EDITOR"
563 \\Format dvi        dvi     DVI                    D  "$DVI_VIEWER"     ""
564 \\Format eps        eps     EPS                    "" "$EPS_VIEWER"     ""
565 \\Format fax        ""      Fax                    "" ""        ""
566 \\Format fen        fen     FEN                    "" "$FEN_VIEWER"     "$FEN_EDITOR"
567 \\Format fig        fig     XFig                   "" "$FIG_VIEWER"     "$FIG_EDITOR"
568 \\Format gif        gif     GIF                    "" "$RASTERIMAGE_VIEWER"     "$RASTERIMAGE_EDITOR"
569 \\Format html       html    HTML                   H  "$HTML_VIEWER"    ""
570 \\Format jpg        jpg     JPG                    "" "$RASTERIMAGE_VIEWER"     "$RASTERIMAGE_EDITOR"
571 \\Format latex      tex     LaTeX                  L  ""        "$TEXT_EDITOR"
572 \\Format linuxdoc   sgml    LinuxDoc               x  ""        "$TEXT_EDITOR"
573 \\Format lyx        lyx     LyX                    "" "lyx"     "lyx"
574 \\Format lyxpreview lyxpreview "LyX Preview"       "" ""        ""
575 \\Format literate   nw      NoWeb                  N  ""        "$TEXT_EDITOR"
576 \\Format pbm        pbm     PBM                    "" "$RASTERIMAGE_VIEWER"     "$RASTERIMAGE_EDITOR"
577 \\Format pdf        pdf    "PDF (ps2pdf)"          P  "$PDF_VIEWER"     ""
578 \\Format pdf2       pdf    "PDF (pdflatex)"        F  "$PDF_VIEWER"     ""
579 \\Format pdf3       pdf    "PDF (dvipdfm)"         m  "$PDF_VIEWER"     ""
580 \\Format pdftex     pdftex_t PDFTEX                "" ""        ""
581 \\Format pgm        pgm     PGM                    "" "$RASTERIMAGE_VIEWER"     "$RASTERIMAGE_EDITOR"
582 \\Format png        png     PNG                    "" "$RASTERIMAGE_VIEWER"     "$RASTERIMAGE_EDITOR"
583 \\Format ppm        ppm     PPM                    "" "$RASTERIMAGE_VIEWER"     "$RASTERIMAGE_EDITOR"
584 \\Format program    ""      Program                "" ""        ""
585 \\Format ps         ps      Postscript             t  "$PS_VIEWER"      ""
586 \\Format pstex      pstex_t PSTEX                  "" ""        ""
587 \\Format tgif       obj     TGIF                   "" "$TGIF_VIEWER"    "$TGIF_EDITOR"
588 \\Format sxw        sxw    "OpenOffice.Org Writer" O  ""        ""
589 \\Format text       txt     ASCII                  A  ""        "$TEXT_EDITOR"
590 \\Format textparagraph txt "ASCII (paragraphs)"    "" ""        "$TEXT_EDITOR"
591 \\Format tiff       tif     TIFF                   "" "$RASTERIMAGE_VIEWER"     "$RASTERIMAGE_EDITOR"
592 \\Format word       doc     Word                   W  ""        ""
593 \\Format xbm        xbm     XBM                    "" "$RASTERIMAGE_VIEWER"     "$RASTERIMAGE_EDITOR"
594 \\Format xpm        xpm     XPM                    "" "$RASTERIMAGE_VIEWER"     "$RASTERIMAGE_EDITOR"
595
596 \\converter date       dateout    "date +%d-%m-%Y > \$\$o"      ""
597 \\converter docbook    docbook-xml "cp \$\$i \$\$o" "xml"
598 \\converter docbook    dvi        "$docbook_to_dvi_command"     ""
599 \\converter docbook    html       "$docbook_to_html_command"    ""
600 \\converter dvi        pdf3       "$dvi_to_pdf_command" ""
601 \\converter dvi        ps         "$dvi_to_ps_command"  ""
602 \\converter fen        asciichess "python \$\$s/fen2ascii.py \$\$i \$\$o"       ""
603 \\converter fig        pdftex     "sh \$\$s/fig2pdftex.sh \$\$i \$\$o"  ""
604 \\converter fig        pstex      "sh \$\$s/fig2pstex.sh \$\$i \$\$o"   ""
605 \\converter html       latex      "$html_to_latex_command"      ""
606 \\converter latex      html       "$latex_to_html_command"      "originaldir,needaux"
607 \\converter latex      dvi        "$latex_to_dvi"       "latex"
608 \\converter latex      lyx        "$tex_to_lyx_command" ""
609 \\converter latex      pdf2       "$latex_to_pdf"       "latex"
610 \\converter latex      sxw        "$latex_to_sxw_command"       "latex"
611 \\converter linuxdoc   dvi        "$linuxdoc_to_dvi_command"    ""
612 \\converter linuxdoc   html       "$linuxdoc_to_html_command"   ""
613 \\converter linuxdoc   latex      "$linuxdoc_to_latex_command"  ""
614 \\converter linuxdoc   lyx        "$linuxdoc_to_lyx_command"    ""
615 \\converter literate   latex      "$literate_to_tex_command"    ""
616 \\converter literate   lyx        "$literate_to_lyx_command"    ""
617 \\converter lyxpreview png        "$lyxpreview_to_png_command"  ""
618 \\converter lyxpreview ppm        "$lyxpreview_to_bitmap_command"       ""
619 \\converter ps         fax        "$fax_command"        ""
620 \\converter ps         pdf        "$ps_to_pdf_command"  ""
621 \\converter sxw        latex      "$sxw_to_latex_command"       ""
622 \\converter word       latex      "$word_to_latex_command"      ""
623 EOF
624
625 ### the graphic converter part with the predefined ones
626 #### Search for the nonstandard converting progs
627 #
628 SEARCH_PROG([for an FIG -> EPS/PPM converter], FIG2DEV, fig2dev)
629 if test "$FIG2DEV" = "fig2dev"; then
630 cat >>$outfile <<EOF
631 \\converter fig        eps        "fig2dev -L eps \$\$i \$\$o" ""
632 \\converter fig        ppm        "fig2dev -L ppm \$\$i \$\$o" ""
633 \\converter fig        png        "fig2dev -L png \$\$i \$\$o" ""
634 EOF
635 fi
636
637 SEARCH_PROG([for an TIFF -> PS converter], TIFF2PS, tiff2ps)
638 if test "$TIFF2PS" = "tiff2ps"; then
639 cat >>$outfile <<EOF
640 \\converter tiff       eps        "tiff2ps \$\$i > \$\$o" ""
641 EOF
642 fi
643
644 SEARCH_PROG([for an TGIF -> EPS/PPM converter], TGIF, tgif)
645 if test "$TGIF" = "tgif"; then
646 cat >>$outfile <<EOF
647 \\converter tgif       eps        "tgif -stdout -print -color -eps \$\$i > \$\$o" ""
648 \\converter tgif       pdf        "tgif -stdout -print -color -pdf \$\$i > \$\$o" ""
649 EOF
650 fi
651
652 SEARCH_PROG([for an EPS -> PDF converter], EPSTOPDF, epstopdf)
653 if test "$EPSTOPDF" = "epstopdf"; then
654 cat >>$outfile <<EOF
655 \\converter eps        pdf        "epstopdf --outfile=\$\$o \$\$i" ""
656 EOF
657 fi
658
659 #### Add Grace conversions (xmgrace needs an Xserver, gracebat doesn't.)
660 SEARCH_PROG([for a Grace -> Image converter], GRACE, gracebat)
661 if test "$GRACE" = "gracebat"; then
662 cat >>$outfile <<EOF
663 \\converter agr        eps        "gracebat -hardcopy -printfile \$\$o -hdevice EPS \$\$i 2>/dev/null" ""
664 \\converter agr        png        "gracebat -hardcopy -printfile \$\$o -hdevice PNG \$\$i 2>/dev/null" ""
665 \\converter agr        jpg        "gracebat -hardcopy -printfile \$\$o -hdevice JPEG \$\$i 2>/dev/null" ""
666 \\converter agr        ppm        "gracebat -hardcopy -printfile \$\$o -hdevice PNM \$\$i 2>/dev/null" ""
667 EOF
668 fi
669
670 cat >>$outfile <<EOF
671
672 \\copier    fig        "sh \$\$s/fig_copy.sh \$\$i \$\$o"
673 \\copier    pstex      "python \$\$s/tex_copy.py \$\$i \$\$o \$\$l"
674 \\copier    pdftex     "python \$\$s/tex_copy.py \$\$i \$\$o \$\$l"
675
676 $rc_entries
677 \\font_encoding "$chk_fontenc"
678 EOF
679
680 ######## X FONTS
681 # create a fonts.dir file to make X fonts available to LyX
682 echo "checking for TeX fonts"
683
684 fontlist="cmex10 cmmi10 cmr10 cmsy10 eufm10 msam10 msbm10 wasy10"
685 rm -f xfonts/fonts.dir xfonts/fonts.scale xfonts/tmpfonts
686
687 num=0
688 touch xfonts/tmpfonts
689 for font in $fontlist ; do
690   MSG_CHECKING(for $font,+)
691   result=no
692   for ext in pfb pfa ttf ; do
693     if filepath=`kpsewhich $font.$ext` ; then
694       result="yes ($ext)"
695       rm -f xfonts/$font.$ext
696       ln -s $filepath xfonts 2>/dev/null
697       echo "$font.$ext -unknown-$font-medium-r-normal--0-0-0-0-p-0-adobe-fontspecific" >>xfonts/tmpfonts
698       num=`expr $num + 1`
699       break
700     fi
701   done
702   MSG_RESULT($result)
703 done
704
705 if test ! $num = 0 ; then
706   echo $num >xfonts/fonts.scale
707   cat xfonts/tmpfonts >>xfonts/fonts.scale
708   cp xfonts/fonts.scale xfonts/fonts.dir
709   # create a resource list file for Display Postscript
710   (cd xfonts ; rm -f PSres.upr ; makepsres) 2>/dev/null || true
711 fi
712 rm -f xfonts/tmpfonts
713
714
715 # Remove superfluous files if we are not writing in the main lib
716 # directory
717 for file in $outfile textclass.lst packages.lst \
718             doc/LaTeXConfig.lyx xfonts/fonts.dir ; do
719   # we rename the file first, so that we avoid comparing a file with itself
720   mv $file $file.new
721   if test -r "${srcdir}"/$file && diff $file.new "${srcdir}"/$file >/dev/null 2>/dev/null ;
722   then
723     echo "removing $file, which is identical to the system global version"
724     rm -f $file.new
725   else
726     mv $file.new $file
727   fi
728 done
729 if test ! -r xfonts/fonts.dir ; then
730     echo "removing font links"
731     rm -f xfonts/*.pfb xfonts/fonts.scale
732 fi
733
734 # Final clean-up
735 if test $lyx_keep_temps = no ; then
736 rm -f chkconfig.sed chkconfig.vars wrap_chkconfig.* chklayouts.tex \
737       missfont.log
738 fi