]> git.donarmstrong.com Git - lilypond.git/blob - aclocal.m4
Issue 5108 Let configure find all needed files with guile-2.2
[lilypond.git] / aclocal.m4
1 dnl aclocal.m4   -*-shell-script-*-
2 dnl StepMake subroutines for configure.ac
3
4
5 ### mostly interal macros
6
7 # Get full path of executable ($1)
8 AC_DEFUN(STEPMAKE_GET_EXECUTABLE, [
9     ## which doesn't work in ash, if /usr/bin/which isn't installed
10     ## type -p doesn't work in ash
11     ## command -v doesn't work in zsh
12     ## command -v "$1" 2>&1
13     ## this test should work in ash, bash, pdksh (ksh), zsh
14     type -p $1 2>/dev/null | tail -n 1 | awk '{print $NF}'
15 ])
16
17
18 # Get version string from executable ($1)
19 AC_DEFUN(STEPMAKE_GET_VERSION, [
20     ## "$1" --version 2>&1 | grep -v '^$' | head -n 1 | awk '{print $NF}'
21     ##
22     ## ARG.
23     ## Workaround for broken Debian gcc version string:
24     ##     gcc (GCC) 3.1.1 20020606 (Debian prerelease)
25     ##
26     ## -V: Workaround for python
27
28     changequote(<<, >>)#dnl
29
30     ## Assume and hunt for dotted version multiplet.
31     ## use eval trickery, because we cannot use multi-level $() instead of ``
32     ## for compatibility reasons.
33     
34     ## grab the first version number in  --version output.
35     eval _ver=\"\`("$1" --version || "$1" -V) 2>&1 |
36                 grep -E '(^| )[0-9][0-9]*\.[0-9]' |
37                 head -n 1 |
38                 tr ' ' '\n' |
39                 sed 's/\([0-9][0-9]*\.[0-9][0-9.]*\).*/\1/g' |
40                 grep -E '(^| )[0-9][0-9]*\.[0-9]' |
41                 head -n 1\`\"
42
43     if test -z "$_ver"; then
44         ## If empty, try date [fontforge]
45         eval _ver=\"\`("$1" --version || "$1" -V) 2>&1 \
46             | grep '\(^\|[^0-9a-f]\)[0-9]\{6,8\}\([^0-9a-f]\|$\)' \
47             | head -n 1 \
48             | sed -e 's/^[^.0-9]*//' -e 's/[^.0-9]*$//'\`\"
49     fi
50     echo "$_ver"
51     changequote([, ])#dnl
52 ])
53
54 # Calculate simplistic numeric version from version string ($1)
55 # As yet, we have no need for something more elaborate.
56 AC_DEFUN(STEPMAKE_NUMERIC_VERSION, [
57     echo "$1" | awk -F. '
58     {
59       if ([$]3) {three = [$]3}
60       else {three = 0}
61     }
62     {printf "%.0f\n", [$]1*1000000 + [$]2*1000 + three}'
63 ])
64
65
66 # Add item ($2) to list ($1, one of 'OPTIONAL', 'REQUIRED')
67 AC_DEFUN(STEPMAKE_ADD_ENTRY, [
68     eval "$1"=\"`eval echo \"'$'$1\" \"$2\"`\"
69 ])
70
71 # Check if tested program ($2) was found ($1).
72 # If not, add entry to missing-list ($3, one of 'OPTIONAL', 'REQUIRED').
73 # We could abort here if a 'REQUIRED' program is not found
74 AC_DEFUN(STEPMAKE_OPTIONAL_REQUIRED, [
75     STEPMAKE_CHECK_SEARCH_RESULT($1)
76     if test $? -ne 0; then
77         STEPMAKE_ADD_ENTRY($3, $2)
78         if test "$3" = "REQUIRED"; then
79             command="echo ERROR: $2 not found"
80             # abort configure process here?
81         else
82             command="- echo $2 not found"
83         fi
84         eval "$1"='$command'
85         false
86     else
87         true
88     fi
89 ])
90
91
92 # Return if tested proram ($1) was found (true) or not (false).
93 AC_DEFUN(STEPMAKE_CHECK_SEARCH_RESULT, [
94     r="`eval echo '$'"$1"`"
95     if test -n "$r" -a "$r" != "error" -a "$r" != "no" && expr '`eval echo '$'"$1"`' : '.*\(echo\)' > /dev/null; then
96         true
97     else
98         ##STEPMAKE_WARN(cannot find $2. $3)
99         false
100     fi
101 ])
102
103
104 # Check version of program ($1)
105 # If version ($4: optional argument, supply if version cannot be
106 # parsed using --version or -V ) is smaller than requested ($3), add
107 # entry to missing-list ($2, one of 'OPTIONAL', 'REQUIRED').
108 AC_DEFUN(STEPMAKE_CHECK_VERSION, [
109     r="`eval echo '$'"$1"`"
110     AC_MSG_CHECKING([$r version])
111     exe=`STEPMAKE_GET_EXECUTABLE($r)`
112     if test -n "$4"; then
113         ver="$4"
114     else
115         ver=`STEPMAKE_GET_VERSION($exe)`
116     fi
117     num=`STEPMAKE_NUMERIC_VERSION($ver)`
118     req=`STEPMAKE_NUMERIC_VERSION($3)`
119     AC_MSG_RESULT([$ver])
120     if test "$num" -lt "$req"; then
121         STEPMAKE_ADD_ENTRY($2, ["$r >= $3 (installed: $ver)"])
122     fi
123     vervar="`echo $1 | tr '[a-z]' '[A-Z]'`_VERSION"
124     eval `echo $vervar=$num`
125 ##    AC_SUBST(`eval echo $vervar`)
126 ])
127
128 # Check version of program ($1)
129 # If version is greater than or equals unsupported ($3),
130 # add entry to unsupported list ($2, 'UNSUPPORTED')
131 AC_DEFUN(STEPMAKE_CHECK_VERSION_UNSUPPORTED, [
132     r="`eval echo '$'"$1"`"
133     AC_MSG_CHECKING([$r version])
134     exe=`STEPMAKE_GET_EXECUTABLE($r)`
135     ver=`STEPMAKE_GET_VERSION($exe)`
136     num=`STEPMAKE_NUMERIC_VERSION($ver)`
137     sup=`STEPMAKE_NUMERIC_VERSION($3)`
138     AC_MSG_RESULT([$ver])
139     if test "$num" -ge "$sup"; then
140         STEPMAKE_ADD_ENTRY($2, ["$r < $3 (installed: $ver)"])
141     fi
142 ])
143
144 ### Macros to build configure.ac
145
146
147 AC_DEFUN(STEPMAKE_BIBTEX2HTML, [
148     STEPMAKE_PROGS(BIBTEX2HTML, bibtex2html bib2html, $1)
149     if test "$BIBTEX2HTML" = "bib2html"; then
150         BIBTEX2HTML_FLAGS='$< $(@)'
151     else
152         BIBTEX2HTML_FLAGS='-o $(@D)/$(*F) $<'
153     fi
154     AC_SUBST(BIBTEX2HTML)
155     AC_SUBST(BIBTEX2HTML_FLAGS)
156 ])
157
158
159 AC_DEFUN(STEPMAKE_BISON, [
160     # ugh, automake: we want (and check for) bison
161     AC_PROG_YACC
162     
163     STEPMAKE_PROGS(BISON, bison, $1)
164     
165     # urg.  should test functionality rather than version.
166     if test "$BISON" = "bison" -a -n "$2"; then
167         STEPMAKE_CHECK_VERSION(BISON, $1, $2)
168     fi
169 ])
170
171 AC_DEFUN(STEPMAKE_COMPILE_BEFORE, [
172     # -O is necessary to get inlining
173     CFLAGS=${CFLAGS-""}
174     CXXFLAGS=${CXXFLAGS-$CFLAGS}
175     LDFLAGS=${LDFLAGS-""}
176     optimise_b=yes
177     checks_b=no
178     profile_b=no
179     debug_b=yes
180     pipe_b=yes
181
182     AC_ARG_ENABLE(debugging,
183     [AS_HELP_STRING([--enable-debugging],
184                     [compile with debugging info.  Default: on])],
185     [debug_b=$enableval])
186
187     AC_ARG_ENABLE(checking,
188     [AS_HELP_STRING([--enable-checking],
189                     [compile with expensive run-time checks.  Default: off])],
190     [checks_b=$enableval])
191
192     AC_ARG_ENABLE(optimising,
193     [AS_HELP_STRING([--enable-optimising],
194                     [compile with optimising.  Default: on])],
195     [optimise_b=$enableval])
196
197     AC_ARG_ENABLE(profiling, 
198     [AS_HELP_STRING([--enable-profiling],
199                     [compile with gprof support.  Default: off])],
200     [profile_b=$enableval])
201     
202     AC_ARG_ENABLE(pipe, 
203     [AS_HELP_STRING([--enable-pipe],
204                     [compile with -pipe.  Default: on])],
205     [pipe_b=$enableval])
206
207     if test "$optimise_b" = yes; then
208         OPTIMIZE=" -O2 -finline-functions"
209         # following two lines are compatibility while Patchy has not
210         # yet learnt about --enable-checking.  But once it has, we
211         # don't want -DDEBUG twice, so we omit it here if it is going
212         # to get added anyway later.
213     elif test "$checks_b" != yes; then
214         DEFINES="$DEFINES -DDEBUG"
215     fi
216
217     if test "$checks_b" = yes; then
218         DEFINES="$DEFINES -DDEBUG"
219     fi
220
221     if test $profile_b = yes; then
222         EXTRA_LIBS="-pg"
223         OPTIMIZE="$OPTIMIZE -pg"
224     fi
225
226     if test $debug_b = yes; then
227         OPTIMIZE="$OPTIMIZE -g"
228     fi
229 ])
230
231 AC_DEFUN(STEPMAKE_COMPILE, [
232
233     AC_REQUIRE([STEPMAKE_COMPILE_BEFORE])
234     AC_REQUIRE([AC_PROG_CC])
235
236     STEPMAKE_OPTIONAL_REQUIRED(CC, cc, $1)
237     LD='$(CC)'
238     AC_SUBST(LD)
239
240     # If -pipe requested, test if it works and add to CFLAGS.
241     if test "$pipe_b" = yes; then
242         save_cflags="$CFLAGS"
243         CFLAGS=" -pipe $CFLAGS";
244         AC_CACHE_CHECK([whether compiler understands -pipe],
245             [stepmake_cv_cflags_pipe],
246             AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[/* -pipe test */]])],
247                 [stepmake_cv_cflags_pipe=yes],
248                 [stepmake_cv_cflags_pipe=no]))
249         CFLAGS=$save_cflags
250         if test $stepmake_cv_cflags_pipe = yes; then
251             OPTIMIZE="$OPTIMIZE -pipe"
252         fi
253     fi
254
255     CFLAGS="$CFLAGS $OPTIMIZE"
256     CPPFLAGS=${CPPFLAGS-""}
257
258     AC_MSG_CHECKING([for IEEE-conformance compiler flags])
259     save_cflags="$CFLAGS"
260     case "$host" in
261         alpha*-*-*)
262             dnl should do compile test?
263             AC_MSG_RESULT(-mieee)
264             CFLAGS=" -mieee $CFLAGS"
265             ;;
266         *)
267             AC_MSG_RESULT([none])
268             ;;
269     esac
270
271     AC_SUBST(cross_compiling)
272     AC_SUBST(CFLAGS)
273     AC_SUBST(CPPFLAGS)
274     AC_SUBST(LDFLAGS)
275     AC_SUBST(DEFINES)
276     AC_SUBST(EXTRA_LIBS)
277 ])
278
279 AC_DEFUN(STEPMAKE_CXX, [
280     AC_PROG_CXX
281     STEPMAKE_OPTIONAL_REQUIRED(CXX, c++, $1)
282
283     CXXFLAGS="$CXXFLAGS $OPTIMIZE"
284
285     AC_SUBST(CXX)
286     AC_SUBST(CXXFLAGS)
287 ])
288
289
290 AC_DEFUN(STEPMAKE_CXXTEMPLATE, [
291     AC_CACHE_CHECK([whether explicit instantiation is needed],
292         stepmake_cv_need_explicit_instantiation,
293         AC_LINK_IFELSE([AC_LANG_PROGRAM([[
294     template <class T> struct foo { static int baz; };
295     template <class T> int foo<T>::baz = 1;
296     ]], [[ return foo<int>::baz; ]])],[stepmake_cv_need_explicit_instantiation=no],[stepmake_cv_need_explicit_instantiation=yes]))
297     if test x"$stepmake_cv_need_explicit_instantiation"x = x"yes"x; then
298         AC_DEFINE(NEED_EXPLICIT_INSTANTIATION)
299     fi
300 ])
301
302 AC_DEFUN(STEPMAKE_GXXCODEGENBUG, [
303     AC_MSG_CHECKING([options for known g++ bugs])
304     case "$GXX:$CXX_VERSION" in
305         yes:400600[[0-2]])
306             AC_MSG_RESULT([-fno-optimize-sibling-calls (tail call bug)])
307             CXXFLAGS="$CXXFLAGS -fno-optimize-sibling-calls"
308             ;;
309         yes:400700?)
310             AC_MSG_RESULT([-fno-tree-vrp (comparison bug)])
311             CXXFLAGS="$CXXFLAGS -fno-tree-vrp"
312             ;;
313         *) AC_MSG_RESULT([none])
314     esac
315     AC_SUBST(CXXFLAGS)
316 ])
317
318
319 AC_DEFUN(STEPMAKE_DATADIR, [
320     presome=${prefix}
321     if test "$prefix" = "NONE"; then
322         presome=${ac_default_prefix}
323     fi
324     
325     build_package_datadir=$ugh_ugh_autoconf250_builddir/out$CONFIGSUFFIX/share/$package
326     
327     DATADIR=`echo ${datadir} | sed "s!\\\${datarootdir}!${presome}/share!"`
328     DATADIR=`echo ${DATADIR} | sed "s!\\\${prefix}!$presome!"`
329     BUILD_PACKAGE_DATADIR=`echo ${build_package_datadir} | sed "s!\\\${prefix}!$presome!"`
330     
331     AC_SUBST(datadir)
332     AC_SUBST(datarootdir)
333     AC_SUBST(build_package_datadir)
334     AC_DEFINE_UNQUOTED(DATADIR, ["${DATADIR}"])
335     AC_DEFINE_UNQUOTED(BUILD_PACKAGE_DATADIR, ["${BUILD_PACKAGE_DATADIR}"])
336 ])
337
338 ## ugh: cut & paste programming from datadir. 
339 AC_DEFUN(STEPMAKE_LIBDIR, [
340     presome=${exec_prefix}
341     if test "$presome" = "NONE"; then
342             presome=${prefix}
343     fi
344     if test "$presome" = "NONE"; then
345             presome=${ac_default_prefix}
346     fi
347
348     build_package_libdir=$ugh_ugh_autoconf250_builddir/out$CONFIGSUFFIX/lib/$package
349     
350     LIBDIR=`echo ${libdir} | sed "s!\\\${exec_prefix}!$presome!"`
351     BUILD_PACKAGE_LIBDIR=`echo ${build_package_libdir} | sed "s!\\\${exec_prefix}!$presome!"`
352     
353     AC_SUBST(libdir)
354     AC_SUBST(build_package_libdir)
355     AC_DEFINE_UNQUOTED(LIBDIR, ["${LIBDIR}"])
356     AC_DEFINE_UNQUOTED(BUILD_PACKAGE_LIBDIR, ["${BUILD_PACKAGE_LIBDIR}"])
357 ])
358
359
360 AC_DEFUN(STEPMAKE_PREFIX_EXPAND_FIXUP, [
361     # undo expanding of explicit --infodir=/usr/share
362     # to ease install-time override with prefix=...
363     strip=`echo $includedir | eval sed s@^$prefix@@`
364     if test "$includedir" = "`eval echo $prefix$strip`"; then
365             includedir='${prefix}'$strip''
366     fi
367     strip=`echo $libdir | eval sed s@^$exec_prefix@@`
368     if test "$libdir" = "`eval echo $exec_prefix$strip`"; then
369             libdir='${exec_prefix}'$strip''
370     fi
371     strip=`echo $infodir | eval sed s@^$datarootdir@@`
372     if test "$infodir" = "`eval echo $datarootdir$strip`"; then
373             infodir='${datarootdir}'$strip''
374     fi
375     strip=`echo $mandir | eval sed s@^$datarootdir@@`
376     if test "$mandir" = "`eval echo $datarootdir$strip`"; then
377             mandir='${datarootdir}'$strip''
378     fi
379 ])
380
381
382 AC_DEFUN(STEPMAKE_END, [
383     STEPMAKE_PREFIX_EXPAND_FIXUP
384
385     AC_SUBST(OPTIONAL)
386     AC_SUBST(REQUIRED)
387     
388     AC_CONFIG_FILES([$CONFIGFILE.make:config.make.in])
389     AC_OUTPUT
390     
391     if test -n "$OPTIONAL"; then
392         echo
393         echo "WARNING: Please consider installing optional programs or files: $OPTIONAL"
394     fi
395
396     if test -n "$REQUIRED"; then
397         echo
398         echo "ERROR: Please install required programs: $REQUIRED"
399     fi
400     
401     if test -n "$UNSUPPORTED"; then
402         echo
403         echo "ERROR: Please use older version of programs: $UNSUPPORTED"
404     fi
405     
406     if test -n "$OPTIONAL$REQUIRED$UNSUPPORTED"; then
407         echo
408         echo "See INSTALL.txt for more information on how to build $PACKAGE_NAME"
409         if test -f config.cache ; then
410             echo "Remove config.cache before rerunning ./configure"
411         fi 
412     fi
413     
414     if test -n "$REQUIRED$UNSUPPORTED"; then
415         rm -f $srcdir/GNUmakefile
416         exit 1
417     fi
418
419     # regular in-place build
420     # test for srcdir_build = yes ?
421     if test "$srcdir_build" = "yes"; then
422         rm -f $srcdir/GNUmakefile
423         cp $srcdir/GNUmakefile.in $srcdir/GNUmakefile
424         chmod 444 $srcdir/GNUmakefile
425     else
426         if test -f $srcdir/GNUmakefile; then
427             cat <<EOF
428 Source directory already configured.  Please clean the source directory
429
430      make -C $srcdir distclean
431
432 and rerun configure.
433 EOF
434             exit 2
435         fi
436
437         abssrcdir="`cd $srcdir; pwd`"
438         absbuilddir="`pwd`"
439         for d in 2 3 4 5 ; do
440             for mf in `cd $srcdir ; find . -maxdepth $d -mindepth $d -name GNUmakefile`; do
441                 case "$abssrcdir" in
442                     "$absbuilddir"/*)
443 # source is below build directory, always copy
444                         ;;
445                     *)
446                         case "$abssrcdir/${mf#./}" in
447                             "$absbuilddir"/*)
448 # find descended into build directory, don't copy
449                                 continue
450                         esac
451                 esac
452                 mkdir -p ${mf%/*}
453                 cat <<EOF | $PYTHON -  > $mf
454 print 'depth=' + ('../' * ( $d-1 ) )
455 print 'include \$(depth)/config\$(if \$(conf),-\$(conf),).make'
456 print 'include \$(configure-srcdir)/$mf'
457 print 'MODULE_INCLUDES += \$(src-dir)/\$(outbase)'
458 EOF
459             done
460             for mf in `cd $srcdir ; find . -maxdepth $d -mindepth $d -name '*.make' | grep -v config.make `; do
461                 case "$abssrcdir" in
462                     "$absbuilddir"/*)
463 # source is below build directory, always copy
464                         ;;
465                     *)
466                         case "$abssrcdir/${mf#./}" in
467                             "$absbuilddir"/*)
468 # find descended into build directory, don't copy
469                                 continue
470                         esac
471                 esac
472                 mkdir -p ${mf%/*}
473                 cat <<EOF | $PYTHON -  > $mf
474 print 'include \$(depth)/config\$(if \$(conf),-\$(conf),).make'
475 print 'include \$(configure-srcdir)/$mf'
476 EOF
477             done
478         done
479
480         rm -f GNUmakefile
481         cat <<EOF > GNUmakefile
482 depth = .
483 include config\$(if \$(conf),-\$(conf),).make
484 include \$(configure-srcdir)/GNUmakefile.in
485 EOF
486         chmod 444 GNUmakefile
487         AC_SUBST(VPATH)
488     fi
489 ])
490
491
492 AC_DEFUN(STEPMAKE_FLEX, [
493     # ugh, automake: we want (and check for) flex
494     # AC_PROG_LEX
495     # urg: automake 1.3: hope this doesn't break 1.2 ac_cv_pro_lex_root hack...
496
497     # AC_PROG_LEX()
498     # ugh, ugh
499     ac_cv_prog_lex_root=lex.yy
500     STEPMAKE_PROGS(FLEX, flex, $1)
501 ])
502
503
504 AC_DEFUN(STEPMAKE_FLEXLEXER, [
505     AC_CHECK_HEADERS([FlexLexer.h],[true],[false])
506     if test $? -ne 0; then
507         warn='FlexLexer.h (flex package)'
508         STEPMAKE_ADD_ENTRY($1, $warn)
509     fi
510     # check for yyFlexLexer.yy_current_buffer,
511     # in 2.5.4 <= flex < 2.5.29
512     AC_CACHE_CHECK([for yyFlexLexer.yy_current_buffer],
513         [stepmake_cv_flexlexer_yy_current_buffer],
514         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
515 using namespace std;
516 #include <FlexLexer.h>
517 class yy_flex_lexer: public yyFlexLexer
518 {
519   public:
520     yy_flex_lexer ()
521     {
522       yy_current_buffer = 0;
523     }
524 };
525 ]])],
526             [stepmake_cv_flexlexer_yy_current_buffer=yes],
527             [stepmake_cv_flexlexer_yy_current_buffer=no]))
528     if test $stepmake_cv_flexlexer_yy_current_buffer = yes; then
529         AC_DEFINE(HAVE_FLEXLEXER_YY_CURRENT_BUFFER, 1, [Define to 1 if yyFlexLexer has yy_current_buffer.])
530     fi
531 ])
532   
533
534
535 AC_DEFUN(STEPMAKE_FLEXLEXER_LOCATION, [
536         AC_MSG_CHECKING([FlexLexer.h location])
537
538         # ugh.
539         cat <<EOF > conftest.cc
540 using namespace std;
541 #include <FlexLexer.h>
542 EOF
543         FLEXLEXER_FILE=`eval $ac_cpp conftest.cc | \
544           sed 's!# 1 "\(.*FlexLexer.h\)"!@FLEXLEXER@\1@@!g' | grep '@@' | \
545           sed 's!.*@FLEXLEXER@\(.*\)@@.*$!\1!g' ` 1> /dev/null 2> /dev/null
546         rm conftest.cc
547         AC_SUBST(FLEXLEXER_FILE)
548         AC_MSG_RESULT($FLEXLEXER_FILE)
549 ])
550
551 AC_DEFUN(STEPMAKE_GCC_OR_CLANG, [
552     STEPMAKE_HAS_CLANG()
553     if test "$HAS_CLANG" = "no"; then
554         if test "$GCC" = "yes"; then
555             STEPMAKE_CHECK_VERSION(CC, $1, $2)
556         else
557             warn="$CC (Please install *GNU* cc)"
558             STEPMAKE_ADD_ENTRY($1, $warn)
559         fi
560     fi
561     # no else, we're fine with any clang
562 ])
563
564 AC_DEFUN(STEPMAKE_GETTEXT, [
565     presome=${prefix}
566     if test "$prefix" = "NONE"; then
567             presome=${ac_default_prefix}
568     fi
569     LOCALEDIR=`echo ${localedir} | sed "s!\\\${prefix}!$presome!"`
570     
571     AC_SUBST(localedir)
572     AC_DEFINE_UNQUOTED(LOCALEDIR, ["${LOCALEDIR}"])
573     AC_CHECK_LIB(intl, gettext)
574     AC_CHECK_FUNCS(gettext)
575 ])
576
577
578 # Check for guile, between minimum ($2) and maximum version ($3).
579 # If missing, add entry to missing-list ($1, one of 'OPTIONAL', 'REQUIRED')
580 AC_DEFUN(STEPMAKE_GUILE, [
581     AC_MSG_CHECKING([for guile])
582     guile="guile"
583     found="no"
584     for r in $GUILE guile guile2 guile2.0 guile-2.0 guile1 guile1.9 guile1.8 guile-1 guile-1.9 guile-1.8; do
585         exe=`STEPMAKE_GET_EXECUTABLE($r)`
586         if ! $exe --version > /dev/null 2>&1 ; then
587             continue
588         fi
589         ver=`STEPMAKE_GET_VERSION($exe)`
590         num=`STEPMAKE_NUMERIC_VERSION($ver)`
591         req=`STEPMAKE_NUMERIC_VERSION($2)`
592         sup=`STEPMAKE_NUMERIC_VERSION($3)`
593         if test -n "$2" && test "$num" -lt "$req"; then
594             guile=["$r >= $2 (installed: $ver)"]
595             continue
596         else
597             if test -n "$3" && test "$num" -ge "$sup"; then
598                 guile=["$r < $3 (installed: $ver)"]
599                 continue
600             else
601                 guile=$r
602                 found=$r
603                 break
604             fi
605         fi
606     done
607     AC_MSG_RESULT([$found])
608     if test "$found" != "no"; then
609         AC_MSG_CHECKING([$guile version])
610         AC_MSG_RESULT([$ver])
611         GUILE=$found
612     else
613         STEPMAKE_ADD_ENTRY($1, $guile)
614     fi
615     STEPMAKE_PATH_PROG(GUILE, $GUILE)
616 ])
617
618
619 #   STEPMAKE_GUILE_FLAGS --- set flags for compiling and linking with Guile
620 #
621 #   This macro runs the guile-config script, installed with Guile,
622 #   to find out where Guile's header files and libraries are
623 #   installed.  It sets two variables, marked for substitution, as
624 #   by AC_SUBST.
625 #   
626 #     GUILE_CFLAGS --- flags to pass to a C or C++ compiler to build
627 #             code that uses Guile header files.  This is almost
628 #             always just a -I flag.
629 #   
630 #     GUILE_LDFLAGS --- flags to pass to the linker to link a
631 #             program against Guile.  This includes -lguile for
632 #             the Guile library itself, any libraries that Guile
633 #             itself requires (like -lqthreads), and so on.  It may
634 #             also include a -L flag to tell the compiler where to
635 #             find the libraries.
636
637 AC_DEFUN([STEPMAKE_GUILE_FLAGS], [
638     exe=`STEPMAKE_GET_EXECUTABLE($guile_config)`
639     if test -x $exe; then
640         AC_MSG_CHECKING([guile compile flags])
641         GUILE_CFLAGS="`$guile_config compile`"
642         AC_MSG_RESULT($GUILE_CFLAGS)
643         AC_MSG_CHECKING([guile link flags])
644         GUILE_LDFLAGS="`$guile_config link`"
645         AC_MSG_RESULT($GUILE_LDFLAGS)
646     fi
647     AC_SUBST(GUILE_CFLAGS)
648     AC_SUBST(GUILE_LDFLAGS)
649 ])
650
651
652 # Check for guile-config, between minimum ($2) and maximum version ($3).
653 # If missing, add entry to missing-list ($1, one of 'OPTIONAL', 'REQUIRED')
654 AC_DEFUN(STEPMAKE_GUILE_DEVEL, [
655     ## First, let's just see if we can find Guile at all.
656     test -n "$target_alias" && target_guile_config=$target_alias-guile-config
657     test -n "$host_alias" && host_guile_config=$host_alias-guile-config
658     AC_MSG_CHECKING([for guile-config])
659     guile_config="guile-config"
660     found="no"
661     for r in $GUILE_CONFIG \
662       $target_guile_config $host_guile_config $build_guile_config \
663       guile-config guile-2.2-config guile2.2-config guile2-config \
664       guile2.0-config guile-2.0-config guile1-config guile1.9-config \
665       guile1.8-config guile-1-config guile-1.9-config guile-1.8-config; \
666       do
667         exe=`STEPMAKE_GET_EXECUTABLE($r)`
668         if ! $exe --version > /dev/null 2>&1 ; then
669             continue
670         fi
671         ver=`STEPMAKE_GET_VERSION($exe)`
672         num=`STEPMAKE_NUMERIC_VERSION($ver)`
673         req=`STEPMAKE_NUMERIC_VERSION($2)`
674         sup=`STEPMAKE_NUMERIC_VERSION($3)`
675         if test -n "$2" -a "$num" -lt "$req"; then
676             guile_config=["$r >= $2 (installed: $ver)"]
677             continue
678         else
679             if test -n "$3" -a "$num" -ge "$sup"; then
680                 guile_config=["$r < $3 (installed: $ver)"]
681                 continue
682             else
683                 guile_config=$r
684                 found=$r
685                 break
686             fi
687         fi
688     done
689     AC_MSG_RESULT([$found])
690     if test "$found" != "no"; then
691         AC_MSG_CHECKING([$guile_config version])
692         AC_MSG_RESULT([$ver])
693         GUILE_CONFIG=$found
694     else
695         STEPMAKE_ADD_ENTRY($1, "$guile_config (guile-devel, guile-dev or libguile-dev package)")
696     fi
697
698     AC_SUBST(GUILE_CONFIG)
699     
700     guile_version="$ver"
701     changequote(<<, >>)#dnl
702     GUILE_MAJOR_VERSION=`expr $guile_version : '\([0-9]*\)'`
703     GUILE_MINOR_VERSION=`expr $guile_version : '[0-9]*\.\([0-9]*\)'`
704     GUILE_PATCH_LEVEL=`expr $guile_version : '[0-9]*\.[0-9]*\.\([0-9]*\)'`
705     changequote([, ])#dnl
706     STEPMAKE_GUILE_FLAGS
707     save_CPPFLAGS="$CPPFLAGS"
708     save_LIBS="$LIBS"
709     CPPFLAGS="$GUILE_CFLAGS $CPPFLAGS"
710     LIBS="$GUILE_LDFLAGS $LIBS"
711     AC_CHECK_HEADERS([libguile.h])
712     AC_CHECK_LIB(guile, scm_boot_guile)
713     AC_CHECK_FUNCS(scm_boot_guile,,libguile_b=no)
714     if test "$libguile_b" = "no"; then
715             warn='libguile (libguile-dev, guile-devel or guile-dev
716    package).'
717             STEPMAKE_ADD_ENTRY(REQUIRED, $warn)
718     fi
719     CPPFLAGS="$save_CPPFLAGS"
720     LIBS="$save_LIBS"
721     AC_DEFINE_UNQUOTED(GUILE_MAJOR_VERSION, $GUILE_MAJOR_VERSION)
722     AC_DEFINE_UNQUOTED(GUILE_MINOR_VERSION, $GUILE_MINOR_VERSION)
723     AC_DEFINE_UNQUOTED(GUILE_PATCH_LEVEL, $GUILE_PATCH_LEVEL)
724 ])
725
726
727 AC_DEFUN(STEPMAKE_DLOPEN, [
728     AC_CHECK_LIB(dl, dlopen)
729     AC_CHECK_FUNCS(dlopen)
730 ])
731
732 AC_DEFUN(STEPMAKE_HAS_CLANG, [
733     AC_EGREP_CPP(yes,
734       [#ifdef __clang__
735        yes
736        #endif
737       ], HAS_CLANG=yes, HAS_CLANG=no)
738 ])
739
740 AC_DEFUN(STEPMAKE_GXX_OR_CLANG, [
741     STEPMAKE_HAS_CLANG()
742     if test "$HAS_CLANG" = "no"; then
743         if test "$GXX" = "yes"; then
744             STEPMAKE_CHECK_VERSION(CXX, $1, $2)
745         else
746             warn="$CXX (Please install *GNU* c++)"
747             STEPMAKE_ADD_ENTRY($1, $warn)
748         fi
749     fi
750     # no else, we're fine with any clang
751 ])
752
753
754 AC_DEFUN(STEPMAKE_INIT, [
755
756     . $srcdir/VERSION
757     FULL_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$PATCH_LEVEL
758     MICRO_VERSION=$PATCH_LEVEL
759     TOPLEVEL_VERSION=$FULL_VERSION
760     if test x$MY_PATCH_LEVEL != x; then
761         FULL_VERSION=$FULL_VERSION.$MY_PATCH_LEVEL
762     fi
763     VERSION=$FULL_VERSION
764     export MAJOR_VERSION MINOR_VERSION PATCH_LEVEL
765     # urg: don't "fix" this: irix doesn't know about [:lower:] and [:upper:]
766     changequote(<<, >>)#dnl
767     PACKAGE=`echo $PACKAGE_NAME | tr '[a-z]' '[A-Z]'`
768     package=`echo $PACKAGE_NAME | tr '[A-Z]' '[a-z]'`
769     changequote([, ])#dnl
770
771     # No versioning on directory names of sub-packages 
772     # urg, urg
773     stepmake=${datadir}/stepmake
774     presome=${prefix}
775     if test "$prefix" = "NONE"; then
776             presome=${ac_default_prefix}
777     fi
778     stepmake=`echo ${stepmake} | sed "s!\\\${prefix}!$presome!"`
779
780     # urg, how is this supposed to work?
781     if test "$program_prefix" = "NONE"; then
782           program_prefix=
783     fi
784     if test "$program_suffix" = "NONE"; then
785           program_suffix=
786     fi
787
788     AC_MSG_CHECKING(Package)
789     if test "$PACKAGE" = "STEPMAKE"; then
790         AC_MSG_RESULT(Stepmake package!)
791
792         AC_MSG_CHECKING(builddir)
793
794         ugh_ugh_autoconf250_builddir="`pwd`"
795         
796         if test "$srcdir" = "."; then
797             srcdir_build=yes
798         else
799             srcdir_build=no
800             package_builddir="`dirname $ugh_ugh_autoconf250_builddir`"
801             package_srcdir="`dirname  $srcdir`"
802         fi
803         AC_MSG_RESULT($ugh_ugh_autoconf250_builddir)
804
805         (cd stepmake 2>/dev/null || mkdir stepmake)
806         (cd stepmake; rm -f bin; ln -s ../$srcdir/bin .)
807         stepmake=stepmake
808     else
809         AC_MSG_RESULT($PACKAGE)
810
811         AC_MSG_CHECKING(builddir)
812         ugh_ugh_autoconf250_builddir="`pwd`"
813
814         here_dir=$(cd . && pwd)
815         full_src_dir=$(cd $srcdir && pwd)
816
817         if test "$full_src_dir" = "$here_dir"; then
818             srcdir_build=yes
819         else
820             srcdir_build=no
821         fi
822         AC_MSG_RESULT($ugh_ugh_autoconf250_builddir)
823
824         AC_MSG_CHECKING(for stepmake)
825         # Check for installed stepmake
826         if test -d $stepmake; then
827             AC_MSG_RESULT($stepmake)
828         else
829             stepmake="`cd $srcdir/stepmake; pwd`"
830             AC_MSG_RESULT([$srcdir/stepmake  ($datadir/stepmake not found)])
831         fi
832     fi
833
834     AC_SUBST(ugh_ugh_autoconf250_builddir)
835
836     # Use absolute directory for non-srcdir builds, so that build
837     # dir can be moved.
838     if test "$srcdir_build" = "no" ;  then 
839         srcdir="`cd $srcdir; pwd`"
840     fi
841     
842     AC_SUBST(srcdir)
843     AC_SUBST(stepmake)
844     AC_SUBST(package)
845     AC_SUBST(PACKAGE)
846     AC_SUBST(PACKAGE_NAME)
847     AC_SUBST(VERSION)
848     AC_SUBST(MAJOR_VERSION)
849     AC_SUBST(MINOR_VERSION)
850     AC_SUBST(MICRO_VERSION)
851
852     # stepmake nonstandard names
853     AC_SUBST(PATCH_LEVEL)
854     AC_SUBST(TOPLEVEL_VERSION)
855     
856     # We don't need the upper case variant,
857     # so stick to macros are uppercase convention.
858     # AC_DEFINE_UNQUOTED(package, ["${package}"])
859     # AC_DEFINE_UNQUOTED(PACKAGE, ["${PACKAGE}"])
860     AC_DEFINE_UNQUOTED(PACKAGE, ["${package}"])
861     AC_DEFINE_UNQUOTED(PACKAGE_NAME, ["${PACKAGE_NAME}"])
862     AC_DEFINE_UNQUOTED(TOPLEVEL_VERSION, ["${FULL_VERSION}"])
863
864     if test -z "$package_depth"; then
865         package_depth="."
866     else
867         package_depth="../$package_depth"
868     fi
869     export package_depth
870     AC_SUBST(package_depth)
871
872     AUTOGENERATE="This file was automatically generated by configure"
873     AC_SUBST(AUTOGENERATE)
874
875     CONFIGSUFFIX=
876     AC_ARG_ENABLE(config,
877     [AS_HELP_STRING([--enable-config=CONF],
878                     [put settings in config-CONF.make and config-CONF.h;
879                     do `make conf=CONF' to get output in ./out-CONF])],
880     [CONFIGURATION=$enableval])
881
882     ##'`#
883
884     test -n "$CONFIGURATION" && CONFIGSUFFIX="-$CONFIGURATION"
885     CONFIGFILE=config$CONFIGSUFFIX
886     AC_SUBST(CONFIGSUFFIX)
887      
888     AC_CANONICAL_HOST
889     STEPMAKE_PROGS(MAKE, gmake make, REQUIRED)
890     STEPMAKE_PROGS(FIND, find, REQUIRED)
891
892     STEPMAKE_PROGS(TAR, tar, REQUIRED)
893
894     if test "$(echo 2)" != "2" ||
895         test "x`uname`" = "xHP-UX"; then
896         AC_PATH_PROG(KSH, ksh, /bin/ksh)
897         AC_PATH_PROG(BASH, bash, $KSH)
898         STEPMAKE_WARN(avoiding buggy /bin/sh)
899         AC_PATH_PROG(SHELL, bash, $KSH)
900     else
901         SHELL=/bin/sh
902         AC_PATH_PROG(BASH, bash, $SHELL)
903     fi
904     AC_SUBST(SHELL)
905
906     STEPMAKE_PYTHON(REQUIRED, 1.5, 3.0)
907
908     if expr "$MAKE" : '.*\(echo\)' >/dev/null; then
909         $MAKE -v 2> /dev/null | grep GNU > /dev/null
910         if test "$?" = 1; then
911             warn='make (Please install *GNU* make)'
912             # STEPMAKE_WARN($warn)
913             STEPMAKE_ADD_ENTRY(REQUIRED, $warn)
914         fi
915     fi
916
917     ROOTSEP=':'
918     DIRSEP='/'
919     PATHSEP=':'
920     LN=ln
921     LN_S='ln -s'
922     ZIP="zip -r -9"
923
924     AC_SUBST(program_prefix)
925     AC_SUBST(program_suffix)
926     AC_SUBST(ZIP)
927     AC_SUBST(LN)
928     AC_SUBST(LN_S)
929     AC_DEFINE_UNQUOTED(DIRSEP, ['${DIRSEP}'])
930     AC_DEFINE_UNQUOTED(PATHSEP, ['${PATHSEP}'])
931     AC_SUBST(DIRSEP)
932     AC_SUBST(PATHSEP)
933     AC_SUBST(ROOTSEP)
934   
935     STEPMAKE_DATADIR
936     STEPMAKE_LIBDIR
937 ])
938
939     
940 AC_DEFUN(STEPMAKE_LIB, [
941     STEPMAKE_PROGS(AR, ar, $1)
942     AC_PROG_RANLIB
943     STEPMAKE_OPTIONAL_REQUIRED(RANLIB, ranlib, $1)
944 ])
945
946
947 AC_DEFUN(STEPMAKE_LIBTOOL, [
948     # libtool.info ...
949     # **Never** try to set library version numbers so that they correspond
950     # to the release number of your package.  This is an abuse that only
951     # fosters misunderstanding of the purpose of library versions.
952
953     REVISION=$PATCH_LEVEL
954     # CURRENT=$MINOR_VERSION
955     CURRENT=`expr $MINOR_VERSION + 1`
956     # AGE=`expr $MAJOR_VERSION + 1`
957     AGE=$MAJOR_VERSION
958     AC_SUBST(CURRENT)
959     AC_SUBST(REVISION)
960     AC_SUBST(AGE)
961 ])
962
963
964 AC_DEFUN(STEPMAKE_LOCALE, [
965     lang=English
966     ALL_LINGUAS="en nl"
967
968     # with/enable ??
969     AC_ARG_WITH(localedir,
970     [AS_HELP_STRING([--with-localedir=DIR],
971                     [location of locales.  Default: PREFIX/share/locale])],
972     localedir=$with_localedir,
973     localedir='${prefix}/share/locale')
974
975     AC_ARG_WITH(lang,
976     [AS_HELP_STRING([--with-lang=LANG],
977                     [use LANG as language to emit messages])],
978     language=$with_lang,
979     language=English)
980
981     AC_MSG_CHECKING(language)    
982     case "$language" in
983       En* | en* | Am* | am* | US* | us*)
984             lang=English;;
985       NL | nl | Du* | du* | Ned* | ned*)
986             lang=Dutch;;
987       "")
988             lang=English;;
989       *)
990             lang=unknown;;
991     esac
992     AC_MSG_RESULT($lang)
993
994     if test "$lang" = "unknown" ; then
995         STEPMAKE_WARN($language not supported; available are: $ALL_LINGUAS)
996     fi
997
998 ])
999
1000
1001 AC_DEFUN(STEPMAKE_MAKEINFO, [
1002     STEPMAKE_PROGS(MAKEINFO, makeinfo, $1)
1003 ])
1004
1005
1006 AC_DEFUN(STEPMAKE_MAN, [
1007     STEPMAKE_PROGS(GROFF, groff ditroff, $1)
1008     AC_SUBST(GROFF)
1009     STEPMAKE_PROGS(TROFF, troff, $1)
1010     AC_SUBST(TROFF)
1011     STEPMAKE_PROGS(TBL, tbl, $1)
1012     AC_SUBST(TBL)
1013 ])
1014
1015
1016 AC_DEFUN(STEPMAKE_MSGFMT, [
1017     STEPMAKE_PROGS(MSGFMT, msgfmt, $1)
1018 ])
1019
1020
1021 # Check for program ($2), set full path result to ($1).
1022 # If missing, add entry to missing-list ($3, one of 'OPTIONAL', 'REQUIRED')
1023 AC_DEFUN(STEPMAKE_PATH_PROG, [
1024     AC_CHECK_PROGS($1, $2, no)
1025     STEPMAKE_OPTIONAL_REQUIRED($1, $2, $3)
1026     if test $? -eq 0; then
1027         AC_PATH_PROGS($1, $2)
1028         if test -n "$4"; then
1029             STEPMAKE_CHECK_VERSION($1, $3, $4)
1030         fi
1031     fi
1032 ])
1033
1034
1035 # Check for program in set of names ($2), set result to ($1) .
1036 # If missing, add entry to missing-list ($3, one of 'OPTIONAL', 'REQUIRED')
1037 # If exists, and a minimal version ($4) is required
1038 AC_DEFUN(STEPMAKE_PROGS, [
1039     AC_CHECK_PROGS($1, $2, no)
1040     STEPMAKE_OPTIONAL_REQUIRED($1, $2, $3)
1041     if test $? -eq 0 -a -n "$4"; then
1042         STEPMAKE_CHECK_VERSION($1, $3, $4)
1043     fi
1044 ])
1045
1046
1047 AC_DEFUN(STEPMAKE_PERL, [
1048     STEPMAKE_PATH_PROG(PERL, perl, $1)
1049 ])
1050
1051
1052 # Check for python, between minimum ($2) and maximum version ($3).
1053 # If missing, add entry to missing-list ($1, one of 'OPTIONAL', 'REQUIRED')
1054 AC_DEFUN(STEPMAKE_PYTHON, [
1055     AC_MSG_CHECKING([for python])
1056     python="python"
1057     found="no"
1058     for r in $PYTHON python python3 python3.3 python3.2 python3.1 python3.0 python2 python2.7 python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0; do
1059         exe=`STEPMAKE_GET_EXECUTABLE($r)`
1060         if ! $exe -V > /dev/null 2>&1 ; then
1061             continue
1062         fi
1063         ver=`STEPMAKE_GET_VERSION($exe)`
1064         num=`STEPMAKE_NUMERIC_VERSION($ver)`
1065         req=`STEPMAKE_NUMERIC_VERSION($2)`
1066         sup=`STEPMAKE_NUMERIC_VERSION($3)`
1067         if test -n "$2" && test "$num" -lt "$req"; then
1068             python=["$r >= $2 (installed: $ver)"]
1069             continue
1070         else
1071             if test -n "$3" && test "$num" -ge "$sup"; then
1072                 python=["$r < $3 (installed: $ver)"]
1073                 continue
1074             else
1075                 python=$r
1076                 found=$r
1077                 break
1078             fi
1079         fi
1080     done
1081     AC_MSG_RESULT([$found])
1082     if test "$found" != "no"; then
1083         AC_MSG_CHECKING([$python version])
1084         AC_MSG_RESULT([$ver])
1085         PYTHON=$found
1086     else
1087         STEPMAKE_ADD_ENTRY($1, $python)
1088     fi
1089     AC_PATH_PROG(PYTHON, $PYTHON)
1090     AC_SUBST(PYTHON)
1091 ])
1092
1093 # Check for python-config, between minimum ($2) and maximum version ($3).
1094 # If missing, add entry to missing-list ($1, one of 'OPTIONAL', 'REQUIRED')
1095 AC_DEFUN(STEPMAKE_PYTHON_DEVEL, [
1096     AC_ARG_WITH(python-include,
1097         [AS_HELP_STRING([--with-python-include=DIR],
1098                         [location of the python include dir])],[
1099         if test "$withval" = "yes" -o "$withval" = "no"; then
1100             AC_MSG_WARN(Usage: --with-python-include=includedir)
1101         else
1102             PYTHON_CFLAGS="-I${withval}"
1103         fi
1104     ])
1105     
1106     AC_ARG_WITH(python-lib,
1107         [AS_HELP_STRING([--with-python-lib=NAME],
1108                         [name of the python lib])],[
1109         if test "$withval" = "yes" -o "$withval" = "no"; then
1110             AC_MSG_WARN(Usage: --with-python-lib=name)
1111         else
1112             LDFLAGS="$LDFLAGS -l${withval}"
1113         fi
1114     ])
1115
1116     STEPMAKE_PYTHON($1, $2, $3)
1117     AC_CHECK_PROGS(PYTHON_CONFIG, `basename $PYTHON`-config, no)
1118
1119     if test -z "$PYTHON_CFLAGS" -a "$PYTHON_CONFIG" != "no"; then
1120         # Clean out junk: http://bugs.python.org/issue3290
1121         # Python headers may need some -f* flags, leave them in.
1122         # We want the sed commands to look like 's/-[WDOm][[:alnum:][:punct:]][[:alnum:][:punct:]]*//g' and 's/-arch [^[:space:]]*//g', but automake eats brackets.
1123          #PYTHON_CFLAGS=`$PYTHON_CONFIG --cflags | sed -e 's/-[[WDOm]][[[:alnum:][:punct:]]][[[:alnum:][:punct:]]]*//g' | sed -e 's/-arch @<:@^@<:@:space:@:>@@:>@*//g'`
1124          # The above sed BRE matches parts of legal options, stipping down part of that option, resulting in invalid gcc arguments. Gentoo Bug #415793
1125          # For instance, '-floop-stip-mime' becomes '-floop-strip', and '-fvect-cost-model' becomes '-fvect-cost'.
1126          # Tentative fix to require a non alphanumeric character before the initial hyphen of the BRE or the hyphen being the first character in the string.
1127          PYTHON_CFLAGS=`$PYTHON_CONFIG --cflags | sed -e 's/\(^\|[[^[:alnum:]]]\)-[[WDOm]][[[:alnum:][:punct:]]][[[:alnum:][:punct:]]]*//g' | sed -e 's/-arch @<:@^@<:@:space:@:>@@:>@*//g'`
1128         PYTHON_LDFLAGS=`$PYTHON_CONFIG --ldflags`
1129     fi
1130     
1131     if test -z "$PYTHON_CFLAGS" -a "$cross_compiling" = "no"; then
1132         changequote(<<, >>)#dnl
1133         # alternatively, for python >= 2.0
1134         # 'import sys, distutils.sysconfig; sys.stdout.write (distutils.sysconfig.get_python_inc ())'
1135         PYTHON_INCLUDE=`$PYTHON -c 'import sys; sys.stdout.write ("%s/include/python%s" % (sys.prefix, sys.version[:3]))'`
1136         PYTHON_CFLAGS="-I$PYTHON_INCLUDE"
1137         changequote([, ])#dnl
1138     fi
1139     
1140     if test -z "$PYTHON_HEADER"; then
1141         CPPFLAGS="$PYTHON_CFLAGS $CPPFLAGS"
1142         AC_CHECK_HEADERS([Python.h],[PYTHON_HEADER=yes])
1143     fi
1144     
1145     if test -z "$PYTHON_HEADER"; then
1146         warn="Python.h (python-devel, python-dev or libpython-dev package)"
1147         STEPMAKE_ADD_ENTRY($1, $warn)
1148     fi
1149     AC_SUBST(PYTHON_CFLAGS)
1150     AC_SUBST(PYTHON_LDFLAGS)
1151 ])
1152
1153
1154
1155 AC_DEFUN(STEPMAKE_STL_DATA_METHOD, [
1156     AC_CACHE_CHECK([for stl.data () method],
1157         [stepmake_cv_stl_data_method],
1158         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1159 #include <vector>
1160 using namespace std;
1161 vector <int> v;
1162 void *p = v.data ();
1163 ]])],
1164             [stepmake_cv_stl_data_method=yes],
1165             [stepmake_cv_stl_data_method=no]))
1166     if test $stepmake_cv_stl_data_method = yes; then
1167         AC_DEFINE(HAVE_STL_DATA_METHOD, 1, [define if stl classes have data () method])
1168     fi
1169 ])
1170
1171
1172 AC_DEFUN(STEPMAKE_TEXMF_DIRS, [
1173     STEPMAKE_PROGS(KPSEWHICH, kpsewhich, $1)
1174
1175     AC_MSG_CHECKING(for metapost required files)
1176     if test "$MFPLAIN_MP" = ""; then
1177         MFPLAIN_MP=`kpsewhich -format=mp mfplain`
1178     fi
1179     if test "$MFPLAIN_MP" = ""; then
1180         AC_MSG_RESULT(no)
1181         STEPMAKE_ADD_ENTRY($1,['metapost CTAN package (texlive-metapost)'])
1182     else
1183         AC_MSG_RESULT(yes)
1184     fi
1185 ])
1186
1187 AC_DEFUN(STEPMAKE_TEXMF, [
1188     STEPMAKE_PROGS(METAFONT, mf-nowin mf mfw mfont, $1)
1189     STEPMAKE_PROGS(METAPOST, mpost, $1)
1190     if test "$METAPOST" != ""; then
1191         ver=`STEPMAKE_GET_VERSION($METAPOST)`
1192         num=`STEPMAKE_NUMERIC_VERSION($ver)`
1193         # Avoid buggy metapost versions: 1.600 <= x < 1.803
1194         if test "$num" -ge "1600000" -a "$num" -lt "1803000"; then
1195             STEPMAKE_ADD_ENTRY($1, ["mpost (due to a bug in metapost, versions 1.600 <= x < 1.803 are not supported; installed: $ver)"])
1196         fi
1197     fi
1198
1199     AC_MSG_CHECKING(for working metafont mode)
1200     modelist='ljfour lj4 lj3 lj2 ljet laserjet'
1201     for MFMODE in $modelist; do
1202         $METAFONT -progname=mf "\mode:=$MFMODE; mode_setup; end." > /dev/null 2>&1
1203         if test -f mfput.tfm; then
1204             break;
1205         fi
1206     done
1207     AC_MSG_RESULT($MFMODE)
1208
1209     rm -f mfput.*
1210
1211     AC_SUBST(MFMODE)
1212 ])
1213
1214
1215 AC_DEFUN(STEPMAKE_WARN, [
1216     AC_MSG_WARN($1)
1217     warn_b=yes
1218 ])
1219
1220
1221 dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not)
1222 dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page
1223 dnl also defines GSTUFF_PKG_ERRORS on error
1224 AC_DEFUN(PKG_CHECK_MODULES, [
1225   succeeded=no
1226
1227   if test -z "$PKG_CONFIG"; then
1228     AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
1229   fi
1230
1231   if test "$PKG_CONFIG" = "no" ; then
1232      echo "*** The pkg-config script could not be found. Make sure it is"
1233      echo "*** in your path, or set the PKG_CONFIG environment variable"
1234      echo "*** to the full path to pkg-config."
1235      echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
1236   else
1237      PKG_CONFIG_MIN_VERSION=0.9.0
1238      if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
1239         AC_MSG_CHECKING(for $2)
1240
1241         if $PKG_CONFIG --exists "$2" ; then
1242             AC_MSG_RESULT(yes)
1243             succeeded=yes
1244
1245             AC_MSG_CHECKING($1_CFLAGS)
1246             $1_CFLAGS=`$PKG_CONFIG --cflags "$2"`
1247             AC_MSG_RESULT($$1_CFLAGS)
1248
1249             AC_MSG_CHECKING($1_LIBS)
1250             $1_LIBS=`$PKG_CONFIG --libs "$2"`
1251             AC_MSG_RESULT($$1_LIBS)
1252         else
1253             $1_CFLAGS=""
1254             $1_LIBS=""
1255             ## If we have a custom action on failure, don't print errors, but 
1256             ## do set a variable so people can do so.
1257             $1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
1258             ifelse([$4], ,echo $$1_PKG_ERRORS,)
1259         fi
1260
1261         AC_SUBST($1_CFLAGS)
1262         AC_SUBST($1_LIBS)
1263      fi
1264   fi
1265
1266   if test $succeeded = yes; then
1267      ifelse([$3], , :, [$3])
1268   else
1269      ifelse([$4], , AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.]), [$4])
1270   fi
1271 ])
1272
1273 AC_DEFUN(STEPMAKE_FREETYPE2, [
1274     PKG_CHECK_MODULES(FREETYPE2, $1 >= $3, have_freetype2=yes, true)
1275     if test "$have_freetype2" = yes; then
1276         AC_DEFINE(HAVE_FREETYPE2)
1277         save_CPPFLAGS="$CPPFLAGS"
1278         save_LIBS="$LIBS"
1279         CPPFLAGS="$FREETYPE2_CFLAGS $CPPFLAGS"
1280         LIBS="$FREETYPE2_LIBS $LIBS"
1281         AC_SUBST(FREETYPE2_CFLAGS)
1282         AC_SUBST(FREETYPE2_LIBS)
1283         CPPFLAGS="$save_CPPFLAGS"
1284         LIBS="$save_LIBS"
1285     else
1286         # UGR
1287         #r="lib$1-dev or $1-devel"
1288         r="libfreetype6-dev or freetype?-devel"
1289         ver="`pkg-config --modversion $1`"
1290         STEPMAKE_ADD_ENTRY($2, ["$r >= $3 (installed: $ver)"])
1291     fi
1292 ])
1293
1294 AC_DEFUN(STEPMAKE_PANGO, [
1295     PKG_CHECK_MODULES(PANGO, $1 >= $3, have_pango16=yes, true)
1296     if test "$have_pango16" = yes ; then
1297         AC_DEFINE(HAVE_PANGO16)
1298         # Do not pollute user-CPPFLAGS with configure-CPPFLAGS
1299         save_CPPFLAGS="$CPPFLAGS"
1300         save_LIBS="$LIBS"
1301         CPPFLAGS="$PANGO_CFLAGS $CPPFLAGS"
1302         LIBS="$PANGO_LIBS $LIBS"
1303         AC_CHECK_HEADERS([pango/pangofc-fontmap.h])
1304         AC_CHECK_FUNCS([pango_fc_font_map_add_decoder_find_func])
1305         AC_SUBST(PANGO_CFLAGS)
1306         AC_SUBST(PANGO_LIBS)
1307         CPPFLAGS="$save_CPPFLAGS"
1308         LIBS="$save_LIBS"
1309     else
1310         # UGR
1311         #r="lib$1-dev or $1-devel"
1312         r="libpango1.0-dev or pango1.0-devel"
1313         ver="`pkg-config --modversion $1`"
1314         STEPMAKE_ADD_ENTRY($2, ["$r >= $3 (installed: $ver)"])
1315     fi
1316 ])
1317
1318 AC_DEFUN(STEPMAKE_PANGO_FT2, [
1319     PKG_CHECK_MODULES(PANGO_FT2, $1 >= $3, have_pangoft2=yes, true)
1320     if test "$have_pangoft2" = yes ; then
1321         AC_DEFINE(HAVE_PANGO16)
1322         AC_DEFINE(HAVE_PANGO_FT2)
1323         # Do not pollute user-CPPFLAGS with configure-CPPFLAGS
1324         save_CPPFLAGS="$CPPFLAGS"
1325         save_LIBS="$LIBS"
1326         CPPFLAGS="$CPPFLAGS $PANGO_FT2_CFLAGS"
1327         LIBS="$PANGO_FT2_LIBS $LIBS"
1328         AC_CHECK_HEADERS([pango/pangoft2.h])
1329         AC_CHECK_FUNCS([pango_ft2_font_map_create_context])
1330         AC_SUBST(PANGO_FT2_CFLAGS)
1331         AC_SUBST(PANGO_FT2_LIBS)
1332         CPPFLAGS="$save_CPPFLAGS"
1333         LIBS="$save_LIBS"
1334     else
1335         # UGR
1336         #r="lib$1-dev or $1-devel"e
1337         r="libpango1.0-dev or pango?-devel"
1338         ver="`pkg-config --modversion $1`"
1339         STEPMAKE_ADD_ENTRY($2, ["$r >= $3 (installed: $ver)"])
1340     fi
1341 ])
1342
1343 AC_DEFUN(STEPMAKE_FONTCONFIG, [
1344     PKG_CHECK_MODULES(FONTCONFIG, $1 >= $3, have_fontconfig=yes, true)
1345     if test "$have_fontconfig" = yes ; then
1346         AC_DEFINE(HAVE_FONTCONFIG)
1347         # Do not pollute user-CPPFLAGS with configure-CPPFLAGS
1348         save_CPPFLAGS="$CPPFLAGS"
1349         save_LIBS="$LIBS"
1350         CPPFLAGS="$FONTCONFIG_CFLAGS $CPPFLAGS"
1351         LIBS="$FONTCONFIG_LIBS $LIBS"
1352         AC_SUBST(FONTCONFIG_CFLAGS)
1353         AC_SUBST(FONTCONFIG_LIBS)
1354         CPPFLAGS="$save_CPPFLAGS"
1355         LIBS="$save_LIBS"
1356     else
1357         r="lib$1-dev or $1-devel"
1358         ver="`pkg-config --modversion $1`"
1359         STEPMAKE_ADD_ENTRY($2, ["$r >= $3 (installed: $ver)"])
1360     fi
1361 ])
1362
1363 AC_DEFUN(STEPMAKE_WINDOWS, [
1364     AC_CYGWIN
1365     AC_MINGW32
1366
1367     if test "$CYGWIN" = "yes"; then
1368         LN_S='cp -r' # Cygwin symbolic links do not work for native apps.
1369         program_suffix=.exe
1370         INSTALL="\$(SHELL) \$(stepdir)/../bin/install-dot-exe.sh -c"
1371     elif test "$MINGW32" = "yes"; then
1372         LN='cp -r'
1373         LN_S='cp -r'
1374         program_suffix=.exe
1375         INSTALL="\$(SHELL) \$(stepdir)/../bin/install-dot-exe.sh -c"
1376         PATHSEP=';'
1377     fi
1378
1379     AC_SUBST(LN)
1380     AC_SUBST(LN_S)
1381     AC_DEFINE_UNQUOTED(DIRSEP, ['${DIRSEP}'])
1382     AC_DEFINE_UNQUOTED(PATHSEP, ['${PATHSEP}'])
1383     AC_SUBST(DIRSEP)
1384     AC_SUBST(PATHSEP)
1385     AC_SUBST(program_suffix)
1386
1387     AC_MSG_CHECKING([for some flavor of Windows])
1388     if test "$CYGWIN$MINGW32" = "nono"; then
1389         PLATFORM_WINDOWS=no
1390     else
1391         PLATFORM_WINDOWS=yes
1392     fi
1393     AC_MSG_RESULT([$PLATFORM_WINDOWS])
1394     AC_SUBST(PLATFORM_WINDOWS)
1395     STEPMAKE_PROGS(WINDRES, $target-windres windres, x)
1396     AC_SUBST(WINDRES)
1397 ])