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
89 #### Parse the command line
94 Usage: configure [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
101 --without-latex-config)
102 lyx_check_config=no ;;
104 lyx_keep_temps=yes ;;
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
119 ac_n= ac_c='\c' ac_t=
123 #### I do not really know why this is useful, but we might as well keep it.
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
135 #### Guess the directory in which configure is located.
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"
148 #### Create the build directories if necessary
149 for dir in bind doc kbd layouts templates reLyX ; do
150 test ! -d $dir && mkdir $dir
154 #### Searching some useful programs
155 define(CHECKLATEX2E,[
156 ## Check whether this is really LaTeX2e
158 cat >chklatex.ltx <<EOF
159 \\nonstopmode\\makeatletter
160 \\ifx\\undefined\\documentclass\\else
161 \\message{ThisIsLaTeX2e}
165 if eval ${LATEX} chklatex.ltx </dev/null 2>/dev/null \
166 | grep 'ThisIsLaTeX2e' >/dev/null; then
170 ac_result="not useable"
172 rm -f chklatex.ltx chklatex.log])dnl
175 SEARCH_PROG([for a LaTeX2e program],LATEX,latex latex2e,CHECKLATEX2E,dnl
176 [lyx_check_config=no])
177 if test x$lyx_check_config != x ; then
178 SEARCH_PROG([for the pdflatex program],PDFLATEX,pdflatex,CHECKLATEX2E)
181 # Search for an installed reLyX or a ready-to-install one
183 PATH=${PATH}:./reLyX/
184 SEARCH_PROG([for reLyX LaTeX-to-LyX translator],RELYX,reLyX)
187 # Search something to process a literate document
188 SEARCH_PROG([for a Literate programming processor],LITERATE,"noweave -delay -index")
189 if test "$LITERATE" = "none"; then LITERATE_EXT="none"; else LITERATE_EXT=".nw"; fi
191 # Search for a Postscript interpreter
192 SEARCH_PROG([for a Postscript interpreter],GS, gs)
194 # Search something to preview postscript
195 SEARCH_PROG([for a Postscript previewer],GHOSTVIEW,gv ghostview)
197 # Search for a program to preview pdf
198 SEARCH_PROG([for a PDF preview],PDFVIEWER,xpdf acroread gv ghostview)
200 # Search for a program to convert pdf to ps
201 SEARCH_PROG([for a PDF to PS converter],PDFPS,pdf2ps pdftops)
203 # Search for a program to convert dvi to ps
204 SEARCH_PROG([for a DVI to PS converter],DVIPS,dvips)
206 # Search a *roff program (used to translate tables in ASCII export)
207 SEARCH_PROG([for a *roff formatter],ROFF,groff nroff)
208 ascii_roff_command=$ROFF
209 test $ROFF = "groff" && ascii_roff_command="groff -t -Tlatin1 \$\$FName"
210 test $ROFF = "nroff" && ascii_roff_command="tbl \$\$FName | nroff"
212 # Search the ChkTeX program
213 SEARCH_PROG([for ChkTeX],CHKTEX,chktex)
214 chktex_command=$CHKTEX
215 test $CHKTEX = "chktex" && chktex_command="$CHKTEX -n1 -n3 -n6 -n9 -n22 -n25 -n30 -n38"
217 # Search for a spellchecker
218 SEARCH_PROG([for a spell-checker], SPELL,ispell)
220 # Search a Fax handling program
221 SEARCH_PROG([for a fax driver], FAX, sendfax faxsend fax)
222 if test $FAX = sendfax ; then
223 fax_command="sendfax -n -h '\$\$Host' -c '\$\$Comment' -x '\$\$Enterprise' -d '\$\$Name'@'\$\$Phone' '\$\$FName'"
224 elif test $FAX = faxsend ; then
225 fax_command="faxsend '\$\$Phone' '\$\$FName'"
226 elif test $FAX = fax ; then
227 fax_command="fax send '\$\$Phone' '\$\$FName'"
232 # Search for LinuxDoc support
233 SEARCH_PROG([for SGML-tools 1.x (LinuxDoc)], LINUXDOC, sgml2lyx)
235 if test $LINUXDOC != none; then
237 linuxdoc_cmd="\\def\\haslinuxdoc{yes}"
242 linuxdoc_to_latex_command="sgml2latex"
243 linuxdoc_to_html_command="sgml2html '\$\$FName'"
244 linuxdoc_to_lyx_command="sgml2lyx";;
246 linuxdoc_to_latex_command="none"
247 linuxdoc_to_html_command="none"
248 linuxdoc_to_lyx_command="none";;
251 # Search for DocBook support
252 SEARCH_PROG([for SGML-tools 2.x (DocBook) or db2x scripts], DOCBOOK, sgmltools db2dvi)
254 if test $DOCBOOK != none; then
256 docbook_cmd="\\def\\hasdocbook{yes}"
261 docbook_to_dvi_command="sgmltools -b dvi"
262 docbook_to_html_command="sgmltools -b html '\$\$FName'";;
264 docbook_to_dvi_command="db2dvi"
265 docbook_to_html_command="db2html '\$\$FName'";;
267 docbook_to_dvi_command="none"
268 docbook_to_html_command="none";;
271 # Search for a spool command
272 SEARCH_PROG([for a spool command], LPR, lp lpr)
274 lp) print_spool_command=lp
275 print_spool_printerprefix="-d ";;
276 lpr) print_spool_command=lpr
277 print_spool_printerprefix="-P";;
278 *) :;; # leave to empty values
281 # Search for a latex to html converter
282 SEARCH_PROG([for an HTML converter], TOHTML, tth latex2html hevea)
284 tth) html_command="tth -t < '\$\$FName' > '\$\$OutName'";;
285 latex2html) html_command="latex2html -no_subdir -split 0 -show_section_numbers '\$\$FName'";;
286 hevea) html_command="hevea -s '\$\$FName'";;
289 #### Explore the LaTeX configuration
290 MSG_CHECKING(LaTeX configuration)
291 # First, remove the files that we want to re-create
292 rm -f textclass.lst packages.lst chkconfig.sed
293 if test ${lyx_check_config} = no ; then
294 MSG_RESULT(default values)
297 rm -f wrap_chkconfig.ltx chkconfig.vars chkconfig.classes chklayouts.tex
298 cat >wrap_chkconfig.ltx <<EOF
299 \\newcommand\\srcdir{${srcdir}}
302 \\input{${srcdir}/chkconfig.ltx}
304 ## Construct the list of classes to test for.
305 # build the list of available layout files and convert it to commands
307 for file in ./layouts/*.layout ${srcdir}/layouts/*.layout ; do
310 *) test -r "$file" && echo $file ;;
312 done | sed -e 's%^.*layouts/\(.*\)\.layout$%\\TestDocClass{\1}%'\
315 [eval] ${LATEX} wrap_chkconfig.ltx 2>/dev/null | grep '^\+'
316 [eval] `cat chkconfig.vars | sed 's/-/_/g'`
320 # Do we have all the files we need? Useful if latex did not run
322 echo creating textclass.lst
323 PROVIDE_DEFAULT_FILE(textclass.lst,dnl
324 [# This file declares layouts and their associated definition files
325 # (include dir. relative to the place where this file is).
326 # It contains only default values, since chkconfig.ltx could not be run
327 # for some reason. Run ./configure if you need to update it after a
328 # configuration change.
329 article article article
332 linuxdoc linuxdoc linuxdoc
333 letter letter letter])
335 PROVIDE_DEFAULT_FILE(chkconfig.sed,[s/@.*@/???/g])
337 echo creating packages.lst
338 PROVIDE_DEFAULT_FILE(packages.lst,dnl
339 [# This file should contain the list of LaTeX packages that have been
340 # recognized by LyX. Unfortunately, since configure could not find
341 # your LaTeX2e program, the tests have not been run. Run ./configure
342 # if you need to update it after a configuration change.
346 echo creating doc/LaTeXConfig.lyx
347 echo "s/@chk_linuxdoc@/$chk_linuxdoc/g" >> chkconfig.sed
348 echo "s/@chk_docbook@/$chk_docbook/g" >> chkconfig.sed
349 sed -f chkconfig.sed ${srcdir}/doc/LaTeXConfig.lyx.in >doc/LaTeXConfig.lyx
351 echo creating lyxrc.defaults
353 cat >lyxrc.defaults <<EOF
354 # This file has been automatically generated by LyX' lib/configure
355 # script. It contains default settings that have been determined by
356 # examining your system. PLEASE DO NOT MODIFY ANYTHING HERE! If you
357 # want to customize LyX, make a copy of the file LYXDIR/lyxrc as
358 # ~/.lyx/lyxrc and edit this file instead. Any setting in lyxrc will
359 # override the values given here.
360 \\latex_command "$LATEX"
361 \\pdflatex_command "$PDFLATEX"
362 \\view_pdf_command "$PDFVIEWER"
363 \\pdf_to_ps_command "$PDFPS"
364 \\dvi_to_ps_command "$DVIPS"
365 \\relyx_command "$RELYX"
366 \\literate_command "$LITERATE"
367 \\literate_extension "$LITERATE_EXT"
369 \\view_ps_command "$GHOSTVIEW -swap"
370 \\view_pspic_command "$GHOSTVIEW"
371 \\ascii_roff_command "$ascii_roff_command"
372 \\chktex_command "$chktex_command"
373 \\spell_command "$SPELL"
374 \\fax_command "$fax_command"
375 \\linuxdoc_to_latex_command "$linuxdoc_to_latex_command"
376 \\linuxdoc_to_html_command "$linuxdoc_to_html_command"
377 \\linuxdoc_to_lyx_command "$linuxdoc_to_lyx_command"
378 \\docbook_to_dvi_command "$docbook_to_dvi_command"
379 \\docbook_to_html_command "$docbook_to_html_command"
380 \\html_command "$html_command"
381 \\print_spool_command "$print_spool_command"
382 \\print_spool_printerprefix "$print_spool_printerprefix"
383 \\font_encoding "$chk_fontenc"
386 # Remove superfluous files if we are not writing in the main lib
388 for file in lyxrc.defaults textclass.lst packages.lst \
389 doc/LaTeXConfig.lyx ; do
390 # we rename the file first, so that we avoid comparing a file with itself
392 if test -r $srcdir/$file && diff $file.new $srcdir/$file >/dev/null 2>/dev/null ;
394 echo "removing $file, which is identical to the system global version"
403 if test $lyx_keep_temps = no ; then
404 rm -f chkconfig.sed chkconfig.vars wrap_chkconfig.* chklayouts.tex \