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