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