2 dnl Copyright (C) 2007, 2009 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 AC_DEFUN([gl_LOCALE_H],
9 dnl Persuade glibc <locale.h> to define locale_t.
10 AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS])
12 dnl If <stddef.h> is replaced, then <locale.h> must also be replaced.
13 AC_REQUIRE([gl_STDDEF_H])
15 AC_CACHE_CHECK([whether locale.h conforms to POSIX:2001],
16 [gl_cv_header_locale_h_posix2001],
17 [AC_TRY_COMPILE([#include <locale.h>
18 int x = LC_MESSAGES;], [],
19 [gl_cv_header_locale_h_posix2001=yes],
20 [gl_cv_header_locale_h_posix2001=no])])
22 dnl Check for <xlocale.h>.
23 AC_CHECK_HEADERS_ONCE([xlocale.h])
24 if test $ac_cv_header_xlocale_h = yes; then
26 dnl Check whether use of locale_t requires inclusion of <xlocale.h>,
27 dnl e.g. on MacOS X 10.5. If <locale.h> does not define locale_t by
28 dnl itself, we assume that <xlocale.h> will do so.
29 AC_CACHE_CHECK([whether locale.h defines locale_t],
30 [gl_cv_header_locale_has_locale_t],
31 [AC_TRY_COMPILE([#include <locale.h>
33 [gl_cv_header_locale_has_locale_t=yes],
34 [gl_cv_header_locale_has_locale_t=no])
36 if test $gl_cv_header_locale_has_locale_t = yes; then
37 gl_cv_header_locale_h_needs_xlocale_h=no
39 gl_cv_header_locale_h_needs_xlocale_h=yes
43 gl_cv_header_locale_h_needs_xlocale_h=no
45 AC_SUBST([HAVE_XLOCALE_H])
47 if test -z "$STDDEF_H" \
48 && test $gl_cv_header_locale_h_posix2001 = yes \
49 && test $gl_cv_header_locale_h_needs_xlocale_h = no; then
52 gl_CHECK_NEXT_HEADERS([locale.h])