+
+### mostly interal macros
+
+# Get full path of executable ($1)
+AC_DEFUN(STEPMAKE_GET_EXECUTABLE, [
+ ## which doesn't work in ash, if /usr/bin/which isn't installed
+ ## type -p doesn't work in ash
+ ## command -v doesn't work in zsh
+ ## command -v "$1" 2>&1
+ ## this test should work in ash, bash, pdksh (ksh), zsh
+ type -p $1 2>/dev/null | tail -n 1 | awk '{print $NF}'
+])
+
+
+# Get version string from executable ($1)
+AC_DEFUN(STEPMAKE_GET_VERSION, [
+ ## "$1" --version 2>&1 | grep -v '^$' | head -n 1 | awk '{print $NF}'
+ ##
+ ## ARG.
+ ## Workaround for broken Debian gcc version string:
+ ## gcc (GCC) 3.1.1 20020606 (Debian prerelease)
+ ##
+ ## -V: Workaround for python
+
+ changequote(<<, >>)#dnl
+
+ ## Assume and hunt for dotted version multiplet.
+ ## use eval trickery, because we cannot use multi-level $() instead of ``
+ ## for compatibility reasons.
+
+ ## grab the first version number in --version output.
+ eval _ver=\"\`("$1" --version || "$1" -V) 2>&1 |
+ grep -E '(^| )[0-9][0-9]*\.[0-9]' |
+ head -n 1 |
+ tr ' ' '\n' |
+ sed 's/\([0-9][0-9]*\.[0-9][0-9.]*\).*/\1/g' |
+ grep -E '(^| )[0-9][0-9]*\.[0-9]' |
+ head -n 1\`\"
+
+ if test -z "$_ver"; then
+ ## If empty, try date [fontforge]
+ eval _ver=\"\`("$1" --version || "$1" -V) 2>&1 \
+ | grep '\(^\|[^0-9a-f]\)[0-9]\{6,8\}\([^0-9a-f]\|$\)' \
+ | head -n 1 \
+ | sed -e 's/^[^.0-9]*//' -e 's/[^.0-9]*$//'\`\"
+ fi
+ echo "$_ver"
+ changequote([, ])#dnl
+])
+
+# Calculate simplistic numeric version from version string ($1)
+# As yet, we have no need for something more elaborate.
+AC_DEFUN(STEPMAKE_NUMERIC_VERSION, [
+ echo "$1" | awk -F. '
+ {
+ if ([$]3) {three = [$]3}
+ else {three = 0}
+ }
+ {printf "%.0f\n", [$]1*1000000 + [$]2*1000 + three}'
+])
+
+
+# Add item ($2) to list ($1, one of 'OPTIONAL', 'REQUIRED')
+AC_DEFUN(STEPMAKE_ADD_ENTRY, [
+ eval "$1"=\"`eval echo \"'$'$1\" \"$2\"`\"
+])
+
+# Check if tested program ($2) was found ($1).
+# If not, add entry to missing-list ($3, one of 'OPTIONAL', 'REQUIRED').
+# We could abort here if a 'REQUIRED' program is not found
+AC_DEFUN(STEPMAKE_OPTIONAL_REQUIRED, [
+ STEPMAKE_CHECK_SEARCH_RESULT($1)
+ if test $? -ne 0; then
+ STEPMAKE_ADD_ENTRY($3, $2)
+ if test "$3" = "REQUIRED"; then
+ command="echo ERROR: $2 not found"
+ # abort configure process here?
+ else
+ command="- echo $2 not found"
+ fi
+ eval "$1"='$command'
+ false
+ else
+ true
+ fi
+])
+
+
+# Return if tested proram ($1) was found (true) or not (false).
+AC_DEFUN(STEPMAKE_CHECK_SEARCH_RESULT, [
+ r="`eval echo '$'"$1"`"
+ if test -n "$r" -a "$r" != "error" -a "$r" != "no" && expr '`eval echo '$'"$1"`' : '.*\(echo\)' > /dev/null; then
+ true
+ else
+ ##STEPMAKE_WARN(cannot find $2. $3)
+ false
+ fi
+])
+
+
+# Check version of program ($1)
+# If version ($4: optional argument, supply if version cannot be
+# parsed using --version or -V ) is smaller than requested ($3), add
+# entry to missing-list ($2, one of 'OPTIONAL', 'REQUIRED').
+AC_DEFUN(STEPMAKE_CHECK_VERSION, [
+ r="`eval echo '$'"$1"`"
+ AC_MSG_CHECKING([$r version])
+ exe=`STEPMAKE_GET_EXECUTABLE($r)`
+ if test -n "$4"; then
+ ver="$4"
+ else
+ ver=`STEPMAKE_GET_VERSION($exe)`
+ fi
+ num=`STEPMAKE_NUMERIC_VERSION($ver)`
+ req=`STEPMAKE_NUMERIC_VERSION($3)`
+ AC_MSG_RESULT([$ver])
+ if test "$num" -lt "$req"; then
+ STEPMAKE_ADD_ENTRY($2, ["$r >= $3 (installed: $ver)"])
+ fi
+ vervar="`echo $1 | tr '[a-z]' '[A-Z]'`_VERSION"
+ eval `echo $vervar=$num`
+## AC_SUBST(`eval echo $vervar`)
+])
+
+# Check version of program ($1)
+# If version is greater than or equals unsupported ($3),
+# add entry to unsupported list ($2, 'UNSUPPORTED')
+AC_DEFUN(STEPMAKE_CHECK_VERSION_UNSUPPORTED, [
+ r="`eval echo '$'"$1"`"
+ AC_MSG_CHECKING([$r version])
+ exe=`STEPMAKE_GET_EXECUTABLE($r)`
+ ver=`STEPMAKE_GET_VERSION($exe)`
+ num=`STEPMAKE_NUMERIC_VERSION($ver)`
+ sup=`STEPMAKE_NUMERIC_VERSION($3)`
+ AC_MSG_RESULT([$ver])
+ if test "$num" -ge "$sup"; then
+ STEPMAKE_ADD_ENTRY($2, ["$r < $3 (installed: $ver)"])
+ fi
+])
+
+### Macros to build configure.ac
+
+
+AC_DEFUN(STEPMAKE_BIBTEX2HTML, [
+ STEPMAKE_PROGS(BIBTEX2HTML, bibtex2html bib2html, $1)