/tags/rel-0-1-0/FreeSpeech/vflow/macros/gnome-gettext.m4

# · m4 · 336 lines · 241 code · 33 blank · 62 comment · 0 complexity · 3e3df7e2b006f25dbbecd4440970cd75 MD5 · raw file

  1. # Macro to add for using GNU gettext.
  2. # Ulrich Drepper <drepper@cygnus.com>, 1995.
  3. #
  4. # Modified to never use included libintl.
  5. # Owen Taylor <otaylor@redhat.com>, 12/15/1998
  6. #
  7. #
  8. # This file can be copied and used freely without restrictions. It can
  9. # be used in projects which are not available under the GNU Public License
  10. # but which still want to provide support for the GNU gettext functionality.
  11. # Please note that the actual code is *not* freely available.
  12. # serial 5
  13. AC_DEFUN(AM_GNOME_WITH_NLS,
  14. [AC_MSG_CHECKING([whether NLS is requested])
  15. dnl Default is enabled NLS
  16. AC_ARG_ENABLE(nls,
  17. [ --disable-nls do not use Native Language Support],
  18. USE_NLS=$enableval, USE_NLS=yes)
  19. AC_MSG_RESULT($USE_NLS)
  20. AC_SUBST(USE_NLS)
  21. USE_INCLUDED_LIBINTL=no
  22. dnl If we use NLS figure out what method
  23. if test "$USE_NLS" = "yes"; then
  24. AC_DEFINE(ENABLE_NLS)
  25. # AC_MSG_CHECKING([whether included gettext is requested])
  26. # AC_ARG_WITH(included-gettext,
  27. # [ --with-included-gettext use the GNU gettext library included here],
  28. # nls_cv_force_use_gnu_gettext=$withval,
  29. # nls_cv_force_use_gnu_gettext=no)
  30. # AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
  31. nls_cv_force_use_gnu_gettext="no"
  32. nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
  33. if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
  34. dnl User does not insist on using GNU NLS library. Figure out what
  35. dnl to use. If gettext or catgets are available (in this order) we
  36. dnl use this. Else we have to fall back to GNU NLS library.
  37. dnl catgets is only used if permitted by option --with-catgets.
  38. nls_cv_header_intl=
  39. nls_cv_header_libgt=
  40. CATOBJEXT=NONE
  41. AC_CHECK_HEADER(libintl.h,
  42. [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc,
  43. [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")],
  44. gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)])
  45. if test "$gt_cv_func_gettext_libc" != "yes"; then
  46. AC_CHECK_LIB(intl, bindtextdomain,
  47. [AC_CACHE_CHECK([for gettext in libintl],
  48. gt_cv_func_gettext_libintl,
  49. [AC_CHECK_LIB(intl, gettext,
  50. gt_cv_func_gettext_libintl=yes,
  51. gt_cv_func_gettext_libintl=no)],
  52. gt_cv_func_gettext_libintl=no)])
  53. fi
  54. if test "$gt_cv_func_gettext_libc" = "yes" \
  55. || test "$gt_cv_func_gettext_libintl" = "yes"; then
  56. AC_DEFINE(HAVE_GETTEXT)
  57. AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
  58. [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl
  59. if test "$MSGFMT" != "no"; then
  60. AC_CHECK_FUNCS(dcgettext)
  61. AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
  62. AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
  63. [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
  64. AC_TRY_LINK(, [extern int _nl_msg_cat_cntr;
  65. return _nl_msg_cat_cntr],
  66. [CATOBJEXT=.gmo
  67. DATADIRNAME=share],
  68. [CATOBJEXT=.mo
  69. DATADIRNAME=lib])
  70. INSTOBJEXT=.mo
  71. fi
  72. fi
  73. # Added by Martin Baulig 12/15/98 for libc5 systems
  74. if test "$gt_cv_func_gettext_libc" != "yes" \
  75. && test "$gt_cv_func_gettext_libintl" = "yes"; then
  76. INTLLIBS=-lintl
  77. LIBS=`echo $LIBS | sed -e 's/-lintl//'`
  78. fi
  79. ])
  80. if test "$CATOBJEXT" = "NONE"; then
  81. AC_MSG_CHECKING([whether catgets can be used])
  82. AC_ARG_WITH(catgets,
  83. [ --with-catgets use catgets functions if available],
  84. nls_cv_use_catgets=$withval, nls_cv_use_catgets=no)
  85. AC_MSG_RESULT($nls_cv_use_catgets)
  86. if test "$nls_cv_use_catgets" = "yes"; then
  87. dnl No gettext in C library. Try catgets next.
  88. AC_CHECK_LIB(i, main)
  89. AC_CHECK_FUNC(catgets,
  90. [AC_DEFINE(HAVE_CATGETS)
  91. INTLOBJS="\$(CATOBJS)"
  92. AC_PATH_PROG(GENCAT, gencat, no)dnl
  93. # if test "$GENCAT" != "no"; then
  94. # AC_PATH_PROG(GMSGFMT, gmsgfmt, no)
  95. # if test "$GMSGFMT" = "no"; then
  96. # AM_PATH_PROG_WITH_TEST(GMSGFMT, msgfmt,
  97. # [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)
  98. # fi
  99. # AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
  100. # [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
  101. # USE_INCLUDED_LIBINTL=yes
  102. # CATOBJEXT=.cat
  103. # INSTOBJEXT=.cat
  104. # DATADIRNAME=lib
  105. # INTLDEPS='$(top_builddir)/intl/libintl.a'
  106. # INTLLIBS=$INTLDEPS
  107. # LIBS=`echo $LIBS | sed -e 's/-lintl//'`
  108. # nls_cv_header_intl=intl/libintl.h
  109. # nls_cv_header_libgt=intl/libgettext.h
  110. # fi
  111. ])
  112. fi
  113. fi
  114. if test "$CATOBJEXT" = "NONE"; then
  115. dnl Neither gettext nor catgets in included in the C library.
  116. dnl Fall back on GNU gettext library.
  117. nls_cv_use_gnu_gettext=yes
  118. fi
  119. fi
  120. if test "$nls_cv_use_gnu_gettext" != "yes"; then
  121. AC_DEFINE(ENABLE_NLS)
  122. else
  123. # Unset this variable since we use the non-zero value as a flag.
  124. CATOBJEXT=
  125. # dnl Mark actions used to generate GNU NLS library.
  126. # INTLOBJS="\$(GETTOBJS)"
  127. # AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
  128. # [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt)
  129. # AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
  130. # AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
  131. # [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :)
  132. # AC_SUBST(MSGFMT)
  133. # USE_INCLUDED_LIBINTL=yes
  134. # CATOBJEXT=.gmo
  135. # INSTOBJEXT=.mo
  136. # DATADIRNAME=share
  137. # INTLDEPS='$(top_builddir)/intl/libintl.a'
  138. # INTLLIBS=$INTLDEPS
  139. # LIBS=`echo $LIBS | sed -e 's/-lintl//'`
  140. # nls_cv_header_intl=intl/libintl.h
  141. # nls_cv_header_libgt=intl/libgettext.h
  142. fi
  143. dnl Test whether we really found GNU xgettext.
  144. if test "$XGETTEXT" != ":"; then
  145. dnl If it is no GNU xgettext we define it as : so that the
  146. dnl Makefiles still can work.
  147. if $XGETTEXT --omit-header /dev/null 2> /dev/null; then
  148. : ;
  149. else
  150. AC_MSG_RESULT(
  151. [found xgettext program is not GNU xgettext; ignore it])
  152. XGETTEXT=":"
  153. fi
  154. fi
  155. # We need to process the po/ directory.
  156. POSUB=po
  157. else
  158. DATADIRNAME=share
  159. nls_cv_header_intl=intl/libintl.h
  160. nls_cv_header_libgt=intl/libgettext.h
  161. fi
  162. AC_LINK_FILES($nls_cv_header_libgt, $nls_cv_header_intl)
  163. AC_OUTPUT_COMMANDS(
  164. [case "$CONFIG_FILES" in *po/Makefile.in*)
  165. sed -e "/POTFILES =/r po/POTFILES" po/Makefile.in > po/Makefile
  166. esac])
  167. # # If this is used in GNU gettext we have to set USE_NLS to `yes'
  168. # # because some of the sources are only built for this goal.
  169. # if test "$PACKAGE" = gettext; then
  170. # USE_NLS=yes
  171. # USE_INCLUDED_LIBINTL=yes
  172. # fi
  173. dnl These rules are solely for the distribution goal. While doing this
  174. dnl we only have to keep exactly one list of the available catalogs
  175. dnl in configure.in.
  176. for lang in $ALL_LINGUAS; do
  177. GMOFILES="$GMOFILES $lang.gmo"
  178. POFILES="$POFILES $lang.po"
  179. done
  180. dnl Make all variables we use known to autoconf.
  181. AC_SUBST(USE_INCLUDED_LIBINTL)
  182. AC_SUBST(CATALOGS)
  183. AC_SUBST(CATOBJEXT)
  184. AC_SUBST(DATADIRNAME)
  185. AC_SUBST(GMOFILES)
  186. AC_SUBST(INSTOBJEXT)
  187. AC_SUBST(INTLDEPS)
  188. AC_SUBST(INTLLIBS)
  189. AC_SUBST(INTLOBJS)
  190. AC_SUBST(POFILES)
  191. AC_SUBST(POSUB)
  192. ])
  193. AC_DEFUN(AM_GNOME_GETTEXT,
  194. [AC_REQUIRE([AC_PROG_MAKE_SET])dnl
  195. AC_REQUIRE([AC_PROG_CC])dnl
  196. AC_REQUIRE([AC_PROG_RANLIB])dnl
  197. AC_REQUIRE([AC_ISC_POSIX])dnl
  198. AC_REQUIRE([AC_HEADER_STDC])dnl
  199. AC_REQUIRE([AC_C_CONST])dnl
  200. AC_REQUIRE([AC_C_INLINE])dnl
  201. AC_REQUIRE([AC_TYPE_OFF_T])dnl
  202. AC_REQUIRE([AC_TYPE_SIZE_T])dnl
  203. AC_REQUIRE([AC_FUNC_ALLOCA])dnl
  204. AC_REQUIRE([AC_FUNC_MMAP])dnl
  205. AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \
  206. unistd.h sys/param.h])
  207. AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \
  208. strdup __argz_count __argz_stringify __argz_next])
  209. if test "${ac_cv_func_stpcpy+set}" != "set"; then
  210. AC_CHECK_FUNCS(stpcpy)
  211. fi
  212. if test "${ac_cv_func_stpcpy}" = "yes"; then
  213. AC_DEFINE(HAVE_STPCPY)
  214. fi
  215. AM_LC_MESSAGES
  216. AM_GNOME_WITH_NLS
  217. if test "x$CATOBJEXT" != "x"; then
  218. if test "x$ALL_LINGUAS" = "x"; then
  219. LINGUAS=
  220. else
  221. AC_MSG_CHECKING(for catalogs to be installed)
  222. NEW_LINGUAS=
  223. if test "x$LINGUAS" = "x"; then
  224. LINGUAS=$ALL_LINGUAS
  225. fi
  226. for lang in $LINGUAS; do
  227. case "$ALL_LINGUAS" in
  228. *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;;
  229. esac
  230. done
  231. LINGUAS=$NEW_LINGUAS
  232. AC_MSG_RESULT($LINGUAS)
  233. fi
  234. dnl Construct list of names of catalog files to be constructed.
  235. if test -n "$LINGUAS"; then
  236. for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done
  237. fi
  238. fi
  239. dnl The reference to <locale.h> in the installed <libintl.h> file
  240. dnl must be resolved because we cannot expect the users of this
  241. dnl to define HAVE_LOCALE_H.
  242. if test $ac_cv_header_locale_h = yes; then
  243. INCLUDE_LOCALE_H="#include <locale.h>"
  244. else
  245. INCLUDE_LOCALE_H="\
  246. /* The system does not provide the header <locale.h>. Take care yourself. */"
  247. fi
  248. AC_SUBST(INCLUDE_LOCALE_H)
  249. dnl Determine which catalog format we have (if any is needed)
  250. dnl For now we know about two different formats:
  251. dnl Linux libc-5 and the normal X/Open format
  252. test -d intl || mkdir intl
  253. if test "$CATOBJEXT" = ".cat"; then
  254. AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen)
  255. dnl Transform the SED scripts while copying because some dumb SEDs
  256. dnl cannot handle comments.
  257. sed -e '/^#/d' $srcdir/intl/$msgformat-msg.sed > intl/po2msg.sed
  258. fi
  259. dnl po2tbl.sed is always needed.
  260. sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \
  261. $srcdir/intl/po2tbl.sed.in > intl/po2tbl.sed
  262. dnl In the intl/Makefile.in we have a special dependency which makes
  263. dnl only sense for gettext. We comment this out for non-gettext
  264. dnl packages.
  265. if test "$PACKAGE" = "gettext"; then
  266. GT_NO="#NO#"
  267. GT_YES=
  268. else
  269. GT_NO=
  270. GT_YES="#YES#"
  271. fi
  272. AC_SUBST(GT_NO)
  273. AC_SUBST(GT_YES)
  274. dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
  275. dnl find the mkinstalldirs script in another subdir but ($top_srcdir).
  276. dnl Try to locate is.
  277. MKINSTALLDIRS=
  278. if test -n "$ac_aux_dir"; then
  279. MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs"
  280. fi
  281. if test -z "$MKINSTALLDIRS"; then
  282. MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
  283. fi
  284. AC_SUBST(MKINSTALLDIRS)
  285. dnl *** For now the libtool support in intl/Makefile is not for real.
  286. l=
  287. AC_SUBST(l)
  288. dnl Generate list of files to be processed by xgettext which will
  289. dnl be included in po/Makefile.
  290. test -d po || mkdir po
  291. if test "x$srcdir" != "x."; then
  292. if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then
  293. posrcprefix="$srcdir/"
  294. else
  295. posrcprefix="../$srcdir/"
  296. fi
  297. else
  298. posrcprefix="../"
  299. fi
  300. rm -f po/POTFILES
  301. sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \
  302. < $srcdir/po/POTFILES.in > po/POTFILES
  303. ])