1 dnl Process this file with -*- autoconf -*- to produce a configure script.
2 AC_INIT([GNU sed], 4.2.2, bug-sed@gnu.org, sed)
3 AC_CONFIG_AUX_DIR(build-aux)
4 AC_CONFIG_SRCDIR([sed/sed.c])
5 AM_CONFIG_HEADER(config.h:config_h.in)
9 SED_FEATURE_VERSION=4.2.2
10 AC_DEFINE_UNQUOTED(SED_FEATURE_VERSION, "$SED_FEATURE_VERSION",
11 [Define to the version of GNU sed whose features are supported by this sed.])
12 AC_SUBST(SED_FEATURE_VERSION)
15 AC_SUBST(COPYRIGHT_YEAR)
21 AC_CACHE_CHECK([whether "rt" can be used with fopen], [sed_cv_fopen_rt], [
31 fp = fopen ("conftest.c", "rt");
34 }], [sed_cv_fopen_rt=yes],
37 *cygwin* | *mingw*) sed_cv_fopen_rt=yes ;;
38 *) sed_cv_fopen_rt='assuming no' ;;
40 if test "$sed_cv_fopen_rt" = yes; then
41 AC_DEFINE([HAVE_FOPEN_RT], [1],
42 [Defined if "rt" can be used as a mode to fopen.])
45 AC_CACHE_CHECK([whether -lcP is needed], [sed_cv_libcp_needed], [
55 fp = fopen ("conftest.c", "r");
56 if (!fp) return 0; /* error, assume not needed */
57 result = fflush (fp) == EOF && errno == 0;
60 }], [sed_cv_libcp_needed=no],
61 [sed_cv_libcp_needed=yes],
62 [sed_cv_libcp_needed="assuming no"])
64 if test "$sed_cv_libcp_needed" = yes; then
68 AC_CHECK_HEADERS_ONCE(locale.h errno.h wchar.h wctype.h mcheck.h,
69 [], [], [AC_INCLUDES_DEFAULT])
73 AM_GNU_GETTEXT_VERSION(0.17)
74 AM_GNU_GETTEXT([external])
76 AC_CHECK_FUNCS_ONCE(isatty isascii memcpy strchr strtoul lstat readlink
77 popen pathconf fchown fchmod setlocale)
79 # Check whether we are able to follow symlinks
80 if test "$ac_cv_func_lstat:$ac_cv_func_readlink" = yes:yes; then
81 AC_DEFINE(ENABLE_FOLLOW_SYMLINKS, ,[Follow symlinks when processing in place])
85 [ --disable-i18n disable internationalization (default=enabled)], ,
87 if test "x$enable_i18n" = xno; then
91 AC_ARG_ENABLE(regex-tests,
92 [ --enable-regex-tests enable regex matcher regression tests (default=yes)],
93 [if test "x$with_included_regex" = xno; then
96 enable_regex_tests=$with_included_regex)
98 AM_CONDITIONAL(TEST_REGEX, test "x$enable_regex_tests" = xyes)
99 if test "x$enable_regex_tests" = xyes; then
100 AC_DEFINE_UNQUOTED(_REGEX_RE_COMP, 1,
101 [Include BSD functions in regex, used by the testsuite])
104 # Determine whether we should run UTF-8 tests by checking if cyrillic
105 # letters are case-folded properly. The test for UTF-8 locales (both
106 # in general and specifically for a Russian one) is a bit weak, but it
107 # should match exactly what is done in the testsuite. In fact, sed's
108 # logic is portable (though testing it requires care) so it is enough to
109 # have a couple of platforms where these tests pass. Right now, only
110 # Windows and HP/UX do not support the tests.
111 AC_MSG_CHECKING([whether UTF-8 case folding tests should pass])
123 char in[] = "\xD0\xB4";
124 char good[] = "\xD0\x94";
126 wchar_t in_wc, good_wc;
127 if (mbtowc (&in_wc, in, 3) == -1)
129 if (mbtowc (&good_wc, good, 3) == -1)
131 if (towupper (in_wc) != good_wc)
133 if (wctomb (out, good_wc) != 2)
135 if (memcmp (out, good, 2))
145 /* Try hardcoding a Russian UTF-8 locale. If the name "ru_RU.UTF-8"
146 is invalid, use setlocale again just to get the current locale. */
147 old = setlocale (LC_CTYPE, "ru_RU.UTF-8");
154 old = setlocale (LC_CTYPE, "C");
156 /* Maybe cyrillic case folding is implemented for all UTF-8 locales.
157 If the current locale is not UTF-8, the test will be skipped. */
159 if ((len > 6 && !strcmp (old + len - 6, ".UTF-8"))
160 || (len > 6 && !strcmp (old + len - 6, ".utf-8"))
161 || (len > 5 && !strcmp (old + len - 5, ".UTF8"))
162 || (len > 5 && !strcmp (old + len - 5, ".utf8")))
169 /* Run the test in the detected UTF-8 locale. */
170 setlocale (LC_CTYPE, old);
173 ], [AC_MSG_RESULT([yes]); XFAIL_TESTS=],
174 [AC_MSG_RESULT([no]); XFAIL_TESTS='utf8-1 utf8-2 utf8-3 utf8-4'],
175 [AC_MSG_RESULT([don't care (cross compiling)]); XFAIL_TESTS=])
177 # Under MinGW, the bsd.sh test fails because of the EOF character (^Z).
179 *mingw*) XFAIL_TESTS="$XFAIL_TESTS bsd" ;;
182 AC_SUBST([XFAIL_TESTS])
184 AC_CONFIG_FILES([testsuite/version.good:testsuite/version.gin])
185 AC_CONFIG_FILES([Makefile doc/Makefile \
186 lib/Makefile sed/Makefile testsuite/Makefile \