1dnl Process this file with -*- autoconf -*- to produce a configure script. 2AC_INIT(sed, 4.2.1, bug-gnu-utils@gnu.org, sed) 3AC_CONFIG_AUX_DIR(build-aux) 4AC_CONFIG_SRCDIR([sed/sed.c]) 5AM_CONFIG_HEADER(config.h:config_h.in) 6AC_PREREQ(2.60) 7AM_INIT_AUTOMAKE 8 9SED_FEATURE_VERSION=4.2 10AC_DEFINE_UNQUOTED(SED_FEATURE_VERSION, "$SED_FEATURE_VERSION", 11 [Define to the version of GNU sed whose features are supported by this sed.]) 12AC_SUBST(SED_FEATURE_VERSION) 13 14COPYRIGHT_YEAR=2009 15AC_DEFINE_UNQUOTED(COPYRIGHT_YEAR, $COPYRIGHT_YEAR, 16 [Define to the copyright year printed by --version.]) 17AC_SUBST(COPYRIGHT_YEAR) 18 19AC_PROG_CC 20gl_EARLY 21gl_INIT 22gl_DISABLE_THREADS 23AC_SYS_LONG_FILE_NAMES 24AC_CACHE_CHECK([whether -lcP is needed], [sed_cv_libcp_needed], [ 25AC_TRY_RUN([ 26#include <stdio.h> 27#include <errno.h> 28 29int main() 30{ 31 FILE *fp; 32 int result; 33 errno = 0; 34 fp = fopen ("conftest.c", "r"); 35 if (!fp) return 0; /* error, assume not needed */ 36 result = fflush (fp) == EOF && errno == 0; 37 fclose (fp); 38 return result; 39}], [sed_cv_libcp_needed=no], 40 [sed_cv_libcp_needed=yes], 41 [sed_cv_libcp_needed="assuming no"]) 42]) 43if test "$sed_cv_libcp_needed" = yes; then 44 LIBS="-lcP $LIBS" 45fi 46 47AC_HEADER_DIRENT 48AC_CHECK_HEADERS_ONCE(io.h limits.h locale.h stdarg.h alloca.h stddef.h 49 errno.h wchar.h wctype.h sys/file.h mcheck.h, [], [], 50 [AC_INCLUDES_DEFAULT]) 51AC_C_CONST 52AC_TYPE_SIZE_T 53AC_CHECK_TYPE(ssize_t, int) 54 55AC_FUNC_VPRINTF 56 57AC_DEFUN([AM_MKINSTALLDIRS], [MKINSTALLDIRS="$mkdir_p" AC_SUBST(MKINSTALLDIRS)]) 58AM_GNU_GETTEXT_VERSION(0.15) 59AM_GNU_GETTEXT([external]) 60 61AC_CHECK_FUNCS_ONCE(isatty bcopy bzero isascii memcpy memset strchr strtoul 62 popen pathconf fchown fchmod setlocale) 63 64AC_ARG_ENABLE(i18n, 65[ --disable-i18n disable internationalization (default=enabled)], , 66enable_i18n=yes) 67if test "x$enable_i18n" = xno; then 68 ac_cv_func_wcscoll=false 69fi 70 71AC_ARG_ENABLE(regex-tests, 72[ --enable-regex-tests enable regex matcher regression tests (default=yes)], 73[if test "x$with_included_regex" = xno; then 74 enable_regex_tests=no 75fi], 76enable_regex_tests=$with_included_regex) 77 78AM_CONDITIONAL(TEST_REGEX, test "x$enable_regex_tests" = xyes) 79if test "x$enable_regex_tests" = xyes; then 80 AC_DEFINE_UNQUOTED(_REGEX_RE_COMP, 1, 81 [Include BSD functions in regex, used by the testsuite]) 82fi 83 84# Check whether we are able to follow symlinks 85AC_CHECK_FUNC(lstat, have_lstat=yes) 86AC_CHECK_FUNC(readlink, have_readlink=yes) 87if test "x$have_lstat" = xyes -a "x$have_readlink" = xyes; then 88 AC_DEFINE(ENABLE_FOLLOW_SYMLINKS, ,[Follow symlinks when processing in place]) 89fi 90 91# Determine whether we should run UTF-8 tests by checking if cyrillic 92# letters are case-folded properly. The test for UTF-8 locales (bot 93# in general and specifically for a Russian one) is a bit weak, but it 94# should match exactly what is done in the testsuite. In fact, sed's 95# logic is portable (though testing it requires care) so it is enough to 96# have a couple of platforms where these tests pass. Right now, only 97# Windows and HP/UX do not support the tests. 98AC_MSG_CHECKING([whether UTF-8 case folding tests should pass]) 99AC_TRY_RUN([ 100#include <locale.h> 101#include <string.h> 102#include <stdlib.h> 103#include <wchar.h> 104#ifdef HAVE_WCTYPE_H 105#include <wctype.h> 106#endif 107 108int test(void) 109{ 110 char in[] = "\xD0\xB4"; 111 char good[] = "\xD0\x94"; 112 char out[10]; 113 wchar_t in_wc, good_wc; 114 if (mbtowc (&in_wc, in, 3) == -1) 115 return 0; 116 if (mbtowc (&good_wc, good, 3) == -1) 117 return 0; 118 if (towupper (in_wc) != good_wc) 119 return 0; 120 if (wctomb (out, good_wc) != 2) 121 return 0; 122 if (memcmp (out, good, 2)) 123 return 0; 124 return 1; 125} 126 127int main() 128{ 129 char *old; 130 int len; 131 132 /* Try hardcoding a Russian UTF-8 locale. If the name "ru_RU.UTF-8" 133 is invalid, use setlocale again just to get the current locale. */ 134 old = setlocale (LC_CTYPE, "ru_RU.UTF-8"); 135 if (old) 136 { 137 if (test()) 138 exit (0); 139 } 140 else 141 old = setlocale (LC_CTYPE, "C"); 142 143 /* Maybe cyrillic case folding is implemented for all UTF-8 locales. 144 If the current locale is not UTF-8, the test will be skipped. */ 145 len = strlen (old); 146 if ((len > 6 && !strcmp (old + len - 6, ".UTF-8")) 147 || (len > 6 && !strcmp (old + len - 6, ".utf-8")) 148 || (len > 5 && !strcmp (old + len - 5, ".UTF8")) 149 || (len > 5 && !strcmp (old + len - 5, ".utf8"))) 150 151 /* ok */ 152 ; 153 else 154 exit (1); 155 156 /* Run the test in the detected UTF-8 locale. */ 157 setlocale (LC_CTYPE, old); 158 exit (!test ()); 159} 160], [AC_MSG_RESULT([yes]); XFAIL_TESTS=], 161 [AC_MSG_RESULT([no]); XFAIL_TESTS='utf8-1 utf8-2 utf8-3 utf8-4'], 162 [AC_MSG_RESULT([don't care (cross compiling)]); XFAIL_TESTS=]) 163 164# Under MinGW, the bsd.sh test fails because of the EOF character (^Z). 165case $host in 166 *mingw*) XFAIL_TESTS="$XFAIL_TESTS bsd" ;; 167 *) ;; 168esac 169AC_SUBST([XFAIL_TESTS]) 170 171AC_CONFIG_FILES([bootstrap.sh], chmod +x bootstrap.sh) 172AC_CONFIG_FILES([testsuite/version.good:testsuite/version.gin]) 173AC_CONFIG_FILES([Makefile doc/Makefile \ 174lib/Makefile sed/Makefile testsuite/Makefile \ 175po/Makefile.in]) 176AC_OUTPUT 177