NR: Add index entries for `<<`, `\\`, and `>>`
[lilypond/mirror.git] / aclocal.m4
blob718a3414c4f5c1fe16291509bd87fe85f9915d0d
1 dnl aclocal.m4   -*-shell-script-*-
2 dnl StepMake subroutines for configure.ac
4 # This file is part of LilyPond, the GNU music typesetter.
6 # Copyright (C) 1998--2023  Han-Wen Nienhuys <hanwen@xs4all.nl>
7 #                           Jan Nieuwenhuizen <janneke@gnu.org>
9 # LilyPond is free software: you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation, either version 3 of the License, or
12 # (at your option) any later version.
14 # LilyPond is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with LilyPond.  If not, see <http://www.gnu.org/licenses/>.
23 ### mostly internal macros
25 # Get full path of executable ($1)
26 AC_DEFUN(STEPMAKE_GET_EXECUTABLE, [
27     ## which doesn't work in ash, if /usr/bin/which isn't installed
28     ## type -p doesn't work in ash
29     ## command -v doesn't work in zsh
30     ## command -v "$1" 2>&1
31     ## this test should work in ash, bash, pdksh (ksh), zsh
32     type -p $1 2>/dev/null | tail -n 1 | awk '{print $NF}'
36 # Get version string from executable ($1)
37 AC_DEFUN(STEPMAKE_GET_VERSION, [
38     ## "$1" --version 2>&1 | grep -v '^$' | head -n 1 | awk '{print $NF}'
39     ##
40     ## ARG.
41     ## Workaround for broken Debian gcc version string:
42     ##     gcc (GCC) 3.1.1 20020606 (Debian prerelease)
43     ##
44     ## -V: Workaround for python
46     changequote(<<, >>)#dnl
48     ## Assume and hunt for dotted version multiplet.
49     ## use eval trickery, because we cannot use multi-level $() instead of ``
50     ## for compatibility reasons.
52     ## grab the first version number in --version output.
53     eval _ver=\"\`("$1" --version || "$1" -V) 2>&1 |
54         grep -E '(^| )[0-9][0-9]*\.[0-9]' |
55         head -n 1 |
56         tr ' ' '\n' |
57         sed 's/\([0-9][0-9]*\.[0-9][0-9.]*\).*/\1/g' |
58         grep -E '(^| )[0-9][0-9]*\.[0-9]' |
59         head -n 1\`\"
61     if test -z "$_ver"; then
62         ## If empty, try date [fontforge]
63         eval _ver=\"\`("$1" --version || "$1" -V) 2>&1 \
64         | grep '\(^\|[^0-9a-f]\)[0-9]\{6,8\}\([^0-9a-f]\|$\)' \
65         | head -n 1 \
66         | sed -e 's/^[^.0-9]*//' -e 's/[^.0-9]*$//'\`\"
67     fi
68     echo "$_ver"
69     changequote([, ])#dnl
72 # Calculate simplistic numeric version from version string ($1)
73 # As yet, we have no need for something more elaborate.
74 AC_DEFUN(STEPMAKE_NUMERIC_VERSION, [
75     echo "$1" | awk -F. '
76     {
77       one = [$]1
78       two = [$]2
79       three = [$]3
81       if (one > 1000) {
82         # for version dates like '20230124', avoiding numeric overflow
83         three = one
84         two = 0
85         one = 0
86       }
87     }
88     {printf "%.0f\n", one*1000000 + two*1000 + three}'
92 # Add item ($2) to list ($1, one of 'OPTIONAL', 'REQUIRED')
93 AC_DEFUN(STEPMAKE_ADD_ENTRY, [
94     eval "$1"=\"`eval echo \"'$'$1\" \"$2\"`\"
97 # Check if tested program ($2) was found ($1).
98 # If not, add entry to missing-list ($3, one of 'OPTIONAL',
99 # 'REQUIRED') and assign "false" to ($1).  "false" can be tested
100 # clearly in makefiles and will surely fail if run unintentionally.
101 AC_DEFUN(STEPMAKE_OPTIONAL_REQUIRED, [
102     STEPMAKE_CHECK_SEARCH_RESULT($1)
103     if test $? -ne 0; then
104         STEPMAKE_ADD_ENTRY($3, $2)
105         eval "$1"=false
106         false
107     else
108         true
109     fi
113 # Return if tested proram ($1) was found (true) or not (false).
114 AC_DEFUN(STEPMAKE_CHECK_SEARCH_RESULT, [
115     r="`eval echo '$'"$1"`"
116     if test -n "$r" \
117        && test "$r" != "error" \
118        && test "$r" != "no" \
119        && expr '`eval echo '$'"$1"`' : '.*\(echo\)' > /dev/null; then
120         true
121     else
122         false
123     fi
126 # Check version of program ($1)
127 # If version is smaller than requested ($3) or larger than requested
128 # ($4, optional), add entry to missing-list ($2, one of 'OPTIONAL',
129 # 'REQUIRED').
130 AC_DEFUN(STEPMAKE_CHECK_VERSION, [
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     min=`STEPMAKE_NUMERIC_VERSION($3)`
137     AC_MSG_RESULT([$ver])
138     if test "$num" -lt "$min"; then
139         STEPMAKE_ADD_ENTRY($2, ["$r >= $3 (installed: $ver)"])
140     fi
141     if test -n "$4"; then
142         max=`STEPMAKE_NUMERIC_VERSION($4)`
143         if test "$num" -gt "$max"; then
144             STEPMAKE_ADD_ENTRY($2, ["$r <= $4 (installed: $ver)"])
145         fi
146     fi
147     vervar="`echo $1 | tr '[a-z]' '[A-Z]'`_VERSION"
148     eval `echo $vervar=$num`
149 ##    AC_SUBST(`eval echo $vervar`)
153 ### Macros to build configure.ac
156 AC_DEFUN(STEPMAKE_BISON, [
157     STEPMAKE_PROGS(BISON, bison, $1)
159     # urg.  should test functionality rather than version.
160     if test "$BISON" = "bison" && test -n "$2"; then
161         STEPMAKE_CHECK_VERSION(BISON, $1, $2)
162     fi
166 AC_DEFUN(STEPMAKE_COMPILE_BEFORE, [
167     # -O is necessary to get inlining
168     CFLAGS=${CFLAGS-""}
169     CXXFLAGS=${CXXFLAGS-$CFLAGS}
170     LDFLAGS=${LDFLAGS-""}
171     optimise_b=yes
172     profile_b=no
173     debug_b=yes
174     pipe_b=yes
176     AC_ARG_ENABLE(debugging,
177         [AS_HELP_STRING(
178              [--enable-debugging],
179              [compile with debugging info.  Default: on])],
180         [debug_b=$enableval])
182     AC_ARG_ENABLE(optimising,
183         [AS_HELP_STRING(
184             [--enable-optimising],
185             [compile with optimising.  Default: on])],
186         [optimise_b=$enableval])
188     AC_ARG_ENABLE(profiling,
189         [AS_HELP_STRING(
190             [--enable-profiling],
191             [compile with gprof support.  Default: off])],
192         [profile_b=$enableval])
194     AC_ARG_ENABLE(pipe,
195         [AS_HELP_STRING(
196             [--enable-pipe],
197             [compile with -pipe.  Default: on])],
198         [pipe_b=$enableval])
200     if test "$optimise_b" = yes; then
201         OPTIMIZE=" -O2 -finline-functions"
202     fi
204     if test $profile_b = yes; then
205         EXTRA_LIBS="-pg"
206         OPTIMIZE="$OPTIMIZE -pg"
207     fi
209     if test $debug_b = yes; then
210         OPTIMIZE="$OPTIMIZE -g"
211     fi
215 AC_DEFUN(STEPMAKE_COMPILE, [
216     AC_REQUIRE([STEPMAKE_COMPILE_BEFORE])
217     AC_REQUIRE([AC_PROG_CC])
218     AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS])
220     STEPMAKE_OPTIONAL_REQUIRED(CC, cc, $1)
222     # If -pipe requested, test if it works and add to CFLAGS.
223     if test "$pipe_b" = yes; then
224         save_cflags="$CFLAGS"
225         CFLAGS=" -pipe $CFLAGS";
226         AC_CACHE_CHECK([whether compiler understands -pipe],
227             [stepmake_cv_cflags_pipe],
228             AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[/* -pipe test */]])],
229                 [stepmake_cv_cflags_pipe=yes],
230                 [stepmake_cv_cflags_pipe=no]))
231         CFLAGS=$save_cflags
232         if test $stepmake_cv_cflags_pipe = yes; then
233             OPTIMIZE="$OPTIMIZE -pipe"
234         fi
235     fi
237     CFLAGS="$CFLAGS $OPTIMIZE"
238     CPPFLAGS=${CPPFLAGS-""}
240     AC_SUBST(cross_compiling)
241     AC_SUBST(CFLAGS)
242     AC_SUBST(CPPFLAGS)
243     AC_SUBST(LDFLAGS)
244     AC_SUBST(DEFINES)
245     AC_SUBST(EXTRA_LIBS)
249 AC_DEFUN(STEPMAKE_CXX, [
250     AC_PROG_CXX
251     STEPMAKE_OPTIONAL_REQUIRED(CXX, c++, $1)
253     CXXFLAGS="$CXXFLAGS $OPTIMIZE"
255     AC_SUBST(CXX)
256     AC_SUBST(CXXFLAGS)
260 AC_DEFUN(STEPMAKE_DATADIR, [
261     presome=${prefix}
262     if test "$prefix" = "NONE"; then
263         presome=${ac_default_prefix}
264     fi
266     build_package_datadir=$ac_pwd/out/share/$package
268     DATADIR=`echo ${datadir} | sed "s!\\\${datarootdir}!${presome}/share!"`
269     DATADIR=`echo ${DATADIR} | sed "s!\\\${prefix}!$presome!"`
270     BUILD_PACKAGE_DATADIR=`echo ${build_package_datadir} | sed "s!\\\${prefix}!$presome!"`
272     AC_SUBST(datadir)
273     AC_SUBST(datarootdir)
274     AC_SUBST(build_package_datadir)
275     AC_DEFINE_UNQUOTED(CONFIG_DATADIR, ["${DATADIR}"])
276     AC_DEFINE_UNQUOTED(BUILD_PACKAGE_DATADIR, ["${BUILD_PACKAGE_DATADIR}"])
280 ## ugh: cut & paste programming from datadir.
281 AC_DEFUN(STEPMAKE_LIBDIR, [
282     presome=${exec_prefix}
283     if test "$presome" = "NONE"; then
284         presome=${prefix}
285     fi
286     if test "$presome" = "NONE"; then
287         presome=${ac_default_prefix}
288     fi
290     build_package_libdir=$ac_pwd/out/lib/$package
292     LIBDIR=`echo ${libdir} | sed "s!\\\${exec_prefix}!$presome!"`
293     BUILD_PACKAGE_LIBDIR=`echo ${build_package_libdir} | sed "s!\\\${exec_prefix}!$presome!"`
295     AC_SUBST(libdir)
296     AC_SUBST(build_package_libdir)
297     AC_DEFINE_UNQUOTED(CONFIG_LIBDIR, ["${LIBDIR}"])
298     AC_DEFINE_UNQUOTED(BUILD_PACKAGE_LIBDIR, ["${BUILD_PACKAGE_LIBDIR}"])
302 AC_DEFUN(STEPMAKE_PREFIX_EXPAND_FIXUP, [
303     # undo expanding of explicit --infodir=/usr/share
304     # to ease install-time override with prefix=...
305     strip=`echo $includedir | eval sed s@^$prefix@@`
306     if test "$includedir" = "`eval echo $prefix$strip`"; then
307         includedir='${prefix}'$strip''
308     fi
309     strip=`echo $libdir | eval sed s@^$exec_prefix@@`
310     if test "$libdir" = "`eval echo $exec_prefix$strip`"; then
311         libdir='${exec_prefix}'$strip''
312     fi
313     strip=`echo $infodir | eval sed s@^$datarootdir@@`
314     if test "$infodir" = "`eval echo $datarootdir$strip`"; then
315         infodir='${datarootdir}'$strip''
316     fi
317     strip=`echo $mandir | eval sed s@^$datarootdir@@`
318     if test "$mandir" = "`eval echo $datarootdir$strip`"; then
319         mandir='${datarootdir}'$strip''
320     fi
324 AC_DEFUN(STEPMAKE_END, [
325     STEPMAKE_PREFIX_EXPAND_FIXUP
327     AC_SUBST(OPTIONAL)
328     AC_SUBST(REQUIRED)
330     AC_CONFIG_FILES([config.make:config.make.in])
331     AC_OUTPUT
333     if test -n "$OPTIONAL"; then
334         echo
335         echo "WARNING: Please consider installing optional programs or files: $OPTIONAL"
336     fi
338     if test -n "$REQUIRED"; then
339         echo
340         echo "ERROR: Please install required programs: $REQUIRED"
341     fi
343     if test -n "$UNSUPPORTED"; then
344         echo
345         echo "ERROR: Please use older version of programs: $UNSUPPORTED"
346     fi
348     if test -n "$OPTIONAL$REQUIRED$UNSUPPORTED"; then
349         echo
350         echo "See INSTALL.txt for more information on how to build $PACKAGE_NAME"
351         if test -f config.cache ; then
352             echo "Remove config.cache before rerunning ./configure"
353         fi
354     fi
356     if test -n "$REQUIRED$UNSUPPORTED"; then
357         rm -f $srcdir/GNUmakefile
358         exit 1
359     fi
361     # regular in-place build
362     # test for srcdir_build = yes ?
363     if test "$srcdir_build" != "yes"; then
364         if test -f $srcdir/GNUmakefile; then
365             cat <<EOF
366 Source directory already configured.  Please clean the source directory
368     make -C $srcdir distclean
370 and rerun configure.
372             exit 2
373         fi
375         depth=""
376         for d in 2 3 4 5 ; do
377             depth="$depth../"
378             for mf in `cd $srcdir; \
379                        find . -maxdepth $d -mindepth $d -name GNUmakefile`; do
380                 case "$abssrcdir" in
381                 "$absbuilddir"/*)
382                     # source is below build directory, always copy
383                     ;;
384                 *)
385                     case "$abssrcdir/${mf#./}" in
386                     "$absbuilddir"/*)
387                         # find descended into build directory, don't copy
388                         continue
389                     esac
390                 esac
392                 mkdir -p ${mf%/*}
393                 cat <<EOF > $mf
394 depth=$depth
395 include \$(depth)/config.make
396 include \$(configure-srcdir)/$mf
398             done
400             for mf in `cd $srcdir; \
401                        find . -maxdepth $d -mindepth $d -name '*.make' \
402                        | grep -v config.make `; do
403                 case "$abssrcdir" in
404                 "$absbuilddir"/*)
405                     # source is below build directory, always copy
406                     ;;
407                 *)
408                     case "$abssrcdir/${mf#./}" in
409                     "$absbuilddir"/*)
410                         # find descended into build directory, don't copy
411                         continue
412                     esac
413                 esac
415                 mkdir -p ${mf%/*}
416                 cat <<EOF > $mf
417 include \$(depth)/config.make
418 include \$(configure-srcdir)/$mf
420             done
421         done
422     fi
423     rm -f GNUmakefile
424     cat <<EOF > GNUmakefile
425 depth = .
426 include config.make
427 include \$(configure-srcdir)/GNUmakefile.in
429     chmod 444 GNUmakefile
430     AC_SUBST(VPATH)
434 AC_DEFUN(STEPMAKE_FLEX, [
435     # ugh, ugh
436     ac_cv_prog_lex_root=lex.yy
437     STEPMAKE_PROGS(FLEX, flex, $1)
441 AC_DEFUN(STEPMAKE_FLEXLEXER, [
442     save_CPPFLAGS="$CPPFLAGS"
443     if test -n "$FLEXLEXER_DIR"; then
444         FLEXLEXER_CPPFLAGS="-I$FLEXLEXER_DIR"
445         AC_SUBST(FLEXLEXER_CPPFLAGS)
446         CPPFLAGS="$FLEXLEXER_CPPFLAGS $CPPFLAGS"
447     fi
448     AC_CHECK_HEADERS([FlexLexer.h],[true],[false])
449     if test $? -ne 0; then
450         warn='FlexLexer.h (flex package)'
451         STEPMAKE_ADD_ENTRY($1, $warn)
452     fi
453     # check for yyFlexLexer.yypop_buffer_state () since flex 2.5.29
454     AC_CACHE_CHECK([for yyFlexLexer.yypop_buffer_state ()],
455         [stepmake_cv_flexlexer_yypop_buffer_state],
456         AC_COMPILE_IFELSE([
457             AC_LANG_PROGRAM([[
458 #include <FlexLexer.h>
459 class yy_flex_lexer: public yyFlexLexer
461   public:
462     yy_flex_lexer ()
463     {
464       yypop_buffer_state ();
465     }
468             ]])],
469             [stepmake_cv_flexlexer_yypop_buffer_state=yes],
470             [stepmake_cv_flexlexer_yypop_buffer_state=no]))
472     if test $stepmake_cv_flexlexer_yypop_buffer_state = no; then
473         warn='FlexLexer.h with yypop_buffer_state (flex >= 2.5.29)'
474         STEPMAKE_ADD_ENTRY($1, $warn)
475     fi
476     CPPFLAGS=$save_CPPFLAGS
480 AC_DEFUN(STEPMAKE_GETTEXT, [
481     presome=${prefix}
482     if test "$prefix" = "NONE"; then
483         presome=${ac_default_prefix}
484     fi
485     LOCALEDIR=`echo ${localedir} | sed "s!\\\${prefix}!$presome!"`
487     AC_SUBST(localedir)
488     AC_DEFINE_UNQUOTED(LOCALEDIR, ["${LOCALEDIR}"])
489     AC_CHECK_LIB(intl, gettext)
490     AC_CHECK_FUNCS(gettext)
494 AC_DEFUN(STEPMAKE_GUILE_DEVEL, [
495     AC_ARG_VAR(GUILE_FLAVOR,
496                AS_HELP_STRING([], [pkgconfig name for Guile, like guile-3.0.
497                                    If the respective .pc file
498                                    cannot be found by pkgconfig,
499                                    add its path to PKG_CONFIG_PATH]))dnl
501     if test -n "$GUILE_FLAVOR"; then
502         PKG_CHECK_MODULES([GUILE], [$GUILE_FLAVOR],
503                             [true], [GUILE_FLAVOR="missing"])
504     else
505         PKG_CHECK_MODULES([GUILE], [guile-3.0 >= 3.0.7],
506                             [GUILE_FLAVOR="guile-3.0"], [
507             GUILE_FLAVOR="missing"
508         ])
509     fi
511     if test "$GUILE_FLAVOR" = "missing"; then
512         STEPMAKE_ADD_ENTRY(REQUIRED, ["guile-devel >= 3.0.7"])
513     fi
517 AC_DEFUN(STEPMAKE_INIT, [
518     . $srcdir/VERSION
519     FULL_VERSION=$MAJOR_VERSION.$MINOR_VERSION.$PATCH_LEVEL
520     TOPLEVEL_VERSION=$FULL_VERSION
521     if test x$MY_PATCH_LEVEL != x; then
522         FULL_VERSION=$FULL_VERSION.$MY_PATCH_LEVEL
523     fi
524     VERSION=$FULL_VERSION
525     export MAJOR_VERSION MINOR_VERSION PATCH_LEVEL
527     # urg, how is this supposed to work?
528     if test "$program_prefix" = "NONE"; then
529         program_prefix=
530     fi
531     if test "$program_suffix" = "NONE"; then
532         program_suffix=
533     fi
535     # From configure: "When building in place, set srcdir=."
536     if test "$srcdir" = "."; then
537         srcdir_build=yes
538     else
539         srcdir_build=no
540     fi
541     abssrcdir="`cd $srcdir; pwd`"
542     absbuilddir="`pwd`"
545     AC_SUBST(VERSION)
546     AC_SUBST(MAJOR_VERSION)
547     AC_SUBST(MINOR_VERSION)
549     # stepmake nonstandard names
550     AC_SUBST(PATCH_LEVEL)
551     AC_SUBST(TOPLEVEL_VERSION)
553     AUTOGENERATE="This file was automatically generated by configure"
554     AC_SUBST(AUTOGENERATE)
556     AC_CANONICAL_HOST
557     STEPMAKE_PROGS(MAKE, gmake make, REQUIRED)
558     STEPMAKE_CHECK_VERSION(MAKE, REQUIRED, 4.2)
559     STEPMAKE_PROGS(FIND, find, REQUIRED)
561     STEPMAKE_PROGS(TAR, tar, REQUIRED)
563     if expr "$MAKE" : '.*\(echo\)' >/dev/null; then
564         $MAKE -v 2> /dev/null | grep GNU > /dev/null
565         if test "$?" = 1; then
566             warn='make (Please install *GNU* make)'
567             STEPMAKE_ADD_ENTRY(REQUIRED, $warn)
568         fi
569     fi
571     PATHSEP=':'
572     LN=ln
574     AC_SUBST(program_prefix)
575     AC_SUBST(program_suffix)
576     AC_SUBST(LN)
577     AC_DEFINE_UNQUOTED(PATHSEP, ['${PATHSEP}'])
578     AC_SUBST(PATHSEP)
580     STEPMAKE_DATADIR
581     STEPMAKE_LIBDIR
585 AC_DEFUN(STEPMAKE_LIB, [
586     STEPMAKE_PROGS(AR, ar, $1)
587     AC_PROG_RANLIB
588     STEPMAKE_OPTIONAL_REQUIRED(RANLIB, ranlib, $1)
592 AC_DEFUN(STEPMAKE_LOCALE, [
593     # with/enable ??
594     AC_ARG_WITH(localedir,
595         [AS_HELP_STRING(
596              [--with-localedir=DIR],
597              [location of locales.  Default: PREFIX/share/locale])],
598         localedir=$with_localedir,
599         localedir='${prefix}/share/locale')
603 AC_DEFUN(STEPMAKE_MSGFMT, [
604     STEPMAKE_PROGS(MSGFMT, msgfmt, $1)
608 # Check for program ($2).  If found, assign full path result to ($1).
609 # If missing, add entry to missing-list ($3, one of 'OPTIONAL', 'REQUIRED')
610 # and assign "false" to ($1).
611 AC_DEFUN(STEPMAKE_PATH_PROG, [
612     AC_CHECK_PROGS($1, $2, no)
613     STEPMAKE_OPTIONAL_REQUIRED($1, $2, $3)
614     if test $? -eq 0; then
615         AC_PATH_PROGS($1, $2)
616         if test -n "$4"; then
617             STEPMAKE_CHECK_VERSION($1, $3, $4)
618         fi
619     fi
623 # Check for program in a set of names ($2).  If found, assign result to ($1).
624 # If missing, add entry to missing-list ($3, one of 'OPTIONAL', 'REQUIRED')
625 # and assign "false" to ($1).
626 # Otherwise, compare version to minimum version ($4, optional) and/or maximum
627 # version ($5, optional).
628 AC_DEFUN(STEPMAKE_PROGS, [
629     AC_CHECK_PROGS($1, $2, no)
630     STEPMAKE_OPTIONAL_REQUIRED($1, $2, $3)
631     if test $? -eq 0; then
632         if test -n "$4" || test -n "$5"; then
633             STEPMAKE_CHECK_VERSION($1, $3, $4, $5)
634         fi
635     fi
639 AC_DEFUN(STEPMAKE_PERL, [
640     STEPMAKE_PATH_PROG(PERL, perl, $1)
644 # Check for python, between minimum ($2) and maximum version ($3).
645 # If missing, add entry to missing-list ($1, one of 'OPTIONAL', 'REQUIRED')
646 AC_DEFUN(STEPMAKE_PYTHON, [
647     AC_MSG_CHECKING([for python])
648     python="python"
649     found="no"
650     for r in $PYTHON python python3; do
651         exe=`STEPMAKE_GET_EXECUTABLE($r)`
652         if ! $exe -V > /dev/null 2>&1 ; then
653             continue
654         fi
655         ver=`STEPMAKE_GET_VERSION($exe)`
656         num=`STEPMAKE_NUMERIC_VERSION($ver)`
657         req=`STEPMAKE_NUMERIC_VERSION($2)`
658         sup=`STEPMAKE_NUMERIC_VERSION($3)`
659         if test -n "$2" && test "$num" -lt "$req"; then
660             python=["$r >= $2 (installed: $ver)"]
661             continue
662         else
663             if test -n "$3" && test "$num" -ge "$sup"; then
664                 python=["$r < $3 (installed: $ver)"]
665                 continue
666             else
667                 python=$r
668                 found=$r
669                 break
670             fi
671         fi
672     done
673     AC_MSG_RESULT([$found])
674     if test "$found" != "no"; then
675         AC_MSG_CHECKING([$python version])
676         AC_MSG_RESULT([$ver])
677         PYTHON=$found
678     else
679         STEPMAKE_ADD_ENTRY($1, $python)
680     fi
681     AC_PATH_PROG(PYTHON, $PYTHON)
682     AC_SUBST(PYTHON)
686 AC_DEFUN(STEPMAKE_FONTFORGE, [
687     STEPMAKE_PATH_PROG(FONTFORGE, fontforge, $1, 20110222)
688     if test $? -eq 0; then
689         min_quiet=`STEPMAKE_NUMERIC_VERSION(20220308)`
690         # `num` comes from `STEPMAKE_PATH_PROG`; we compare it with the
691         # first version that gives the `-quiet` option the expected
692         # functionality, that is, suppressing version and copyright
693         # information sent to stderr.
694         if test "$num" -ge "$min_quiet"; then
695             FONTFORGE_QUIET_OPTION=-quiet
696             AC_SUBST(FONTFORGE_QUIET_OPTION)
697         fi
698     fi
702 AC_DEFUN(STEPMAKE_TEXMF_DIRS, [
703     STEPMAKE_PROGS(KPSEWHICH, kpsewhich, $1)
705     AC_MSG_CHECKING(for metapost required files)
706     if test "$MFPLAIN_MP" = ""; then
707         MFPLAIN_MP=`kpsewhich -format=mp mfplain`
708     fi
709     if test "$MFPLAIN_MP" = ""; then
710         AC_MSG_RESULT(no)
711         STEPMAKE_ADD_ENTRY($1,
712             ['metapost CTAN package (texlive-metapost)'])
713     else
714         AC_MSG_RESULT(yes)
715     fi
719 AC_DEFUN(STEPMAKE_TEXMF, [
720     STEPMAKE_PROGS(METAFONT, mf-nowin mf mfw mfont, $1)
721     STEPMAKE_PROGS(METAPOST, mpost, $1)
722     if test "$METAPOST" != ""; then
723         ver=`STEPMAKE_GET_VERSION($METAPOST)`
724         num=`STEPMAKE_NUMERIC_VERSION($ver)`
725         # Avoid buggy metapost versions: 1.600 <= x < 1.803
726         if test "$num" -ge "1600000" \
727            && test "$num" -lt "1803000"; then
728             STEPMAKE_ADD_ENTRY($1,
729                 ["mpost (due to a bug in metapost, versions 1.600 <= x < 1.803 are not supported; installed: $ver)"])
730         fi
731     fi
735 AC_DEFUN(STEPMAKE_WINDOWS, [
736     AC_MSG_CHECKING([for some flavor of Windows])
737     AC_CANONICAL_HOST
738     case $host_os in
739       *cygwin* )
740         program_suffix=.exe
741         PLATFORM_WINDOWS=yes
742         ;;
743       *mingw32* )
744         LN='cp -r'
745         program_suffix=.exe
746         PATHSEP=';'
747         PLATFORM_WINDOWS=yes
748         ;;
749       * )
750         PLATFORM_WINDOWS=no
751         ;;
752     esac
753     AC_MSG_RESULT([$PLATFORM_WINDOWS])
755     AC_SUBST(LN)
756     AC_DEFINE_UNQUOTED(PATHSEP, ['${PATHSEP}'])
757     AC_SUBST(PATHSEP)
758     AC_SUBST(program_suffix)
760     AC_SUBST(PLATFORM_WINDOWS)
761     STEPMAKE_PROGS(WINDRES, $host-windres windres, x)
762     AC_SUBST(WINDRES)
765 m4_include([m4/pkg.m4])