source: branches/libc-0.6/src/binutils/gettext.m4@ 2509

Last change on this file since 2509 was 1851, checked in by bird, 20 years ago

Uncommented intl hack.

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