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 PROVIDE_DEFAULT_FILE(FILE, DEFAULT-VALUE)
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
81 dnl ######### End M4 macros #############################################
84 ####some configuration variables
90 #### Parse the command line
95 Usage: configure [options]
97 --help show this help lines
98 --keep-temps keep temporary files (for debug. purposes)
99 --without-latex-config do not run LaTeX to determine configuration
100 --with-lyx-suffix=suffix suffix of binary installed files
103 --without-latex-config)
104 lyx_check_config=no ;;
106 lyx_keep_temps=yes ;;
108 lyx_suffix=`echo "$ac_option" | sed 's,--with-lyx-suffix=,,;s,^,-,'`
113 #### Checking for some echo oddities
114 if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then
115 # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu.
116 if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then
123 ac_n= ac_c='\c' ac_t=
127 #### I do not really know why this is useful, but we might as well keep it.
129 # Only set these to C if already set. These must not be set unconditionally
130 # because not all systems understand e.g. LANG=C (notably SCO).
131 # Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'!
132 # Non-C LC_CTYPE values break the ctype check.
133 if test "${LANG+set}" = set; then LANG=C; export LANG; fi
134 if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
135 if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi
136 if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi
139 #### Guess the directory in which configure is located.
143 srcdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'`
144 srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'`
145 test "x$srcdir" = "x$ac_prog" && srcdir=.
146 if test ! -r ${srcdir}/chkconfig.ltx ; then
147 echo "configure: error: cannot find chkconfig.ltx script"
151 #### Adjust PATH for Win32 (Cygwin)
152 if test "x$OSTYPE" = xcygwin; then
153 echo "configure: cygwin detected; path correction"
154 srcdir=`cygpath -w "${srcdir}" | tr '\\\\' /`
155 echo "srcdir=${srcdir}"
158 #### Create the build directories if necessary
159 for dir in bind clipart doc examples images kbd layouts reLyX \
160 scripts templates ui ; do
161 test ! -d $dir && mkdir $dir
165 #### Searching some useful programs
166 define(CHECKLATEX2E,[
167 ## Check whether this is really LaTeX2e
169 cat >chklatex.ltx <<EOF
170 \\nonstopmode\\makeatletter
171 \\ifx\\undefined\\documentclass\\else
172 \\message{ThisIsLaTeX2e}
176 if eval ${LATEX} chklatex.ltx </dev/null 2>/dev/null \
177 | grep 'ThisIsLaTeX2e' >/dev/null; then
181 ac_result="not useable"
183 rm -f chklatex.ltx chklatex.log])dnl
186 SEARCH_PROG([for a LaTeX2e program],LATEX,latex latex2e,CHECKLATEX2E,dnl
187 [lyx_check_config=no])
188 if test x$lyx_check_config != x ; then
189 SEARCH_PROG([for the pdflatex program],PDFLATEX,pdflatex,CHECKLATEX2E)
192 # Search for an installed reLyX or a ready-to-install one
194 PATH=${PATH}:./reLyX/
195 SEARCH_PROG([for a LaTeX -> LyX converter],tex_to_lyx_command,reLyX)
197 test $tex_to_lyx_command = "reLyX" && tex_to_lyx_command="reLyX -f \$\$i"
198 tex_to_lyx_command=`echo $tex_to_lyx_command | sed "s,reLyX,reLyX$lyx_suffix,"`
200 SEARCH_PROG([for a Noweb -> LyX converter],literate_to_lyx_command,noweb2lyx)
201 test $literate_to_lyx_command = "noweb2lyx" && literate_to_lyx_command="noweb2lyx \$\$i \$\$o"
202 literate_to_lyx_command=`echo $literate_to_lyx_command | sed "s,noweb2lyx,noweb2lyx$lyx_suffix,"`
204 # Search something to process a literate document
205 SEARCH_PROG([for a Noweb -> LaTeX converter],literate_to_tex_command,noweave)
206 test $literate_to_tex_command = "noweave" && literate_to_tex_command="noweave -delay -index \$\$i > \$\$o"
208 SEARCH_PROG([for a HTML -> Latex converter],html_to_latex_command,html2latex)
209 test $html_to_latex_command = "html2latex" && html_to_latex_command="html2latex \$\$i"
211 SEARCH_PROG([for a MSWord -> Latex converter],word_to_latex_command,wvCleanLatex word2x)
212 test "$word_to_latex_command" = "wvCleanLatex" && word_to_latex_command="wvCleanLatex \$\$i \$\$o"
213 test "$word_to_latex_command" = "word2x" && word_to_latex_command="word2x -f latex \$\$i"
215 SEARCH_PROG([for Image converter],image_command,convert)
216 test $image_command = "convert" && image_command="convert \$\$i \$\$o"
218 # Search for a Postscript interpreter
219 SEARCH_PROG([for a Postscript interpreter],GS, gs)
221 # Search something to preview postscript
222 SEARCH_PROG([for a Postscript previewer],GHOSTVIEW,gv ghostview)
224 # Search for a program to preview pdf
225 SEARCH_PROG([for a PDF preview],PDF_VIEWER,acroread gv ghostview xpdf)
227 # Search something to preview dvi
228 SEARCH_PROG([for a DVI previewer],DVI_VIEWER, xdvi windvi yap)
230 # Search something to preview html
231 SEARCH_PROG([for a HTML previewer],HTML_VIEWER, netscape)
233 # Search for a program to convert ps to pdf
234 SEARCH_PROG([for a PS to PDF converter],ps_to_pdf_command,ps2pdf)
235 test $ps_to_pdf_command = "ps2pdf" && ps_to_pdf_command="ps2pdf \$\$i"
237 # Search for a program to convert dvi to ps
238 SEARCH_PROG([for a DVI to PS converter],dvi_to_ps_command,dvips)
239 test $dvi_to_ps_command = "dvips" && dvi_to_ps_command="dvips -o \$\$o \$\$i"
241 # Search for a program to convert dvi to pdf
242 SEARCH_PROG([for a DVI to PDF converter],dvi_to_pdf_command,dvipdfm)
243 test $dvi_to_pdf_command = "dvipdfm" && dvi_to_pdf_command="dvipdfm \$\$i"
245 # Search a *roff program (used to translate tables in ASCII export)
246 SEARCH_PROG([for a *roff formatter],ROFF,groff nroff)
247 ascii_roff_command=$ROFF
248 test $ROFF = "groff" && ascii_roff_command="groff -t -Tlatin1 \$\$FName"
249 test $ROFF = "nroff" && ascii_roff_command="tbl \$\$FName | nroff"
251 # Search the ChkTeX program
252 SEARCH_PROG([for ChkTeX],CHKTEX,chktex)
253 chktex_command=$CHKTEX
254 test $CHKTEX = "chktex" && chktex_command="$CHKTEX -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38"
256 # Search for a spellchecker
257 SEARCH_PROG([for a spell-checker], SPELL,ispell)
259 dnl # Search a Fax handling program
260 dnl SEARCH_PROG([for a fax driver], FAX, sendfax faxsend fax)
261 dnl if test $FAX = sendfax ; then
262 dnl fax_command="sendfax -n -h '\$\$Host' -c '\$\$Comment' -x '\$\$Enterprise' -d '\$\$Name'@'\$\$Phone' '\$\$FName'"
263 dnl elif test $FAX = faxsend ; then
264 dnl fax_command="faxsend '\$\$Phone' '\$\$FName'"
265 dnl elif test $FAX = fax ; then
266 dnl fax_command="fax send '\$\$Phone' '\$\$FName'"
268 dnl fax_command="none"
271 # Search a GUI Fax program
272 SEARCH_PROG([for a fax program], fax_command, ksendfax)
273 test $fax_command = "ksendfax" && fax_command="ksendfax \$\$i"
275 # Search for LinuxDoc support
276 SEARCH_PROG([for SGML-tools 1.x (LinuxDoc)], LINUXDOC, sgml2lyx)
278 if test $LINUXDOC != none; then
280 linuxdoc_cmd="\\def\\haslinuxdoc{yes}"
285 linuxdoc_to_latex_command="sgml2latex \$\$i"
286 linuxdoc_to_dvi_command="sgml2latex -o dvi \$\$i"
287 linuxdoc_to_html_command="sgml2html \$\$i"
288 linuxdoc_to_lyx_command="sgml2lyx \$\$i";;
290 linuxdoc_to_latex_command="none"
291 linuxdoc_to_dvi_command="none"
292 linuxdoc_to_html_command="none"
293 linuxdoc_to_lyx_command="none";;
296 # Search for DocBook support
297 SEARCH_PROG([for SGML-tools 2.x (DocBook) or db2x scripts], DOCBOOK, sgmltools db2dvi)
299 if test $DOCBOOK != none; then
301 docbook_cmd="\\def\\hasdocbook{yes}"
306 docbook_to_dvi_command="sgmltools -b dvi \$\$i"
307 docbook_to_html_command="sgmltools -b html \$\$i";;
309 docbook_to_dvi_command="db2dvi \$\$i"
310 docbook_to_html_command="db2html \$\$i";;
312 docbook_to_dvi_command="none"
313 docbook_to_html_command="none";;
316 # Search for a spool command
317 SEARCH_PROG([for a spool command], LPR, lp lpr)
319 lp) print_spool_command=lp
320 print_spool_printerprefix="-d ";;
321 lpr) print_spool_command=lpr
322 print_spool_printerprefix="-P";;
323 *) :;; # leave to empty values
326 SEARCH_PROG([for a LaTeX -> HTML converter], TOHTML, tth latex2html hevea)
327 latex_to_html_command=$TOHTML
329 tth) latex_to_html_command="tth -t -e2 -L\$\$b < \$\$i > \$\$o";;
330 latex2html) latex_to_html_command="latex2html -no_subdir -split 0 -show_section_numbers \$\$i";;
331 hevea) latex_to_html_command="hevea -s \$\$i";;
334 #### Search for image conversion ####
335 SEARCH_PROG([for an Image -> EPS converter], TOEPS, convert pnmtops)
337 convert) gif_to_eps="convert GIF:\$\$i EPS:\$\$o" png_to_eps="convert PNG:\$\$i EPS:\$\$o" jpg_to_eps="convert JPG:\$\$i EPS:\$\$o";;
338 pnmtops) gif_to_eps="giftopnm \$\$i | pnmtops > \$\$o" png_to_eps="pngtopnm \$\$i | pnmtops >\$\$o" jpg_to_eps="jpegtopnm \$\$i | pnmtops >\$\$o";;
341 SEARCH_PROG([for a Image -> PNG converter], TOPNG, convert pnmtopng)
343 convert) gif_to_png="convert GIF:\$\$i PNG:\$\$o" eps_to_png="convert EPS:\$\$i PNG:\$\$o" jpg_to_png="convert JPG:\$\$i PNG:\$\$o";;
344 pnmtopng) gif_to_png="giftopnm \$\$i | pnmtopng >\$\$o" eps_to_png="pstopnm \$\$i| pnmtopng >\$\$o" jpg_to_png="jpegtopnm \$\$i | pnmtopng >\$\$o";;
347 SEARCH_PROG([For an EPS -> PDF converter], EPSTOPDF, epstopdf)
349 epstopdf) eps_to_pdf="epstopdf --outfile=\$\$o \$\$i";;
352 #### Explore the LaTeX configuration
353 MSG_CHECKING(LaTeX configuration)
354 # First, remove the files that we want to re-create
355 rm -f textclass.lst packages.lst chkconfig.sed
356 if test ${lyx_check_config} = no ; then
357 MSG_RESULT(default values)
360 rm -f wrap_chkconfig.ltx chkconfig.vars chkconfig.classes chklayouts.tex
361 cat >wrap_chkconfig.ltx <<EOF
362 \\newcommand\\srcdir{${srcdir}}
365 \\input{${srcdir}/chkconfig.ltx}
367 ## Construct the list of classes to test for.
368 # build the list of available layout files and convert it to commands
370 for file in ./layouts/*.layout ${srcdir}/layouts/*.layout ; do
373 *) test -r "$file" && echo $file ;;
375 done | sed -e 's%^.*layouts/\(.*\)\.layout$%\\TestDocClass{\1}%'\
378 [eval] ${LATEX} wrap_chkconfig.ltx 2>/dev/null | grep '^\+'
379 [eval] `cat chkconfig.vars | sed 's/-/_/g'`
383 # Do we have all the files we need? Useful if latex did not run
385 echo creating textclass.lst
386 PROVIDE_DEFAULT_FILE(textclass.lst,dnl
387 [# This file declares layouts and their associated definition files
388 # (include dir. relative to the place where this file is).
389 # It contains only default values, since chkconfig.ltx could not be run
390 # for some reason. Run ./configure if you need to update it after a
391 # configuration change.
392 article article article
395 linuxdoc linuxdoc linuxdoc
396 letter letter letter])
398 PROVIDE_DEFAULT_FILE(chkconfig.sed,[s/@.*@/???/g])
400 echo creating packages.lst
401 PROVIDE_DEFAULT_FILE(packages.lst,dnl
402 [# This file should contain the list of LaTeX packages that have been
403 # recognized by LyX. Unfortunately, since configure could not find
404 # your LaTeX2e program, the tests have not been run. Run ./configure
405 # if you need to update it after a configuration change.
409 echo creating doc/LaTeXConfig.lyx
410 echo "s/@chk_linuxdoc@/$chk_linuxdoc/g" >> chkconfig.sed
411 echo "s/@chk_docbook@/$chk_docbook/g" >> chkconfig.sed
412 sed -f chkconfig.sed ${srcdir}/doc/LaTeXConfig.lyx.in >doc/LaTeXConfig.lyx
414 echo creating lyxrc.defaults
416 cat >lyxrc.defaults <<EOF
417 # This file has been automatically generated by LyX' lib/configure
418 # script. It contains default settings that have been determined by
419 # examining your system. PLEASE DO NOT MODIFY ANYTHING HERE! If you
420 # want to customize LyX, make a copy of the file LYXDIR/lyxrc as
421 # ~/.lyx/lyxrc and edit this file instead. Any setting in lyxrc will
422 # override the values given here.
423 \\Format text txt ASCII A
424 \\Format textparagraph txt ASCII(paragraphs) ""
425 \\Format docbook sgml DocBook B
426 \\Format dvi dvi DVI D
427 \\Format eps eps EPS ""
428 \\Format epsi epsi EPSI ""
429 \\Format fax "" Fax ""
430 \\Format gif gif GIF ""
431 \\Format html html HTML H
432 \\Format jpg jpg JPEG ""
433 \\Format latex tex LaTeX L
434 \\Format linuxdoc sgml LinuxDoc x
435 \\Format lyx lyx LyX ""
436 \\Format literate nw NoWeb N
437 \\Format pdf pdf PDF P
438 \\Format pdf2 pdf "PDF (pdflatex)" F
439 \\Format pdf3 pdf "PDF (dvipdfm)" m
440 \\Format png png PNG ""
441 \\Format ps ps Postscript t
442 \\Format program "" Program ""
443 \\Format word doc Word W
445 \\converter latex dvi "$LATEX \$\$i" "latex"
446 \\converter latex pdf2 "$PDFLATEX \$\$i" "latex"
447 \\converter latex html "$latex_to_html_command" "originaldir,needaux"
448 \\converter literate latex "$literate_to_tex_command" ""
449 \\converter dvi pdf3 "$dvi_to_pdf_command" ""
450 \\converter dvi ps "$dvi_to_ps_command" ""
451 \\converter ps pdf "$ps_to_pdf_command" ""
452 \\converter ps fax "$fax_command" ""
453 \\converter linuxdoc lyx "$linuxdoc_to_lyx_command" ""
454 \\converter linuxdoc latex "$linuxdoc_to_latex_command" ""
455 \\converter linuxdoc dvi "$linuxdoc_to_dvi_command" ""
456 \\converter linuxdoc html "$linuxdoc_to_html_command" ""
457 \\converter docbook dvi "$docbook_to_dvi_command" ""
458 \\converter docbook html "$docbook_to_html_command" ""
460 \\converter latex lyx "$tex_to_lyx_command" ""
461 \\converter literate lyx "$literate_to_lyx_command" ""
462 \\converter html latex "$html_to_latex_command" ""
463 \\converter word latex "$word_to_latex_command" ""
465 \\converter gif eps "$gif_to_eps" ""
466 \\converter png eps "$png_to_eps" ""
467 \\converter jpg eps "$jpg_to_eps" ""
469 \\converter gif png "$gif_to_png" ""
470 \\converter eps png "$eps_to_png" ""
471 \\converter epsi png "$eps_to_png" ""
472 \\converter jpg png "$jpg_to_png" ""
474 \\converter eps pdf "$eps_to_pdf" ""
475 \\converter epsi pdf "$eps_to_pdf" ""
477 \\viewer dvi "$DVI_VIEWER"
478 \\viewer html "$HTML_VIEWER"
479 \\viewer pdf "$PDF_VIEWER"
480 \\viewer ps "$GHOSTVIEW -swap"
481 \\viewer eps "$GHOSTVIEW"
484 \\ascii_roff_command "$ascii_roff_command"
485 \\chktex_command "$chktex_command"
486 \\spell_command "$SPELL"
487 dnl \\fax_command "$fax_command"
488 \\print_spool_command "$print_spool_command"
489 \\print_spool_printerprefix "$print_spool_printerprefix"
490 \\font_encoding "$chk_fontenc"
493 # Remove superfluous files if we are not writing in the main lib
495 for file in lyxrc.defaults textclass.lst packages.lst \
496 doc/LaTeXConfig.lyx ; do
497 # we rename the file first, so that we avoid comparing a file with itself
499 if test -r $srcdir/$file && diff $file.new $srcdir/$file >/dev/null 2>/dev/null ;
501 echo "removing $file, which is identical to the system global version"
510 if test $lyx_keep_temps = no ; then
511 rm -f chkconfig.sed chkconfig.vars wrap_chkconfig.* chklayouts.tex \