build: Allow autoconf/ast_ext_tool_check to handle cross-compiling better.
[asterisk/asterisk.git] / autoconf / ast_prog_sed.m4
1 # AST_PROG_SED
2 # -----------
3 # Check for a fully functional sed program that truncates
4 # as few characters as possible.  Prefer GNU sed if found.
5 AC_DEFUN([AST_PROG_SED],
6 [AC_CACHE_CHECK([for a sed that does not truncate output], ac_cv_path_SED,
7     [dnl ac_script should not contain more than 99 commands (for HP-UX sed),
8      dnl but more than about 7000 bytes, to catch a limit in Solaris 8 /usr/ucb/sed.
9      ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
10      for ac_i in 1 2 3 4 5 6 7; do
11        ac_script="$ac_script$as_nl$ac_script"
12      done
13      echo "$ac_script" | sed 99q >conftest.sed
14      $as_unset ac_script || ac_script=
15      ifdef([_AC_PATH_PROGS_FEATURE_CHECK], [_AC_PATH_PROGS_FEATURE_CHECK], [_AC_PATH_PROG_FEATURE_CHECK])(SED, [sed gsed],
16         [_AC_FEATURE_CHECK_LENGTH([ac_path_SED], [ac_cv_path_SED],
17                 ["$ac_path_SED" -f conftest.sed])])])
18  SED="$ac_cv_path_SED"
19  AC_SUBST([SED])dnl
20  rm -f conftest.sed
21 ])# AST_PROG_SED