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