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.
8 dnl ######### Begin M4 macros #########################################
9 dnl This is a template for my stripped-down configure script.
10 dnl First, a few convenient macros.
14 dnl MSG_CHECKING(FEATURE-DESCRIPTION,PREFIX)
17 [echo $ac_n "$2checking $1""... $ac_c"])dnl
20 dnl MSG_RESULT(RESULT-DESCRIPTION)
23 [echo "$ac_t""$1"])dnl
26 dnl SEARCH_PROG(FEATURE-DESCRIPTION,VARIABLE-NAME,PROGRAMS-LIST,
27 dnl ACTION-IF-FOUND,ACTION-IF-NOT-FOUND)
29 define(SEARCH_PROG,[dnl
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
50 if test -n "[$]$2"; then
56 MSG_RESULT($ac_result)
57 test -n "[$]$2" && break
61 if test -z "[$]$2" ; then
70 dnl LYXRC_VAR(VARIABLE_NAME, VALUE)
72 rc_entries="$rc_entries
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)
83 dnl PROVIDE_DEFAULT_FILE(FILE, DEFAULT-VALUE)
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
94 dnl ######### End M4 macros #############################################
97 ####some configuration variables
98 outfile=lyxrc.defaults
105 #### Parse the command line
110 Usage: configure [options]
112 --help show this help lines
113 --keep-temps keep temporary files (for debug. purposes)
114 --without-latex-config do not run LaTeX to determine configuration
115 --with-version-suffix=suffix suffix of binary installed files
118 --without-latex-config)
119 lyx_check_config=no ;;
121 lyx_keep_temps=yes ;;
122 --with-version-suffix*)
123 version_suffix=`echo "$ac_option" | sed 's,--with-version-suffix=,,'`
128 #### Checking for some echo oddities
129 if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
130 # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
131 if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
138 ac_n= ac_c='\c' ac_t=
142 #### I do not really know why this is useful, but we might as well keep it.
144 # Only set these to C if already set. These must not be set unconditionally
145 # because not all systems understand e.g. LANG=C (notably SCO).
146 # Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
147 # Non-C LC_CTYPE values break the ctype check.
148 if test "${LANG+set}" = set; then LANG=C; export LANG; fi
149 if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
150 if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
151 if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
154 #### Guess the directory in which configure is located.
158 srcdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
159 srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
160 test "x$srcdir" = "x$ac_prog" && srcdir=.
161 if test ! -r ${srcdir}/chkconfig.ltx ; then
162 echo "configure: error: cannot find chkconfig.ltx script"
166 #### Adjust PATH for Win32 (Cygwin)
169 echo "configure: cygwin detected; path correction"
170 srcdir=`cygpath -w "${srcdir}" | tr '\\\\' /`
171 echo "srcdir=${srcdir}" ;;
174 #### Create the build directories if necessary
175 for dir in bind clipart doc examples help images kbd layouts reLyX \
176 scripts templates ui xfonts; do
177 test ! -d $dir && mkdir $dir
181 #### Searching some useful programs
182 define(CHECKLATEX2E,[
183 ## Check whether this is really LaTeX2e
185 cat >chklatex.ltx <<EOF
186 \\nonstopmode\\makeatletter
187 \\ifx\\undefined\\documentclass\\else
188 \\message{ThisIsLaTeX2e}
192 if eval ${LATEX} chklatex.ltx </dev/null 2>/dev/null \
193 | grep 'ThisIsLaTeX2e' >/dev/null; then
197 ac_result="not useable"
199 rm -f chklatex.ltx chklatex.log])dnl
202 SEARCH_PROG([for a LaTeX2e program],LATEX,latex latex2e,CHECKLATEX2E,dnl
203 [lyx_check_config=no])
205 test -z "$latex_to_dvi" && latex_to_dvi="none"
207 # Search for pdflatex
208 if test ${lyx_check_config} = no ; then
211 SEARCH_PROG([for the pdflatex program],latex_to_pdf,pdflatex)
214 test $latex_to_dvi != "none" && latex_to_dvi="$latex_to_dvi \$\$i"
215 test $latex_to_pdf != "none" && latex_to_pdf="$latex_to_pdf \$\$i"
217 # Search for an installed reLyX or a ready-to-install one
219 PATH=${PATH}:./reLyX/
220 SEARCH_PROG([for a LaTeX -> LyX converter],tex_to_lyx_command,reLyX)
222 test $tex_to_lyx_command = "reLyX" && tex_to_lyx_command="reLyX -f \$\$i"
223 tex_to_lyx_command=`echo $tex_to_lyx_command | sed "s,reLyX,reLyX$version_suffix,"`
225 SEARCH_PROG([for a Noweb -> LyX converter],literate_to_lyx_command,noweb2lyx)
226 test $literate_to_lyx_command = "noweb2lyx" && literate_to_lyx_command="noweb2lyx \$\$i \$\$o"
227 literate_to_lyx_command=`echo $literate_to_lyx_command | sed "s,noweb2lyx,noweb2lyx$version_suffix,"`
229 # Search something to process a literate document
230 SEARCH_PROG([for a Noweb -> LaTeX converter],literate_to_tex_command,noweave)
231 test $literate_to_tex_command = "noweave" && literate_to_tex_command="noweave -delay -index \$\$i > \$\$o"
233 SEARCH_PROG([for a HTML -> Latex converter],html_to_latex_command,html2latex)
234 test $html_to_latex_command = "html2latex" && html_to_latex_command="html2latex \$\$i"
236 SEARCH_PROG([for a MSWord -> Latex converter],word_to_latex_command,wvCleanLatex word2x)
237 test "$word_to_latex_command" = "wvCleanLatex" && word_to_latex_command="wvCleanLatex \$\$i \$\$o"
238 test "$word_to_latex_command" = "word2x" && word_to_latex_command="word2x -f latex \$\$i"
240 SEARCH_PROG([for Image converter],image_command,convert)
241 test $image_command = "convert" && image_command="convert \$\$i \$\$o"
243 # Search for a Postscript interpreter
244 LYXRC_PROG([for a Postscript interpreter], \ps_command, gs)
246 # Search something to preview postscript
247 SEARCH_PROG([for a Postscript previewer],GHOSTVIEW,gv ghostview)
249 # Search for a program to preview pdf
250 SEARCH_PROG([for a PDF preview],PDF_VIEWER,acroread gv ghostview xpdf)
252 # Search something to preview dvi
253 SEARCH_PROG([for a DVI previewer],DVI_VIEWER, xdvi windvi yap)
255 # Search something to preview html
256 SEARCH_PROG([for a HTML previewer],HTML_VIEWER, netscape)
258 # Search for a program to preview latex code
259 SEARCH_PROG([for a LaTeX preview],LATEX_VIEWER, "xterm -e less")
261 # Search for a program to convert ps to pdf
262 SEARCH_PROG([for a PS to PDF converter],ps_to_pdf_command,ps2pdf)
263 test $ps_to_pdf_command = "ps2pdf" && ps_to_pdf_command="ps2pdf \$\$i"
265 # Search for a program to convert dvi to ps
266 SEARCH_PROG([for a DVI to PS converter],dvi_to_ps_command,dvips)
267 test $dvi_to_ps_command = "dvips" && dvi_to_ps_command="dvips -o \$\$o \$\$i"
269 # Search for a program to convert dvi to pdf
270 SEARCH_PROG([for a DVI to PDF converter],dvi_to_pdf_command,dvipdfm)
271 test $dvi_to_pdf_command = "dvipdfm" && dvi_to_pdf_command="dvipdfm \$\$i"
273 # We have a script to convert previewlyx to ppm
274 lyxpreview_to_ppm_command="lyxpreview2ppm.sh"
276 # Search a *roff program (used to translate tables in ASCII export)
277 LYXRC_PROG([for a *roff formatter], \ascii_roff_command, dnl
278 'groff -t -Tlatin1 $$FName' nroff,dnl
279 test "$prog" = "nroff" && prog='tbl $$FName | nroff')
281 # Search the ChkTeX program
282 LYXRC_PROG([for ChkTeX], \chktex_command,dnl
283 "chktex -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38")
285 # Search for a spellchecker
286 LYXRC_PROG([for a spell-checker], \spell_command, ispell)
288 dnl # Search a Fax handling program
289 dnl SEARCH_PROG([for a fax driver], FAX, sendfax faxsend fax)
290 dnl if test $FAX = sendfax ; then
291 dnl fax_command="sendfax -n -h '\$\$Host' -c '\$\$Comment' -x '\$\$Enterprise' -d '\$\$Name'@'\$\$Phone' '\$\$FName'"
292 dnl elif test $FAX = faxsend ; then
293 dnl fax_command="faxsend '\$\$Phone' '\$\$FName'"
294 dnl elif test $FAX = fax ; then
295 dnl fax_command="fax send '\$\$Phone' '\$\$FName'"
297 dnl fax_command="none"
300 # Search a GUI Fax program
301 SEARCH_PROG([for a fax program], fax_command, ksendfax)
302 test $fax_command = "ksendfax" && fax_command="ksendfax \$\$i"
304 # Search for LinuxDoc support
305 SEARCH_PROG([for SGML-tools 1.x (LinuxDoc)], LINUXDOC, sgml2lyx)
307 if test $LINUXDOC != none; then
309 linuxdoc_cmd="\\def\\haslinuxdoc{yes}"
314 linuxdoc_to_latex_command="sgml2latex \$\$i"
315 linuxdoc_to_dvi_command="sgml2latex -o dvi \$\$i"
316 linuxdoc_to_html_command="sgml2html \$\$i"
317 linuxdoc_to_lyx_command="sgml2lyx \$\$i";;
319 linuxdoc_to_latex_command="none"
320 linuxdoc_to_dvi_command="none"
321 linuxdoc_to_html_command="none"
322 linuxdoc_to_lyx_command="none";;
325 # Search for DocBook support
326 SEARCH_PROG([for SGML-tools 2.x (DocBook) or db2x scripts], DOCBOOK, sgmltools db2dvi)
328 if test $DOCBOOK != none; then
330 docbook_cmd="\\def\\hasdocbook{yes}"
335 docbook_to_dvi_command="sgmltools -b dvi \$\$i"
336 docbook_to_html_command="sgmltools -b html \$\$i";;
338 docbook_to_dvi_command="db2dvi \$\$i"
339 docbook_to_html_command="db2html \$\$i";;
341 docbook_to_dvi_command="none"
342 docbook_to_html_command="none";;
345 # Search for a spool command
346 LYXRC_PROG([for a spool command], \print_spool_command, lp lpr)
348 lp) print_spool_printerprefix="-d ";;
349 lpr) print_spool_printerprefix="-P";;
350 *) :;; # leave to empty values
352 LYXRC_VAR(\print_spool_printerprefix, $print_spool_printerprefix)
354 SEARCH_PROG([for a LaTeX -> HTML converter], TOHTML, tth latex2html hevea)
355 latex_to_html_command=$TOHTML
357 tth) latex_to_html_command="tth -t -e2 -L\$\$b < \$\$i > \$\$o";;
358 latex2html) latex_to_html_command="latex2html -no_subdir -split 0 -show_section_numbers \$\$i";;
359 hevea) latex_to_html_command="hevea -s \$\$i";;
362 #### Explore the LaTeX configuration
363 MSG_CHECKING(LaTeX configuration)
364 # First, remove the files that we want to re-create
365 rm -f textclass.lst packages.lst chkconfig.sed
366 if test ${lyx_check_config} = no ; then
367 MSG_RESULT(default values)
370 rm -f wrap_chkconfig.ltx chkconfig.vars chkconfig.classes chklayouts.tex
371 cat >wrap_chkconfig.ltx <<EOF
372 \\newcommand\\srcdir{${srcdir}}
375 \\input{${srcdir}/chkconfig.ltx}
377 ## Construct the list of classes to test for.
378 # build the list of available layout files and convert it to commands
380 for file in ./layouts/*.layout ${srcdir}/layouts/*.layout ; do
383 *) test -r "$file" && echo $file ;;
385 done | sed -e 's%^.*layouts/\(.*\)\.layout$%\\TestDocClass{\1}%'\
388 [eval] ${LATEX} wrap_chkconfig.ltx 2>/dev/null | grep '^\+'
389 [eval] `cat chkconfig.vars | sed 's/-/_/g'`
393 # Do we have all the files we need? Useful if latex did not run
395 echo "creating textclass.lst"
396 PROVIDE_DEFAULT_FILE(textclass.lst,dnl
397 [# This file declares layouts and their associated definition files
398 # (include dir. relative to the place where this file is).
399 # It contains only default values, since chkconfig.ltx could not be run
400 # for some reason. Run ./configure if you need to update it after a
401 # configuration change.
402 article article article
405 linuxdoc linuxdoc linuxdoc
406 letter letter letter])
408 PROVIDE_DEFAULT_FILE(chkconfig.sed,[s/@.*@/???/g])
410 echo "creating packages.lst"
411 PROVIDE_DEFAULT_FILE(packages.lst,dnl
412 [# This file should contain the list of LaTeX packages that have been
413 # recognized by LyX. Unfortunately, since configure could not find
414 # your LaTeX2e program, the tests have not been run. Run ./configure
415 # if you need to update it after a configuration change.
419 echo "creating doc/LaTeXConfig.lyx"
420 echo "s/@chk_linuxdoc@/$chk_linuxdoc/g" >> chkconfig.sed
421 echo "s/@chk_docbook@/$chk_docbook/g" >> chkconfig.sed
422 sed -f chkconfig.sed ${srcdir}/doc/LaTeXConfig.lyx.in >doc/LaTeXConfig.lyx
424 echo "creating $outfile"
426 # This file has been automatically generated by LyX' lib/configure
427 # script. It contains default settings that have been determined by
428 # examining your system. PLEASE DO NOT MODIFY ANYTHING HERE! If you
429 # want to customize LyX, make a copy of the file LYXDIR/lyxrc as
430 # ~/.lyx/lyxrc and edit this file instead. Any setting in lyxrc will
431 # override the values given here.
432 \\Format text txt ASCII A
433 \\Format textparagraph txt ASCII(paragraphs) ""
434 \\Format docbook sgml DocBook B
435 \\Format bmp bmp BMP ""
436 \\Format dvi dvi DVI D
437 \\Format eps eps EPS ""
438 \\Format epsi epsi EPSI ""
439 \\Format fax "" Fax ""
440 \\Format fig fig XFig ""
441 \\Format agr agr GRACE ""
442 \\Format html html HTML H
443 \\Format latex tex LaTeX L
444 \\Format linuxdoc sgml LinuxDoc x
445 \\Format lyx lyx LyX ""
446 \\Format literate nw NoWeb N
447 \\Format pdf pdf PDF P
448 \\Format pdf2 pdf "PDF (pdflatex)" F
449 \\Format pdf3 pdf "PDF (dvipdfm)" m
450 \\Format png png PNG ""
451 \\Format ppm ppm PPM ""
452 \\Format ps ps Postscript t
453 \\Format program "" Program ""
454 \\Format tgif obj TGIF ""
455 \\Format tiff tif TIFF ""
456 \\Format word doc Word W
457 \\Format xpm xpm XPM ""
458 \\Format lyxpreview lyxpreview "LyX Preview" ""
460 \\converter latex dvi "$latex_to_dvi" "latex"
461 \\converter latex pdf2 "$latex_to_pdf" "latex"
462 \\converter latex html "$latex_to_html_command" "originaldir,needaux"
463 \\converter literate latex "$literate_to_tex_command" ""
464 \\converter dvi pdf3 "$dvi_to_pdf_command" ""
465 \\converter dvi ps "$dvi_to_ps_command" ""
466 \\converter ps pdf "$ps_to_pdf_command" ""
467 \\converter ps fax "$fax_command" ""
468 \\converter linuxdoc lyx "$linuxdoc_to_lyx_command" ""
469 \\converter linuxdoc latex "$linuxdoc_to_latex_command" ""
470 \\converter linuxdoc dvi "$linuxdoc_to_dvi_command" ""
471 \\converter linuxdoc html "$linuxdoc_to_html_command" ""
472 \\converter docbook dvi "$docbook_to_dvi_command" ""
473 \\converter docbook html "$docbook_to_html_command" ""
474 \\converter lyxpreview ppm "$lyxpreview_to_ppm_command" ""
476 \\converter latex lyx "$tex_to_lyx_command" ""
477 \\converter literate lyx "$literate_to_lyx_command" ""
478 \\converter html latex "$html_to_latex_command" ""
479 \\converter word latex "$word_to_latex_command" ""
481 \\viewer dvi "$DVI_VIEWER"
482 \\viewer html "$HTML_VIEWER"
483 \\viewer pdf "$PDF_VIEWER"
484 \\viewer ps "$GHOSTVIEW -swap"
485 \\viewer eps "$GHOSTVIEW"
486 \\viewer latex "$LATEX_VIEWER"
489 \\font_encoding "$chk_fontenc"
492 ### the graphic converter part with the predefined ones
493 #### Search for tne nonstandard converting progs
495 SEARCH_PROG([for an FIG -> EPS/XPM converter], FIG2DEV, fig2dev)
496 if test "$FIG2DEV" = "fig2dev"; then
498 \\converter fig eps "fig2dev -L eps \$\$i \$\$o" ""
499 \\converter fig xpm "fig2dev -L xpm \$\$i \$\$o" ""
503 SEARCH_PROG([for an TIFF -> PS converter], TIFF2PS, tiff2ps)
504 if test "$TIFF2PS" = "tiff2ps"; then
506 \\converter tiff eps "tiff2ps \$\$i > \$\$o" ""
510 SEARCH_PROG([for an TGIF -> EPS/XPM converter], TGIF, tgif)
511 if test "$TGIF" = "tgif"; then
513 \\converter tgif eps "tgif -print -eps \$\$i" ""
514 \\converter tgif pdf "tgif -print -pdf \$\$i" ""
515 \\converter tgif png "tgif -print -png \$\$i" ""
516 \\converter tgif xpm "tgif -print -stdout -xpm \$\$i > \$\$o" ""
520 SEARCH_PROG([for an EPS -> PDF converter], EPSTOPDF, epstopdf)
521 if test "$EPSTOPDF" = "epstopdf"; then
523 \\converter eps pdf "epstopdf --outfile=\$\$o \$\$i" ""
527 SEARCH_PROG([for an EPSI -> EPS/XPM converter], EPS2EPS, eps2eps)
528 if test "$EPS2EPS" = "eps2eps"; then
530 \\converter epsi pdf "epstopdf --outfile=\$\$o \$\$i" ""
531 \\converter epsi eps "eps2eps \$\$i $$o" ""
532 \\converter epsi xpm "eps2eps -sOutputFile=- \$\$i dummy.eps | convert - \$\$o" ""
536 #### Add Grace conversions (xmgrace needs an Xserver, gracebat doesn't.)
537 SEARCH_PROG([for a Grace -> Image converter], GRACE, gracebat)
538 if test "$GRACE" = "gracebat"; then
540 \\converter agr eps "gracebat -hardcopy -printfile \$\$o -hdevice EPS \$\$i 2>/dev/null" ""
541 \\converter agr png "gracebat -hardcopy -printfile \$\$o -hdevice PNG \$\$i 2>/dev/null" ""
542 \\converter agr xpm "gracebat -hardcopy -printfile - -hdevice PNG \$\$i 2>/dev/null | convert - \$\$o" ""
547 # create a fonts.dir file to make X fonts available to LyX
548 echo "checking for TeX fonts"
550 fontlist="cmex10 cmmi10 cmr10 cmsy10 eufm10 msam10 msbm10 wasy10"
551 rm -f xfonts/fonts.dir xfonts/fonts.scale xfonts/tmpfonts
554 touch xfonts/tmpfonts
555 for font in $fontlist ; do
556 MSG_CHECKING([for $font])
558 for ext in pfb pfa ttf ; do
559 if filepath=`kpsewhich $font.$ext` ; then
561 rm -f xfonts/$font.$ext
562 ln -s $filepath xfonts 2>/dev/null
563 echo "$font.$ext -unknown-$font-medium-r-normal--0-0-0-0-p-0-adobe-fontspecific" >>xfonts/tmpfonts
571 if test ! $num = 0 ; then
572 echo $num >xfonts/fonts.scale
573 cat xfonts/tmpfonts >>xfonts/fonts.scale
574 cp xfonts/fonts.scale xfonts/fonts.dir
576 rm -f xfonts/tmpfonts
579 # Remove superfluous files if we are not writing in the main lib
581 for file in $outfile textclass.lst packages.lst \
582 doc/LaTeXConfig.lyx xfonts/fonts.dir ; do
583 # we rename the file first, so that we avoid comparing a file with itself
585 if test -r $srcdir/$file && diff $file.new $srcdir/$file >/dev/null 2>/dev/null ;
587 echo "removing $file, which is identical to the system global version"
596 if test $lyx_keep_temps = no ; then
597 rm -f chkconfig.sed chkconfig.vars wrap_chkconfig.* chklayouts.tex \