source: trunk/src/binutils/gettext.m4@ 1101

Last change on this file since 1101 was 1101, checked in by bird, 22 years ago

Corrected tests so we recognize gettext tools and newer intl libs.

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