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