]>
Commit | Line | Data |
---|---|---|
6eb95e99 ZW |
1 | # This file is derived from `gettext.m4'. The difference is that the |
2 | # included macros assume Cygnus-style source and build trees. | |
3 | ||
4 | #serial 1 | |
5 | dnl This test replaces the one in autoconf. | |
6 | dnl Currently this macro should have the same name as the autoconf macro | |
7 | dnl because gettext's gettext.m4 (distributed in the automake package) | |
8 | dnl still uses it. Otherwise, the use in gettext.m4 makes autoheader | |
9 | dnl give these diagnostics: | |
10 | dnl configure.in:556: AC_TRY_COMPILE was called before AC_ISC_POSIX | |
11 | dnl configure.in:556: AC_TRY_RUN was called before AC_ISC_POSIX | |
12 | ||
13 | undefine([AC_ISC_POSIX]) | |
14 | AC_DEFUN(AC_ISC_POSIX, | |
15 | [ | |
16 | dnl This test replaces the obsolescent AC_ISC_POSIX kludge. | |
17 | AC_CHECK_LIB(cposix, strerror, [LIBS="$LIBS -lcposix"]) | |
18 | ] | |
19 | ) | |
20 | ||
21 | # Macro to add for using GNU gettext. | |
22 | # Ulrich Drepper <drepper@cygnus.com>, 1995. | |
23 | # | |
24 | # This file file be copied and used freely without restrictions. It can | |
25 | # be used in projects which are not available under the GNU Public License | |
26 | # but which still want to provide support for the GNU gettext functionality. | |
27 | # Please note that the actual code is *not* freely available. | |
28 | ||
29 | # serial 3 | |
30 | ||
31 | AC_DEFUN(CY_WITH_NLS, | |
32 | [AC_MSG_CHECKING([whether NLS is requested]) | |
33 | dnl Default is enabled NLS | |
34 | AC_ARG_ENABLE(nls, | |
35 | [ --disable-nls do not use Native Language Support], | |
36 | USE_NLS=$enableval, USE_NLS=yes) | |
37 | AC_MSG_RESULT($USE_NLS) | |
38 | AC_SUBST(USE_NLS) | |
39 | ||
40 | USE_INCLUDED_LIBINTL=no | |
41 | ||
42 | dnl If we use NLS figure out what method | |
43 | if test "$USE_NLS" = "yes"; then | |
44 | AC_DEFINE(ENABLE_NLS, 1, [Define to 1 if NLS is requested]) | |
45 | AC_MSG_CHECKING([whether included gettext is requested]) | |
46 | AC_ARG_WITH(included-gettext, | |
47 | [ --with-included-gettext use the GNU gettext library included here], | |
48 | nls_cv_force_use_gnu_gettext=$withval, | |
49 | nls_cv_force_use_gnu_gettext=no) | |
50 | AC_MSG_RESULT($nls_cv_force_use_gnu_gettext) | |
51 | ||
52 | nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext" | |
53 | if test "$nls_cv_force_use_gnu_gettext" != "yes"; then | |
54 | dnl User does not insist on using GNU NLS library. Figure out what | |
55 | dnl to use. If gettext or catgets are available (in this order) we | |
56 | dnl use this. Else we have to fall back to GNU NLS library. | |
57 | dnl catgets is only used if permitted by option --with-catgets. | |
58 | nls_cv_header_intl= | |
59 | nls_cv_header_libgt= | |
60 | CATOBJEXT=NONE | |
61 | ||
62 | AC_CHECK_HEADER(libintl.h, | |
63 | [AC_CACHE_CHECK([for gettext in libc], gt_cv_func_gettext_libc, | |
64 | [AC_TRY_LINK([#include <libintl.h>], [return (int) gettext ("")], | |
65 | gt_cv_func_gettext_libc=yes, gt_cv_func_gettext_libc=no)]) | |
66 | ||
67 | if test "$gt_cv_func_gettext_libc" != "yes"; then | |
68 | AC_CHECK_LIB(intl, bindtextdomain, | |
69 | [AC_CACHE_CHECK([for gettext in libintl], | |
70 | gt_cv_func_gettext_libintl, | |
71 | [AC_TRY_LINK([], [return (int) gettext ("")], | |
72 | gt_cv_func_gettext_libintl=yes, | |
73 | gt_cv_func_gettext_libintl=no)])]) | |
74 | fi | |
75 | ||
76 | if test "$gt_cv_func_gettext_libc" = "yes" \ | |
77 | || test "$gt_cv_func_gettext_libintl" = "yes"; then | |
78 | AC_DEFINE(HAVE_GETTEXT, 1, | |
79 | [Define as 1 if you have gettext and don't want to use GNU gettext.]) | |
80 | AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, | |
81 | [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], no)dnl | |
82 | if test "$MSGFMT" != "no"; then | |
83 | AC_CHECK_FUNCS(dcgettext) | |
84 | AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT) | |
85 | AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, | |
86 | [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :) | |
87 | AC_TRY_LINK(, [extern int _nl_msg_cat_cntr; | |
88 | return _nl_msg_cat_cntr], | |
89 | [CATOBJEXT=.gmo | |
90 | DATADIRNAME=share], | |
91 | [CATOBJEXT=.mo | |
92 | DATADIRNAME=lib]) | |
93 | INSTOBJEXT=.mo | |
94 | fi | |
95 | fi | |
96 | ]) | |
97 | ||
98 | dnl In the standard gettext, we would now check for catgets. | |
99 | dnl However, we never want to use catgets for our releases. | |
100 | ||
101 | if test "$CATOBJEXT" = "NONE"; then | |
102 | dnl Neither gettext nor catgets in included in the C library. | |
103 | dnl Fall back on GNU gettext library. | |
104 | nls_cv_use_gnu_gettext=yes | |
105 | fi | |
106 | fi | |
107 | ||
108 | if test "$nls_cv_use_gnu_gettext" = "yes"; then | |
109 | dnl Mark actions used to generate GNU NLS library. | |
110 | INTLOBJS="\$(GETTOBJS)" | |
111 | AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt, | |
112 | [test -z "`$ac_dir/$ac_word -h 2>&1 | grep 'dv '`"], msgfmt) | |
113 | AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT) | |
114 | AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext, | |
115 | [test -z "`$ac_dir/$ac_word -h 2>&1 | grep '(HELP)'`"], :) | |
116 | AC_SUBST(MSGFMT) | |
117 | USE_INCLUDED_LIBINTL=yes | |
118 | CATOBJEXT=.gmo | |
119 | INSTOBJEXT=.mo | |
120 | DATADIRNAME=share | |
121 | INTLDEPS='$(top_builddir)/../intl/libintl.a' | |
122 | INTLLIBS=$INTLDEPS | |
123 | LIBS=`echo $LIBS | sed -e 's/-lintl//'` | |
124 | nls_cv_header_intl=libintl.h | |
125 | nls_cv_header_libgt=libgettext.h | |
126 | fi | |
127 | ||
128 | dnl Test whether we really found GNU xgettext. | |
129 | if test "$XGETTEXT" != ":"; then | |
130 | dnl If it is no GNU xgettext we define it as : so that the | |
131 | dnl Makefiles still can work. | |
132 | if $XGETTEXT --omit-header /dev/null 2> /dev/null; then | |
133 | : ; | |
134 | else | |
135 | AC_MSG_RESULT( | |
136 | [found xgettext programs is not GNU xgettext; ignore it]) | |
137 | XGETTEXT=":" | |
138 | fi | |
139 | fi | |
140 | ||
141 | # We need to process the po/ directory. | |
142 | POSUB=po | |
143 | else | |
144 | DATADIRNAME=share | |
145 | nls_cv_header_intl=libintl.h | |
146 | nls_cv_header_libgt=libgettext.h | |
147 | fi | |
148 | ||
149 | # If this is used in GNU gettext we have to set USE_NLS to `yes' | |
150 | # because some of the sources are only built for this goal. | |
151 | if test "$PACKAGE" = gettext; then | |
152 | USE_NLS=yes | |
153 | USE_INCLUDED_LIBINTL=yes | |
154 | fi | |
155 | ||
156 | dnl These rules are solely for the distribution goal. While doing this | |
157 | dnl we only have to keep exactly one list of the available catalogs | |
158 | dnl in configure.in. | |
159 | for lang in $ALL_LINGUAS; do | |
160 | GMOFILES="$GMOFILES $lang.gmo" | |
161 | POFILES="$POFILES $lang.po" | |
162 | done | |
163 | ||
164 | dnl Make all variables we use known to autoconf. | |
165 | AC_SUBST(USE_INCLUDED_LIBINTL) | |
166 | AC_SUBST(CATALOGS) | |
167 | AC_SUBST(CATOBJEXT) | |
168 | AC_SUBST(DATADIRNAME) | |
169 | AC_SUBST(GMOFILES) | |
170 | AC_SUBST(INSTOBJEXT) | |
171 | AC_SUBST(INTLDEPS) | |
172 | AC_SUBST(INTLLIBS) | |
173 | AC_SUBST(INTLOBJS) | |
174 | AC_SUBST(POFILES) | |
175 | AC_SUBST(POSUB) | |
176 | ]) | |
177 | ||
178 | AC_DEFUN(CY_GNU_GETTEXT, | |
179 | [AC_REQUIRE([AC_PROG_MAKE_SET])dnl | |
180 | AC_REQUIRE([AC_PROG_CC])dnl | |
181 | AC_REQUIRE([AC_PROG_RANLIB])dnl | |
182 | AC_REQUIRE([AC_ISC_POSIX])dnl | |
183 | AC_REQUIRE([AC_HEADER_STDC])dnl | |
184 | AC_REQUIRE([AC_C_CONST])dnl | |
185 | AC_REQUIRE([AC_C_INLINE])dnl | |
186 | AC_REQUIRE([AC_TYPE_OFF_T])dnl | |
187 | AC_REQUIRE([AC_TYPE_SIZE_T])dnl | |
188 | AC_REQUIRE([AC_FUNC_ALLOCA])dnl | |
189 | AC_REQUIRE([AC_FUNC_MMAP])dnl | |
190 | ||
191 | AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h string.h \ | |
192 | unistd.h values.h sys/param.h]) | |
193 | AC_CHECK_FUNCS([getcwd munmap putenv setenv setlocale strchr strcasecmp \ | |
194 | __argz_count __argz_stringify __argz_next]) | |
195 | ||
196 | if test "${ac_cv_func_stpcpy+set}" != "set"; then | |
197 | AC_CHECK_FUNCS(stpcpy) | |
198 | fi | |
199 | if test "${ac_cv_func_stpcpy}" = "yes"; then | |
200 | AC_DEFINE(HAVE_STPCPY, 1, [Define if you have the stpcpy function]) | |
201 | fi | |
202 | ||
203 | AM_LC_MESSAGES | |
204 | CY_WITH_NLS | |
205 | ||
206 | if test "x$CATOBJEXT" != "x"; then | |
207 | if test "x$ALL_LINGUAS" = "x"; then | |
208 | LINGUAS= | |
209 | else | |
210 | AC_MSG_CHECKING(for catalogs to be installed) | |
211 | NEW_LINGUAS= | |
212 | for lang in ${LINGUAS=$ALL_LINGUAS}; do | |
213 | case "$ALL_LINGUAS" in | |
214 | *$lang*) NEW_LINGUAS="$NEW_LINGUAS $lang" ;; | |
215 | esac | |
216 | done | |
217 | LINGUAS=$NEW_LINGUAS | |
218 | AC_MSG_RESULT($LINGUAS) | |
219 | fi | |
220 | ||
221 | dnl Construct list of names of catalog files to be constructed. | |
222 | if test -n "$LINGUAS"; then | |
223 | for lang in $LINGUAS; do CATALOGS="$CATALOGS $lang$CATOBJEXT"; done | |
224 | fi | |
225 | fi | |
226 | ||
227 | dnl The reference to <locale.h> in the installed <libintl.h> file | |
228 | dnl must be resolved because we cannot expect the users of this | |
229 | dnl to define HAVE_LOCALE_H. | |
230 | if test $ac_cv_header_locale_h = yes; then | |
231 | INCLUDE_LOCALE_H="#include <locale.h>" | |
232 | else | |
233 | INCLUDE_LOCALE_H="\ | |
234 | /* The system does not provide the header <locale.h>. Take care yourself. */" | |
235 | fi | |
236 | AC_SUBST(INCLUDE_LOCALE_H) | |
237 | ||
238 | dnl Determine which catalog format we have (if any is needed) | |
239 | dnl For now we know about two different formats: | |
240 | dnl Linux libc-5 and the normal X/Open format | |
241 | if test -f $srcdir/po2tbl.sed.in; then | |
242 | if test "$CATOBJEXT" = ".cat"; then | |
243 | AC_CHECK_HEADER(linux/version.h, msgformat=linux, msgformat=xopen) | |
244 | ||
245 | dnl Transform the SED scripts while copying because some dumb SEDs | |
246 | dnl cannot handle comments. | |
247 | sed -e '/^#/d' $srcdir/$msgformat-msg.sed > po2msg.sed | |
248 | fi | |
249 | dnl po2tbl.sed is always needed. | |
250 | sed -e '/^#.*[^\\]$/d' -e '/^#$/d' \ | |
251 | $srcdir/po2tbl.sed.in > po2tbl.sed | |
252 | fi | |
253 | ||
254 | dnl In the intl/Makefile.in we have a special dependency which makes | |
255 | dnl only sense for gettext. We comment this out for non-gettext | |
256 | dnl packages. | |
257 | if test "$PACKAGE" = "gettext"; then | |
258 | GT_NO="#NO#" | |
259 | GT_YES= | |
260 | else | |
261 | GT_NO= | |
262 | GT_YES="#YES#" | |
263 | fi | |
264 | AC_SUBST(GT_NO) | |
265 | AC_SUBST(GT_YES) | |
266 | ||
267 | MKINSTALLDIRS="\$(srcdir)/../../mkinstalldirs" | |
268 | AC_SUBST(MKINSTALLDIRS) | |
269 | ||
270 | dnl *** For now the libtool support in intl/Makefile is not for real. | |
271 | l= | |
272 | AC_SUBST(l) | |
273 | ||
274 | dnl Generate list of files to be processed by xgettext which will | |
275 | dnl be included in po/Makefile. But only do this if the po directory | |
276 | dnl exists in srcdir and contains POTFILES.in. | |
277 | if test -f $srcdir/po/POTFILES.in; then | |
278 | test -d po || mkdir po | |
279 | if test "x$srcdir" != "x."; then | |
280 | if test "x`echo $srcdir | sed 's@/.*@@'`" = "x"; then | |
281 | posrcprefix="$srcdir/" | |
282 | else | |
283 | posrcprefix="../$srcdir/" | |
284 | fi | |
285 | else | |
286 | posrcprefix="../" | |
287 | fi | |
288 | rm -f po/POTFILES | |
289 | sed -e "/^#/d" -e "/^\$/d" -e "s,.*, $posrcprefix& \\\\," -e "\$s/\(.*\) \\\\/\1/" \ | |
290 | < $srcdir/po/POTFILES.in > po/POTFILES | |
291 | fi | |
292 | ]) | |
293 | ||
294 | # Search path for a program which passes the given test. | |
295 | # Ulrich Drepper <drepper@cygnus.com>, 1996. | |
296 | # | |
297 | # This file file be copied and used freely without restrictions. It can | |
298 | # be used in projects which are not available under the GNU Public License | |
299 | # but which still want to provide support for the GNU gettext functionality. | |
300 | # Please note that the actual code is *not* freely available. | |
301 | ||
302 | # serial 1 | |
303 | ||
304 | dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR, | |
305 | dnl TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]]) | |
306 | AC_DEFUN(AM_PATH_PROG_WITH_TEST, | |
307 | [# Extract the first word of "$2", so it can be a program name with args. | |
308 | set dummy $2; ac_word=[$]2 | |
309 | AC_MSG_CHECKING([for $ac_word]) | |
310 | AC_CACHE_VAL(ac_cv_path_$1, | |
311 | [case "[$]$1" in | |
312 | /*) | |
313 | ac_cv_path_$1="[$]$1" # Let the user override the test with a path. | |
314 | ;; | |
315 | *) | |
316 | IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" | |
317 | for ac_dir in ifelse([$5], , $PATH, [$5]); do | |
318 | test -z "$ac_dir" && ac_dir=. | |
319 | if test -f $ac_dir/$ac_word; then | |
320 | if [$3]; then | |
321 | ac_cv_path_$1="$ac_dir/$ac_word" | |
322 | break | |
323 | fi | |
324 | fi | |
325 | done | |
326 | IFS="$ac_save_ifs" | |
327 | dnl If no 4th arg is given, leave the cache variable unset, | |
328 | dnl so AC_PATH_PROGS will keep looking. | |
329 | ifelse([$4], , , [ test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4" | |
330 | ])dnl | |
331 | ;; | |
332 | esac])dnl | |
333 | $1="$ac_cv_path_$1" | |
334 | if test -n "[$]$1"; then | |
335 | AC_MSG_RESULT([$]$1) | |
336 | else | |
337 | AC_MSG_RESULT(no) | |
338 | fi | |
339 | AC_SUBST($1)dnl | |
340 | ]) | |
341 | ||
342 | # Check whether LC_MESSAGES is available in <locale.h>. | |
343 | # Ulrich Drepper <drepper@cygnus.com>, 1995. | |
344 | # | |
345 | # This file file be copied and used freely without restrictions. It can | |
346 | # be used in projects which are not available under the GNU Public License | |
347 | # but which still want to provide support for the GNU gettext functionality. | |
348 | # Please note that the actual code is *not* freely available. | |
349 | ||
350 | # serial 1 | |
351 | ||
352 | AC_DEFUN(AM_LC_MESSAGES, | |
353 | [if test $ac_cv_header_locale_h = yes; then | |
354 | AC_CACHE_CHECK([for LC_MESSAGES], am_cv_val_LC_MESSAGES, | |
355 | [AC_TRY_LINK([#include <locale.h>], [return LC_MESSAGES], | |
356 | am_cv_val_LC_MESSAGES=yes, am_cv_val_LC_MESSAGES=no)]) | |
357 | if test $am_cv_val_LC_MESSAGES = yes; then | |
358 | AC_DEFINE(HAVE_LC_MESSAGES, 1, | |
359 | [Define if your locale.h file contains LC_MESSAGES.]) | |
360 | fi | |
361 | fi]) |