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