gettext.m4 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549
  1. # gettext.m4 serial 36 (gettext-0.14.3)
  2. dnl Copyright (C) 1995-2005 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.
  6. dnl
  7. dnl This file can can be used in projects which are not available under
  8. dnl the GNU General Public License or the GNU Library General Public
  9. dnl License but which still want to provide support for the GNU gettext
  10. dnl functionality.
  11. dnl Please note that the actual code of the GNU gettext library is covered
  12. dnl by the GNU Library General Public License, and the rest of the GNU
  13. dnl gettext package package is covered by the GNU General Public License.
  14. dnl They are *not* in the public domain.
  15. dnl Authors:
  16. dnl Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
  17. dnl Bruno Haible <haible@clisp.cons.org>, 2000-2003.
  18. dnl Macro to add for using GNU gettext.
  19. dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]).
  20. dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The
  21. dnl default (if it is not specified or empty) is 'no-libtool'.
  22. dnl INTLSYMBOL should be 'external' for packages with no intl directory,
  23. dnl and 'no-libtool' or 'use-libtool' for packages with an intl directory.
  24. dnl If INTLSYMBOL is 'use-libtool', then a libtool library
  25. dnl $(top_builddir)/intl/libintl.la will be created (shared and/or static,
  26. dnl depending on --{enable,disable}-{shared,static} and on the presence of
  27. dnl AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library
  28. dnl $(top_builddir)/intl/libintl.a will be created.
  29. dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
  30. dnl implementations (in libc or libintl) without the ngettext() function
  31. dnl will be ignored. If NEEDSYMBOL is specified and is
  32. dnl 'need-formatstring-macros', then GNU gettext implementations that don't
  33. dnl support the ISO C 99 <inttypes.h> formatstring macros will be ignored.
  34. dnl INTLDIR is used to find the intl libraries. If empty,
  35. dnl the value `$(top_builddir)/intl/' is used.
  36. dnl
  37. dnl The result of the configuration is one of three cases:
  38. dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
  39. dnl and used.
  40. dnl Catalog format: GNU --> install in $(datadir)
  41. dnl Catalog extension: .mo after installation, .gmo in source tree
  42. dnl 2) GNU gettext has been found in the system's C library.
  43. dnl Catalog format: GNU --> install in $(datadir)
  44. dnl Catalog extension: .mo after installation, .gmo in source tree
  45. dnl 3) No internationalization, always use English msgid.
  46. dnl Catalog format: none
  47. dnl Catalog extension: none
  48. dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur.
  49. dnl The use of .gmo is historical (it was needed to avoid overwriting the
  50. dnl GNU format catalogs when building on a platform with an X/Open gettext),
  51. dnl but we keep it in order not to force irrelevant filename changes on the
  52. dnl maintainers.
  53. dnl
  54. AC_DEFUN([AM_GNU_GETTEXT],
  55. [
  56. dnl Argument checking.
  57. ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], ,
  58. [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT
  59. ])])])])])
  60. ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], ,
  61. [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT
  62. ])])])])
  63. define([gt_included_intl], ifelse([$1], [external], [no], [yes]))
  64. define([gt_libtool_suffix_prefix], ifelse([$1], [use-libtool], [l], []))
  65. AC_REQUIRE([AM_PO_SUBDIRS])dnl
  66. ifelse(gt_included_intl, yes, [
  67. AC_REQUIRE([AM_INTL_SUBDIR])dnl
  68. ])
  69. dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
  70. AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
  71. AC_REQUIRE([AC_LIB_RPATH])
  72. dnl Sometimes libintl requires libiconv, so first search for libiconv.
  73. dnl Ideally we would do this search only after the
  74. dnl if test "$USE_NLS" = "yes"; then
  75. dnl if test "$gt_cv_func_gnugettext_libc" != "yes"; then
  76. dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT
  77. dnl the configure script would need to contain the same shell code
  78. dnl again, outside any 'if'. There are two solutions:
  79. dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'.
  80. dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE.
  81. dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not
  82. dnl documented, we avoid it.
  83. ifelse(gt_included_intl, yes, , [
  84. AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
  85. ])
  86. dnl Sometimes, on MacOS X, libintl requires linking with CoreFoundation.
  87. gt_INTL_MACOSX
  88. dnl Set USE_NLS.
  89. AM_NLS
  90. ifelse(gt_included_intl, yes, [
  91. BUILD_INCLUDED_LIBINTL=no
  92. USE_INCLUDED_LIBINTL=no
  93. ])
  94. LIBINTL=
  95. LTLIBINTL=
  96. POSUB=
  97. dnl If we use NLS figure out what method
  98. if test "$USE_NLS" = "yes"; then
  99. gt_use_preinstalled_gnugettext=no
  100. ifelse(gt_included_intl, yes, [
  101. AC_MSG_CHECKING([whether included gettext is requested])
  102. AC_ARG_WITH(included-gettext,
  103. [ --with-included-gettext use the GNU gettext library included here],
  104. nls_cv_force_use_gnu_gettext=$withval,
  105. nls_cv_force_use_gnu_gettext=no)
  106. AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
  107. nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
  108. if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
  109. ])
  110. dnl User does not insist on using GNU NLS library. Figure out what
  111. dnl to use. If GNU gettext is available we use this. Else we have
  112. dnl to fall back to GNU NLS library.
  113. dnl Add a version number to the cache macros.
  114. define([gt_api_version], ifelse([$2], [need-formatstring-macros], 3, ifelse([$2], [need-ngettext], 2, 1)))
  115. define([gt_cv_func_gnugettext_libc], [gt_cv_func_gnugettext]gt_api_version[_libc])
  116. define([gt_cv_func_gnugettext_libintl], [gt_cv_func_gnugettext]gt_api_version[_libintl])
  117. AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc,
  118. [AC_TRY_LINK([#include <libintl.h>
  119. ]ifelse([$2], [need-formatstring-macros],
  120. [#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
  121. #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
  122. #endif
  123. changequote(,)dnl
  124. typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
  125. changequote([,])dnl
  126. ], [])[extern int _nl_msg_cat_cntr;
  127. extern int *_nl_domain_bindings;],
  128. [bindtextdomain ("", "");
  129. return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_domain_bindings],
  130. gt_cv_func_gnugettext_libc=yes,
  131. gt_cv_func_gnugettext_libc=no)])
  132. if test "$gt_cv_func_gnugettext_libc" != "yes"; then
  133. dnl Sometimes libintl requires libiconv, so first search for libiconv.
  134. ifelse(gt_included_intl, yes, , [
  135. AM_ICONV_LINK
  136. ])
  137. dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL
  138. dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv])
  139. dnl because that would add "-liconv" to LIBINTL and LTLIBINTL
  140. dnl even if libiconv doesn't exist.
  141. AC_LIB_LINKFLAGS_BODY([intl])
  142. AC_CACHE_CHECK([for GNU gettext in libintl],
  143. gt_cv_func_gnugettext_libintl,
  144. [gt_save_CPPFLAGS="$CPPFLAGS"
  145. CPPFLAGS="$CPPFLAGS $INCINTL"
  146. gt_save_LIBS="$LIBS"
  147. LIBS="$LIBS $LIBINTL"
  148. dnl Now see whether libintl exists and does not depend on libiconv.
  149. AC_TRY_LINK([#include <libintl.h>
  150. ]ifelse([$2], [need-formatstring-macros],
  151. [#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
  152. #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
  153. #endif
  154. changequote(,)dnl
  155. typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
  156. changequote([,])dnl
  157. ], [])[extern int _nl_msg_cat_cntr;
  158. extern
  159. #ifdef __cplusplus
  160. "C"
  161. #endif
  162. const char *_nl_expand_alias (const char *);],
  163. [bindtextdomain ("", "");
  164. return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias ("")],
  165. gt_cv_func_gnugettext_libintl=yes,
  166. gt_cv_func_gnugettext_libintl=no)
  167. dnl Now see whether libintl exists and depends on libiconv.
  168. if test "$gt_cv_func_gnugettext_libintl" != yes && test -n "$LIBICONV"; then
  169. LIBS="$LIBS $LIBICONV"
  170. AC_TRY_LINK([#include <libintl.h>
  171. ]ifelse([$2], [need-formatstring-macros],
  172. [#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
  173. #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
  174. #endif
  175. changequote(,)dnl
  176. typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
  177. changequote([,])dnl
  178. ], [])[extern int _nl_msg_cat_cntr;
  179. extern
  180. #ifdef __cplusplus
  181. "C"
  182. #endif
  183. const char *_nl_expand_alias (const char *);],
  184. [bindtextdomain ("", "");
  185. return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias ("")],
  186. [LIBINTL="$LIBINTL $LIBICONV"
  187. LTLIBINTL="$LTLIBINTL $LTLIBICONV"
  188. gt_cv_func_gnugettext_libintl=yes
  189. ])
  190. fi
  191. CPPFLAGS="$gt_save_CPPFLAGS"
  192. LIBS="$gt_save_LIBS"])
  193. fi
  194. dnl If an already present or preinstalled GNU gettext() is found,
  195. dnl use it. But if this macro is used in GNU gettext, and GNU
  196. dnl gettext is already preinstalled in libintl, we update this
  197. dnl libintl. (Cf. the install rule in intl/Makefile.in.)
  198. if test "$gt_cv_func_gnugettext_libc" = "yes" \
  199. || { test "$gt_cv_func_gnugettext_libintl" = "yes" \
  200. && test "$PACKAGE" != gettext-runtime \
  201. && test "$PACKAGE" != gettext-tools; }; then
  202. gt_use_preinstalled_gnugettext=yes
  203. else
  204. dnl Reset the values set by searching for libintl.
  205. LIBINTL=
  206. LTLIBINTL=
  207. INCINTL=
  208. fi
  209. ifelse(gt_included_intl, yes, [
  210. if test "$gt_use_preinstalled_gnugettext" != "yes"; then
  211. dnl GNU gettext is not found in the C library.
  212. dnl Fall back on included GNU gettext library.
  213. nls_cv_use_gnu_gettext=yes
  214. fi
  215. fi
  216. if test "$nls_cv_use_gnu_gettext" = "yes"; then
  217. dnl Mark actions used to generate GNU NLS library.
  218. BUILD_INCLUDED_LIBINTL=yes
  219. USE_INCLUDED_LIBINTL=yes
  220. LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV"
  221. LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV"
  222. LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
  223. fi
  224. CATOBJEXT=
  225. if test "$gt_use_preinstalled_gnugettext" = "yes" \
  226. || test "$nls_cv_use_gnu_gettext" = "yes"; then
  227. dnl Mark actions to use GNU gettext tools.
  228. CATOBJEXT=.gmo
  229. fi
  230. ])
  231. if test -n "$INTL_MACOSX_LIBS"; then
  232. if test "$gt_use_preinstalled_gnugettext" = "yes" \
  233. || test "$nls_cv_use_gnu_gettext" = "yes"; then
  234. dnl Some extra flags are needed during linking.
  235. LIBINTL="$LIBINTL $INTL_MACOSX_LIBS"
  236. LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS"
  237. fi
  238. fi
  239. if test "$gt_use_preinstalled_gnugettext" = "yes" \
  240. || test "$nls_cv_use_gnu_gettext" = "yes"; then
  241. AC_DEFINE(ENABLE_NLS, 1,
  242. [Define to 1 if translation of program messages to the user's native language
  243. is requested.])
  244. else
  245. USE_NLS=no
  246. fi
  247. fi
  248. AC_MSG_CHECKING([whether to use NLS])
  249. AC_MSG_RESULT([$USE_NLS])
  250. if test "$USE_NLS" = "yes"; then
  251. AC_MSG_CHECKING([where the gettext function comes from])
  252. if test "$gt_use_preinstalled_gnugettext" = "yes"; then
  253. if test "$gt_cv_func_gnugettext_libintl" = "yes"; then
  254. gt_source="external libintl"
  255. else
  256. gt_source="libc"
  257. fi
  258. else
  259. gt_source="included intl directory"
  260. fi
  261. AC_MSG_RESULT([$gt_source])
  262. fi
  263. if test "$USE_NLS" = "yes"; then
  264. if test "$gt_use_preinstalled_gnugettext" = "yes"; then
  265. if test "$gt_cv_func_gnugettext_libintl" = "yes"; then
  266. AC_MSG_CHECKING([how to link with libintl])
  267. AC_MSG_RESULT([$LIBINTL])
  268. AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL])
  269. fi
  270. dnl For backward compatibility. Some packages may be using this.
  271. AC_DEFINE(HAVE_GETTEXT, 1,
  272. [Define if the GNU gettext() function is already present or preinstalled.])
  273. AC_DEFINE(HAVE_DCGETTEXT, 1,
  274. [Define if the GNU dcgettext() function is already present or preinstalled.])
  275. fi
  276. dnl We need to process the po/ directory.
  277. POSUB=po
  278. fi
  279. ifelse(gt_included_intl, yes, [
  280. dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
  281. dnl to 'yes' because some of the testsuite requires it.
  282. if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then
  283. BUILD_INCLUDED_LIBINTL=yes
  284. fi
  285. dnl Make all variables we use known to autoconf.
  286. AC_SUBST(BUILD_INCLUDED_LIBINTL)
  287. AC_SUBST(USE_INCLUDED_LIBINTL)
  288. AC_SUBST(CATOBJEXT)
  289. dnl For backward compatibility. Some configure.ins may be using this.
  290. nls_cv_header_intl=
  291. nls_cv_header_libgt=
  292. dnl For backward compatibility. Some Makefiles may be using this.
  293. DATADIRNAME=share
  294. AC_SUBST(DATADIRNAME)
  295. dnl For backward compatibility. Some Makefiles may be using this.
  296. INSTOBJEXT=.mo
  297. AC_SUBST(INSTOBJEXT)
  298. dnl For backward compatibility. Some Makefiles may be using this.
  299. GENCAT=gencat
  300. AC_SUBST(GENCAT)
  301. dnl For backward compatibility. Some Makefiles may be using this.
  302. INTLOBJS=
  303. if test "$USE_INCLUDED_LIBINTL" = yes; then
  304. INTLOBJS="\$(GETTOBJS)"
  305. fi
  306. AC_SUBST(INTLOBJS)
  307. dnl Enable libtool support if the surrounding package wishes it.
  308. INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix
  309. AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX)
  310. ])
  311. dnl For backward compatibility. Some Makefiles may be using this.
  312. INTLLIBS="$LIBINTL"
  313. AC_SUBST(INTLLIBS)
  314. dnl Make all documented variables known to autoconf.
  315. AC_SUBST(LIBINTL)
  316. AC_SUBST(LTLIBINTL)
  317. AC_SUBST(POSUB)
  318. ])
  319. dnl Checks for all prerequisites of the intl subdirectory,
  320. dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS,
  321. dnl USE_INCLUDED_LIBINTL, BUILD_INCLUDED_LIBINTL.
  322. AC_DEFUN([AM_INTL_SUBDIR],
  323. [
  324. AC_REQUIRE([AC_PROG_INSTALL])dnl
  325. AC_REQUIRE([AM_MKINSTALLDIRS])dnl
  326. AC_REQUIRE([AC_PROG_CC])dnl
  327. AC_REQUIRE([AC_CANONICAL_HOST])dnl
  328. AC_REQUIRE([gt_GLIBC2])dnl
  329. AC_REQUIRE([AC_PROG_RANLIB])dnl
  330. AC_REQUIRE([AC_ISC_POSIX])dnl
  331. AC_REQUIRE([AC_HEADER_STDC])dnl
  332. AC_REQUIRE([AC_C_CONST])dnl
  333. AC_REQUIRE([bh_C_SIGNED])dnl
  334. AC_REQUIRE([AC_C_INLINE])dnl
  335. AC_REQUIRE([AC_TYPE_OFF_T])dnl
  336. AC_REQUIRE([AC_TYPE_SIZE_T])dnl
  337. AC_REQUIRE([gl_AC_TYPE_LONG_LONG])dnl
  338. AC_REQUIRE([gt_TYPE_LONGDOUBLE])dnl
  339. AC_REQUIRE([gt_TYPE_WCHAR_T])dnl
  340. AC_REQUIRE([gt_TYPE_WINT_T])dnl
  341. AC_REQUIRE([gl_AC_HEADER_INTTYPES_H])
  342. AC_REQUIRE([gl_AC_HEADER_STDINT_H])
  343. AC_REQUIRE([gt_TYPE_INTMAX_T])
  344. AC_REQUIRE([gt_PRINTF_POSIX])
  345. AC_REQUIRE([AC_FUNC_ALLOCA])dnl
  346. AC_REQUIRE([AC_FUNC_MMAP])dnl
  347. AC_REQUIRE([gl_GLIBC21])dnl
  348. AC_REQUIRE([gt_INTDIV0])dnl
  349. AC_REQUIRE([gl_AC_TYPE_UINTMAX_T])dnl
  350. AC_REQUIRE([gt_HEADER_INTTYPES_H])dnl
  351. AC_REQUIRE([gt_INTTYPES_PRI])dnl
  352. AC_REQUIRE([gl_XSIZE])dnl
  353. AC_REQUIRE([gt_INTL_MACOSX])dnl
  354. AC_CHECK_TYPE([ptrdiff_t], ,
  355. [AC_DEFINE([ptrdiff_t], [long],
  356. [Define as the type of the result of subtracting two pointers, if the system doesn't define it.])
  357. ])
  358. AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
  359. stdlib.h string.h unistd.h sys/param.h])
  360. AC_CHECK_FUNCS([asprintf fwprintf getcwd getegid geteuid getgid getuid \
  361. mempcpy munmap putenv setenv setlocale snprintf stpcpy strcasecmp strdup \
  362. strtoul tsearch wcslen __argz_count __argz_stringify __argz_next \
  363. __fsetlocking])
  364. dnl Use the _snprintf function only if it is declared (because on NetBSD it
  365. dnl is defined as a weak alias of snprintf; we prefer to use the latter).
  366. gt_CHECK_DECL(_snprintf, [#include <stdio.h>])
  367. gt_CHECK_DECL(_snwprintf, [#include <stdio.h>])
  368. dnl Use the *_unlocked functions only if they are declared.
  369. dnl (because some of them were defined without being declared in Solaris
  370. dnl 2.5.1 but were removed in Solaris 2.6, whereas we want binaries built
  371. dnl on Solaris 2.5.1 to run on Solaris 2.6).
  372. dnl Don't use AC_CHECK_DECLS because it isn't supported in autoconf-2.13.
  373. gt_CHECK_DECL(feof_unlocked, [#include <stdio.h>])
  374. gt_CHECK_DECL(fgets_unlocked, [#include <stdio.h>])
  375. gt_CHECK_DECL(getc_unlocked, [#include <stdio.h>])
  376. case $gt_cv_func_printf_posix in
  377. *yes) HAVE_POSIX_PRINTF=1 ;;
  378. *) HAVE_POSIX_PRINTF=0 ;;
  379. esac
  380. AC_SUBST([HAVE_POSIX_PRINTF])
  381. if test "$ac_cv_func_asprintf" = yes; then
  382. HAVE_ASPRINTF=1
  383. else
  384. HAVE_ASPRINTF=0
  385. fi
  386. AC_SUBST([HAVE_ASPRINTF])
  387. if test "$ac_cv_func_snprintf" = yes; then
  388. HAVE_SNPRINTF=1
  389. else
  390. HAVE_SNPRINTF=0
  391. fi
  392. AC_SUBST([HAVE_SNPRINTF])
  393. if test "$ac_cv_func_wprintf" = yes; then
  394. HAVE_WPRINTF=1
  395. else
  396. HAVE_WPRINTF=0
  397. fi
  398. AC_SUBST([HAVE_WPRINTF])
  399. AM_ICONV
  400. AM_LANGINFO_CODESET
  401. if test $ac_cv_header_locale_h = yes; then
  402. gt_LC_MESSAGES
  403. fi
  404. if test -n "$INTL_MACOSX_LIBS"; then
  405. CPPFLAGS="$CPPFLAGS -I/System/Library/Frameworks/CoreFoundation.framework/Headers"
  406. fi
  407. dnl intl/plural.c is generated from intl/plural.y. It requires bison,
  408. dnl because plural.y uses bison specific features. It requires at least
  409. dnl bison-1.26 because earlier versions generate a plural.c that doesn't
  410. dnl compile.
  411. dnl bison is only needed for the maintainer (who touches plural.y). But in
  412. dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
  413. dnl the rule in general Makefile. Now, some people carelessly touch the
  414. dnl files or have a broken "make" program, hence the plural.c rule will
  415. dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
  416. dnl present or too old.
  417. AC_CHECK_PROGS([INTLBISON], [bison])
  418. if test -z "$INTLBISON"; then
  419. ac_verc_fail=yes
  420. else
  421. dnl Found it, now check the version.
  422. AC_MSG_CHECKING([version of bison])
  423. changequote(<<,>>)dnl
  424. ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
  425. case $ac_prog_version in
  426. '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
  427. 1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
  428. changequote([,])dnl
  429. ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
  430. *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
  431. esac
  432. AC_MSG_RESULT([$ac_prog_version])
  433. fi
  434. if test $ac_verc_fail = yes; then
  435. INTLBISON=:
  436. fi
  437. ])
  438. dnl Checks for special options needed on MacOS X.
  439. dnl Defines INTL_MACOSX_LIBS.
  440. AC_DEFUN([gt_INTL_MACOSX],
  441. [
  442. dnl Check for API introduced in MacOS X 10.2.
  443. AC_CACHE_CHECK([for CFPreferencesCopyAppValue],
  444. gt_cv_func_CFPreferencesCopyAppValue,
  445. [gt_save_CPPFLAGS="$CPPFLAGS"
  446. CPPFLAGS="$CPPFLAGS -I/System/Library/Frameworks/CoreFoundation.framework/Headers"
  447. gt_save_LIBS="$LIBS"
  448. LIBS="$LIBS -framework CoreFoundation"
  449. AC_TRY_LINK([#include <CFPreferences.h>],
  450. [CFPreferencesCopyAppValue(NULL, NULL)],
  451. [gt_cv_func_CFPreferencesCopyAppValue=yes],
  452. [gt_cv_func_CFPreferencesCopyAppValue=no])
  453. CPPFLAGS="$gt_save_CPPFLAGS"
  454. LIBS="$gt_save_LIBS"])
  455. if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then
  456. AC_DEFINE([HAVE_CFPREFERENCESCOPYAPPVALUE], 1,
  457. [Define to 1 if you have the MacOS X function CFPreferencesCopyAppValue in the CoreFoundation framework.])
  458. fi
  459. dnl Check for API introduced in MacOS X 10.3.
  460. AC_CACHE_CHECK([for CFLocaleCopyCurrent], gt_cv_func_CFLocaleCopyCurrent,
  461. [gt_save_CPPFLAGS="$CPPFLAGS"
  462. CPPFLAGS="$CPPFLAGS -I/System/Library/Frameworks/CoreFoundation.framework/Headers"
  463. gt_save_LIBS="$LIBS"
  464. LIBS="$LIBS -framework CoreFoundation"
  465. AC_TRY_LINK([#include <CFLocale.h>], [CFLocaleCopyCurrent();],
  466. [gt_cv_func_CFLocaleCopyCurrent=yes],
  467. [gt_cv_func_CFLocaleCopyCurrent=no])
  468. CPPFLAGS="$gt_save_CPPFLAGS"
  469. LIBS="$gt_save_LIBS"])
  470. if test $gt_cv_func_CFLocaleCopyCurrent = yes; then
  471. AC_DEFINE([HAVE_CFLOCALECOPYCURRENT], 1,
  472. [Define to 1 if you have the MacOS X function CFLocaleCopyCurrent in the CoreFoundation framework.])
  473. fi
  474. INTL_MACOSX_LIBS=
  475. if test $gt_cv_func_CFPreferencesCopyAppValue = yes || test $gt_cv_func_CFLocaleCopyCurrent = yes; then
  476. INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation"
  477. fi
  478. AC_SUBST([INTL_MACOSX_LIBS])
  479. ])
  480. dnl gt_CHECK_DECL(FUNC, INCLUDES)
  481. dnl Check whether a function is declared.
  482. AC_DEFUN([gt_CHECK_DECL],
  483. [
  484. AC_CACHE_CHECK([whether $1 is declared], ac_cv_have_decl_$1,
  485. [AC_TRY_COMPILE([$2], [
  486. #ifndef $1
  487. char *p = (char *) $1;
  488. #endif
  489. ], ac_cv_have_decl_$1=yes, ac_cv_have_decl_$1=no)])
  490. if test $ac_cv_have_decl_$1 = yes; then
  491. gt_value=1
  492. else
  493. gt_value=0
  494. fi
  495. AC_DEFINE_UNQUOTED([HAVE_DECL_]translit($1, [a-z], [A-Z]), [$gt_value],
  496. [Define to 1 if you have the declaration of `$1', and to 0 if you don't.])
  497. ])
  498. dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version])
  499. AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])