Blame m4/wchar_h.m4

Packit Service c3aa71
dnl A placeholder for ISO C99 <wchar.h>, for platforms that have issues.
Packit Service c3aa71
Packit Service c3aa71
dnl Copyright (C) 2007-2015 Free Software Foundation, Inc.
Packit Service c3aa71
dnl This file is free software; the Free Software Foundation
Packit Service c3aa71
dnl gives unlimited permission to copy and/or distribute it,
Packit Service c3aa71
dnl with or without modifications, as long as this notice is preserved.
Packit Service c3aa71
Packit Service c3aa71
dnl Written by Eric Blake.
Packit Service c3aa71
Packit Service c3aa71
# wchar_h.m4 serial 39
Packit Service c3aa71
Packit Service c3aa71
AC_DEFUN([gl_WCHAR_H],
Packit Service c3aa71
[
Packit Service c3aa71
  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
Packit Service c3aa71
  AC_REQUIRE([gl_WCHAR_H_INLINE_OK])
Packit Service c3aa71
  dnl Prepare for creating substitute <wchar.h>.
Packit Service c3aa71
  dnl Check for <wchar.h> (missing in Linux uClibc when built without wide
Packit Service c3aa71
  dnl character support).
Packit Service c3aa71
  dnl <wchar.h> is always overridden, because of GNULIB_POSIXCHECK.
Packit Service c3aa71
  gl_CHECK_NEXT_HEADERS([wchar.h])
Packit Service c3aa71
  if test $ac_cv_header_wchar_h = yes; then
Packit Service c3aa71
    HAVE_WCHAR_H=1
Packit Service c3aa71
  else
Packit Service c3aa71
    HAVE_WCHAR_H=0
Packit Service c3aa71
  fi
Packit Service c3aa71
  AC_SUBST([HAVE_WCHAR_H])
Packit Service c3aa71
Packit Service c3aa71
  AC_REQUIRE([gl_FEATURES_H])
Packit Service c3aa71
Packit Service c3aa71
  AC_REQUIRE([gt_TYPE_WINT_T])
Packit Service c3aa71
  if test $gt_cv_c_wint_t = yes; then
Packit Service c3aa71
    HAVE_WINT_T=1
Packit Service c3aa71
  else
Packit Service c3aa71
    HAVE_WINT_T=0
Packit Service c3aa71
  fi
Packit Service c3aa71
  AC_SUBST([HAVE_WINT_T])
Packit Service c3aa71
Packit Service c3aa71
  dnl Check for declarations of anything we want to poison if the
Packit Service c3aa71
  dnl corresponding gnulib module is not in use.
Packit Service c3aa71
  gl_WARN_ON_USE_PREPARE([[
Packit Service c3aa71
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
Packit Service c3aa71
   <wchar.h>.
Packit Service c3aa71
   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
Packit Service c3aa71
   included before <wchar.h>.  */
Packit Service c3aa71
#if !(defined __GLIBC__ && !defined __UCLIBC__)
Packit Service c3aa71
# include <stddef.h>
Packit Service c3aa71
# include <stdio.h>
Packit Service c3aa71
# include <time.h>
Packit Service c3aa71
#endif
Packit Service c3aa71
#include <wchar.h>
Packit Service c3aa71
    ]],
Packit Service c3aa71
    [btowc wctob mbsinit mbrtowc mbrlen mbsrtowcs mbsnrtowcs wcrtomb
Packit Service c3aa71
     wcsrtombs wcsnrtombs wcwidth wmemchr wmemcmp wmemcpy wmemmove wmemset
Packit Service c3aa71
     wcslen wcsnlen wcscpy wcpcpy wcsncpy wcpncpy wcscat wcsncat wcscmp
Packit Service c3aa71
     wcsncmp wcscasecmp wcsncasecmp wcscoll wcsxfrm wcsdup wcschr wcsrchr
Packit Service c3aa71
     wcscspn wcsspn wcspbrk wcsstr wcstok wcswidth
Packit Service c3aa71
    ])
Packit Service c3aa71
])
Packit Service c3aa71
Packit Service c3aa71
dnl Check whether <wchar.h> is usable at all.
Packit Service c3aa71
AC_DEFUN([gl_WCHAR_H_INLINE_OK],
Packit Service c3aa71
[
Packit Service c3aa71
  dnl Test whether <wchar.h> suffers due to the transition from '__inline' to
Packit Service c3aa71
  dnl 'gnu_inline'. See <http://sourceware.org/bugzilla/show_bug.cgi?id=4022>
Packit Service c3aa71
  dnl and <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42440>. In summary,
Packit Service c3aa71
  dnl glibc version 2.5 or older, together with gcc version 4.3 or newer and
Packit Service c3aa71
  dnl the option -std=c99 or -std=gnu99, leads to a broken <wchar.h>.
Packit Service c3aa71
  AC_CACHE_CHECK([whether <wchar.h> uses 'inline' correctly],
Packit Service c3aa71
    [gl_cv_header_wchar_h_correct_inline],
Packit Service c3aa71
    [gl_cv_header_wchar_h_correct_inline=yes
Packit Service c3aa71
     AC_LANG_CONFTEST([
Packit Service c3aa71
       AC_LANG_SOURCE([[#define wcstod renamed_wcstod
Packit Service c3aa71
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
Packit Service c3aa71
   <wchar.h>.
Packit Service c3aa71
   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
Packit Service c3aa71
   included before <wchar.h>.  */
Packit Service c3aa71
#include <stddef.h>
Packit Service c3aa71
#include <stdio.h>
Packit Service c3aa71
#include <time.h>
Packit Service c3aa71
#include <wchar.h>
Packit Service c3aa71
extern int zero (void);
Packit Service c3aa71
int main () { return zero(); }
Packit Service c3aa71
]])])
Packit Service c3aa71
     if AC_TRY_EVAL([ac_compile]); then
Packit Service c3aa71
       mv conftest.$ac_objext conftest1.$ac_objext
Packit Service c3aa71
       AC_LANG_CONFTEST([
Packit Service c3aa71
         AC_LANG_SOURCE([[#define wcstod renamed_wcstod
Packit Service c3aa71
/* Tru64 with Desktop Toolkit C has a bug: <stdio.h> must be included before
Packit Service c3aa71
   <wchar.h>.
Packit Service c3aa71
   BSD/OS 4.0.1 has a bug: <stddef.h>, <stdio.h> and <time.h> must be
Packit Service c3aa71
   included before <wchar.h>.  */
Packit Service c3aa71
#include <stddef.h>
Packit Service c3aa71
#include <stdio.h>
Packit Service c3aa71
#include <time.h>
Packit Service c3aa71
#include <wchar.h>
Packit Service c3aa71
int zero (void) { return 0; }
Packit Service c3aa71
]])])
Packit Service c3aa71
       if AC_TRY_EVAL([ac_compile]); then
Packit Service c3aa71
         mv conftest.$ac_objext conftest2.$ac_objext
Packit Service c3aa71
         if $CC -o conftest$ac_exeext $CFLAGS $LDFLAGS conftest1.$ac_objext conftest2.$ac_objext $LIBS >&AS_MESSAGE_LOG_FD 2>&1; then
Packit Service c3aa71
           :
Packit Service c3aa71
         else
Packit Service c3aa71
           gl_cv_header_wchar_h_correct_inline=no
Packit Service c3aa71
         fi
Packit Service c3aa71
       fi
Packit Service c3aa71
     fi
Packit Service c3aa71
     rm -f conftest1.$ac_objext conftest2.$ac_objext conftest$ac_exeext
Packit Service c3aa71
    ])
Packit Service c3aa71
  if test $gl_cv_header_wchar_h_correct_inline = no; then
Packit Service c3aa71
    AC_MSG_ERROR([<wchar.h> cannot be used with this compiler ($CC $CFLAGS $CPPFLAGS).
Packit Service c3aa71
This is a known interoperability problem of glibc <= 2.5 with gcc >= 4.3 in
Packit Service c3aa71
C99 mode. You have four options:
Packit Service c3aa71
  - Add the flag -fgnu89-inline to CC and reconfigure, or
Packit Service c3aa71
  - Fix your include files, using parts of
Packit Service c3aa71
    <http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=b037a293a48718af30d706c2e18c929d0e69a621>, or
Packit Service c3aa71
  - Use a gcc version older than 4.3, or
Packit Service c3aa71
  - Don't use the flags -std=c99 or -std=gnu99.
Packit Service c3aa71
Configuration aborted.])
Packit Service c3aa71
  fi
Packit Service c3aa71
])
Packit Service c3aa71
Packit Service c3aa71
AC_DEFUN([gl_WCHAR_MODULE_INDICATOR],
Packit Service c3aa71
[
Packit Service c3aa71
  dnl Use AC_REQUIRE here, so that the default settings are expanded once only.
Packit Service c3aa71
  AC_REQUIRE([gl_WCHAR_H_DEFAULTS])
Packit Service c3aa71
  gl_MODULE_INDICATOR_SET_VARIABLE([$1])
Packit Service c3aa71
  dnl Define it also as a C macro, for the benefit of the unit tests.
Packit Service c3aa71
  gl_MODULE_INDICATOR_FOR_TESTS([$1])
Packit Service c3aa71
])
Packit Service c3aa71
Packit Service c3aa71
AC_DEFUN([gl_WCHAR_H_DEFAULTS],
Packit Service c3aa71
[
Packit Service c3aa71
  GNULIB_BTOWC=0;       AC_SUBST([GNULIB_BTOWC])
Packit Service c3aa71
  GNULIB_WCTOB=0;       AC_SUBST([GNULIB_WCTOB])
Packit Service c3aa71
  GNULIB_MBSINIT=0;     AC_SUBST([GNULIB_MBSINIT])
Packit Service c3aa71
  GNULIB_MBRTOWC=0;     AC_SUBST([GNULIB_MBRTOWC])
Packit Service c3aa71
  GNULIB_MBRLEN=0;      AC_SUBST([GNULIB_MBRLEN])
Packit Service c3aa71
  GNULIB_MBSRTOWCS=0;   AC_SUBST([GNULIB_MBSRTOWCS])
Packit Service c3aa71
  GNULIB_MBSNRTOWCS=0;  AC_SUBST([GNULIB_MBSNRTOWCS])
Packit Service c3aa71
  GNULIB_WCRTOMB=0;     AC_SUBST([GNULIB_WCRTOMB])
Packit Service c3aa71
  GNULIB_WCSRTOMBS=0;   AC_SUBST([GNULIB_WCSRTOMBS])
Packit Service c3aa71
  GNULIB_WCSNRTOMBS=0;  AC_SUBST([GNULIB_WCSNRTOMBS])
Packit Service c3aa71
  GNULIB_WCWIDTH=0;     AC_SUBST([GNULIB_WCWIDTH])
Packit Service c3aa71
  GNULIB_WMEMCHR=0;     AC_SUBST([GNULIB_WMEMCHR])
Packit Service c3aa71
  GNULIB_WMEMCMP=0;     AC_SUBST([GNULIB_WMEMCMP])
Packit Service c3aa71
  GNULIB_WMEMCPY=0;     AC_SUBST([GNULIB_WMEMCPY])
Packit Service c3aa71
  GNULIB_WMEMMOVE=0;    AC_SUBST([GNULIB_WMEMMOVE])
Packit Service c3aa71
  GNULIB_WMEMSET=0;     AC_SUBST([GNULIB_WMEMSET])
Packit Service c3aa71
  GNULIB_WCSLEN=0;      AC_SUBST([GNULIB_WCSLEN])
Packit Service c3aa71
  GNULIB_WCSNLEN=0;     AC_SUBST([GNULIB_WCSNLEN])
Packit Service c3aa71
  GNULIB_WCSCPY=0;      AC_SUBST([GNULIB_WCSCPY])
Packit Service c3aa71
  GNULIB_WCPCPY=0;      AC_SUBST([GNULIB_WCPCPY])
Packit Service c3aa71
  GNULIB_WCSNCPY=0;     AC_SUBST([GNULIB_WCSNCPY])
Packit Service c3aa71
  GNULIB_WCPNCPY=0;     AC_SUBST([GNULIB_WCPNCPY])
Packit Service c3aa71
  GNULIB_WCSCAT=0;      AC_SUBST([GNULIB_WCSCAT])
Packit Service c3aa71
  GNULIB_WCSNCAT=0;     AC_SUBST([GNULIB_WCSNCAT])
Packit Service c3aa71
  GNULIB_WCSCMP=0;      AC_SUBST([GNULIB_WCSCMP])
Packit Service c3aa71
  GNULIB_WCSNCMP=0;     AC_SUBST([GNULIB_WCSNCMP])
Packit Service c3aa71
  GNULIB_WCSCASECMP=0;  AC_SUBST([GNULIB_WCSCASECMP])
Packit Service c3aa71
  GNULIB_WCSNCASECMP=0; AC_SUBST([GNULIB_WCSNCASECMP])
Packit Service c3aa71
  GNULIB_WCSCOLL=0;     AC_SUBST([GNULIB_WCSCOLL])
Packit Service c3aa71
  GNULIB_WCSXFRM=0;     AC_SUBST([GNULIB_WCSXFRM])
Packit Service c3aa71
  GNULIB_WCSDUP=0;      AC_SUBST([GNULIB_WCSDUP])
Packit Service c3aa71
  GNULIB_WCSCHR=0;      AC_SUBST([GNULIB_WCSCHR])
Packit Service c3aa71
  GNULIB_WCSRCHR=0;     AC_SUBST([GNULIB_WCSRCHR])
Packit Service c3aa71
  GNULIB_WCSCSPN=0;     AC_SUBST([GNULIB_WCSCSPN])
Packit Service c3aa71
  GNULIB_WCSSPN=0;      AC_SUBST([GNULIB_WCSSPN])
Packit Service c3aa71
  GNULIB_WCSPBRK=0;     AC_SUBST([GNULIB_WCSPBRK])
Packit Service c3aa71
  GNULIB_WCSSTR=0;      AC_SUBST([GNULIB_WCSSTR])
Packit Service c3aa71
  GNULIB_WCSTOK=0;      AC_SUBST([GNULIB_WCSTOK])
Packit Service c3aa71
  GNULIB_WCSWIDTH=0;    AC_SUBST([GNULIB_WCSWIDTH])
Packit Service c3aa71
  dnl Assume proper GNU behavior unless another module says otherwise.
Packit Service c3aa71
  HAVE_BTOWC=1;         AC_SUBST([HAVE_BTOWC])
Packit Service c3aa71
  HAVE_MBSINIT=1;       AC_SUBST([HAVE_MBSINIT])
Packit Service c3aa71
  HAVE_MBRTOWC=1;       AC_SUBST([HAVE_MBRTOWC])
Packit Service c3aa71
  HAVE_MBRLEN=1;        AC_SUBST([HAVE_MBRLEN])
Packit Service c3aa71
  HAVE_MBSRTOWCS=1;     AC_SUBST([HAVE_MBSRTOWCS])
Packit Service c3aa71
  HAVE_MBSNRTOWCS=1;    AC_SUBST([HAVE_MBSNRTOWCS])
Packit Service c3aa71
  HAVE_WCRTOMB=1;       AC_SUBST([HAVE_WCRTOMB])
Packit Service c3aa71
  HAVE_WCSRTOMBS=1;     AC_SUBST([HAVE_WCSRTOMBS])
Packit Service c3aa71
  HAVE_WCSNRTOMBS=1;    AC_SUBST([HAVE_WCSNRTOMBS])
Packit Service c3aa71
  HAVE_WMEMCHR=1;       AC_SUBST([HAVE_WMEMCHR])
Packit Service c3aa71
  HAVE_WMEMCMP=1;       AC_SUBST([HAVE_WMEMCMP])
Packit Service c3aa71
  HAVE_WMEMCPY=1;       AC_SUBST([HAVE_WMEMCPY])
Packit Service c3aa71
  HAVE_WMEMMOVE=1;      AC_SUBST([HAVE_WMEMMOVE])
Packit Service c3aa71
  HAVE_WMEMSET=1;       AC_SUBST([HAVE_WMEMSET])
Packit Service c3aa71
  HAVE_WCSLEN=1;        AC_SUBST([HAVE_WCSLEN])
Packit Service c3aa71
  HAVE_WCSNLEN=1;       AC_SUBST([HAVE_WCSNLEN])
Packit Service c3aa71
  HAVE_WCSCPY=1;        AC_SUBST([HAVE_WCSCPY])
Packit Service c3aa71
  HAVE_WCPCPY=1;        AC_SUBST([HAVE_WCPCPY])
Packit Service c3aa71
  HAVE_WCSNCPY=1;       AC_SUBST([HAVE_WCSNCPY])
Packit Service c3aa71
  HAVE_WCPNCPY=1;       AC_SUBST([HAVE_WCPNCPY])
Packit Service c3aa71
  HAVE_WCSCAT=1;        AC_SUBST([HAVE_WCSCAT])
Packit Service c3aa71
  HAVE_WCSNCAT=1;       AC_SUBST([HAVE_WCSNCAT])
Packit Service c3aa71
  HAVE_WCSCMP=1;        AC_SUBST([HAVE_WCSCMP])
Packit Service c3aa71
  HAVE_WCSNCMP=1;       AC_SUBST([HAVE_WCSNCMP])
Packit Service c3aa71
  HAVE_WCSCASECMP=1;    AC_SUBST([HAVE_WCSCASECMP])
Packit Service c3aa71
  HAVE_WCSNCASECMP=1;   AC_SUBST([HAVE_WCSNCASECMP])
Packit Service c3aa71
  HAVE_WCSCOLL=1;       AC_SUBST([HAVE_WCSCOLL])
Packit Service c3aa71
  HAVE_WCSXFRM=1;       AC_SUBST([HAVE_WCSXFRM])
Packit Service c3aa71
  HAVE_WCSDUP=1;        AC_SUBST([HAVE_WCSDUP])
Packit Service c3aa71
  HAVE_WCSCHR=1;        AC_SUBST([HAVE_WCSCHR])
Packit Service c3aa71
  HAVE_WCSRCHR=1;       AC_SUBST([HAVE_WCSRCHR])
Packit Service c3aa71
  HAVE_WCSCSPN=1;       AC_SUBST([HAVE_WCSCSPN])
Packit Service c3aa71
  HAVE_WCSSPN=1;        AC_SUBST([HAVE_WCSSPN])
Packit Service c3aa71
  HAVE_WCSPBRK=1;       AC_SUBST([HAVE_WCSPBRK])
Packit Service c3aa71
  HAVE_WCSSTR=1;        AC_SUBST([HAVE_WCSSTR])
Packit Service c3aa71
  HAVE_WCSTOK=1;        AC_SUBST([HAVE_WCSTOK])
Packit Service c3aa71
  HAVE_WCSWIDTH=1;      AC_SUBST([HAVE_WCSWIDTH])
Packit Service c3aa71
  HAVE_DECL_WCTOB=1;    AC_SUBST([HAVE_DECL_WCTOB])
Packit Service c3aa71
  HAVE_DECL_WCWIDTH=1;  AC_SUBST([HAVE_DECL_WCWIDTH])
Packit Service c3aa71
  REPLACE_MBSTATE_T=0;  AC_SUBST([REPLACE_MBSTATE_T])
Packit Service c3aa71
  REPLACE_BTOWC=0;      AC_SUBST([REPLACE_BTOWC])
Packit Service c3aa71
  REPLACE_WCTOB=0;      AC_SUBST([REPLACE_WCTOB])
Packit Service c3aa71
  REPLACE_MBSINIT=0;    AC_SUBST([REPLACE_MBSINIT])
Packit Service c3aa71
  REPLACE_MBRTOWC=0;    AC_SUBST([REPLACE_MBRTOWC])
Packit Service c3aa71
  REPLACE_MBRLEN=0;     AC_SUBST([REPLACE_MBRLEN])
Packit Service c3aa71
  REPLACE_MBSRTOWCS=0;  AC_SUBST([REPLACE_MBSRTOWCS])
Packit Service c3aa71
  REPLACE_MBSNRTOWCS=0; AC_SUBST([REPLACE_MBSNRTOWCS])
Packit Service c3aa71
  REPLACE_WCRTOMB=0;    AC_SUBST([REPLACE_WCRTOMB])
Packit Service c3aa71
  REPLACE_WCSRTOMBS=0;  AC_SUBST([REPLACE_WCSRTOMBS])
Packit Service c3aa71
  REPLACE_WCSNRTOMBS=0; AC_SUBST([REPLACE_WCSNRTOMBS])
Packit Service c3aa71
  REPLACE_WCWIDTH=0;    AC_SUBST([REPLACE_WCWIDTH])
Packit Service c3aa71
  REPLACE_WCSWIDTH=0;   AC_SUBST([REPLACE_WCSWIDTH])
Packit Service c3aa71
])