1AC_DEFUN([jy_SORTZ],
2  [AC_PATH_PROG([SORT], [sort], [sort])
3  AC_MSG_CHECKING([if $SORT supports the -z option])
4if test "x$cross_compiling" = xyes
5then
6        # We are cross-compiling, so cannot test the target's "sort".
7        ac_sort_has_z=false
8else
9    # find out if the sort command has a working -z option.
10    if $SORT -z -c < "${srcdir:-.}/m4/order-good.bin" 2>/dev/null  >/dev/null
11    then
12        # sort has a -z option, but we have not yet established that
13        # sort thinks there is more than one input line there.   We have
14        # to make sort -c do its thing with the input lines in the wrong
15        # order to determine that (we can't do it in one shot because
16        # if sort returns nonzero we can't tell that it wasn't just
17        # complaining about this unknown -z option.
18        if $SORT -z -c < "${srcdir:-.}/m4/order-bad.bin" 2>/dev/null >/dev/null
19        then
20                # sort likes -z but it doesn't seem to make \0
21                # a delimiter.
22                ac_sort_has_z=false
23        else
24                ac_sort_has_z=true
25        fi
26    else
27        # Doesn't like the z option.
28        ac_sort_has_z=false
29    fi
30fi
31
32if test "x$cross_compiling" = xyes
33then
34        AC_MSG_RESULT([assume no, since we are cross compiling])
35        AC_SUBST(SORT_SUPPORTS_Z,[false])
36elif $ac_sort_has_z
37then
38        AC_MSG_RESULT([yes])
39        AC_SUBST(SORT_SUPPORTS_Z,[true])
40else
41        AC_MSG_RESULT([no])
42        AC_SUBST(SORT_SUPPORTS_Z,[false])
43fi
44])
45