You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

384 lines
15 KiB

  1. # gettext.m4 serial 63 (gettext-0.18)
  2. dnl Copyright (C) 1995-2010 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-2006, 2008-2010.
  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(ifelse([$1], [], [old])[]ifelse([$1], [no-libtool], [old]), [old],
  61. [AC_DIAGNOSE([obsolete], [Use of AM_GNU_GETTEXT without [external] argument is deprecated.])])
  62. ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], ,
  63. [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT
  64. ])])])])
  65. define([gt_included_intl],
  66. ifelse([$1], [external],
  67. ifdef([AM_GNU_GETTEXT_][INTL_SUBDIR], [yes], [no]),
  68. [yes]))
  69. define([gt_libtool_suffix_prefix], ifelse([$1], [use-libtool], [l], []))
  70. gt_NEEDS_INIT
  71. AM_GNU_GETTEXT_NEED([$2])
  72. AC_REQUIRE([AM_PO_SUBDIRS])dnl
  73. ifelse(gt_included_intl, yes, [
  74. AC_REQUIRE([AM_INTL_SUBDIR])dnl
  75. ])
  76. dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
  77. AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
  78. AC_REQUIRE([AC_LIB_RPATH])
  79. dnl Sometimes libintl requires libiconv, so first search for libiconv.
  80. dnl Ideally we would do this search only after the
  81. dnl if test "$USE_NLS" = "yes"; then
  82. dnl if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then
  83. dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT
  84. dnl the configure script would need to contain the same shell code
  85. dnl again, outside any 'if'. There are two solutions:
  86. dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'.
  87. dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE.
  88. dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not
  89. dnl documented, we avoid it.
  90. ifelse(gt_included_intl, yes, , [
  91. AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
  92. ])
  93. dnl Sometimes, on MacOS X, libintl requires linking with CoreFoundation.
  94. gt_INTL_MACOSX
  95. dnl Set USE_NLS.
  96. AC_REQUIRE([AM_NLS])
  97. ifelse(gt_included_intl, yes, [
  98. BUILD_INCLUDED_LIBINTL=no
  99. USE_INCLUDED_LIBINTL=no
  100. ])
  101. LIBINTL=
  102. LTLIBINTL=
  103. POSUB=
  104. dnl Add a version number to the cache macros.
  105. case " $gt_needs " in
  106. *" need-formatstring-macros "*) gt_api_version=3 ;;
  107. *" need-ngettext "*) gt_api_version=2 ;;
  108. *) gt_api_version=1 ;;
  109. esac
  110. gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc"
  111. gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl"
  112. dnl If we use NLS figure out what method
  113. if test "$USE_NLS" = "yes"; then
  114. gt_use_preinstalled_gnugettext=no
  115. ifelse(gt_included_intl, yes, [
  116. AC_MSG_CHECKING([whether included gettext is requested])
  117. AC_ARG_WITH([included-gettext],
  118. [ --with-included-gettext use the GNU gettext library included here],
  119. nls_cv_force_use_gnu_gettext=$withval,
  120. nls_cv_force_use_gnu_gettext=no)
  121. AC_MSG_RESULT([$nls_cv_force_use_gnu_gettext])
  122. nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
  123. if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
  124. ])
  125. dnl User does not insist on using GNU NLS library. Figure out what
  126. dnl to use. If GNU gettext is available we use this. Else we have
  127. dnl to fall back to GNU NLS library.
  128. if test $gt_api_version -ge 3; then
  129. gt_revision_test_code='
  130. #ifndef __GNU_GETTEXT_SUPPORTED_REVISION
  131. #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
  132. #endif
  133. changequote(,)dnl
  134. typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
  135. changequote([,])dnl
  136. '
  137. else
  138. gt_revision_test_code=
  139. fi
  140. if test $gt_api_version -ge 2; then
  141. gt_expression_test_code=' + * ngettext ("", "", 0)'
  142. else
  143. gt_expression_test_code=
  144. fi
  145. AC_CACHE_CHECK([for GNU gettext in libc], [$gt_func_gnugettext_libc],
  146. [AC_TRY_LINK([#include <libintl.h>
  147. $gt_revision_test_code
  148. extern int _nl_msg_cat_cntr;
  149. extern int *_nl_domain_bindings;],
  150. [bindtextdomain ("", "");
  151. return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_domain_bindings],
  152. [eval "$gt_func_gnugettext_libc=yes"],
  153. [eval "$gt_func_gnugettext_libc=no"])])
  154. if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then
  155. dnl Sometimes libintl requires libiconv, so first search for libiconv.
  156. ifelse(gt_included_intl, yes, , [
  157. AM_ICONV_LINK
  158. ])
  159. dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL
  160. dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv])
  161. dnl because that would add "-liconv" to LIBINTL and LTLIBINTL
  162. dnl even if libiconv doesn't exist.
  163. AC_LIB_LINKFLAGS_BODY([intl])
  164. AC_CACHE_CHECK([for GNU gettext in libintl],
  165. [$gt_func_gnugettext_libintl],
  166. [gt_save_CPPFLAGS="$CPPFLAGS"
  167. CPPFLAGS="$CPPFLAGS $INCINTL"
  168. gt_save_LIBS="$LIBS"
  169. LIBS="$LIBS $LIBINTL"
  170. dnl Now see whether libintl exists and does not depend on libiconv.
  171. AC_TRY_LINK([#include <libintl.h>
  172. $gt_revision_test_code
  173. extern int _nl_msg_cat_cntr;
  174. extern
  175. #ifdef __cplusplus
  176. "C"
  177. #endif
  178. const char *_nl_expand_alias (const char *);],
  179. [bindtextdomain ("", "");
  180. return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")],
  181. [eval "$gt_func_gnugettext_libintl=yes"],
  182. [eval "$gt_func_gnugettext_libintl=no"])
  183. dnl Now see whether libintl exists and depends on libiconv.
  184. if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } && test -n "$LIBICONV"; then
  185. LIBS="$LIBS $LIBICONV"
  186. AC_TRY_LINK([#include <libintl.h>
  187. $gt_revision_test_code
  188. extern int _nl_msg_cat_cntr;
  189. extern
  190. #ifdef __cplusplus
  191. "C"
  192. #endif
  193. const char *_nl_expand_alias (const char *);],
  194. [bindtextdomain ("", "");
  195. return * gettext ("")$gt_expression_test_code + _nl_msg_cat_cntr + *_nl_expand_alias ("")],
  196. [LIBINTL="$LIBINTL $LIBICONV"
  197. LTLIBINTL="$LTLIBINTL $LTLIBICONV"
  198. eval "$gt_func_gnugettext_libintl=yes"
  199. ])
  200. fi
  201. CPPFLAGS="$gt_save_CPPFLAGS"
  202. LIBS="$gt_save_LIBS"])
  203. fi
  204. dnl If an already present or preinstalled GNU gettext() is found,
  205. dnl use it. But if this macro is used in GNU gettext, and GNU
  206. dnl gettext is already preinstalled in libintl, we update this
  207. dnl libintl. (Cf. the install rule in intl/Makefile.in.)
  208. if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" = "yes"; } \
  209. || { { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; } \
  210. && test "$PACKAGE" != gettext-runtime \
  211. && test "$PACKAGE" != gettext-tools; }; then
  212. gt_use_preinstalled_gnugettext=yes
  213. else
  214. dnl Reset the values set by searching for libintl.
  215. LIBINTL=
  216. LTLIBINTL=
  217. INCINTL=
  218. fi
  219. ifelse(gt_included_intl, yes, [
  220. if test "$gt_use_preinstalled_gnugettext" != "yes"; then
  221. dnl GNU gettext is not found in the C library.
  222. dnl Fall back on included GNU gettext library.
  223. nls_cv_use_gnu_gettext=yes
  224. fi
  225. fi
  226. if test "$nls_cv_use_gnu_gettext" = "yes"; then
  227. dnl Mark actions used to generate GNU NLS library.
  228. BUILD_INCLUDED_LIBINTL=yes
  229. USE_INCLUDED_LIBINTL=yes
  230. LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV $LIBTHREAD"
  231. LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV $LTLIBTHREAD"
  232. LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
  233. fi
  234. CATOBJEXT=
  235. if test "$gt_use_preinstalled_gnugettext" = "yes" \
  236. || test "$nls_cv_use_gnu_gettext" = "yes"; then
  237. dnl Mark actions to use GNU gettext tools.
  238. CATOBJEXT=.gmo
  239. fi
  240. ])
  241. if test -n "$INTL_MACOSX_LIBS"; then
  242. if test "$gt_use_preinstalled_gnugettext" = "yes" \
  243. || test "$nls_cv_use_gnu_gettext" = "yes"; then
  244. dnl Some extra flags are needed during linking.
  245. LIBINTL="$LIBINTL $INTL_MACOSX_LIBS"
  246. LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS"
  247. fi
  248. fi
  249. if test "$gt_use_preinstalled_gnugettext" = "yes" \
  250. || test "$nls_cv_use_gnu_gettext" = "yes"; then
  251. AC_DEFINE([ENABLE_NLS], [1],
  252. [Define to 1 if translation of program messages to the user's native language
  253. is requested.])
  254. else
  255. USE_NLS=no
  256. fi
  257. fi
  258. AC_MSG_CHECKING([whether to use NLS])
  259. AC_MSG_RESULT([$USE_NLS])
  260. if test "$USE_NLS" = "yes"; then
  261. AC_MSG_CHECKING([where the gettext function comes from])
  262. if test "$gt_use_preinstalled_gnugettext" = "yes"; then
  263. if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then
  264. gt_source="external libintl"
  265. else
  266. gt_source="libc"
  267. fi
  268. else
  269. gt_source="included intl directory"
  270. fi
  271. AC_MSG_RESULT([$gt_source])
  272. fi
  273. if test "$USE_NLS" = "yes"; then
  274. if test "$gt_use_preinstalled_gnugettext" = "yes"; then
  275. if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then
  276. AC_MSG_CHECKING([how to link with libintl])
  277. AC_MSG_RESULT([$LIBINTL])
  278. AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL])
  279. fi
  280. dnl For backward compatibility. Some packages may be using this.
  281. AC_DEFINE([HAVE_GETTEXT], [1],
  282. [Define if the GNU gettext() function is already present or preinstalled.])
  283. AC_DEFINE([HAVE_DCGETTEXT], [1],
  284. [Define if the GNU dcgettext() function is already present or preinstalled.])
  285. fi
  286. dnl We need to process the po/ directory.
  287. POSUB=po
  288. fi
  289. ifelse(gt_included_intl, yes, [
  290. dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
  291. dnl to 'yes' because some of the testsuite requires it.
  292. if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then
  293. BUILD_INCLUDED_LIBINTL=yes
  294. fi
  295. dnl Make all variables we use known to autoconf.
  296. AC_SUBST([BUILD_INCLUDED_LIBINTL])
  297. AC_SUBST([USE_INCLUDED_LIBINTL])
  298. AC_SUBST([CATOBJEXT])
  299. dnl For backward compatibility. Some configure.ins may be using this.
  300. nls_cv_header_intl=
  301. nls_cv_header_libgt=
  302. dnl For backward compatibility. Some Makefiles may be using this.
  303. DATADIRNAME=share
  304. AC_SUBST([DATADIRNAME])
  305. dnl For backward compatibility. Some Makefiles may be using this.
  306. INSTOBJEXT=.mo
  307. AC_SUBST([INSTOBJEXT])
  308. dnl For backward compatibility. Some Makefiles may be using this.
  309. GENCAT=gencat
  310. AC_SUBST([GENCAT])
  311. dnl For backward compatibility. Some Makefiles may be using this.
  312. INTLOBJS=
  313. if test "$USE_INCLUDED_LIBINTL" = yes; then
  314. INTLOBJS="\$(GETTOBJS)"
  315. fi
  316. AC_SUBST([INTLOBJS])
  317. dnl Enable libtool support if the surrounding package wishes it.
  318. INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix
  319. AC_SUBST([INTL_LIBTOOL_SUFFIX_PREFIX])
  320. ])
  321. dnl For backward compatibility. Some Makefiles may be using this.
  322. INTLLIBS="$LIBINTL"
  323. AC_SUBST([INTLLIBS])
  324. dnl Make all documented variables known to autoconf.
  325. AC_SUBST([LIBINTL])
  326. AC_SUBST([LTLIBINTL])
  327. AC_SUBST([POSUB])
  328. ])
  329. dnl gt_NEEDS_INIT ensures that the gt_needs variable is initialized.
  330. m4_define([gt_NEEDS_INIT],
  331. [
  332. m4_divert_text([DEFAULTS], [gt_needs=])
  333. m4_define([gt_NEEDS_INIT], [])
  334. ])
  335. dnl Usage: AM_GNU_GETTEXT_NEED([NEEDSYMBOL])
  336. AC_DEFUN([AM_GNU_GETTEXT_NEED],
  337. [
  338. m4_divert_text([INIT_PREPARE], [gt_needs="$gt_needs $1"])
  339. ])
  340. dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version])
  341. AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])