]> git.donarmstrong.com Git - lilypond.git/blob - aclocal.m4
Add '-dcrop' option to ps and svg backends
[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 \
664       guile2-config   guile-2-config   guile-config-2   \
665       guile2.2-config guile-2.2-config guile-config-2.2 \
666       guile2.0-config guile-2.0-config guile-config-2.0 \
667       guile1-config   guile-1-config   guile-config-1   \
668       guile1.9-config guile-1.9-config guile-config-1.9 \
669       guile1.8-config guile-1.8-config guile-config-1.8; \
670       do
671         exe=`STEPMAKE_GET_EXECUTABLE($r)`
672         if ! $exe --version > /dev/null 2>&1 ; then
673             continue
674         fi
675         ver=`STEPMAKE_GET_VERSION($exe)`
676         num=`STEPMAKE_NUMERIC_VERSION($ver)`
677         req=`STEPMAKE_NUMERIC_VERSION($2)`
678         sup=`STEPMAKE_NUMERIC_VERSION($3)`
679         if test -n "$2" -a "$num" -lt "$req"; then
680             guile_config=["$r >= $2 (installed: $ver)"]
681             continue
682         else
683             if test -n "$3" -a "$num" -ge "$sup"; then
684                 guile_config=["$r < $3 (installed: $ver)"]
685                 continue
686             else
687                 guile_config=$r
688                 found=$r
689                 break
690             fi
691         fi
692     done
693     AC_MSG_RESULT([$found])
694     if test "$found" != "no"; then
695         AC_MSG_CHECKING([$guile_config version])
696         AC_MSG_RESULT([$ver])
697         GUILE_CONFIG=$found
698     else
699         STEPMAKE_ADD_ENTRY($1, "$guile_config (guile-devel, guile-dev or libguile-dev package)")
700     fi
701
702     AC_SUBST(GUILE_CONFIG)
703     
704     guile_version="$ver"
705     changequote(<<, >>)#dnl
706     GUILE_MAJOR_VERSION=`expr $guile_version : '\([0-9]*\)'`
707     GUILE_MINOR_VERSION=`expr $guile_version : '[0-9]*\.\([0-9]*\)'`
708     GUILE_PATCH_LEVEL=`expr $guile_version : '[0-9]*\.[0-9]*\.\([0-9]*\)'`
709     changequote([, ])#dnl
710     STEPMAKE_GUILE_FLAGS
711     save_CPPFLAGS="$CPPFLAGS"
712     save_LIBS="$LIBS"
713     CPPFLAGS="$GUILE_CFLAGS $CPPFLAGS"
714     LIBS="$GUILE_LDFLAGS $LIBS"
715     AC_CHECK_HEADERS([libguile.h])
716     AC_CHECK_LIB(guile, scm_boot_guile)
717     AC_CHECK_FUNCS(scm_boot_guile,,libguile_b=no)
718     if test "$libguile_b" = "no"; then
719             warn='libguile (libguile-dev, guile-devel or guile-dev
720    package).'
721             STEPMAKE_ADD_ENTRY(REQUIRED, $warn)
722     fi
723     CPPFLAGS="$save_CPPFLAGS"
724     LIBS="$save_LIBS"
725     AC_DEFINE_UNQUOTED(GUILE_MAJOR_VERSION, $GUILE_MAJOR_VERSION)
726     AC_DEFINE_UNQUOTED(GUILE_MINOR_VERSION, $GUILE_MINOR_VERSION)
727     AC_DEFINE_UNQUOTED(GUILE_PATCH_LEVEL, $GUILE_PATCH_LEVEL)
728 ])
729
730
731 AC_DEFUN(STEPMAKE_DLOPEN, [
732     AC_CHECK_LIB(dl, dlopen)
733     AC_CHECK_FUNCS(dlopen)
734 ])
735
736 AC_DEFUN(STEPMAKE_HAS_CLANG, [
737     AC_EGREP_CPP(yes,
738       [#ifdef __clang__
739        yes
740        #endif
741       ], HAS_CLANG=yes, HAS_CLANG=no)
742 ])
743
744 AC_DEFUN(STEPMAKE_GXX_OR_CLANG, [
745     STEPMAKE_HAS_CLANG()
746     if test "$HAS_CLANG" = "no"; then
747         if test "$GXX" = "yes"; then
748             STEPMAKE_CHECK_VERSION(CXX, $1, $2)
749         else
750             warn="$CXX (Please install *GNU* c++)"
751             STEPMAKE_ADD_ENTRY($1, $warn)
752         fi
753     fi
754     # no else, we're fine with any clang
755 ])
756
757
758 AC_DEFUN(STEPMAKE_INIT, [
759
760     . $srcdir/VERSION
761     FULL_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$PATCH_LEVEL
762     MICRO_VERSION=$PATCH_LEVEL
763     TOPLEVEL_VERSION=$FULL_VERSION
764     if test x$MY_PATCH_LEVEL != x; then
765         FULL_VERSION=$FULL_VERSION.$MY_PATCH_LEVEL
766     fi
767     VERSION=$FULL_VERSION
768     export MAJOR_VERSION MINOR_VERSION PATCH_LEVEL
769     # urg: don't "fix" this: irix doesn't know about [:lower:] and [:upper:]
770     changequote(<<, >>)#dnl
771     PACKAGE=`echo $PACKAGE_NAME | tr '[a-z]' '[A-Z]'`
772     package=`echo $PACKAGE_NAME | tr '[A-Z]' '[a-z]'`
773     changequote([, ])#dnl
774
775     # No versioning on directory names of sub-packages 
776     # urg, urg
777     stepmake=${datadir}/stepmake
778     presome=${prefix}
779     if test "$prefix" = "NONE"; then
780             presome=${ac_default_prefix}
781     fi
782     stepmake=`echo ${stepmake} | sed "s!\\\${prefix}!$presome!"`
783
784     # urg, how is this supposed to work?
785     if test "$program_prefix" = "NONE"; then
786           program_prefix=
787     fi
788     if test "$program_suffix" = "NONE"; then
789           program_suffix=
790     fi
791
792     AC_MSG_CHECKING(Package)
793     if test "$PACKAGE" = "STEPMAKE"; then
794         AC_MSG_RESULT(Stepmake package!)
795
796         AC_MSG_CHECKING(builddir)
797
798         ugh_ugh_autoconf250_builddir="`pwd`"
799         
800         if test "$srcdir" = "."; then
801             srcdir_build=yes
802         else
803             srcdir_build=no
804             package_builddir="`dirname $ugh_ugh_autoconf250_builddir`"
805             package_srcdir="`dirname  $srcdir`"
806         fi
807         AC_MSG_RESULT($ugh_ugh_autoconf250_builddir)
808
809         (cd stepmake 2>/dev/null || mkdir stepmake)
810         (cd stepmake; rm -f bin; ln -s ../$srcdir/bin .)
811         stepmake=stepmake
812     else
813         AC_MSG_RESULT($PACKAGE)
814
815         AC_MSG_CHECKING(builddir)
816         ugh_ugh_autoconf250_builddir="`pwd`"
817
818         here_dir=$(cd . && pwd)
819         full_src_dir=$(cd $srcdir && pwd)
820
821         if test "$full_src_dir" = "$here_dir"; then
822             srcdir_build=yes
823         else
824             srcdir_build=no
825         fi
826         AC_MSG_RESULT($ugh_ugh_autoconf250_builddir)
827
828         AC_MSG_CHECKING(for stepmake)
829         # Check for installed stepmake
830         if test -d $stepmake; then
831             AC_MSG_RESULT($stepmake)
832         else
833             stepmake="`cd $srcdir/stepmake; pwd`"
834             AC_MSG_RESULT([$srcdir/stepmake  ($datadir/stepmake not found)])
835         fi
836     fi
837
838     AC_SUBST(ugh_ugh_autoconf250_builddir)
839
840     # Use absolute directory for non-srcdir builds, so that build
841     # dir can be moved.
842     if test "$srcdir_build" = "no" ;  then 
843         srcdir="`cd $srcdir; pwd`"
844     fi
845     
846     AC_SUBST(srcdir)
847     AC_SUBST(stepmake)
848     AC_SUBST(package)
849     AC_SUBST(PACKAGE)
850     AC_SUBST(PACKAGE_NAME)
851     AC_SUBST(VERSION)
852     AC_SUBST(MAJOR_VERSION)
853     AC_SUBST(MINOR_VERSION)
854     AC_SUBST(MICRO_VERSION)
855
856     # stepmake nonstandard names
857     AC_SUBST(PATCH_LEVEL)
858     AC_SUBST(TOPLEVEL_VERSION)
859     
860     # We don't need the upper case variant,
861     # so stick to macros are uppercase convention.
862     # AC_DEFINE_UNQUOTED(package, ["${package}"])
863     # AC_DEFINE_UNQUOTED(PACKAGE, ["${PACKAGE}"])
864     AC_DEFINE_UNQUOTED(PACKAGE, ["${package}"])
865     AC_DEFINE_UNQUOTED(PACKAGE_NAME, ["${PACKAGE_NAME}"])
866     AC_DEFINE_UNQUOTED(TOPLEVEL_VERSION, ["${FULL_VERSION}"])
867
868     if test -z "$package_depth"; then
869         package_depth="."
870     else
871         package_depth="../$package_depth"
872     fi
873     export package_depth
874     AC_SUBST(package_depth)
875
876     AUTOGENERATE="This file was automatically generated by configure"
877     AC_SUBST(AUTOGENERATE)
878
879     CONFIGSUFFIX=
880     AC_ARG_ENABLE(config,
881     [AS_HELP_STRING([--enable-config=CONF],
882                     [put settings in config-CONF.make and config-CONF.h;
883                     do `make conf=CONF' to get output in ./out-CONF])],
884     [CONFIGURATION=$enableval])
885
886     ##'`#
887
888     test -n "$CONFIGURATION" && CONFIGSUFFIX="-$CONFIGURATION"
889     CONFIGFILE=config$CONFIGSUFFIX
890     AC_SUBST(CONFIGSUFFIX)
891      
892     AC_CANONICAL_HOST
893     STEPMAKE_PROGS(MAKE, gmake make, REQUIRED)
894     STEPMAKE_PROGS(FIND, find, REQUIRED)
895
896     STEPMAKE_PROGS(TAR, tar, REQUIRED)
897
898     if test "$(echo 2)" != "2" ||
899         test "x`uname`" = "xHP-UX"; then
900         AC_PATH_PROG(KSH, ksh, /bin/ksh)
901         AC_PATH_PROG(BASH, bash, $KSH)
902         STEPMAKE_WARN(avoiding buggy /bin/sh)
903         AC_PATH_PROG(SHELL, bash, $KSH)
904     else
905         SHELL=/bin/sh
906         AC_PATH_PROG(BASH, bash, $SHELL)
907     fi
908     AC_SUBST(SHELL)
909
910     STEPMAKE_PYTHON(REQUIRED, 1.5, 3.0)
911
912     if expr "$MAKE" : '.*\(echo\)' >/dev/null; then
913         $MAKE -v 2> /dev/null | grep GNU > /dev/null
914         if test "$?" = 1; then
915             warn='make (Please install *GNU* make)'
916             # STEPMAKE_WARN($warn)
917             STEPMAKE_ADD_ENTRY(REQUIRED, $warn)
918         fi
919     fi
920
921     ROOTSEP=':'
922     DIRSEP='/'
923     PATHSEP=':'
924     LN=ln
925     LN_S='ln -s'
926     ZIP="zip -r -9"
927
928     AC_SUBST(program_prefix)
929     AC_SUBST(program_suffix)
930     AC_SUBST(ZIP)
931     AC_SUBST(LN)
932     AC_SUBST(LN_S)
933     AC_DEFINE_UNQUOTED(DIRSEP, ['${DIRSEP}'])
934     AC_DEFINE_UNQUOTED(PATHSEP, ['${PATHSEP}'])
935     AC_SUBST(DIRSEP)
936     AC_SUBST(PATHSEP)
937     AC_SUBST(ROOTSEP)
938   
939     STEPMAKE_DATADIR
940     STEPMAKE_LIBDIR
941 ])
942
943     
944 AC_DEFUN(STEPMAKE_LIB, [
945     STEPMAKE_PROGS(AR, ar, $1)
946     AC_PROG_RANLIB
947     STEPMAKE_OPTIONAL_REQUIRED(RANLIB, ranlib, $1)
948 ])
949
950
951 AC_DEFUN(STEPMAKE_LIBTOOL, [
952     # libtool.info ...
953     # **Never** try to set library version numbers so that they correspond
954     # to the release number of your package.  This is an abuse that only
955     # fosters misunderstanding of the purpose of library versions.
956
957     REVISION=$PATCH_LEVEL
958     # CURRENT=$MINOR_VERSION
959     CURRENT=`expr $MINOR_VERSION + 1`
960     # AGE=`expr $MAJOR_VERSION + 1`
961     AGE=$MAJOR_VERSION
962     AC_SUBST(CURRENT)
963     AC_SUBST(REVISION)
964     AC_SUBST(AGE)
965 ])
966
967
968 AC_DEFUN(STEPMAKE_LOCALE, [
969     lang=English
970     ALL_LINGUAS="en nl"
971
972     # with/enable ??
973     AC_ARG_WITH(localedir,
974     [AS_HELP_STRING([--with-localedir=DIR],
975                     [location of locales.  Default: PREFIX/share/locale])],
976     localedir=$with_localedir,
977     localedir='${prefix}/share/locale')
978
979     AC_ARG_WITH(lang,
980     [AS_HELP_STRING([--with-lang=LANG],
981                     [use LANG as language to emit messages])],
982     language=$with_lang,
983     language=English)
984
985     AC_MSG_CHECKING(language)    
986     case "$language" in
987       En* | en* | Am* | am* | US* | us*)
988             lang=English;;
989       NL | nl | Du* | du* | Ned* | ned*)
990             lang=Dutch;;
991       "")
992             lang=English;;
993       *)
994             lang=unknown;;
995     esac
996     AC_MSG_RESULT($lang)
997
998     if test "$lang" = "unknown" ; then
999         STEPMAKE_WARN($language not supported; available are: $ALL_LINGUAS)
1000     fi
1001
1002 ])
1003
1004
1005 AC_DEFUN(STEPMAKE_MAKEINFO, [
1006     STEPMAKE_PROGS(MAKEINFO, makeinfo, $1)
1007 ])
1008
1009
1010 AC_DEFUN(STEPMAKE_MAN, [
1011     STEPMAKE_PROGS(GROFF, groff ditroff, $1)
1012     AC_SUBST(GROFF)
1013     STEPMAKE_PROGS(TROFF, troff, $1)
1014     AC_SUBST(TROFF)
1015     STEPMAKE_PROGS(TBL, tbl, $1)
1016     AC_SUBST(TBL)
1017 ])
1018
1019
1020 AC_DEFUN(STEPMAKE_MSGFMT, [
1021     STEPMAKE_PROGS(MSGFMT, msgfmt, $1)
1022 ])
1023
1024
1025 # Check for program ($2), set full path result to ($1).
1026 # If missing, add entry to missing-list ($3, one of 'OPTIONAL', 'REQUIRED')
1027 AC_DEFUN(STEPMAKE_PATH_PROG, [
1028     AC_CHECK_PROGS($1, $2, no)
1029     STEPMAKE_OPTIONAL_REQUIRED($1, $2, $3)
1030     if test $? -eq 0; then
1031         AC_PATH_PROGS($1, $2)
1032         if test -n "$4"; then
1033             STEPMAKE_CHECK_VERSION($1, $3, $4)
1034         fi
1035     fi
1036 ])
1037
1038
1039 # Check for program in set of names ($2), set result to ($1) .
1040 # If missing, add entry to missing-list ($3, one of 'OPTIONAL', 'REQUIRED')
1041 # If exists, and a minimal version ($4) is required
1042 AC_DEFUN(STEPMAKE_PROGS, [
1043     AC_CHECK_PROGS($1, $2, no)
1044     STEPMAKE_OPTIONAL_REQUIRED($1, $2, $3)
1045     if test $? -eq 0 -a -n "$4"; then
1046         STEPMAKE_CHECK_VERSION($1, $3, $4)
1047     fi
1048 ])
1049
1050
1051 AC_DEFUN(STEPMAKE_PERL, [
1052     STEPMAKE_PATH_PROG(PERL, perl, $1)
1053 ])
1054
1055
1056 # Check for python, between minimum ($2) and maximum version ($3).
1057 # If missing, add entry to missing-list ($1, one of 'OPTIONAL', 'REQUIRED')
1058 AC_DEFUN(STEPMAKE_PYTHON, [
1059     AC_MSG_CHECKING([for python])
1060     python="python"
1061     found="no"
1062     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
1063         exe=`STEPMAKE_GET_EXECUTABLE($r)`
1064         if ! $exe -V > /dev/null 2>&1 ; then
1065             continue
1066         fi
1067         ver=`STEPMAKE_GET_VERSION($exe)`
1068         num=`STEPMAKE_NUMERIC_VERSION($ver)`
1069         req=`STEPMAKE_NUMERIC_VERSION($2)`
1070         sup=`STEPMAKE_NUMERIC_VERSION($3)`
1071         if test -n "$2" && test "$num" -lt "$req"; then
1072             python=["$r >= $2 (installed: $ver)"]
1073             continue
1074         else
1075             if test -n "$3" && test "$num" -ge "$sup"; then
1076                 python=["$r < $3 (installed: $ver)"]
1077                 continue
1078             else
1079                 python=$r
1080                 found=$r
1081                 break
1082             fi
1083         fi
1084     done
1085     AC_MSG_RESULT([$found])
1086     if test "$found" != "no"; then
1087         AC_MSG_CHECKING([$python version])
1088         AC_MSG_RESULT([$ver])
1089         PYTHON=$found
1090     else
1091         STEPMAKE_ADD_ENTRY($1, $python)
1092     fi
1093     AC_PATH_PROG(PYTHON, $PYTHON)
1094     AC_SUBST(PYTHON)
1095 ])
1096
1097 # Check for python-config, between minimum ($2) and maximum version ($3).
1098 # If missing, add entry to missing-list ($1, one of 'OPTIONAL', 'REQUIRED')
1099 AC_DEFUN(STEPMAKE_PYTHON_DEVEL, [
1100     AC_ARG_WITH(python-include,
1101         [AS_HELP_STRING([--with-python-include=DIR],
1102                         [location of the python include dir])],[
1103         if test "$withval" = "yes" -o "$withval" = "no"; then
1104             AC_MSG_WARN(Usage: --with-python-include=includedir)
1105         else
1106             PYTHON_CFLAGS="-I${withval}"
1107         fi
1108     ])
1109     
1110     AC_ARG_WITH(python-lib,
1111         [AS_HELP_STRING([--with-python-lib=NAME],
1112                         [name of the python lib])],[
1113         if test "$withval" = "yes" -o "$withval" = "no"; then
1114             AC_MSG_WARN(Usage: --with-python-lib=name)
1115         else
1116             LDFLAGS="$LDFLAGS -l${withval}"
1117         fi
1118     ])
1119
1120     STEPMAKE_PYTHON($1, $2, $3)
1121     AC_CHECK_PROGS(PYTHON_CONFIG, `basename $PYTHON`-config, no)
1122
1123     if test -z "$PYTHON_CFLAGS" -a "$PYTHON_CONFIG" != "no"; then
1124         # Clean out junk: http://bugs.python.org/issue3290
1125         # Python headers may need some -f* flags, leave them in.
1126         # We want the sed commands to look like 's/-[WDOm][[:alnum:][:punct:]][[:alnum:][:punct:]]*//g' and 's/-arch [^[:space:]]*//g', but automake eats brackets.
1127          #PYTHON_CFLAGS=`$PYTHON_CONFIG --cflags | sed -e 's/-[[WDOm]][[[:alnum:][:punct:]]][[[:alnum:][:punct:]]]*//g' | sed -e 's/-arch @<:@^@<:@:space:@:>@@:>@*//g'`
1128          # The above sed BRE matches parts of legal options, stipping down part of that option, resulting in invalid gcc arguments. Gentoo Bug #415793
1129          # For instance, '-floop-stip-mime' becomes '-floop-strip', and '-fvect-cost-model' becomes '-fvect-cost'.
1130          # 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.
1131          PYTHON_CFLAGS=`$PYTHON_CONFIG --cflags | sed -e 's/\(^\|[[^[:alnum:]]]\)-[[WDOm]][[[:alnum:][:punct:]]][[[:alnum:][:punct:]]]*//g' | sed -e 's/-arch @<:@^@<:@:space:@:>@@:>@*//g'`
1132         PYTHON_LDFLAGS=`$PYTHON_CONFIG --ldflags`
1133     fi
1134     
1135     if test -z "$PYTHON_CFLAGS" -a "$cross_compiling" = "no"; then
1136         changequote(<<, >>)#dnl
1137         # alternatively, for python >= 2.0
1138         # 'import sys, distutils.sysconfig; sys.stdout.write (distutils.sysconfig.get_python_inc ())'
1139         PYTHON_INCLUDE=`$PYTHON -c 'import sys; sys.stdout.write ("%s/include/python%s" % (sys.prefix, sys.version[:3]))'`
1140         PYTHON_CFLAGS="-I$PYTHON_INCLUDE"
1141         changequote([, ])#dnl
1142     fi
1143     
1144     if test -z "$PYTHON_HEADER"; then
1145         CPPFLAGS="$PYTHON_CFLAGS $CPPFLAGS"
1146         AC_CHECK_HEADERS([Python.h],[PYTHON_HEADER=yes])
1147     fi
1148     
1149     if test -z "$PYTHON_HEADER"; then
1150         warn="Python.h (python-devel, python-dev or libpython-dev package)"
1151         STEPMAKE_ADD_ENTRY($1, $warn)
1152     fi
1153     AC_SUBST(PYTHON_CFLAGS)
1154     AC_SUBST(PYTHON_LDFLAGS)
1155 ])
1156
1157
1158
1159 AC_DEFUN(STEPMAKE_STL_DATA_METHOD, [
1160     AC_CACHE_CHECK([for stl.data () method],
1161         [stepmake_cv_stl_data_method],
1162         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1163 #include <vector>
1164 using namespace std;
1165 vector <int> v;
1166 void *p = v.data ();
1167 ]])],
1168             [stepmake_cv_stl_data_method=yes],
1169             [stepmake_cv_stl_data_method=no]))
1170     if test $stepmake_cv_stl_data_method = yes; then
1171         AC_DEFINE(HAVE_STL_DATA_METHOD, 1, [define if stl classes have data () method])
1172     fi
1173 ])
1174
1175
1176 AC_DEFUN(STEPMAKE_TEXMF_DIRS, [
1177     STEPMAKE_PROGS(KPSEWHICH, kpsewhich, $1)
1178
1179     AC_MSG_CHECKING(for metapost required files)
1180     if test "$MFPLAIN_MP" = ""; then
1181         MFPLAIN_MP=`kpsewhich -format=mp mfplain`
1182     fi
1183     if test "$MFPLAIN_MP" = ""; then
1184         AC_MSG_RESULT(no)
1185         STEPMAKE_ADD_ENTRY($1,['metapost CTAN package (texlive-metapost)'])
1186     else
1187         AC_MSG_RESULT(yes)
1188     fi
1189 ])
1190
1191 AC_DEFUN(STEPMAKE_TEXMF, [
1192     STEPMAKE_PROGS(METAFONT, mf-nowin mf mfw mfont, $1)
1193     STEPMAKE_PROGS(METAPOST, mpost, $1)
1194     if test "$METAPOST" != ""; then
1195         ver=`STEPMAKE_GET_VERSION($METAPOST)`
1196         num=`STEPMAKE_NUMERIC_VERSION($ver)`
1197         # Avoid buggy metapost versions: 1.600 <= x < 1.803
1198         if test "$num" -ge "1600000" -a "$num" -lt "1803000"; then
1199             STEPMAKE_ADD_ENTRY($1, ["mpost (due to a bug in metapost, versions 1.600 <= x < 1.803 are not supported; installed: $ver)"])
1200         fi
1201     fi
1202
1203     AC_MSG_CHECKING(for working metafont mode)
1204     modelist='ljfour lj4 lj3 lj2 ljet laserjet'
1205     for MFMODE in $modelist; do
1206         $METAFONT -progname=mf "\mode:=$MFMODE; mode_setup; end." > /dev/null 2>&1
1207         if test -f mfput.tfm; then
1208             break;
1209         fi
1210     done
1211     AC_MSG_RESULT($MFMODE)
1212
1213     rm -f mfput.*
1214
1215     AC_SUBST(MFMODE)
1216 ])
1217
1218
1219 AC_DEFUN(STEPMAKE_WARN, [
1220     AC_MSG_WARN($1)
1221     warn_b=yes
1222 ])
1223
1224
1225 dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not)
1226 dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page
1227 dnl also defines GSTUFF_PKG_ERRORS on error
1228 AC_DEFUN(PKG_CHECK_MODULES, [
1229   succeeded=no
1230
1231   if test -z "$PKG_CONFIG"; then
1232     AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
1233   fi
1234
1235   if test "$PKG_CONFIG" = "no" ; then
1236      echo "*** The pkg-config script could not be found. Make sure it is"
1237      echo "*** in your path, or set the PKG_CONFIG environment variable"
1238      echo "*** to the full path to pkg-config."
1239      echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
1240   else
1241      PKG_CONFIG_MIN_VERSION=0.9.0
1242      if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
1243         AC_MSG_CHECKING(for $2)
1244
1245         if $PKG_CONFIG --exists "$2" ; then
1246             AC_MSG_RESULT(yes)
1247             succeeded=yes
1248
1249             AC_MSG_CHECKING($1_CFLAGS)
1250             $1_CFLAGS=`$PKG_CONFIG --cflags "$2"`
1251             AC_MSG_RESULT($$1_CFLAGS)
1252
1253             AC_MSG_CHECKING($1_LIBS)
1254             $1_LIBS=`$PKG_CONFIG --libs "$2"`
1255             AC_MSG_RESULT($$1_LIBS)
1256         else
1257             $1_CFLAGS=""
1258             $1_LIBS=""
1259             ## If we have a custom action on failure, don't print errors, but 
1260             ## do set a variable so people can do so.
1261             $1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
1262             ifelse([$4], ,echo $$1_PKG_ERRORS,)
1263         fi
1264
1265         AC_SUBST($1_CFLAGS)
1266         AC_SUBST($1_LIBS)
1267      fi
1268   fi
1269
1270   if test $succeeded = yes; then
1271      ifelse([$3], , :, [$3])
1272   else
1273      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])
1274   fi
1275 ])
1276
1277 AC_DEFUN(STEPMAKE_FREETYPE2, [
1278     PKG_CHECK_MODULES(FREETYPE2, $1 >= $3, have_freetype2=yes, true)
1279     if test "$have_freetype2" = yes; then
1280         AC_DEFINE(HAVE_FREETYPE2)
1281         save_CPPFLAGS="$CPPFLAGS"
1282         save_LIBS="$LIBS"
1283         CPPFLAGS="$FREETYPE2_CFLAGS $CPPFLAGS"
1284         LIBS="$FREETYPE2_LIBS $LIBS"
1285         AC_SUBST(FREETYPE2_CFLAGS)
1286         AC_SUBST(FREETYPE2_LIBS)
1287         CPPFLAGS="$save_CPPFLAGS"
1288         LIBS="$save_LIBS"
1289     else
1290         # UGR
1291         #r="lib$1-dev or $1-devel"
1292         r="libfreetype6-dev or freetype?-devel"
1293         ver="`pkg-config --modversion $1`"
1294         STEPMAKE_ADD_ENTRY($2, ["$r >= $3 (installed: $ver)"])
1295     fi
1296 ])
1297
1298 AC_DEFUN(STEPMAKE_PANGO, [
1299     PKG_CHECK_MODULES(PANGO, $1 >= $3, have_pango16=yes, true)
1300     if test "$have_pango16" = yes ; then
1301         AC_DEFINE(HAVE_PANGO16)
1302         # Do not pollute user-CPPFLAGS with configure-CPPFLAGS
1303         save_CPPFLAGS="$CPPFLAGS"
1304         save_LIBS="$LIBS"
1305         CPPFLAGS="$PANGO_CFLAGS $CPPFLAGS"
1306         LIBS="$PANGO_LIBS $LIBS"
1307         AC_CHECK_HEADERS([pango/pangofc-fontmap.h])
1308         AC_CHECK_FUNCS([pango_fc_font_map_add_decoder_find_func])
1309         AC_SUBST(PANGO_CFLAGS)
1310         AC_SUBST(PANGO_LIBS)
1311         CPPFLAGS="$save_CPPFLAGS"
1312         LIBS="$save_LIBS"
1313     else
1314         # UGR
1315         #r="lib$1-dev or $1-devel"
1316         r="libpango1.0-dev or pango1.0-devel"
1317         ver="`pkg-config --modversion $1`"
1318         STEPMAKE_ADD_ENTRY($2, ["$r >= $3 (installed: $ver)"])
1319     fi
1320 ])
1321
1322 AC_DEFUN(STEPMAKE_PANGO_FT2, [
1323     PKG_CHECK_MODULES(PANGO_FT2, $1 >= $3, have_pangoft2=yes, true)
1324     if test "$have_pangoft2" = yes ; then
1325         AC_DEFINE(HAVE_PANGO16)
1326         AC_DEFINE(HAVE_PANGO_FT2)
1327         # Do not pollute user-CPPFLAGS with configure-CPPFLAGS
1328         save_CPPFLAGS="$CPPFLAGS"
1329         save_LIBS="$LIBS"
1330         CPPFLAGS="$CPPFLAGS $PANGO_FT2_CFLAGS"
1331         LIBS="$PANGO_FT2_LIBS $LIBS"
1332         AC_CHECK_HEADERS([pango/pangoft2.h])
1333         AC_CHECK_FUNCS([pango_ft2_font_map_create_context])
1334         AC_SUBST(PANGO_FT2_CFLAGS)
1335         AC_SUBST(PANGO_FT2_LIBS)
1336         CPPFLAGS="$save_CPPFLAGS"
1337         LIBS="$save_LIBS"
1338     else
1339         # UGR
1340         #r="lib$1-dev or $1-devel"e
1341         r="libpango1.0-dev or pango?-devel"
1342         ver="`pkg-config --modversion $1`"
1343         STEPMAKE_ADD_ENTRY($2, ["$r >= $3 (installed: $ver)"])
1344     fi
1345 ])
1346
1347 AC_DEFUN(STEPMAKE_PANGO_FT2_WITH_OTF_FEATURE, [
1348         PKG_CHECK_MODULES(PANGO_FT2, $1 >= $3,
1349                           have_pangoft2_with_otf_feature=yes, true)
1350     if test "$have_pangoft2_with_otf_feature" = yes ; then
1351         AC_DEFINE(HAVE_PANGO16)
1352         AC_DEFINE(HAVE_PANGO_FT2)
1353         AC_DEFINE(HAVE_PANGO_FT2_WITH_OTF_FEATURE)
1354         # Do not pollute user-CPPFLAGS with configure-CPPFLAGS
1355         save_CPPFLAGS="$CPPFLAGS"
1356         save_LIBS="$LIBS"
1357         CPPFLAGS="$CPPFLAGS $PANGO_FT2_CFLAGS"
1358         LIBS="$PANGO_FT2_LIBS $LIBS"
1359         AC_CHECK_HEADERS([pango/pangoft2.h])
1360         AC_CHECK_FUNCS([pango_ft2_font_map_create_context])
1361         AC_SUBST(PANGO_FT2_CFLAGS)
1362         AC_SUBST(PANGO_FT2_LIBS)
1363         CPPFLAGS="$save_CPPFLAGS"
1364         LIBS="$save_LIBS"
1365     else
1366         # UGR
1367         #r="lib$1-dev or $1-devel"e
1368         r="libpango1.0-dev or pango?-devel"
1369         ver="`pkg-config --modversion $1`"
1370         STEPMAKE_ADD_ENTRY($2, ["$r >= $3 (It is required if you'd like "])
1371         STEPMAKE_ADD_ENTRY($2, ["to use OpenType font feature. "])
1372         STEPMAKE_ADD_ENTRY($2, ["installed: $ver)"])
1373     fi
1374 ])
1375
1376 AC_DEFUN(STEPMAKE_FONTCONFIG, [
1377     PKG_CHECK_MODULES(FONTCONFIG, $1 >= $3, have_fontconfig=yes, true)
1378     if test "$have_fontconfig" = yes ; then
1379         AC_DEFINE(HAVE_FONTCONFIG)
1380         # Do not pollute user-CPPFLAGS with configure-CPPFLAGS
1381         save_CPPFLAGS="$CPPFLAGS"
1382         save_LIBS="$LIBS"
1383         CPPFLAGS="$FONTCONFIG_CFLAGS $CPPFLAGS"
1384         LIBS="$FONTCONFIG_LIBS $LIBS"
1385         AC_SUBST(FONTCONFIG_CFLAGS)
1386         AC_SUBST(FONTCONFIG_LIBS)
1387         CPPFLAGS="$save_CPPFLAGS"
1388         LIBS="$save_LIBS"
1389     else
1390         r="lib$1-dev or $1-devel"
1391         ver="`pkg-config --modversion $1`"
1392         STEPMAKE_ADD_ENTRY($2, ["$r >= $3 (installed: $ver)"])
1393     fi
1394 ])
1395
1396 AC_DEFUN(STEPMAKE_WINDOWS, [
1397     AC_CYGWIN
1398     AC_MINGW32
1399
1400     if test "$CYGWIN" = "yes"; then
1401         LN_S='cp -r' # Cygwin symbolic links do not work for native apps.
1402         program_suffix=.exe
1403         INSTALL="\$(SHELL) \$(stepdir)/../bin/install-dot-exe.sh -c"
1404     elif test "$MINGW32" = "yes"; then
1405         LN='cp -r'
1406         LN_S='cp -r'
1407         program_suffix=.exe
1408         INSTALL="\$(SHELL) \$(stepdir)/../bin/install-dot-exe.sh -c"
1409         PATHSEP=';'
1410     fi
1411
1412     AC_SUBST(LN)
1413     AC_SUBST(LN_S)
1414     AC_DEFINE_UNQUOTED(DIRSEP, ['${DIRSEP}'])
1415     AC_DEFINE_UNQUOTED(PATHSEP, ['${PATHSEP}'])
1416     AC_SUBST(DIRSEP)
1417     AC_SUBST(PATHSEP)
1418     AC_SUBST(program_suffix)
1419
1420     AC_MSG_CHECKING([for some flavor of Windows])
1421     if test "$CYGWIN$MINGW32" = "nono"; then
1422         PLATFORM_WINDOWS=no
1423     else
1424         PLATFORM_WINDOWS=yes
1425     fi
1426     AC_MSG_RESULT([$PLATFORM_WINDOWS])
1427     AC_SUBST(PLATFORM_WINDOWS)
1428     STEPMAKE_PROGS(WINDRES, $target-windres windres, x)
1429     AC_SUBST(WINDRES)
1430 ])