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