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

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

AC_CHECK_LIB doesn't work correctly it seems.. Hacked -lintl in there.

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