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