]> git.donarmstrong.com Git - lilypond.git/blob - aclocal.m4
patch::: 1.1.43.jcn1
[lilypond.git] / aclocal.m4
1 dnl aclocal.m4   -*-shell-script-*-
2 dnl StepMake subroutines for configure.in
3
4 AC_DEFUN(AC_STEPMAKE_COMPILE, [
5     # -O is necessary to get inlining
6     OPTIMIZE=""
7     CXXFLAGS=${CXXFLAGS:-""}
8     CFLAGS=${CFLAGS:-""}
9     checking_b=yes
10     optimise_b=no
11     profile_b=no
12     debug_b=yes
13
14     AC_ARG_ENABLE(checking,
15     [  enable-checking         set runtime checks (assert calls). Default: on],
16     [checking_b=$enableval] )
17
18     # actually, the default is: tja='-O' to get inlining...
19     # off=''  --jcn
20
21     #actually, that sucks.
22     #  tja looks like a typo.  Default is optimisation off. --hwn
23     
24     AC_ARG_ENABLE(optimise,
25     [  enable-optimise         use maximal speed optimisations. Default: off],
26     [optimise_b=$enableval])
27     
28     AC_ARG_ENABLE(profiling, 
29     [  enable-profiling        compile with gprof support. Default: off],
30     [profile_b=$enableval])
31     
32     AC_ARG_ENABLE(debugging,
33     [  enable-debugging        set debug info. Default: on],
34     [debug_b=$enableval])
35
36     AC_ARG_ENABLE(mingw-prefix,
37     [  enable-mingw-prefix=DIR set the mingw32 directory (standalone windows32 exes)],
38     [MINGWPREFIX=$enableval],
39     [MINGWPREFIX=no])
40
41     if test "$printing_b" = no; then
42         # ugh
43         AC_DEFINE(NPRINT)
44         DEFINES="$DEFINES -DNPRINT"
45     fi
46         
47     if test "$checking_b" = no; then
48         # ugh
49         AC_DEFINE(NDEBUG)
50         DEFINES="$DEFINES -DNDEBUG"
51     fi
52
53     if test "$optimise_b" = yes; then
54         OPTIMIZE="-O2 -finline-functions"
55     fi
56
57     if test "$optimise_b" = no; then
58         OPTIMIZE=""
59     fi
60
61     if test $profile_b = yes; then
62         EXTRA_LIBES="-pg"
63         OPTIMIZE="$OPTIMIZE -pg"
64     fi
65
66     if test $debug_b = yes; then        
67         OPTIMIZE="$OPTIMIZE -g"
68     fi
69
70     # however, C++ support in mingw32 v 0.1.4 is still flaky
71     if test x$MINGWPREFIX != xno; then 
72         ICFLAGS="-I$MINGWPREFIX/include"
73         ILDFLAGS="-$MINGWPREFIX/lib"
74     fi
75
76     AC_PROG_CC
77     LD='$(CC)'
78     AC_SUBST(LD)
79
80     CFLAGS="$CFLAGS $OPTIMIZE"
81     CPPFLAGS=${CPPFLAGS:-""}
82     AC_SUBST(CFLAGS)
83     AC_SUBST(CPPFLAGS)
84     AC_SUBST(LDFLAGS)
85     AC_SUBST(ICFLAGS)
86     AC_SUBST(ILDFLAGS)
87     AC_SUBST(DEFINES)
88     AC_SUBST(EXTRA_LIBES)
89 ])
90
91 AC_DEFUN(AC_STEPMAKE_CXX, [
92     AC_LANG_CPLUSPLUS
93     AC_PROG_CXX
94
95     AC_CHECK_HEADER(FlexLexer.h, true,
96         AC_STEPMAKE_WARN(can"\'"t find flex header. Please install Flex headers correctly))
97
98     CPPFLAGS="$CPPFLAGS $DEFINES"
99     CXXFLAGS="$CXXFLAGS $OPTIMIZE"
100     LDFLAGS=$EXTRA_LIBES
101
102     AC_SUBST(CXXFLAGS)
103     AC_SUBST(CXX)
104     LD='$(CXX)'
105     AC_SUBST(LD)
106 ])
107
108 AC_DEFUN(AC_STEPMAKE_CXXTEMPLATE, [
109     AC_CACHE_CHECK([whether explicit instantiation is needed],
110         lily_cv_need_explicit_instantiation,
111         AC_TRY_LINK([
112     template <class T> struct foo { static int baz; };
113     template <class T> int foo<T>::baz = 1;
114     ], [ return foo<int>::baz; ],
115             lily_cv_need_explicit_instantiation=no,
116             lily_cv_need_explicit_instantiation=yes))
117     if test x"$lily_cv_need_explicit_instantiation"x = x"yes"x; then
118         AC_DEFINE(NEED_EXPLICIT_INSTANTIATION)
119     fi
120 ])
121
122 AC_DEFUN(AC_STEPMAKE_DATADIR, [
123     if test "$datadir" = "\${prefix}/share"; then
124             datadir='${prefix}/share/'$package
125     fi
126     DIR_DATADIR=${datadir}
127     presome=${prefix}
128     if test "$prefix" = "NONE"; then
129             presome=${ac_default_prefix}
130     fi
131     DIR_DATADIR=`echo ${DIR_DATADIR} | sed "s!\\\${prefix}!$presome!"`
132     AC_SUBST(datadir)
133     AC_SUBST(DIR_DATADIR)
134     AC_DEFINE_UNQUOTED(DIR_DATADIR, "${DIR_DATADIR}")
135 ])
136
137 AC_DEFUN(AC_STEPMAKE_END, [
138     AC_OUTPUT($CONFIGFILE.make:config.make.in)
139
140     rm -f GNUmakefile
141     cp make/toplevel.make.in ./GNUmakefile
142     chmod 444 GNUmakefile
143 ])
144
145 AC_DEFUN(AC_STEPMAKE_GXX, [
146     # ugh autoconf
147     # urg, egcs: how to check for egcs >= 1.1?
148     changequote(<<, >>)dnl
149     if $CXX --version | grep '2\.8' > /dev/null ||
150         $CXX --version | grep 'egcs' > /dev/null
151     changequote([, ])dnl
152     then
153             true
154     else
155             AC_STEPMAKE_WARN(can\'t find g++ 2.8 or egcs 1.1)
156     fi
157 ])
158
159 AC_DEFUN(AC_STEPMAKE_GUILE, [
160     # on some systems, -lguile succeeds for guile-1.3
161     # others need readline, dl (or even more)
162     # urg, must check for different functions in libguile
163     # to force new check iso reading from cache
164
165     # gh_scm2doubles,gh_doubles2scm are new in 1.3
166     GUILE_FLAGS
167     AC_CHECK_LIB(guile, gh_scm2doubles,
168       [LIBS="`echo $GUILE_LDFLAGS | sed -e 's/-L[[/-_a-zA-Z0-9]]\+ //g'` $LIBS"
169       AC_DEFINE(HAVE_LIBGUILE)], , $GUILE_LDFLAGS dnl
170     )
171     if test "$ac_cv_lib_guile_gh_scm2doubles" != yes ; then
172         AC_STEPMAKE_WARN(You should install guile 1.3 or newer)
173     fi
174 ])
175
176 AC_DEFUN(AC_STEPMAKE_INIT, [
177
178     . $srcdir/VERSION
179     FULL_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$PATCH_LEVEL
180     if test x$MY_PATCH_LEVEL != x; then
181         FULL_VERSION=$FULL_VERSION.$MY_PATCH_LEVEL
182     fi
183
184     # urg: don't "fix" this: irix doesn't know about [:lower:] and [:upper:]
185     changequote(<<, >>)dnl
186     PACKAGE=`echo $PACKAGE_NAME | tr '[a-z]' '[A-Z]'`
187     package=`echo $PACKAGE_NAME | tr '[A-Z]' '[a-z]'`
188     changequote([, ])dnl
189
190     # No versioning on directory names of sub-packages 
191     # urg, urg
192     stepmake=${datadir}/stepmake
193     presome=${prefix}
194     if test "$prefix" = "NONE"; then
195             presome=${ac_default_prefix}
196     fi
197     stepmake=`echo ${stepmake} | sed "s!\\\${prefix}!$presome!"`
198
199     AC_MSG_CHECKING(Package)
200     if test "x$PACKAGE" = "xSTEPMAKE"; then
201         AC_MSG_RESULT(Stepmake package!)
202         (cd stepmake; rm -f stepmake; ln -s ../stepmake .)
203         (cd stepmake; rm -f bin; ln -s ../bin .)
204         AC_CONFIG_AUX_DIR(bin)
205         stepmake=stepmake
206     else
207         AC_MSG_RESULT($PACKAGE)
208         AC_MSG_CHECKING(for stepmake)
209         # Check for installed stepmake
210         if test -d $stepmake; then
211             AC_MSG_RESULT($stepmake)
212         else
213             stepmake='$(depth)'/stepmake
214             AC_MSG_RESULT(./stepmake  ($datadir/stepmake not found))
215         fi
216         AC_CONFIG_AUX_DIR(\
217           $HOME/usr/local/share/stepmake/bin\
218           $HOME/usr/local/lib/stepmake/bin\
219           $HOME/usr/share/stepmake/bin\
220           $HOME/usr/lib/stepmake/bin\
221           /usr/local/share/stepmake/bin\
222           /usr/local/lib/stepmake/bin\
223           /usr/share/stepmake/bin\
224           /usr/lib/stepmake/bin\
225           stepmake/bin\
226         )
227     fi
228
229     AC_SUBST(stepmake)
230     AC_SUBST(package)
231     AC_SUBST(PACKAGE)
232     AC_SUBST(PACKAGE_NAME)
233     AC_DEFINE_UNQUOTED(PACKAGE, "${PACKAGE_NAME}")
234     AC_DEFINE_UNQUOTED(TOPLEVEL_VERSION, "${FULL_VERSION}")
235
236     if test "$package_depth" = "" ; then
237         package_depth="."
238     else
239         package_depth="../$package_depth"
240     fi
241     export package_depth
242     AC_SUBST(package_depth)
243
244     AUTOGENERATE="This file was automatically generated by configure"
245     AC_SUBST(AUTOGENERATE)
246     absolute_builddir="`pwd`"
247     AC_SUBST(absolute_builddir)
248
249     STATE_VECTOR=`ls make/STATE-VECTOR 2>/dev/null`
250     if test "x$STATE_VECTOR" != "x"; then
251         STATE_VECTOR="\$(depth)/$STATE_VECTOR"
252     fi
253     AC_SUBST(STATE_VECTOR)
254
255     CONFIGSUFFIX=
256     AC_ARG_ENABLE(config,
257     [  enable-config=FILE      put configure settings in config-FILE.make],
258     [CONFIGSUFFIX=$enableval])
259
260     if test "$CONFIGSUFFIX" != "" ; then
261         CONFIGFILE=config-$CONFIGSUFFIX
262     else
263         CONFIGFILE=config
264     fi
265     AC_SUBST(CONFIGSUFFIX)
266      
267     AC_CANONICAL_HOST
268     AC_CHECK_PROGS(MAKE, gmake make, error)
269     AC_CHECK_PROGS(FIND, find, error)
270
271 dnl system supplied INSTALL is unsafe; use our own install.
272 dnl    AC_PROG_INSTALL
273 dnl    if test "$INSTALL" = "bin/install-sh"; then
274 dnl     export INSTALL="\$\(depth\)/bin/install-sh"
275 dnl    fi
276
277     AC_CHECK_PROGS(TAR, tar, error)
278
279     if test "x`uname`" = "xHP-UX"; then
280         AC_STEPMAKE_WARN(avoiding buggy /bin/sh)
281         AC_CHECK_PROGS(SHELL, bash, /bin/ksh)
282     else
283         SHELL=/bin/sh
284         AC_SUBST(SHELL)
285     fi
286
287     AC_CHECK_PROGS(BASH, bash, /bin/sh)
288
289     AC_PATH_PROG(PYTHON, ${PYTHON:-python}, -echo no python)
290     AC_SUBST(PYTHON)
291
292     if test $MAKE != "error" ; then
293         $MAKE -v 2> /dev/null | grep GNU > /dev/null
294         if test "$?" = 1
295         then
296                 AC_STEPMAKE_WARN(Please install *GNU* make) 
297         fi
298     fi 
299
300     AC_CHECK_SEARCH_RESULT($PYTHON, python, You should install Python)
301
302     if test "x$OSTYPE" = "xcygwin32" || test "x$OSTYPE" = "xWindows_NT"; then
303         LN=cp # hard link does not work under cygnus-nt
304         LN_S='cp -r' # symbolic link does not work for native nt
305         ZIP="zip -r -9" #
306         DOTEXE=.exe
307         # urg
308         # DIRSEP='\\'
309         # PATHSEP=';'
310         #
311         # cygwin fixes all these things.  
312         # it seems these were used because of dos-style TEXINPUTS and
313         # MFINPUTS needed for miktex.
314         # but this breaks parsing of all other cygwin/unix style paths.
315         #
316         # if your (mik)tex breaks, make a:
317         #    /usr/local/bin/tex:
318         #    #!/bin/sh
319         #    TEXINPUTS=`cygpath -pw $TEXINPUTS` /texmf/miktex/bin/tex $*
320         #
321         # and
322         #
323         #    /usr/local/bin/mf:
324         #    #!/bin/sh
325         #    MFINPUTS=`cygpath -pw $MFINPUTS` /texmf/miktex/bin/mf $*
326         #
327         # this way, you may have buildscripts/out/lilypond-profile 
328         # 'automatically' sourced from /usr/etc/profile.d/ too.
329         #
330         DIRSEP='/'
331         PATHSEP=':'
332         INSTALL="\$(SHELL) \$(stepdir)/../bin/install-dot-exe.sh -c"
333     else
334         DIRSEP='/'
335         PATHSEP=':'
336         LN=ln
337         LN_S='ln -s'
338         ZIP="zip -r -9"
339         INSTALL="\$(SHELL) \$(stepdir)/../bin/install-sh -c"
340     fi
341     AC_SUBST(DOTEXE)
342     AC_SUBST(ZIP)
343     AC_SUBST(LN)
344     AC_SUBST(LN_S)
345     AC_SUBST(INSTALL)
346     AC_DEFINE_UNQUOTED(DIRSEP, '${DIRSEP}')
347     AC_DEFINE_UNQUOTED(PATHSEP, '${PATHSEP}')
348     AC_SUBST(PATHSEP)
349     AC_SUBST(DIRSEP)
350   
351    
352     AC_STEPMAKE_DATADIR
353 ])
354
355 AC_DEFUN(AC_STEPMAKE_LEXYACC, [
356     # ugh, automake: we want (and check for) bison
357     AC_PROG_YACC
358     # ugh, automake: we want (and check for) flex
359     # AC_PROG_LEX
360     # urg: automake 1.3: hope this doesn't break 1.2 ac_cv_pro_lex_root hack...
361
362     # AC_DECL_YYTEXT
363     # ugh, ugh
364     ac_cv_prog_lex_root=lex.yy
365
366     AC_CHECK_PROGS(BISON, bison, error)
367     AC_CHECK_PROGS(FLEX, flex, error)
368     AC_CHECK_SEARCH_RESULT($BISON, bison,  Please install Bison, 1.25 or newer)
369     AC_CHECK_SEARCH_RESULT($FLEX,  flex, Please install Flex, 2.5 or newer)
370
371     if test $BISON != "error"; then
372         bison_version=`$BISON --version | sed 's/^.*version 1.//g'`
373         if test `echo $bison_version | sed 's/\..*$//g'` -lt 25; then
374             AC_STEPMAKE_WARN(Your bison is a bit old (1.$bison_version). You might have to install 1.25)
375         fi      
376     fi
377
378     AC_SUBST(BISON)
379     AC_SUBST(FLEX)
380 ])
381
382 AC_DEFUN(AC_STEPMAKE_LIB, [
383     AC_CHECK_PROGS(AR, ar, error)
384     AC_PROG_RANLIB
385
386     AC_SUBST(AR)
387     AC_SUBST(RANLIB)
388 ])
389
390 AC_DEFUN(AC_STEPMAKE_LIBTOOL, [
391     # libtool.info ...
392     # **Never** try to set library version numbers so that they correspond
393     # to the release number of your package.  This is an abuse that only
394     # fosters misunderstanding of the purpose of library versions.
395
396     REVISION=$PATCH_LEVEL
397     # CURRENT=$MINOR_VERSION
398     CURRENT=`expr $MINOR_VERSION + 1`
399     # AGE=$(expr $MAJOR_VERSION + 1)
400     AGE=$MAJOR_VERSION
401     AC_SUBST(CURRENT)
402     AC_SUBST(REVISION)
403     AC_SUBST(AGE)
404 ])
405
406 AC_DEFUN(AC_STEPMAKE_LOCALE, [
407     lang=English
408     ALL_LINGUAS="en nl"
409
410     # with/enable ??
411     AC_ARG_WITH(localedir,
412     [  with-localedir=LOCALE   use LOCALE as locale dir. Default: PREFIX/share/locale ],
413     localedir=$with_localedir,
414     localedir='${prefix}/share/locale')
415
416     AC_ARG_WITH(lang,
417     [  with-lang=LANG          use LANG as language to emit messages],
418     language=$with_lang,
419     language=English)
420
421     AC_MSG_CHECKING(language)    
422     case "$language" in
423       En* | en* | Am* | am* | US* | us*)
424             lang=English;;
425       NL | nl | Du* | du* | Ned* | ned*)
426             lang=Dutch;;
427       "")
428             lang=English;;
429       *)
430             lang=unknown;;
431     esac
432     AC_MSG_RESULT($lang)
433
434     if test "$lang" = "unknown" ; then
435         AC_STEPMAKE_WARN($language not supported; available are: $ALL_LINGUAS)
436     fi
437
438 ])
439
440 AC_DEFUN(AC_STEPMAKE_GETTEXT, [
441     DIR_LOCALEDIR=${localedir}
442     presome=${prefix}
443     if test "$prefix" = "NONE"; then
444             presome=${ac_default_prefix}
445     fi
446     DIR_LOCALEDIR=`echo ${DIR_LOCALEDIR} | sed "s!\\\${prefix}!$presome!"`
447     AC_SUBST(localedir)
448     AC_SUBST(DIR_LOCALEDIR)
449     AC_DEFINE_UNQUOTED(DIR_LOCALEDIR, "${DIR_LOCALEDIR}")
450
451     AC_CHECK_LIB(intl, gettext)
452     AC_CHECK_FUNCS(gettext)
453 ])
454
455 AC_DEFUN(AC_STEPMAKE_MAN, [
456     AC_CHECK_PROGS(GROFF, groff ditroff, -echo no groff)
457     AC_CHECK_PROGS(TROFF, troff, -echo no troff)
458     AC_CHECK_PROGS(TBL, tbl, cat)
459 ])
460
461 AC_DEFUN(AC_STEPMAKE_MSGFMT, [
462     # AC_CHECK_PROGS(MSGFMT, msgfmt, -echo no msgfmt)
463     AC_CHECK_PROGS(MSGFMT, msgfmt, \$(SHELL) \$(step-bindir)/fake-msgfmt.sh )
464     AC_MSG_CHECKING(whether msgfmt accepts -o)
465     msgfmt_output="`msgfmt -o bla 2>&1 | grep usage`"
466     if test "$msgfmt_output" = ""; then
467         AC_MSG_RESULT(yes)
468     else
469         # urg
470         MSGFMT="\$(SHELL) \$(step-bindir)/fake-msgfmt.sh"
471         AC_MSG_RESULT(no)
472         AC_STEPMAKE_WARN(please install msgfmt from GNU gettext)
473     fi
474     if test ! -n "$MSGFMT"; then
475         AC_STEPMAKE_WARN(please install msgfmt from GNU gettext)
476     fi
477 ])
478
479 #why has this been dropped?
480 AC_DEFUN(XXAC_STEPMAKE_TEXMF_DIRS, [
481     AC_ARG_ENABLE(tex-prefix,
482     [  enable-tex-prefix=DIR   set the tex-directory to find TeX subdirectories. (default: PREFIX)],
483     [TEXPREFIX=$enableval],
484     [TEXPREFIX=auto] )
485     
486     AC_ARG_ENABLE(tex-dir,
487     [  enable-tex-dir=DIR      set the directory to put $PACKAGE_NAME TeX files in. ],
488     [TEXDIR=$enableval],
489     [TEXDIR=auto] )
490
491     AC_ARG_ENABLE(mf-dir,
492     [  enable-mf-dir=DIR       set the directory to put $PACKAGE_NAME MetaFont files in. ],
493     [MFDIR=$enableval],
494     [MFDIR=auto])
495
496     if test "x$TEXPREFIX" = xauto ; then
497         AC_TEX_PREFIX(TEXPREFIX)
498     else
499      find_texprefix=$TEXPREFIX
500     fi
501
502     if test "x$MFDIR" = xauto; then
503         AC_MF_SUBDIR(MFDIR)
504     fi
505         
506     if test "x$TEXDIR" = xauto ; then
507         AC_TEX_SUBDIR(TEXDIR)
508     fi
509     AC_SUBST(TEXPREFIX)
510     AC_SUBST(TEXDIR)
511     AC_SUBST(MFDIR)
512 ])
513
514 AC_DEFUN(AC_STEPMAKE_TEXMF_DIRS, [
515     AC_ARG_ENABLE(tex-tfmdir,
516     [  enable-tex-tfmdir=DIR   set the tex-directory where cmr10.tfm lives (default: use kpsewhich)],
517     [TFMDIR=$enableval],
518     [TFMDIR=auto] )
519
520     AC_MSG_CHECKING(TeX TFM directory)
521     if test "x$TFMDIR" = xauto ; then
522         if test "x$TEX_TFMDIR" = "x" ; then
523             if kpsewhich --version > /dev/null 2>&1 ; then
524                 TEX_TFMDIR=`kpsewhich tfm cmr10.tfm`
525                 CMR10=`kpsewhich tfm cmr10.tfm`
526                 TEX_TFMDIR=`dirname $CMR10`
527             else
528                 AC_STEPMAKE_WARN(Please set TEX_TFMDIR (to where cmr10.tfm lives):
529         TEX_TFMDIR=/usr/local/TeX/lib/tex/fonts ./configure)
530             fi
531         fi
532     fi
533     AC_MSG_RESULT($TEX_TFMDIR)
534     AC_SUBST(TEX_TFMDIR)
535 ])
536
537 AC_DEFUN(AC_STEPMAKE_TEXMF, [
538     # urg, never know what names these teTeX guys will think up
539
540     AC_CHECK_PROGS(METAFONT, mf, no)
541     if test "x$METAFONT" = "xno"; then
542         AC_CHECK_PROGS(MFONT, mfont, -echo no mf or mfont)
543         METAFONT=$MFONT
544     fi
545
546     AC_CHECK_PROGS(METAPOST, mp, no)
547     if test "x$METAPOST" = "xno"; then
548         AC_CHECK_PROGS(MPOST, mpost, -echo no mp or mpost)
549         METAPOST=$MPOST
550     fi
551
552     AC_CHECK_PROGS(INIMETAFONT, inimf, no)
553     if test "x$INIMETAFONT" = "xno"; then
554         AC_CHECK_PROGS(INIMFONT, inimfont, -echo no inimf or inimfont)
555         INIMETAFONT=$INIMFONT
556     fi
557
558     AC_CHECK_PROGS(INIMETAPOST, inimp, no)
559     if test "x$INIMETAPOST" = "xno"; then
560         AC_CHECK_PROGS(INIMPOST, inimpost, -echo no inimp or inimpost)
561         INIMETAPOST=$INIMPOST
562     fi
563
564     AC_SUBST(METAFONT)
565     AC_SUBST(METAPOST)
566     AC_SUBST(INIMETAFONT)
567     AC_SUBST(INIMETAPOST)
568 ])
569
570 AC_DEFUN(AC_STEPMAKE_WARN, [
571     AC_MSG_WARN($1)
572     warn_b=yes
573 ])
574
575 AC_DEFUN(AC_STEPMAKE_YODL, [
576     if test "x$YODL" = "x"; then 
577         AC_CHECK_PROGS(STRIPROFF, striproff, -echo no striproff)
578         AC_CHECK_PROGS(YODL, yodl, -echo no yodl)
579         AC_CHECK_PROGS(YODL2HTML, yodl2html, -echo no yodl)
580         AC_CHECK_PROGS(YODL2LATEX, yodl2latex, )
581         AC_CHECK_PROGS(YODL2MAN, yodl2man, -echo no yodl)
582         AC_CHECK_PROGS(YODL2MSLESS, yodl2msless, -echo no yodl)
583         AC_CHECK_PROGS(YODL2TEXINFO, yodl2texinfo, -echo no yodl)
584         AC_CHECK_PROGS(YODL2TXT, yodl2txt, -echo no yodl)
585         YODL2LESS_DIR='$(bindir)/'
586     else
587         AC_SUBST(STRIPROFF)
588         AC_SUBST(YODL)
589         AC_SUBST(YODL2HTML)
590         AC_SUBST(YODL2LATEX)
591         AC_SUBST(YODL2LESS_DIR)
592         AC_SUBST(YODL2MAN)
593         AC_SUBST(YODL2MSLESS)
594         AC_SUBST(YODL2TEXINFO)
595         AC_SUBST(YODL2TXT)
596         export STRIPROFF YODL YODL2HTML YODL2LATEX YODL2MAN YODL2MSLESS YODL2TEXINFO YODL2TXT
597     fi
598     if test "x$YODL" = "-echo no yodl"; then
599         AC_STEPMAKE_WARN(Did not find YODL (Yodl is Yet Oneother Document Language, see http://www.cs.uu.nl/~hanwen/yodl))
600     fi    
601 ])
602
603 dnl should cache result.
604 dnl should  look in $prefix first.
605 dnl should probably assume TDS
606
607 AC_DEFUN(AC_TEX_PREFIX, [
608     
609
610     AC_MSG_CHECKING(TeX/MF root dir directory)    
611
612     find_root_prefix="$prefix"
613     
614
615     test "x$find_root_prefix" = xNONE && find_root_prefix="$ac_default_prefix"
616     find_texpostfix="";
617     for postfix in "/lib/tex/" "/lib/texmf" "/lib" "/tex" "/texmf"; do
618         find_texprefix="$find_root_prefix$postfix"
619         if test -d $find_texprefix; then
620             find_texpostfix=$postfix
621             break;
622         fi
623     done
624     
625     if test "x$find_texpostfix" = x; then
626         find_texpostfix='/lib/texmf/tex'
627         AC_STEPMAKE_WARN(Cannot determine the TeX-directory. Please use --enable-tex-prefix)
628     fi
629
630     find_texprefix="$find_root_prefix/$find_texpostfix"
631
632     # only assign if variablename not empty
633     if test x != "x[$]$1"; then
634         $1='${prefix}'/"$find_texpostfix"
635     fi
636     AC_MSG_RESULT($find_texprefix)
637
638 ])
639  
640
641 # find a directory inside a prefix, 
642 # $1 the prefix (expanded version)
643 # $2 variable to assign
644 # $3 the directory name 
645 # $4 description
646 AC_DEFUN(AC_FIND_DIR_IN_PREFIX, [
647     
648     AC_MSG_CHECKING($4 directory)    
649     find_dirdir=`(cd $1; 
650       $FIND ./ -type d -a -name $3 -print |sort|head -1|sed 's#^\./##')`
651     
652
653     if test "x$find_dirdir" = x; then
654        find_dirdir="/$3";
655        AC_STEPMAKE_WARN(Cannot determine $4 subdirectory. Please set from command-line)
656         true
657     fi
658     $2=$find_dirdir
659     AC_MSG_RESULT($1/$find_dirdir)
660 ])
661
662 # ugh.  this is hopeless
663 AC_DEFUN(AC_KPSE_TEX_DIR, [
664         kpse_paths=`(kpsepath -n latex tex; kpsepath -n tex tex) | sed 's/:/ /g' | tr ' ' '\012' |sort | uniq -d`
665         kpse_syspaths=`echo $kpse_paths | grep '!'| sed 's/!//g'`
666         echo $kpse_paths
667         if test -w "$kpse_syspaths";
668         then
669                 dir=`echo $kpse_syspaths | head -1`
670         else
671                 dir=`echo $kpse_paths | grep -v '!'| head -1`
672         fi
673         if test "$prefix" = "NONE"; then
674                 local_prefix=$ac_default_prefix
675                 local_prefix_quote='${prefix}'
676
677         else
678                 local_prefix=$prefix
679                 local_prefix_quote=$prefix
680         fi
681         echo $local_prefix_quote = $local_prefix
682         echo $dir
683         echo $dir  | sed 's!'$local_prefix'!\$local_prefix_quote!g'
684 ])
685
686 AC_DEFUN(AC_TEX_SUBDIR, [
687 dnl    AC_REQUIRE([AC_TEX_PREFIX])
688     AC_FIND_DIR_IN_PREFIX($find_texprefix, $1, tex,TeX input)
689     $1="$TEXPREFIX/$$1"
690 ])
691
692 AC_DEFUN(AC_MF_SUBDIR, [
693 dnl     AC_REQUIRE([AC_TEX_PREFIX])
694     AC_FIND_DIR_IN_PREFIX($find_texprefix, $1, source, MF input)
695     $1="$TEXPREFIX/$$1"
696 ])
697
698 AC_DEFUN(AC_CHECK_SEARCH_RESULT, [
699         result="`echo \"$1\" | grep echo`"
700         if test "x$1" = "xerror" -o "x$result" != "x"; then
701                 AC_STEPMAKE_WARN(can\'t find $2. $3)
702         fi
703 ])
704
705 dnl   GUILE_FLAGS --- set flags for compiling and linking with Guile
706 dnl
707 dnl   This macro runs the `guile-config' script, installed with Guile,
708 dnl   to find out where Guile's header files and libraries are
709 dnl   installed.  It sets two variables, marked for substitution, as
710 dnl   by AC_SUBST.
711 dnl   
712 dnl     GUILE_CFLAGS --- flags to pass to a C or C++ compiler to build
713 dnl             code that uses Guile header files.  This is almost
714 dnl             always just a -I flag.
715 dnl   
716 dnl     GUILE_LDFLAGS --- flags to pass to the linker to link a
717 dnl             program against Guile.  This includes `-lguile' for
718 dnl             the Guile library itself, any libraries that Guile
719 dnl             itself requires (like -lqthreads), and so on.  It may
720 dnl             also include a -L flag to tell the compiler where to
721 dnl             find the libraries.
722
723 AC_DEFUN([GUILE_FLAGS],[
724 ## The GUILE_FLAGS macro.
725   ## First, let's just see if we can find Guile at all.
726   AC_MSG_CHECKING(for Guile)
727   guile-config link > /dev/null || {
728     echo "configure: cannot find guile-config; is Guile installed?" 1>&2
729     exit 1
730   }
731   GUILE_CFLAGS="`guile-config compile`"
732   GUILE_LDFLAGS="`guile-config link`"
733   AC_SUBST(GUILE_CFLAGS)
734   AC_SUBST(GUILE_LDFLAGS)
735   AC_MSG_RESULT(yes)
736 ])
737
738
739 # Configure paths for GTK+
740 # Owen Taylor     97-11-3
741
742 dnl AM_PATH_GTK([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
743 dnl Test for GTK, and define GTK_CFLAGS and GTK_LIBS
744 dnl
745 AC_DEFUN(AM_PATH_GTK,
746 [dnl 
747 dnl Get the cflags and libraries from the gtk-config script
748 dnl
749   AC_PATH_PROG(GTK_CONFIG, gtk-config, no)
750   min_gtk_version=ifelse([$1], ,1.1.1,$1)
751   AC_MSG_CHECKING(for GTK - version >= $min_gtk_version)
752   no_gtk=""
753   if test "$GTK_CONFIG" != "no" ; then
754     GTK_CFLAGS=`$GTK_CONFIG --cflags`
755     GTK_LIBS=`$GTK_CONFIG --libs`
756     ac_save_CFLAGS="$CFLAGS"
757     ac_save_LIBS="$LIBS"
758     ac_save_CXXFLAGS="$CXXFLAGS"
759     CFLAGS="$CFLAGS $GTK_CFLAGS"
760     CXXFLAGS="$CXXFLAGS $GTK_CFLAGS"
761     LIBS="$LIBS $GTK_LIBS"
762 dnl
763 dnl Now check if the installed GTK is sufficiently new. (Also sanity
764 dnl checks the results of gtk-config to some extent)
765 dnl
766     AC_TRY_RUN([
767 #include <gtk/gtk.h>
768 #include <stdio.h>
769
770 int 
771 main ()
772 {
773   int major, minor, micro;
774
775   if (sscanf("$min_gtk_version", "%d.%d.%d", &major, &minor, &micro) != 3) {
776      printf("%s, bad version string\n", "$min_gtk_version");
777      exit(1);
778    }
779
780    return !((gtk_major_version > major) ||
781             ((gtk_major_version == major) && (gtk_minor_version > minor)) ||
782             ((gtk_major_version == major) && (gtk_minor_version == minor) && (gtk_micro_version >= micro)));
783 }
784 ],, no_gtk=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
785      CFLAGS="$ac_save_CFLAGS"
786      CXXFLAGS="$ac_save_CXXFLAGS"
787      LIBS="$ac_save_LIBS"
788   else
789      no_gtk=yes
790   fi
791   if test "x$no_gtk" = x ; then
792      AC_MSG_RESULT(yes)
793      ifelse([$2], , :, [$2])     
794   else
795      AC_MSG_RESULT(no)
796      GTK_CFLAGS=""
797      GTK_LIBS=""
798      ifelse([$3], , :, [$3])
799   fi
800   CXXFLAGS="$CXXFLAGS $GTK_CFLAGS"
801   AC_SUBST(CXXFLAGS)
802   AC_SUBST(GTK_CFLAGS)
803   AC_SUBST(GTK_LIBS)
804 ])
805
806
807 # Configure paths for GTK--
808 # Erik Andersen 30 May 1998
809 # Modified by Tero Pulkkinen (added the compiler checks... I hope they work..)
810
811 dnl Test for GTK__, and define GTK___CFLAGS and GTK___LIBS
812 dnl   to be used as follows:
813 dnl AM_PATH_GTKMM([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
814 dnl
815
816 dnl Get the cflags and libraries from the gtkmm-config script
817 dnl
818 AC_ARG_WITH(gtkmm-prefix,[  --with-gtkmm-prefix=PREFIX
819                           Prefix where GTK-- is installed (optional)],
820             gtkmm_config_prefix="$withval", gtkmm_config_prefix="")
821 AC_ARG_WITH(gtkmm-exec-prefix,[  --with-gtkmm-exec-prefix=PREFIX
822                           Exec prefix where GTK-- is installed (optional)],
823             gtkmm_config_exec_prefix="$withval", gtkmm_config_exec_prefix="")
824 AC_ARG_ENABLE(gtkmmtest, [  --disable-gtkmmtest     Do not try to compile and run a test GTK-- program],
825                     , enable_gtkmmtest=yes)
826
827   if test x$gtkmm_config_exec_prefix != x ; then
828      gtkmm_config_args="$gtkmm_config_args --exec-prefix=$gtkmm_config_exec_prefix"
829      if test x${GTKMM_CONFIG+set} != xset ; then
830         GTKMM_CONFIG=$gtkmm_config_exec_prefix/bin/gtkmm-config
831      fi
832   fi
833   if test x$gtkmm_config_prefix != x ; then
834      gtkmm_config_args="$gtkmm_config_args --prefix=$gtkmm_config_prefix"
835      if test x${GTKMM_CONFIG+set} != xset ; then
836         GTKMM_CONFIG=$gtkmm_config_prefix/bin/gtkmm-config
837      fi
838   fi
839
840
841 AC_DEFUN(AM_PATH_GTKMM,
842 [dnl 
843
844 dnl
845 dnl Check if the installed GTK-- is sufficiently new.
846 dnl
847   AC_PATH_PROG(GTKMM_CONFIG, gtkmm-config, no)
848   min_gtkmm_version=ifelse([$1], ,0.9.14,$1)
849
850   AC_MSG_CHECKING(for GTK-- - version >= $min_gtkmm_version)
851   no_gtkmm=""
852   if test "$GTKMM_CONFIG" = "no" ; then
853     no_gtkmm=yes
854   else
855     AC_LANG_SAVE
856     AC_LANG_CPLUSPLUS
857
858     GTK___CFLAGS=`$GTKMM_CONFIG $gtkmm_config_args --cflags`
859     GTK___LIBS=`$GTKMM_CONFIG $gtkmm_config_args --libs`
860     gtkmm_config_major_version=`$GTKMM_CONFIG $gtkmm_config_args --version | \
861            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\1/'`
862     gtkmm_config_minor_version=`$GTKMM_CONFIG $gtkmm_config_args --version | \
863            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\2/'`
864     gtkmm_config_micro_version=`$GTKMM_CONFIG $gtkmm_config_args --version | \
865            sed 's/\([[0-9]]*\).\([[0-9]]*\).\([[0-9]]*\)/\3/'`
866     if test "x$enable_gtkmmtest" = "xyes" ; then
867       ac_save_CXXFLAGS="$CXXFLAGS"
868       ac_save_LIBS="$LIBS"
869       CXXFLAGS="$CXXFLAGS $GTK___CFLAGS"
870       LIBS="$LIBS $GTK___LIBS"
871 dnl
872 dnl Now check if the installed GTK-- is sufficiently new. (Also sanity
873 dnl checks the results of gtkmm-config to some extent
874 dnl
875       rm -f conf.gtkmmtest
876       AC_TRY_RUN([
877 #include <gtk--.h>
878 #include <stdio.h>
879 #include <stdlib.h>
880
881 int 
882 main ()
883 {
884   int major, minor, micro;
885   char *tmp_version;
886
887   system ("touch conf.gtkmmtest");
888
889   /* HP/UX 0 (%@#!) writes to sscanf strings */
890   tmp_version = g_strdup("$min_gtkmm_version");
891   if (sscanf(tmp_version, "%d.%d.%d", &major, &minor, &micro) != 3) {
892      printf("%s, bad version string\n", "$min_gtkmm_version");
893      exit(1);
894    }
895
896   if ((gtkmm_major_version != $gtkmm_config_major_version) ||
897       (gtkmm_minor_version != $gtkmm_config_minor_version) ||
898       (gtkmm_micro_version != $gtkmm_config_micro_version))
899     {
900       printf("\n*** 'gtkmm-config --version' returned %d.%d.%d, but GTK-- (%d.%d.%d)\n", 
901              $gtkmm_config_major_version, $gtkmm_config_minor_version, $gtkmm_config_micro_version,
902              gtkmm_major_version, gtkmm_minor_version, gtkmm_micro_version);
903       printf ("*** was found! If gtkmm-config was correct, then it is best\n");
904       printf ("*** to remove the old version of GTK--. You may also be able to fix the error\n");
905       printf("*** by modifying your LD_LIBRARY_PATH enviroment variable, or by editing\n");
906       printf("*** /etc/ld.so.conf. Make sure you have run ldconfig if that is\n");
907       printf("*** required on your system.\n");
908       printf("*** If gtkmm-config was wrong, set the environment variable GTKMM_CONFIG\n");
909       printf("*** to point to the correct copy of gtkmm-config, and remove the file config.cache\n");
910       printf("*** before re-running configure\n");
911     } 
912 /* GTK-- does not have the GTKMM_*_VERSION constants */
913 /* 
914   else if ((gtkmm_major_version != GTKMM_MAJOR_VERSION) ||
915            (gtkmm_minor_version != GTKMM_MINOR_VERSION) ||
916            (gtkmm_micro_version != GTKMM_MICRO_VERSION))
917     {
918       printf("*** GTK-- header files (version %d.%d.%d) do not match\n",
919              GTKMM_MAJOR_VERSION, GTKMM_MINOR_VERSION, GTKMM_MICRO_VERSION);
920       printf("*** library (version %d.%d.%d)\n",
921              gtkmm_major_version, gtkmm_minor_version, gtkmm_micro_version);
922     }
923 */
924   else
925     {
926       if ((gtkmm_major_version > major) ||
927         ((gtkmm_major_version == major) && (gtkmm_minor_version > minor)) ||
928         ((gtkmm_major_version == major) && (gtkmm_minor_version == minor) && (gtkmm_micro_version >= micro)))
929       {
930         return 0;
931        }
932      else
933       {
934         printf("\n*** An old version of GTK-- (%d.%d.%d) was found.\n",
935                gtkmm_major_version, gtkmm_minor_version, gtkmm_micro_version);
936         printf("*** You need a version of GTK-- newer than %d.%d.%d. The latest version of\n",
937                major, minor, micro);
938         printf("*** GTK-- is always available from ftp://ftp.gtk.org.\n");
939         printf("***\n");
940         printf("*** If you have already installed a sufficiently new version, this error\n");
941         printf("*** probably means that the wrong copy of the gtkmm-config shell script is\n");
942         printf("*** being found. The easiest way to fix this is to remove the old version\n");
943         printf("*** of GTK--, but you can also set the GTKMM_CONFIG environment to point to the\n");
944         printf("*** correct copy of gtkmm-config. (In this case, you will have to\n");
945         printf("*** modify your LD_LIBRARY_PATH enviroment variable, or edit /etc/ld.so.conf\n");
946         printf("*** so that the correct libraries are found at run-time))\n");
947       }
948     }
949   return 1;
950 }
951 ],, no_gtkmm=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
952        CXXFLAGS="$ac_save_CXXFLAGS"
953        LIBS="$ac_save_LIBS"
954      fi
955   fi
956   if test "x$no_gtkmm" = x ; then
957      AC_MSG_RESULT(yes)
958      ifelse([$2], , :, [$2])     
959   else
960      AC_MSG_RESULT(no)
961      if test "$GTKMM_CONFIG" = "no" ; then
962        echo "*** The gtkmm-config script installed by GTK-- could not be found"
963        echo "*** If GTK-- was installed in PREFIX, make sure PREFIX/bin is in"
964        echo "*** your path, or set the GTK_CONFIG environment variable to the"
965        echo "*** full path to gtk-config."
966        echo "*** The gtkmm-config script was not available in GTK-- versions"
967        echo "*** prior to 0.9.12. Perhaps you need to update your installed"
968        echo "*** version to 0.9.12 or newer"
969      else
970        if test -f conf.gtkmmtest ; then
971         :
972        else
973           echo "*** Could not run GTK-- test program, checking why..."
974           CXXFLAGS="$CFLAGS $GTKMM_CXXFLAGS"
975           LIBS="$LIBS $GTK___LIBS"
976           AC_TRY_LINK([
977 #include <gtk--.h>
978 #include <stdio.h>
979 ],      [ return ((gtkmm_major_version) || (gtkmm_minor_version) || (gtkmm_micro_version)); ],
980         [ echo "*** The test program compiled, but did not run. This usually means"
981           echo "*** that the run-time linker is not finding GTK-- or finding the wrong"
982           echo "*** version of GTK--. If it is not finding GTK--, you'll need to set your"
983           echo "*** LD_LIBRARY_PATH environment variable, or edit /etc/ld.so.conf to point"
984           echo "*** to the installed location  Also, make sure you have run ldconfig if that"
985           echo "*** is required on your system"
986           echo "***"
987           echo "*** If you have an old version installed, it is best to remove it, although"
988           echo "*** you may also be able to get things to work by modifying LD_LIBRARY_PATH" ],
989         [ echo "*** The test program failed to compile or link. See the file config.log for the"
990           echo "*** exact error that occured. This usually means GTK-- was incorrectly installed"
991           echo "*** or that you have moved GTK-- since it was installed. In the latter case, you"
992           echo "*** may want to edit the gtkmm-config script: $GTKMM_CONFIG" ])
993           CXXFLAGS="$ac_save_CXXFLAGS"
994           LIBS="$ac_save_LIBS"
995        fi
996      fi
997      GTK___CFLAGS=""
998      GTK__LIBS=""
999      ifelse([$3], , :, [$3])
1000      AC_LANG_RESTORE
1001   fi
1002   AC_SUBST(GTK___CFLAGS)
1003   AC_SUBST(GTK___LIBS)
1004   rm -f conf.gtkmmtest
1005 ])
1006
1007 # Configure paths for GTK--DRAW
1008 # Derek Quinn Wyatt   98-08-21  (adapted from Jan Nieuwenhuizen's code)
1009
1010 dnl AM_PATH_GTK__DRAW([MINIMUM-VERSION, [ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]]])
1011 dnl Test for GTK--DRAW, and define GTK___CFLAGS and GTK___LIBS
1012 dnl
1013 AC_DEFUN(AM_PATH_GTK__DRAW,
1014 [dnl 
1015 dnl Get the cflags and libraries from the gtk__-config script
1016 dnl
1017   AC_PATH_PROG(GTKMM_CONFIG, gtkmm-config, no)
1018   min_gtk___version=ifelse([$1], ,0.0.5,$1)
1019   AC_MSG_CHECKING(for GTK--DRAW - version >= $min_gtk___version)
1020   no_gtk__=""
1021   if test "$GTKMM_CONFIG" != "no" ; then
1022     GTK___CFLAGS=`$GTKMM_CONFIG --cflags`
1023     GTK___LIBS=`$GTKMM_CONFIG --libs`
1024     GTK___DLIBS="$GTK___LIBS -lgtkmmdraw"
1025     GTK___LIBS="$GTK___DLIBS"
1026     ac_save_CFLAGS="$CFLAGS"
1027     ac_save_LIBS="$LIBS"
1028     ac_save_CXXFLAGS="$CXXFLAGS"
1029     CFLAGS="$CFLAGS $GTK___CFLAGS"
1030     CXXFLAGS="$CXXFLAGS $GTK___CFLAGS"
1031     LIBS="$LIBS $GTK___LIBS"
1032 dnl
1033 dnl Now check if the installed GTK__ is sufficiently new. (Also sanity
1034 dnl checks the results of gtk__-config to some extent)
1035 dnl
1036     AC_TRY_RUN([
1037 #include <gtk--.h>
1038 #include <stdio.h>
1039
1040 int 
1041 main ()
1042 {
1043   // urg
1044   return 0;
1045 }
1046 ],, no_gtk__=yes,[echo $ac_n "cross compiling; assumed OK... $ac_c"])
1047      CFLAGS="$ac_save_CFLAGS"
1048      CXXFLAGS="$ac_save_CXXFLAGS"
1049      LIBS="$ac_save_LIBS"
1050   else
1051      no_gtk__=yes
1052   fi
1053   if test "x$no_gtk__" = x ; then
1054      AC_MSG_RESULT(yes)
1055      ifelse([$2], , :, [$2])     
1056   else
1057      AC_MSG_RESULT(no)
1058      GTK___CFLAGS=""
1059      GTK___LIBS=""
1060      ifelse([$3], , :, [$3])
1061   fi
1062   CXXFLAGS="$CXXFLAGS $GTK___CFLAGS"
1063   AC_SUBST(CXXFLAGS)
1064   AC_SUBST(GTK___CFLAGS)
1065   AC_SUBST(GTK___LIBS)
1066 ])
1067
1068 dnl   GUILE_FLAGS --- set flags for compiling and linking with Guile
1069 dnl
1070 dnl   This macro runs the `guile-config' script, installed with Guile,
1071 dnl   to find out where Guile's header files and libraries are
1072 dnl   installed.  It sets two variables, marked for substitution, as
1073 dnl   by AC_SUBST.
1074 dnl   
1075 dnl     GUILE_CFLAGS --- flags to pass to a C or C++ compiler to build
1076 dnl             code that uses Guile header files.  This is almost
1077 dnl             always just a -I flag.
1078 dnl   
1079 dnl     GUILE_LDFLAGS --- flags to pass to the linker to link a
1080 dnl             program against Guile.  This includes `-lguile' for
1081 dnl             the Guile library itself, any libraries that Guile
1082 dnl             itself requires (like -lqthreads), and so on.  It may
1083 dnl             also include a -L flag to tell the compiler where to
1084 dnl             find the libraries.
1085
1086 AC_DEFUN([GUILE_FLAGS],[
1087 ## The GUILE_FLAGS macro.
1088   ## First, let's just see if we can find Guile at all.
1089   AC_MSG_CHECKING(for Guile)
1090   guile-config link > /dev/null || {
1091     echo "configure: cannot find guile-config; is Guile installed?" 1>&2
1092     exit 1
1093   }
1094   GUILE_CFLAGS="`guile-config compile`"
1095   GUILE_LDFLAGS="`guile-config link`"
1096   AC_SUBST(GUILE_CFLAGS)
1097   AC_SUBST(GUILE_LDFLAGS)
1098   AC_MSG_RESULT(yes)
1099 ])
1100