]> git.lyx.org Git - lyx.git/blob - lib/configure.m4
Converter patch from Dekel, Preference patch from Angus, menu patch from Rob
[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   else
53     ac_result=no
54   fi
55   ifelse($4,,,[$4])
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 PROVIDE_DEFAULT_FILE(FILE, DEFAULT-VALUE)
71 dnl
72 define(PROVIDE_DEFAULT_FILE,[dnl
73 # if $1 does not exist (because LaTeX did not run), 
74 # then provide a standard version.
75 if test ! -f $1 ; then
76   cat >$1 <<EOF
77 $2
78 EOF
79 fi])
80 changequote(,)dnl
81 dnl ######### End M4 macros #############################################
82
83
84 ####some configuration variables
85 lyx_check_config=yes
86 lyx_keep_temps=no
87 srcdir=
88
89 #### Parse the command line
90 for ac_option do
91   case "$ac_option" in
92     -help | --help | -h)
93       cat << EOF
94 Usage: configure [options] 
95 Options: 
96   --help                   show this help lines
97   --keep-temps             keep temporary files (for debug. purposes)
98   --without-latex-config   do not run LaTeX to determine configuration
99 EOF
100       exit 0;;
101     --without-latex-config)
102       lyx_check_config=no ;;
103     --keep-temps)
104       lyx_keep_temps=yes ;;
105   esac 
106 done
107
108
109 #### Checking for some echo oddities
110 if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
111   # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
112   if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
113     ac_n= ac_c='
114 ' ac_t='        '
115   else
116     ac_n=-n ac_c= ac_t=
117   fi
118 else
119   ac_n= ac_c='\c' ac_t=
120 fi
121
122
123 #### I do not really know why this is useful, but we might as well keep it.
124 # NLS nuisances.
125 # Only set these to C if already set.  These must not be set unconditionally
126 # because not all systems understand e.g. LANG=C (notably SCO).
127 # Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
128 # Non-C LC_CTYPE values break the ctype check.
129 if test "${LANG+set}"   = set; then LANG=C;   export LANG;   fi
130 if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
131 if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
132 if test "${LC_CTYPE+set}"    = set; then LC_CTYPE=C;    export LC_CTYPE;    fi
133
134
135 #### Guess the directory in which configure is located.
136 changequote([,])dnl
137 ac_prog=[$]0
138 changequote(,)dnl
139 srcdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` 
140 srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
141 test "x$srcdir" = "x$ac_prog" && srcdir=.
142 if test ! -r ${srcdir}/chkconfig.ltx ; then
143   echo "configure: error: cannot find chkconfig.ltx script"
144   exit 1
145 fi
146
147
148 #### Create the build directories if necessary
149 for dir in bind clipart doc examples images kbd layouts reLyX \
150     scripts templates ui ; do
151   test ! -d $dir && mkdir $dir
152 done
153
154
155 #### Searching some useful programs
156 define(CHECKLATEX2E,[
157 ## Check whether this is really LaTeX2e
158 rm -f chklatex.ltx
159 cat >chklatex.ltx <<EOF
160 \\nonstopmode\\makeatletter
161 \\ifx\\undefined\\documentclass\\else
162   \\message{ThisIsLaTeX2e}
163 \\fi
164 \\@@end
165 EOF
166 if eval ${LATEX} chklatex.ltx </dev/null 2>/dev/null \
167                        | grep 'ThisIsLaTeX2e' >/dev/null; then
168   :
169 else
170   LATEX=
171   ac_result="not useable"
172 fi
173 rm -f chklatex.ltx chklatex.log])dnl
174 dnl
175 # Search LaTeX2e
176 SEARCH_PROG([for a LaTeX2e program],LATEX,latex latex2e,CHECKLATEX2E,dnl
177   [lyx_check_config=no])
178 if test x$lyx_check_config != x ; then
179 SEARCH_PROG([for the pdflatex program],PDFLATEX,pdflatex,CHECKLATEX2E)
180 fi
181
182 # Search for an installed reLyX or a ready-to-install one
183 save_PATH=${PATH}
184 PATH=${PATH}:./reLyX/
185 SEARCH_PROG([for a LaTeX -> LyX converter],tex_to_lyx_command,reLyX)
186 PATH=${save_PATH}
187 test $tex_to_lyx_command = "reLyX" && tex_to_lyx_command="reLyX -f \$\$i"
188
189 SEARCH_PROG([for a Noweb -> LyX converter],literate_to_lyx_command,noweb2lyx)
190 test $literate_to_lyx_command = "noweb2lyx" && literate_to_lyx_command="noweb2lyx \$\$i \$\$o"
191
192 # Search something to process a literate document
193 SEARCH_PROG([for a Noweb -> LaTeX converter],literate_to_tex_command,noweave)
194 test $literate_to_tex_command = "noweave" && literate_to_tex_command="noweave -delay -index \$\$i > \$\$o"
195
196 SEARCH_PROG([for a HTML -> Latex converter],html_to_latex_command,html2latex)
197 test $html_to_latex_command = "html2latex" && html_to_latex_command="html2latex \$\$i"
198
199 SEARCH_PROG([for a MSWord -> Latex converter],word_to_latex_command,wvCleanLatex word2x)
200 test $word_to_latex_command = "wvCleanLatex" && word_to_latex_command="wvCleanLatex \$\$i \$\$o"
201 test $word_to_latex_command = "word2x" && word_to_latex_command="word2x -f latex \$\$i"
202
203 SEARCH_PROG([for Image converter],image_command,convert)
204 test $image_command = "convert" && image_command="convert \$\$i \$\$o"
205
206 # Search for a Postscript interpreter
207 SEARCH_PROG([for a Postscript interpreter],GS, gs)
208
209 # Search something to preview postscript
210 SEARCH_PROG([for a Postscript previewer],GHOSTVIEW,gv ghostview)
211
212 # Search for a program to preview pdf
213 SEARCH_PROG([for a PDF preview],PDF_VIEWER,acroread gv ghostview xpdf)
214
215 # Search something to preview dvi
216 SEARCH_PROG([for a DVI previewer],DVI_VIEWER, xdvi)
217
218 # Search something to preview html
219 SEARCH_PROG([for a HTML previewer],HTML_VIEWER, netscape)
220
221 # Search for a program to convert ps to pdf
222 SEARCH_PROG([for a PS to PDF converter],ps_to_pdf_command,ps2pdf)
223 test $ps_to_pdf_command = "ps2pdf" && ps_to_pdf_command="ps2pdf \$\$i"
224
225 # Search for a program to convert dvi to ps
226 SEARCH_PROG([for a DVI to PS converter],dvi_to_ps_command,dvips)
227 test $dvi_to_ps_command = "dvips" && dvi_to_ps_command="dvips -o \$\$o \$\$i"
228
229 # Search a *roff program (used to translate tables in ASCII export)
230 SEARCH_PROG([for a *roff formatter],ROFF,groff nroff)
231 ascii_roff_command=$ROFF
232 test $ROFF = "groff" && ascii_roff_command="groff -t -Tlatin1 \$\$FName"
233 test $ROFF = "nroff" && ascii_roff_command="tbl \$\$FName | nroff"
234
235 # Search the ChkTeX program
236 SEARCH_PROG([for ChkTeX],CHKTEX,chktex)
237 chktex_command=$CHKTEX
238 test $CHKTEX = "chktex" && chktex_command="$CHKTEX -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38"
239
240 # Search for a spellchecker
241 SEARCH_PROG([for a spell-checker], SPELL,ispell)
242
243 dnl # Search a Fax handling program
244 dnl SEARCH_PROG([for a fax driver], FAX, sendfax faxsend fax)
245 dnl if test $FAX = sendfax ; then
246 dnl   fax_command="sendfax -n -h '\$\$Host' -c '\$\$Comment' -x '\$\$Enterprise' -d '\$\$Name'@'\$\$Phone' '\$\$FName'"
247 dnl elif test $FAX = faxsend ; then
248 dnl   fax_command="faxsend '\$\$Phone' '\$\$FName'"
249 dnl elif test $FAX = fax ; then
250 dnl   fax_command="fax send '\$\$Phone' '\$\$FName'"
251 dnl else
252 dnl   fax_command="none"
253 dnl fi
254
255 # Search a GUI Fax program
256 SEARCH_PROG([for a fax program], fax_command, ksendfax)
257 test $fax_command = "ksendfax" && fax_command="ksendfax \$\$i"
258
259 # Search for LinuxDoc support
260 SEARCH_PROG([for SGML-tools 1.x (LinuxDoc)], LINUXDOC, sgml2lyx)
261 chk_linuxdoc=no
262 if test $LINUXDOC != none; then
263   chk_linuxdoc=yes
264   linuxdoc_cmd="\\def\\haslinuxdoc{yes}"
265 fi
266
267 case $LINUXDOC in
268   sgml2lyx)
269     linuxdoc_to_latex_command="sgml2latex \$\$i"
270     linuxdoc_to_dvi_command="sgml2latex -o dvi \$\$i"
271     linuxdoc_to_html_command="sgml2html \$\$i"
272     linuxdoc_to_lyx_command="sgml2lyx \$\$i";;
273   none)
274     linuxdoc_to_latex_command="none"
275     linuxdoc_to_dvi_command="none"
276     linuxdoc_to_html_command="none"
277     linuxdoc_to_lyx_command="none";;
278 esac
279
280 # Search for DocBook support
281 SEARCH_PROG([for SGML-tools 2.x (DocBook) or db2x scripts], DOCBOOK, sgmltools db2dvi)
282 chk_docbook=no
283 if test $DOCBOOK != none; then
284   chk_docbook=yes
285   docbook_cmd="\\def\\hasdocbook{yes}"
286 fi
287
288 case $DOCBOOK in
289   sgmltools)
290     docbook_to_dvi_command="sgmltools -b dvi \$\$i"
291     docbook_to_html_command="sgmltools -b html \$\$i";;
292   db2dvi)
293     docbook_to_dvi_command="db2dvi \$\$i"
294     docbook_to_html_command="db2html \$\$i";;
295   none)
296     docbook_to_dvi_command="none"
297     docbook_to_html_command="none";;
298 esac
299
300 # Search for a spool command
301 SEARCH_PROG([for a spool command], LPR, lp lpr)
302 case $LPR in
303   lp) print_spool_command=lp
304       print_spool_printerprefix="-d ";;
305  lpr) print_spool_command=lpr
306       print_spool_printerprefix="-P";;
307    *) :;; # leave to empty values
308 esac
309
310 SEARCH_PROG([for a LaTeX -> HTML converter], TOHTML, tth latex2html hevea)
311 latex_to_html_command=$TOHTML
312 case $TOHTML in
313         tth) latex_to_html_command="tth -t -e2 -L\$\$b < \$\$i > \$\$o";;
314  latex2html) latex_to_html_command="latex2html -no_subdir -split 0 -show_section_numbers \$\$i";;
315       hevea) latex_to_html_command="hevea -s \$\$i";;
316 esac
317
318 #### Explore the LaTeX configuration
319 MSG_CHECKING(LaTeX configuration)
320 # First, remove the files that we want to re-create
321 rm -f textclass.lst packages.lst chkconfig.sed
322 if test ${lyx_check_config} = no ; then
323   MSG_RESULT(default values)
324 else
325   MSG_RESULT(auto)
326   rm -f wrap_chkconfig.ltx chkconfig.vars chkconfig.classes chklayouts.tex
327   cat >wrap_chkconfig.ltx <<EOF
328 \\newcommand\\srcdir{${srcdir}}
329 ${linuxdoc_cmd}
330 ${docbook_cmd}
331 \\input{${srcdir}/chkconfig.ltx}
332 EOF
333   ## Construct the list of classes to test for.
334   # build the list of available layout files and convert it to commands 
335   # for chkconfig.ltx 
336   for file in ./layouts/*.layout ${srcdir}/layouts/*.layout ; do 
337     case $file in
338       */\*.layout) ;;
339       *) test -r "$file" && echo $file ;;
340     esac
341   done | sed -e 's%^.*layouts/\(.*\)\.layout$%\\TestDocClass{\1}%'\
342              > chklayouts.tex
343 changequote([,])dnl
344   [eval] ${LATEX} wrap_chkconfig.ltx 2>/dev/null | grep '^\+'
345   [eval] `cat chkconfig.vars | sed 's/-/_/g'`
346 changequote(,)dnl
347 fi
348
349 # Do we have all the files we need? Useful if latex did not run
350 changequote([,])dnl
351 echo creating textclass.lst 
352 PROVIDE_DEFAULT_FILE(textclass.lst,dnl
353 [# This file declares layouts and their associated definition files
354 # (include dir. relative to the place where this file is).
355 # It contains only default values, since chkconfig.ltx could not be run 
356 # for some reason. Run ./configure if you need to update it after a
357 # configuration change.  
358 article article article
359 report  report  report
360 book    book    book
361 linuxdoc        linuxdoc        linuxdoc
362 letter  letter  letter])
363
364 PROVIDE_DEFAULT_FILE(chkconfig.sed,[s/@.*@/???/g])
365
366 echo creating packages.lst
367 PROVIDE_DEFAULT_FILE(packages.lst,dnl
368 [# This file should contain the list of LaTeX packages that have been
369 # recognized by LyX. Unfortunately, since configure could not find
370 # your LaTeX2e program, the tests have not been run. Run ./configure
371 # if you need to update it after a configuration change.
372 ])
373 changequote(,)dnl
374
375 echo creating doc/LaTeXConfig.lyx
376 echo "s/@chk_linuxdoc@/$chk_linuxdoc/g" >> chkconfig.sed
377 echo "s/@chk_docbook@/$chk_docbook/g" >> chkconfig.sed
378 sed -f chkconfig.sed ${srcdir}/doc/LaTeXConfig.lyx.in >doc/LaTeXConfig.lyx
379
380 echo creating lyxrc.defaults
381 rm -f lyxrc.defaults
382 cat >lyxrc.defaults <<EOF
383 # This file has been automatically generated by LyX' lib/configure
384 # script. It contains default settings that have been determined by
385 # examining your system. PLEASE DO NOT MODIFY ANYTHING HERE! If you
386 # want to customize LyX, make a copy of the file LYXDIR/lyxrc as
387 # ~/.lyx/lyxrc and edit this file instead. Any setting in lyxrc will
388 # override the values given here.
389 \\Format text     txt   ASCII           A
390 \\Format textparagraph txt ASCII(paragraphs)    ""
391 \\Format docbook  sgml  DocBook         B
392 \\Format dvi      dvi   DVI             D
393 \\Format eps      eps   EPS             ""
394 \\Format fax      ""    Fax             ""
395 \\Format gif      gif   GIF             ""
396 \\Format html     html  HTML            H
397 \\Format jpg      jpg   JPEG            ""
398 \\Format latex    tex   LaTeX           L
399 \\Format linuxdoc sgml  LinuxDoc        x
400 \\Format lyx      lyx   LyX             ""
401 \\Format literate nw    NoWeb           N
402 \\Format pdf      pdf   PDF             P
403 \\Format pdf2     pdf  "PDF (pdflatex)" F
404 \\Format png      png   PNG             ""
405 \\Format ps       ps    Postscript      t
406 \\Format program  ""    Program         ""
407 \\Format word     doc   Word            W
408
409
410 \\converter latex dvi "$LATEX \$\$i" "latex"
411 \\converter latex pdf2 "$PDFLATEX \$\$i" "latex"
412 \\converter latex html "$latex_to_html_command" "originaldir,needaux"
413 \\converter literate latex "$literate_to_tex_command" ""
414 \\converter dvi ps "$dvi_to_ps_command" ""
415 \\converter ps pdf "$ps_to_pdf_command" ""
416 \\converter ps fax "$fax_command" ""
417 \\converter linuxdoc lyx "$linuxdoc_to_lyx_command" ""
418 \\converter linuxdoc latex "$linuxdoc_to_latex_command" ""
419 \\converter linuxdoc dvi "$linuxdoc_to_dvi_command" ""
420 \\converter linuxdoc html "$linuxdoc_to_html_command" ""
421 \\converter docbook dvi "$docbook_to_dvi_command" ""
422 \\converter docbook html "$docbook_to_html_command" ""
423
424 \\converter latex lyx "$tex_to_lyx_command" ""
425 \\converter literate lyx "$literate_to_lyx_command" ""
426 \\converter html latex "$html_to_latex_command" ""
427 \\converter word latex "$word_to_latex_command" ""
428
429 \converter gif eps "$image_command" ""
430 \converter png eps "$image_command" ""
431 \converter jpg eps "$image_command" ""
432 \converter gif png "$image_command" ""
433
434 \\viewer dvi "$DVI_VIEWER"
435 \\viewer html "$HTML_VIEWER"
436 \\viewer pdf "$PDF_VIEWER"
437 \\viewer ps "$GHOSTVIEW -swap"
438 \\viewer eps "$GHOSTVIEW"
439
440 \\ps_command "$GS"
441 \\ascii_roff_command "$ascii_roff_command"
442 \\chktex_command "$chktex_command"
443 \\spell_command "$SPELL"
444 dnl \\fax_command "$fax_command"
445 \\print_spool_command "$print_spool_command"
446 \\print_spool_printerprefix "$print_spool_printerprefix"
447 \\font_encoding "$chk_fontenc"
448 EOF
449
450 # Remove superfluous files if we are not writing in the main lib
451 # directory 
452 for file in lyxrc.defaults textclass.lst packages.lst \
453             doc/LaTeXConfig.lyx ; do
454   # we rename the file first, so that we avoid comparing a file with itself
455   mv $file $file.new
456   if test -r $srcdir/$file && diff $file.new $srcdir/$file >/dev/null 2>/dev/null ; 
457   then 
458     echo "removing $file, which is identical to the system global version"
459     rm -f $file.new
460   else
461     mv $file.new $file
462   fi
463 done
464
465
466 # Final clean-up
467 if test $lyx_keep_temps = no ; then
468 rm -f chkconfig.sed chkconfig.vars wrap_chkconfig.* chklayouts.tex \
469       missfont.log
470 fi