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