File: libclocale.m4

package info (click to toggle)
libbfio 20140105-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 8,800 kB
  • ctags: 2,962
  • sloc: ansic: 95,778; sh: 11,974; makefile: 714; sed: 16
file content (257 lines) | stat: -rw-r--r-- 6,091 bytes parent folder | download | duplicates (27)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
dnl Functions for libclocale
dnl
dnl Version: 20130406

dnl Function to detect if libclocale is available
dnl ac_libclocale_dummy is used to prevent AC_CHECK_LIB adding unnecessary -l<library> arguments
AC_DEFUN([AX_LIBCLOCALE_CHECK_LIB],
 [dnl Check if parameters were provided
 AS_IF(
  [test "x$ac_cv_with_libclocale" != x && test "x$ac_cv_with_libclocale" != xno && test "x$ac_cv_with_libclocale" != xauto-detect],
  [AS_IF(
   [test -d "$ac_cv_with_libclocale"],
   [CFLAGS="$CFLAGS -I${ac_cv_with_libclocale}/include"
   LDFLAGS="$LDFLAGS -L${ac_cv_with_libclocale}/lib"],
   [AC_MSG_WARN([no such directory: $ac_cv_with_libclocale])
   ])
  ])

 AS_IF(
  [test "x$ac_cv_with_libclocale" = xno],
  [ac_cv_libclocale=no],
  [dnl Check for a pkg-config file
  AS_IF(
   [test "x$cross_compiling" != "xyes" && test "x$PKGCONFIG" != "x"],
   [PKG_CHECK_MODULES(
    [libclocale],
    [libclocale >= 20120425],
    [ac_cv_libclocale=yes],
    [ac_cv_libclocale=no])
   ])

  AS_IF(
   [test "x$ac_cv_libclocale" = xyes],
   [ac_cv_libclocale_CPPFLAGS="$pkg_cv_libclocale_CFLAGS"
   ac_cv_libclocale_LIBADD="$pkg_cv_libclocale_LIBS"],
   [dnl Check for headers
   AC_CHECK_HEADERS([libclocale.h])

   AS_IF(
    [test "x$ac_cv_header_libclocale_h" = xno],
    [ac_cv_libclocale=no],
    [dnl Check for the individual functions
    ac_cv_libclocale=yes

    AC_CHECK_LIB(
     clocale,
     libclocale_get_version,
     [ac_cv_libclocale_dummy=yes],
     [ac_cv_libclocale=no])

    dnl Codepage functions
    AC_CHECK_LIB(
     clocale,
     libclocale_codepage,
     [ac_cv_libclocale_dummy=yes],
     [ac_cv_libclocale=no])
    AC_CHECK_LIB(
     clocale,
     libclocale_codepage_get,
     [ac_cv_libclocale_dummy=yes],
     [ac_cv_libclocale=no])
    AC_CHECK_LIB(
     clocale,
     libclocale_codepage_set,
     [ac_cv_libclocale_dummy=yes],
     [ac_cv_libclocale=no])
    AC_CHECK_LIB(
     clocale,
     libclocale_codepage_copy_from_string,
     [ac_cv_libclocale_dummy=yes],
     [ac_cv_libclocale=no])

   AS_IF(
    [test "x$ac_cv_enable_wide_character_type" != xno],
    [AC_CHECK_LIB(
     clocale,
     libclocale_codepage_copy_from_string_wide,
     [ac_cv_libclocale_dummy=yes],
     [ac_cv_libclocale=no])
    ])

    dnl Locale functions
    AC_CHECK_LIB(
     clocale,
     libclocale_locale_get_codepage,
     [ac_cv_libclocale_dummy=yes],
     [ac_cv_libclocale=no])
    AC_CHECK_LIB(
     clocale,
     libclocale_locale_get_decimal_point,
     [ac_cv_libclocale_dummy=yes],
     [ac_cv_libclocale=no])

    dnl Support functions
    AC_CHECK_LIB(
     clocale,
     libclocale_initialize,
     [ac_cv_libclocale_dummy=yes],
     [ac_cv_libclocale=no])

    ac_cv_libclocale_LIBADD="-lclocale"
    ])
   ])
  ])

 AS_IF(
  [test "x$ac_cv_libclocale" = xyes],
  [AC_DEFINE(
   [HAVE_LIBCLOCALE],
   [1],
   [Define to 1 if you have the `clocale' library (-lclocale).])
  ])

 AS_IF(
  [test "x$ac_cv_libclocale" = xyes],
  [AC_SUBST(
   [HAVE_LIBCLOCALE],
   [1]) ],
  [AC_SUBST(
   [HAVE_LIBCLOCALE],
   [0])
  ])
 ])

dnl Function to detect whether nl_langinfo supports CODESET
AC_DEFUN([AX_LIBCLOCALE_CHECK_FUNC_LANGINFO_CODESET],
 [AC_CHECK_FUNCS([nl_langinfo])

 AS_IF(
  [test "x$ac_cv_func_nl_langinfo" = xyes],
  [AC_CACHE_CHECK(
   [for nl_langinfo CODESET support],
   [ac_cv_cv_langinfo_codeset],
   [AC_LANG_PUSH(C)
   AC_LINK_IFELSE(
    [AC_LANG_PROGRAM(
     [[#include <langinfo.h>]],
     [[char* charset = nl_langinfo( CODESET );]] )],
    [ac_cv_cv_langinfo_codeset=yes],
    [ac_cv_cv_langinfo_codeset=no])
   AC_LANG_POP(C) ]) ],
  [ac_cv_cv_langinfo_codeset=no])

 AS_IF(
  [test "x$ac_cv_cv_langinfo_codeset" = xyes],
  [AC_DEFINE(
   [HAVE_LANGINFO_CODESET],
   [1],
   [Define if nl_langinfo has CODESET support.])
  ])
 ])

dnl Function to detect if libclocale dependencies are available
AC_DEFUN([AX_LIBCLOCALE_CHECK_LOCAL],
 [dnl Headers included in libclocale/libclocale_locale.c
 AC_CHECK_HEADERS([langinfo.h locale.h])

 dnl Check for environment functions in libclocale/libclocale_locale.c
 AC_CHECK_FUNCS([getenv])

 AS_IF(
  [test "x$ac_cv_func_getenv" != xyes],
  [AC_MSG_FAILURE(
   [Missing function: getenv],
   [1])
  ])

 dnl Check for localization functions in libclocale/libclocale_locale.c
 AS_IF(
  [test "x$ac_cv_enable_winapi" = xno],
  [AC_CHECK_FUNCS([localeconv])

  AS_IF(
   [test "x$ac_cv_func_localeconv" != xyes],
   [AC_MSG_FAILURE(
    [Missing function: localeconv],
    [1])
   ])
  ])

 AC_CHECK_FUNCS([setlocale])

 AS_IF(
  [test "x$ac_cv_func_setlocale" != xyes],
  [AC_MSG_FAILURE(
   [Missing function: setlocale],
   [1])
  ])

 AX_LIBCLOCALE_CHECK_FUNC_LANGINFO_CODESET

 ac_cv_libclocale_CPPFLAGS="-I../libclocale";
 ac_cv_libclocale_LIBADD="../libclocale/libclocale.la";

 ac_cv_libclocale=local
 ])

dnl Function to detect how to enable libclocale
AC_DEFUN([AX_LIBCLOCALE_CHECK_ENABLE],
 [AX_COMMON_ARG_WITH(
  [libclocale],
  [libclocale],
  [search for libclocale in includedir and libdir or in the specified DIR, or no if to use local version],
  [auto-detect],
  [DIR])

 dnl Check for a shared library version
 AX_LIBCLOCALE_CHECK_LIB

 dnl Check if the dependencies for the local library version
 AS_IF(
  [test "x$ac_cv_libclocale" != xyes],
  [AX_LIBCLOCALE_CHECK_LOCAL

  AC_DEFINE(
   [HAVE_LOCAL_LIBCLOCALE],
   [1],
   [Define to 1 if the local version of libclocale is used.])
  AC_SUBST(
   [HAVE_LOCAL_LIBCLOCALE],
   [1])
  ])

 AM_CONDITIONAL(
  [HAVE_LOCAL_LIBCLOCALE],
  [test "x$ac_cv_libclocale" = xlocal])
 AS_IF(
  [test "x$ac_cv_libclocale_CPPFLAGS" != "x"],
  [AC_SUBST(
   [LIBCLOCALE_CPPFLAGS],
   [$ac_cv_libclocale_CPPFLAGS])
  ])
 AS_IF(
  [test "x$ac_cv_libclocale_LIBADD" != "x"],
  [AC_SUBST(
   [LIBCLOCALE_LIBADD],
   [$ac_cv_libclocale_LIBADD])
  ])

 AS_IF(
  [test "x$ac_cv_libclocale" = xyes],
  [AC_SUBST(
   [ax_libclocale_pc_libs_private],
   [-lclocale])
  ])

 AS_IF(
  [test "x$ac_cv_libclocale" = xyes],
  [AC_SUBST(
   [ax_libclocale_spec_requires],
   [libclocale])
  AC_SUBST(
   [ax_libclocale_spec_build_requires],
   [libclocale-devel])
  ])
 ])