Blame m4/wchar_h.m4

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