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