HGM fixed cygwin compile for winboard
[xboard.git] / aclocal.m4
1 # nls.m4 serial 1 (gettext-0.12)
2 dnl Copyright (C) 1995-2003 Free Software Foundation, Inc.
3 dnl This file is free software, distributed under the terms of the GNU
4 dnl General Public License.  As a special exception to the GNU General
5 dnl Public License, this file may be distributed as part of a program
6 dnl that contains a configuration script generated by Autoconf, under
7 dnl the same distribution terms as the rest of that program.
8 dnl
9 dnl This file can can be used in projects which are not available under
10 dnl the GNU General Public License or the GNU Library General Public
11 dnl License but which still want to provide support for the GNU gettext
12 dnl functionality.
13 dnl Please note that the actual code of the GNU gettext library is covered
14 dnl by the GNU Library General Public License, and the rest of the GNU
15 dnl gettext package package is covered by the GNU General Public License.
16 dnl They are *not* in the public domain.
17
18 dnl Authors:
19 dnl   Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
20 dnl   Bruno Haible <haible@clisp.cons.org>, 2000-2003.
21
22 AC_DEFUN([AM_NLS],
23 [
24   AC_MSG_CHECKING([whether NLS is requested])
25   dnl Default is enabled NLS
26   AC_ARG_ENABLE(nls,
27     [  --disable-nls           do not use Native Language Support],
28     USE_NLS=$enableval, USE_NLS=yes)
29   AC_MSG_RESULT($USE_NLS)
30   AC_SUBST(USE_NLS)
31 ])
32
33 AC_DEFUN([AM_MKINSTALLDIRS],
34 [
35   dnl If the AC_CONFIG_AUX_DIR macro for autoconf is used we possibly
36   dnl find the mkinstalldirs script in another subdir but $(top_srcdir).
37   dnl Try to locate it.
38   MKINSTALLDIRS=
39   if test -n "$ac_aux_dir"; then
40     case "$ac_aux_dir" in
41       /*) MKINSTALLDIRS="$ac_aux_dir/mkinstalldirs" ;;
42       *) MKINSTALLDIRS="\$(top_builddir)/$ac_aux_dir/mkinstalldirs" ;;
43     esac
44   fi
45   if test -z "$MKINSTALLDIRS"; then
46     MKINSTALLDIRS="\$(top_srcdir)/mkinstalldirs"
47   fi
48   AC_SUBST(MKINSTALLDIRS)
49 ])
50 # po.m4 serial 1 (gettext-0.12)
51 dnl Copyright (C) 1995-2003 Free Software Foundation, Inc.
52 dnl This file is free software, distributed under the terms of the GNU
53 dnl General Public License.  As a special exception to the GNU General
54 dnl Public License, this file may be distributed as part of a program
55 dnl that contains a configuration script generated by Autoconf, under
56 dnl the same distribution terms as the rest of that program.
57 dnl
58 dnl This file can can be used in projects which are not available under
59 dnl the GNU General Public License or the GNU Library General Public
60 dnl License but which still want to provide support for the GNU gettext
61 dnl functionality.
62 dnl Please note that the actual code of the GNU gettext library is covered
63 dnl by the GNU Library General Public License, and the rest of the GNU
64 dnl gettext package package is covered by the GNU General Public License.
65 dnl They are *not* in the public domain.
66
67 dnl Authors:
68 dnl   Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
69 dnl   Bruno Haible <haible@clisp.cons.org>, 2000-2003.
70
71 dnl Checks for all prerequisites of the po subdirectory.
72 AC_DEFUN([AM_PO_SUBDIRS],
73 [
74   AC_REQUIRE([AC_PROG_MAKE_SET])dnl
75   AC_REQUIRE([AC_PROG_INSTALL])dnl
76   AC_REQUIRE([AM_MKINSTALLDIRS])dnl
77   AC_REQUIRE([AM_NLS])dnl
78
79   dnl Perform the following tests also if --disable-nls has been given,
80   dnl because they are needed for "make dist" to work.
81
82   dnl Search for GNU msgfmt in the PATH.
83   dnl The first test excludes Solaris msgfmt and early GNU msgfmt versions.
84   dnl The second test excludes FreeBSD msgfmt.
85   AM_PATH_PROG_WITH_TEST(MSGFMT, msgfmt,
86     [$ac_dir/$ac_word --statistics /dev/null >/dev/null 2>&1 &&
87      (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
88     :)
89   AC_PATH_PROG(GMSGFMT, gmsgfmt, $MSGFMT)
90
91   dnl Search for GNU xgettext 0.12 or newer in the PATH.
92   dnl The first test excludes Solaris xgettext and early GNU xgettext versions.
93   dnl The second test excludes FreeBSD xgettext.
94   AM_PATH_PROG_WITH_TEST(XGETTEXT, xgettext,
95     [$ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >/dev/null 2>&1 &&
96      (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi)],
97     :)
98   dnl Remove leftover from FreeBSD xgettext call.
99   rm -f messages.po
100
101   dnl Search for GNU msgmerge 0.11 or newer in the PATH.
102   AM_PATH_PROG_WITH_TEST(MSGMERGE, msgmerge,
103     [$ac_dir/$ac_word --update -q /dev/null /dev/null >/dev/null 2>&1], :)
104
105   dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
106   dnl Test whether we really found GNU msgfmt.
107   if test "$GMSGFMT" != ":"; then
108     dnl If it is no GNU msgfmt we define it as : so that the
109     dnl Makefiles still can work.
110     if $GMSGFMT --statistics /dev/null >/dev/null 2>&1 &&
111        (if $GMSGFMT --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then
112       : ;
113     else
114       GMSGFMT=`echo "$GMSGFMT" | sed -e 's,^.*/,,'`
115       AC_MSG_RESULT(
116         [found $GMSGFMT program is not GNU msgfmt; ignore it])
117       GMSGFMT=":"
118     fi
119   fi
120
121   dnl This could go away some day; the PATH_PROG_WITH_TEST already does it.
122   dnl Test whether we really found GNU xgettext.
123   if test "$XGETTEXT" != ":"; then
124     dnl If it is no GNU xgettext we define it as : so that the
125     dnl Makefiles still can work.
126     if $XGETTEXT --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >/dev/null 2>&1 &&
127        (if $XGETTEXT --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then
128       : ;
129     else
130       AC_MSG_RESULT(
131         [found xgettext program is not GNU xgettext; ignore it])
132       XGETTEXT=":"
133     fi
134     dnl Remove leftover from FreeBSD xgettext call.
135     rm -f messages.po
136   fi
137
138   AC_OUTPUT_COMMANDS([
139     for ac_file in $CONFIG_FILES; do
140       # Support "outfile[:infile[:infile...]]"
141       case "$ac_file" in
142         *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;
143       esac
144       # PO directories have a Makefile.in generated from Makefile.in.in.
145       case "$ac_file" in */Makefile.in)
146         # Adjust a relative srcdir.
147         ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`
148         ac_dir_suffix="/`echo "$ac_dir"|sed 's%^\./%%'`"
149         ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`
150         # In autoconf-2.13 it is called $ac_given_srcdir.
151         # In autoconf-2.50 it is called $srcdir.
152         test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"
153         case "$ac_given_srcdir" in
154           .)  top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;
155           /*) top_srcdir="$ac_given_srcdir" ;;
156           *)  top_srcdir="$ac_dots$ac_given_srcdir" ;;
157         esac
158         if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then
159           rm -f "$ac_dir/POTFILES"
160           test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"
161           cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[   ]*\$/d" -e "s,.*,     $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES"
162           POMAKEFILEDEPS="POTFILES.in"
163           # ALL_LINGUAS, POFILES, GMOFILES, UPDATEPOFILES, DUMMYPOFILES depend
164           # on $ac_dir but don't depend on user-specified configuration
165           # parameters.
166           if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then
167             # The LINGUAS file contains the set of available languages.
168             if test -n "$OBSOLETE_ALL_LINGUAS"; then
169               test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete"
170             fi
171             ALL_LINGUAS_=`sed -e "/^#/d" "$ac_given_srcdir/$ac_dir/LINGUAS"`
172             # Hide the ALL_LINGUAS assigment from automake.
173             eval 'ALL_LINGUAS''=$ALL_LINGUAS_'
174             POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS"
175           else
176             # The set of available languages was given in configure.in.
177             eval 'ALL_LINGUAS''=$OBSOLETE_ALL_LINGUAS'
178           fi
179           case "$ac_given_srcdir" in
180             .) srcdirpre= ;;
181             *) srcdirpre='$(srcdir)/' ;;
182           esac
183           POFILES=
184           GMOFILES=
185           UPDATEPOFILES=
186           DUMMYPOFILES=
187           for lang in $ALL_LINGUAS; do
188             POFILES="$POFILES $srcdirpre$lang.po"
189             GMOFILES="$GMOFILES $srcdirpre$lang.gmo"
190             UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"
191             DUMMYPOFILES="$DUMMYPOFILES $lang.nop"
192           done
193           # CATALOGS depends on both $ac_dir and the user's LINGUAS
194           # environment variable.
195           INST_LINGUAS=
196           if test -n "$ALL_LINGUAS"; then
197             for presentlang in $ALL_LINGUAS; do
198               useit=no
199               if test "%UNSET%" != "$LINGUAS"; then
200                 desiredlanguages="$LINGUAS"
201               else
202                 desiredlanguages="$ALL_LINGUAS"
203               fi
204               for desiredlang in $desiredlanguages; do
205                 # Use the presentlang catalog if desiredlang is
206                 #   a. equal to presentlang, or
207                 #   b. a variant of presentlang (because in this case,
208                 #      presentlang can be used as a fallback for messages
209                 #      which are not translated in the desiredlang catalog).
210                 case "$desiredlang" in
211                   "$presentlang"*) useit=yes;;
212                 esac
213               done
214               if test $useit = yes; then
215                 INST_LINGUAS="$INST_LINGUAS $presentlang"
216               fi
217             done
218           fi
219           CATALOGS=
220           if test -n "$INST_LINGUAS"; then
221             for lang in $INST_LINGUAS; do
222               CATALOGS="$CATALOGS $lang.gmo"
223             done
224           fi
225           test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile"
226           sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile"
227           for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do
228             if test -f "$f"; then
229               case "$f" in
230                 *.orig | *.bak | *~) ;;
231                 *) cat "$f" >> "$ac_dir/Makefile" ;;
232               esac
233             fi
234           done
235         fi
236         ;;
237       esac
238     done],
239    [# Capture the value of obsolete ALL_LINGUAS because we need it to compute
240     # POFILES, GMOFILES, UPDATEPOFILES, DUMMYPOFILES, CATALOGS. But hide it
241     # from automake.
242     eval 'OBSOLETE_ALL_LINGUAS''="$ALL_LINGUAS"'
243     # Capture the value of LINGUAS because we need it to compute CATALOGS.
244     LINGUAS="${LINGUAS-%UNSET%}"
245    ])
246 ])
247 # gettext.m4 serial 20 (gettext-0.12)
248 dnl Copyright (C) 1995-2003 Free Software Foundation, Inc.
249 dnl This file is free software, distributed under the terms of the GNU
250 dnl General Public License.  As a special exception to the GNU General
251 dnl Public License, this file may be distributed as part of a program
252 dnl that contains a configuration script generated by Autoconf, under
253 dnl the same distribution terms as the rest of that program.
254 dnl
255 dnl This file can can be used in projects which are not available under
256 dnl the GNU General Public License or the GNU Library General Public
257 dnl License but which still want to provide support for the GNU gettext
258 dnl functionality.
259 dnl Please note that the actual code of the GNU gettext library is covered
260 dnl by the GNU Library General Public License, and the rest of the GNU
261 dnl gettext package package is covered by the GNU General Public License.
262 dnl They are *not* in the public domain.
263
264 dnl Authors:
265 dnl   Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
266 dnl   Bruno Haible <haible@clisp.cons.org>, 2000-2003.
267
268 dnl Macro to add for using GNU gettext.
269
270 dnl Usage: AM_GNU_GETTEXT([INTLSYMBOL], [NEEDSYMBOL], [INTLDIR]).
271 dnl INTLSYMBOL can be one of 'external', 'no-libtool', 'use-libtool'. The
272 dnl    default (if it is not specified or empty) is 'no-libtool'.
273 dnl    INTLSYMBOL should be 'external' for packages with no intl directory,
274 dnl    and 'no-libtool' or 'use-libtool' for packages with an intl directory.
275 dnl    If INTLSYMBOL is 'use-libtool', then a libtool library
276 dnl    $(top_builddir)/intl/libintl.la will be created (shared and/or static,
277 dnl    depending on --{enable,disable}-{shared,static} and on the presence of
278 dnl    AM-DISABLE-SHARED). If INTLSYMBOL is 'no-libtool', a static library
279 dnl    $(top_builddir)/intl/libintl.a will be created.
280 dnl If NEEDSYMBOL is specified and is 'need-ngettext', then GNU gettext
281 dnl    implementations (in libc or libintl) without the ngettext() function
282 dnl    will be ignored.  If NEEDSYMBOL is specified and is
283 dnl    'need-formatstring-macros', then GNU gettext implementations that don't
284 dnl    support the ISO C 99 <inttypes.h> formatstring macros will be ignored.
285 dnl INTLDIR is used to find the intl libraries.  If empty,
286 dnl    the value `$(top_builddir)/intl/' is used.
287 dnl
288 dnl The result of the configuration is one of three cases:
289 dnl 1) GNU gettext, as included in the intl subdirectory, will be compiled
290 dnl    and used.
291 dnl    Catalog format: GNU --> install in $(datadir)
292 dnl    Catalog extension: .mo after installation, .gmo in source tree
293 dnl 2) GNU gettext has been found in the system's C library.
294 dnl    Catalog format: GNU --> install in $(datadir)
295 dnl    Catalog extension: .mo after installation, .gmo in source tree
296 dnl 3) No internationalization, always use English msgid.
297 dnl    Catalog format: none
298 dnl    Catalog extension: none
299 dnl If INTLSYMBOL is 'external', only cases 2 and 3 can occur.
300 dnl The use of .gmo is historical (it was needed to avoid overwriting the
301 dnl GNU format catalogs when building on a platform with an X/Open gettext),
302 dnl but we keep it in order not to force irrelevant filename changes on the
303 dnl maintainers.
304 dnl
305 AC_DEFUN([AM_GNU_GETTEXT],
306 [
307   dnl Argument checking.
308   ifelse([$1], [], , [ifelse([$1], [external], , [ifelse([$1], [no-libtool], , [ifelse([$1], [use-libtool], ,
309     [errprint([ERROR: invalid first argument to AM_GNU_GETTEXT
310 ])])])])])
311   ifelse([$2], [], , [ifelse([$2], [need-ngettext], , [ifelse([$2], [need-formatstring-macros], ,
312     [errprint([ERROR: invalid second argument to AM_GNU_GETTEXT
313 ])])])])
314   define(gt_included_intl, ifelse([$1], [external], [no], [yes]))
315   define(gt_libtool_suffix_prefix, ifelse([$1], [use-libtool], [l], []))
316
317   AC_REQUIRE([AM_PO_SUBDIRS])dnl
318   ifelse(gt_included_intl, yes, [
319     AC_REQUIRE([AM_INTL_SUBDIR])dnl
320   ])
321
322   dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
323   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
324   AC_REQUIRE([AC_LIB_RPATH])
325
326   dnl Sometimes libintl requires libiconv, so first search for libiconv.
327   dnl Ideally we would do this search only after the
328   dnl      if test "$USE_NLS" = "yes"; then
329   dnl        if test "$gt_cv_func_gnugettext_libc" != "yes"; then
330   dnl tests. But if configure.in invokes AM_ICONV after AM_GNU_GETTEXT
331   dnl the configure script would need to contain the same shell code
332   dnl again, outside any 'if'. There are two solutions:
333   dnl - Invoke AM_ICONV_LINKFLAGS_BODY here, outside any 'if'.
334   dnl - Control the expansions in more detail using AC_PROVIDE_IFELSE.
335   dnl Since AC_PROVIDE_IFELSE is only in autoconf >= 2.52 and not
336   dnl documented, we avoid it.
337   ifelse(gt_included_intl, yes, , [
338     AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
339   ])
340
341   dnl Set USE_NLS.
342   AM_NLS
343
344   ifelse(gt_included_intl, yes, [
345     BUILD_INCLUDED_LIBINTL=no
346     USE_INCLUDED_LIBINTL=no
347   ])
348   LIBINTL=
349   LTLIBINTL=
350   POSUB=
351
352   dnl If we use NLS figure out what method
353   if test "$USE_NLS" = "yes"; then
354     gt_use_preinstalled_gnugettext=no
355     ifelse(gt_included_intl, yes, [
356       AC_MSG_CHECKING([whether included gettext is requested])
357       AC_ARG_WITH(included-gettext,
358         [  --with-included-gettext use the GNU gettext library included here],
359         nls_cv_force_use_gnu_gettext=$withval,
360         nls_cv_force_use_gnu_gettext=no)
361       AC_MSG_RESULT($nls_cv_force_use_gnu_gettext)
362
363       nls_cv_use_gnu_gettext="$nls_cv_force_use_gnu_gettext"
364       if test "$nls_cv_force_use_gnu_gettext" != "yes"; then
365     ])
366         dnl User does not insist on using GNU NLS library.  Figure out what
367         dnl to use.  If GNU gettext is available we use this.  Else we have
368         dnl to fall back to GNU NLS library.
369
370         dnl Add a version number to the cache macros.
371         define([gt_api_version], ifelse([$2], [need-formatstring-macros], 3, ifelse([$2], [need-ngettext], 2, 1)))
372         define([gt_cv_func_gnugettext_libc], [gt_cv_func_gnugettext]gt_api_version[_libc])
373         define([gt_cv_func_gnugettext_libintl], [gt_cv_func_gnugettext]gt_api_version[_libintl])
374
375         AC_CACHE_CHECK([for GNU gettext in libc], gt_cv_func_gnugettext_libc,
376          [AC_TRY_LINK([#include <libintl.h>
377 ]ifelse([$2], [need-formatstring-macros],
378 [#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
379 #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
380 #endif
381 changequote(,)dnl
382 typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
383 changequote([,])dnl
384 ], [])[extern int _nl_msg_cat_cntr;
385 extern int *_nl_domain_bindings;],
386             [bindtextdomain ("", "");
387 return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_domain_bindings],
388             gt_cv_func_gnugettext_libc=yes,
389             gt_cv_func_gnugettext_libc=no)])
390
391         if test "$gt_cv_func_gnugettext_libc" != "yes"; then
392           dnl Sometimes libintl requires libiconv, so first search for libiconv.
393           ifelse(gt_included_intl, yes, , [
394             AM_ICONV_LINK
395           ])
396           dnl Search for libintl and define LIBINTL, LTLIBINTL and INCINTL
397           dnl accordingly. Don't use AC_LIB_LINKFLAGS_BODY([intl],[iconv])
398           dnl because that would add "-liconv" to LIBINTL and LTLIBINTL
399           dnl even if libiconv doesn't exist.
400           AC_LIB_LINKFLAGS_BODY([intl])
401           AC_CACHE_CHECK([for GNU gettext in libintl],
402             gt_cv_func_gnugettext_libintl,
403            [gt_save_CPPFLAGS="$CPPFLAGS"
404             CPPFLAGS="$CPPFLAGS $INCINTL"
405             gt_save_LIBS="$LIBS"
406             LIBS="$LIBS $LIBINTL"
407             dnl Now see whether libintl exists and does not depend on libiconv.
408             AC_TRY_LINK([#include <libintl.h>
409 ]ifelse([$2], [need-formatstring-macros],
410 [#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
411 #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
412 #endif
413 changequote(,)dnl
414 typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
415 changequote([,])dnl
416 ], [])[extern int _nl_msg_cat_cntr;
417 extern
418 #ifdef __cplusplus
419 "C"
420 #endif
421 const char *_nl_expand_alias ();],
422               [bindtextdomain ("", "");
423 return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias (0)],
424               gt_cv_func_gnugettext_libintl=yes,
425               gt_cv_func_gnugettext_libintl=no)
426             dnl Now see whether libintl exists and depends on libiconv.
427             if test "$gt_cv_func_gnugettext_libintl" != yes && test -n "$LIBICONV"; then
428               LIBS="$LIBS $LIBICONV"
429               AC_TRY_LINK([#include <libintl.h>
430 ]ifelse([$2], [need-formatstring-macros],
431 [#ifndef __GNU_GETTEXT_SUPPORTED_REVISION
432 #define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)
433 #endif
434 changequote(,)dnl
435 typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];
436 changequote([,])dnl
437 ], [])[extern int _nl_msg_cat_cntr;
438 extern
439 #ifdef __cplusplus
440 "C"
441 #endif
442 const char *_nl_expand_alias ();],
443                 [bindtextdomain ("", "");
444 return (int) gettext ("")]ifelse([$2], [need-ngettext], [ + (int) ngettext ("", "", 0)], [])[ + _nl_msg_cat_cntr + *_nl_expand_alias (0)],
445                [LIBINTL="$LIBINTL $LIBICONV"
446                 LTLIBINTL="$LTLIBINTL $LTLIBICONV"
447                 gt_cv_func_gnugettext_libintl=yes
448                ])
449             fi
450             CPPFLAGS="$gt_save_CPPFLAGS"
451             LIBS="$gt_save_LIBS"])
452         fi
453
454         dnl If an already present or preinstalled GNU gettext() is found,
455         dnl use it.  But if this macro is used in GNU gettext, and GNU
456         dnl gettext is already preinstalled in libintl, we update this
457         dnl libintl.  (Cf. the install rule in intl/Makefile.in.)
458         if test "$gt_cv_func_gnugettext_libc" = "yes" \
459            || { test "$gt_cv_func_gnugettext_libintl" = "yes" \
460                 && test "$PACKAGE" != gettext-runtime \
461                 && test "$PACKAGE" != gettext-tools; }; then
462           gt_use_preinstalled_gnugettext=yes
463         else
464           dnl Reset the values set by searching for libintl.
465           LIBINTL=
466           LTLIBINTL=
467           INCINTL=
468         fi
469
470     ifelse(gt_included_intl, yes, [
471         if test "$gt_use_preinstalled_gnugettext" != "yes"; then
472           dnl GNU gettext is not found in the C library.
473           dnl Fall back on included GNU gettext library.
474           nls_cv_use_gnu_gettext=yes
475         fi
476       fi
477
478       if test "$nls_cv_use_gnu_gettext" = "yes"; then
479         dnl Mark actions used to generate GNU NLS library.
480         BUILD_INCLUDED_LIBINTL=yes
481         USE_INCLUDED_LIBINTL=yes
482         LIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LIBICONV"
483         LTLIBINTL="ifelse([$3],[],\${top_builddir}/intl,[$3])/libintl.[]gt_libtool_suffix_prefix[]a $LTLIBICONV"
484         LIBS=`echo " $LIBS " | sed -e 's/ -lintl / /' -e 's/^ //' -e 's/ $//'`
485       fi
486
487       if test "$gt_use_preinstalled_gnugettext" = "yes" \
488          || test "$nls_cv_use_gnu_gettext" = "yes"; then
489         dnl Mark actions to use GNU gettext tools.
490         CATOBJEXT=.gmo
491       fi
492     ])
493
494     if test "$gt_use_preinstalled_gnugettext" = "yes" \
495        || test "$nls_cv_use_gnu_gettext" = "yes"; then
496       AC_DEFINE(ENABLE_NLS, 1,
497         [Define to 1 if translation of program messages to the user's native language
498    is requested.])
499     else
500       USE_NLS=no
501     fi
502   fi
503
504   AC_MSG_CHECKING([whether to use NLS])
505   AC_MSG_RESULT([$USE_NLS])
506   if test "$USE_NLS" = "yes"; then
507     AC_MSG_CHECKING([where the gettext function comes from])
508     if test "$gt_use_preinstalled_gnugettext" = "yes"; then
509       if test "$gt_cv_func_gnugettext_libintl" = "yes"; then
510         gt_source="external libintl"
511       else
512         gt_source="libc"
513       fi
514     else
515       gt_source="included intl directory"
516     fi
517     AC_MSG_RESULT([$gt_source])
518   fi
519
520   if test "$USE_NLS" = "yes"; then
521
522     if test "$gt_use_preinstalled_gnugettext" = "yes"; then
523       if test "$gt_cv_func_gnugettext_libintl" = "yes"; then
524         AC_MSG_CHECKING([how to link with libintl])
525         AC_MSG_RESULT([$LIBINTL])
526         AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCINTL])
527       fi
528
529       dnl For backward compatibility. Some packages may be using this.
530       AC_DEFINE(HAVE_GETTEXT, 1,
531        [Define if the GNU gettext() function is already present or preinstalled.])
532       AC_DEFINE(HAVE_DCGETTEXT, 1,
533        [Define if the GNU dcgettext() function is already present or preinstalled.])
534     fi
535
536     dnl We need to process the po/ directory.
537     POSUB=po
538   fi
539
540   ifelse(gt_included_intl, yes, [
541     dnl If this is used in GNU gettext we have to set BUILD_INCLUDED_LIBINTL
542     dnl to 'yes' because some of the testsuite requires it.
543     if test "$PACKAGE" = gettext-runtime || test "$PACKAGE" = gettext-tools; then
544       BUILD_INCLUDED_LIBINTL=yes
545     fi
546
547     dnl Make all variables we use known to autoconf.
548     AC_SUBST(BUILD_INCLUDED_LIBINTL)
549     AC_SUBST(USE_INCLUDED_LIBINTL)
550     AC_SUBST(CATOBJEXT)
551
552     dnl For backward compatibility. Some configure.ins may be using this.
553     nls_cv_header_intl=
554     nls_cv_header_libgt=
555
556     dnl For backward compatibility. Some Makefiles may be using this.
557     DATADIRNAME=share
558     AC_SUBST(DATADIRNAME)
559
560     dnl For backward compatibility. Some Makefiles may be using this.
561     INSTOBJEXT=.mo
562     AC_SUBST(INSTOBJEXT)
563
564     dnl For backward compatibility. Some Makefiles may be using this.
565     GENCAT=gencat
566     AC_SUBST(GENCAT)
567
568     dnl For backward compatibility. Some Makefiles may be using this.
569     if test "$USE_INCLUDED_LIBINTL" = yes; then
570       INTLOBJS="\$(GETTOBJS)"
571     fi
572     AC_SUBST(INTLOBJS)
573
574     dnl Enable libtool support if the surrounding package wishes it.
575     INTL_LIBTOOL_SUFFIX_PREFIX=gt_libtool_suffix_prefix
576     AC_SUBST(INTL_LIBTOOL_SUFFIX_PREFIX)
577   ])
578
579   dnl For backward compatibility. Some Makefiles may be using this.
580   INTLLIBS="$LIBINTL"
581   AC_SUBST(INTLLIBS)
582
583   dnl Make all documented variables known to autoconf.
584   AC_SUBST(LIBINTL)
585   AC_SUBST(LTLIBINTL)
586   AC_SUBST(POSUB)
587 ])
588
589
590 dnl Checks for all prerequisites of the intl subdirectory,
591 dnl except for INTL_LIBTOOL_SUFFIX_PREFIX (and possibly LIBTOOL), INTLOBJS,
592 dnl            USE_INCLUDED_LIBINTL, BUILD_INCLUDED_LIBINTL.
593 AC_DEFUN([AM_INTL_SUBDIR],
594 [
595   AC_REQUIRE([AC_PROG_INSTALL])dnl
596   AC_REQUIRE([AM_MKINSTALLDIRS])dnl
597   AC_REQUIRE([AC_PROG_CC])dnl
598   AC_REQUIRE([AC_CANONICAL_HOST])dnl
599   AC_REQUIRE([AC_PROG_RANLIB])dnl
600   AC_REQUIRE([AC_ISC_POSIX])dnl
601   AC_REQUIRE([AC_HEADER_STDC])dnl
602   AC_REQUIRE([AC_C_CONST])dnl
603   AC_REQUIRE([AC_C_INLINE])dnl
604   AC_REQUIRE([AC_TYPE_OFF_T])dnl
605   AC_REQUIRE([AC_TYPE_SIZE_T])dnl
606   AC_REQUIRE([AC_FUNC_ALLOCA])dnl
607   AC_REQUIRE([AC_FUNC_MMAP])dnl
608   AC_REQUIRE([jm_GLIBC21])dnl
609   AC_REQUIRE([gt_INTDIV0])dnl
610   AC_REQUIRE([jm_AC_TYPE_UINTMAX_T])dnl
611   AC_REQUIRE([gt_HEADER_INTTYPES_H])dnl
612   AC_REQUIRE([gt_INTTYPES_PRI])dnl
613
614   AC_CHECK_HEADERS([argz.h limits.h locale.h nl_types.h malloc.h stddef.h \
615 stdlib.h string.h unistd.h sys/param.h])
616   AC_CHECK_FUNCS([feof_unlocked fgets_unlocked getc_unlocked getcwd getegid \
617 geteuid getgid getuid mempcpy munmap putenv setenv setlocale stpcpy \
618 strcasecmp strdup strtoul tsearch __argz_count __argz_stringify __argz_next \
619 __fsetlocking])
620
621   AM_ICONV
622   AM_LANGINFO_CODESET
623   if test $ac_cv_header_locale_h = yes; then
624     AM_LC_MESSAGES
625   fi
626
627   dnl intl/plural.c is generated from intl/plural.y. It requires bison,
628   dnl because plural.y uses bison specific features. It requires at least
629   dnl bison-1.26 because earlier versions generate a plural.c that doesn't
630   dnl compile.
631   dnl bison is only needed for the maintainer (who touches plural.y). But in
632   dnl order to avoid separate Makefiles or --enable-maintainer-mode, we put
633   dnl the rule in general Makefile. Now, some people carelessly touch the
634   dnl files or have a broken "make" program, hence the plural.c rule will
635   dnl sometimes fire. To avoid an error, defines BISON to ":" if it is not
636   dnl present or too old.
637   AC_CHECK_PROGS([INTLBISON], [bison])
638   if test -z "$INTLBISON"; then
639     ac_verc_fail=yes
640   else
641     dnl Found it, now check the version.
642     AC_MSG_CHECKING([version of bison])
643 changequote(<<,>>)dnl
644     ac_prog_version=`$INTLBISON --version 2>&1 | sed -n 's/^.*GNU Bison.* \([0-9]*\.[0-9.]*\).*$/\1/p'`
645     case $ac_prog_version in
646       '') ac_prog_version="v. ?.??, bad"; ac_verc_fail=yes;;
647       1.2[6-9]* | 1.[3-9][0-9]* | [2-9].*)
648 changequote([,])dnl
649          ac_prog_version="$ac_prog_version, ok"; ac_verc_fail=no;;
650       *) ac_prog_version="$ac_prog_version, bad"; ac_verc_fail=yes;;
651     esac
652     AC_MSG_RESULT([$ac_prog_version])
653   fi
654   if test $ac_verc_fail = yes; then
655     INTLBISON=:
656   fi
657 ])
658
659
660 dnl Usage: AM_GNU_GETTEXT_VERSION([gettext-version])
661 AC_DEFUN([AM_GNU_GETTEXT_VERSION], [])
662 # iconv.m4 serial AM4 (gettext-0.11.3)
663 dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
664 dnl This file is free software, distributed under the terms of the GNU
665 dnl General Public License.  As a special exception to the GNU General
666 dnl Public License, this file may be distributed as part of a program
667 dnl that contains a configuration script generated by Autoconf, under
668 dnl the same distribution terms as the rest of that program.
669
670 dnl From Bruno Haible.
671
672 AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
673 [
674   dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
675   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
676   AC_REQUIRE([AC_LIB_RPATH])
677
678   dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
679   dnl accordingly.
680   AC_LIB_LINKFLAGS_BODY([iconv])
681 ])
682
683 AC_DEFUN([AM_ICONV_LINK],
684 [
685   dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
686   dnl those with the standalone portable GNU libiconv installed).
687
688   dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
689   dnl accordingly.
690   AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
691
692   dnl Add $INCICONV to CPPFLAGS before performing the following checks,
693   dnl because if the user has installed libiconv and not disabled its use
694   dnl via --without-libiconv-prefix, he wants to use it. The first
695   dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed.
696   am_save_CPPFLAGS="$CPPFLAGS"
697   AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
698
699   AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
700     am_cv_func_iconv="no, consider installing GNU libiconv"
701     am_cv_lib_iconv=no
702     AC_TRY_LINK([#include <stdlib.h>
703 #include <iconv.h>],
704       [iconv_t cd = iconv_open("","");
705        iconv(cd,NULL,NULL,NULL,NULL);
706        iconv_close(cd);],
707       am_cv_func_iconv=yes)
708     if test "$am_cv_func_iconv" != yes; then
709       am_save_LIBS="$LIBS"
710       LIBS="$LIBS $LIBICONV"
711       AC_TRY_LINK([#include <stdlib.h>
712 #include <iconv.h>],
713         [iconv_t cd = iconv_open("","");
714          iconv(cd,NULL,NULL,NULL,NULL);
715          iconv_close(cd);],
716         am_cv_lib_iconv=yes
717         am_cv_func_iconv=yes)
718       LIBS="$am_save_LIBS"
719     fi
720   ])
721   if test "$am_cv_func_iconv" = yes; then
722     AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
723   fi
724   if test "$am_cv_lib_iconv" = yes; then
725     AC_MSG_CHECKING([how to link with libiconv])
726     AC_MSG_RESULT([$LIBICONV])
727   else
728     dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
729     dnl either.
730     CPPFLAGS="$am_save_CPPFLAGS"
731     LIBICONV=
732     LTLIBICONV=
733   fi
734   AC_SUBST(LIBICONV)
735   AC_SUBST(LTLIBICONV)
736 ])
737
738 AC_DEFUN([AM_ICONV],
739 [
740   AM_ICONV_LINK
741   if test "$am_cv_func_iconv" = yes; then
742     AC_MSG_CHECKING([for iconv declaration])
743     AC_CACHE_VAL(am_cv_proto_iconv, [
744       AC_TRY_COMPILE([
745 #include <stdlib.h>
746 #include <iconv.h>
747 extern
748 #ifdef __cplusplus
749 "C"
750 #endif
751 #if defined(__STDC__) || defined(__cplusplus)
752 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
753 #else
754 size_t iconv();
755 #endif
756 ], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
757       am_cv_proto_iconv="extern size_t iconv (iconv_t cd, $am_cv_proto_iconv_arg1 char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);"])
758     am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
759     AC_MSG_RESULT([$]{ac_t:-
760          }[$]am_cv_proto_iconv)
761     AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
762       [Define as const if the declaration of iconv() needs const.])
763   fi
764 ])
765 # lib-ld.m4 serial 2 (gettext-0.12)
766 dnl Copyright (C) 1996-2003 Free Software Foundation, Inc.
767 dnl This file is free software, distributed under the terms of the GNU
768 dnl General Public License.  As a special exception to the GNU General
769 dnl Public License, this file may be distributed as part of a program
770 dnl that contains a configuration script generated by Autoconf, under
771 dnl the same distribution terms as the rest of that program.
772
773 dnl Subroutines of libtool.m4,
774 dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision
775 dnl with libtool.m4.
776
777 dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
778 AC_DEFUN([AC_LIB_PROG_LD_GNU],
779 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld,
780 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
781 if $LD -v 2>&1 </dev/null | egrep '(GNU|with BFD)' 1>&5; then
782   acl_cv_prog_gnu_ld=yes
783 else
784   acl_cv_prog_gnu_ld=no
785 fi])
786 with_gnu_ld=$acl_cv_prog_gnu_ld
787 ])
788
789 dnl From libtool-1.4. Sets the variable LD.
790 AC_DEFUN([AC_LIB_PROG_LD],
791 [AC_ARG_WITH(gnu-ld,
792 [  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
793 test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
794 AC_REQUIRE([AC_PROG_CC])dnl
795 AC_REQUIRE([AC_CANONICAL_HOST])dnl
796 # Prepare PATH_SEPARATOR.
797 # The user is always right.
798 if test "${PATH_SEPARATOR+set}" != set; then
799   echo "#! /bin/sh" >conf$$.sh
800   echo  "exit 0"   >>conf$$.sh
801   chmod +x conf$$.sh
802   if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
803     PATH_SEPARATOR=';'
804   else
805     PATH_SEPARATOR=:
806   fi
807   rm -f conf$$.sh
808 fi
809 ac_prog=ld
810 if test "$GCC" = yes; then
811   # Check if gcc -print-prog-name=ld gives a path.
812   AC_MSG_CHECKING([for ld used by GCC])
813   case $host in
814   *-*-mingw*)
815     # gcc leaves a trailing carriage return which upsets mingw
816     ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
817   *)
818     ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
819   esac
820   case $ac_prog in
821     # Accept absolute paths.
822     [[\\/]* | [A-Za-z]:[\\/]*)]
823       [re_direlt='/[^/][^/]*/\.\./']
824       # Canonicalize the path of ld
825       ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
826       while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
827         ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
828       done
829       test -z "$LD" && LD="$ac_prog"
830       ;;
831   "")
832     # If it fails, then pretend we aren't using GCC.
833     ac_prog=ld
834     ;;
835   *)
836     # If it is relative, then search for the first ld in PATH.
837     with_gnu_ld=unknown
838     ;;
839   esac
840 elif test "$with_gnu_ld" = yes; then
841   AC_MSG_CHECKING([for GNU ld])
842 else
843   AC_MSG_CHECKING([for non-GNU ld])
844 fi
845 AC_CACHE_VAL(acl_cv_path_LD,
846 [if test -z "$LD"; then
847   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
848   for ac_dir in $PATH; do
849     test -z "$ac_dir" && ac_dir=.
850     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
851       acl_cv_path_LD="$ac_dir/$ac_prog"
852       # Check to see if the program is GNU ld.  I'd rather use --version,
853       # but apparently some GNU ld's only accept -v.
854       # Break only if it was the GNU/non-GNU ld that we prefer.
855       if "$acl_cv_path_LD" -v 2>&1 < /dev/null | egrep '(GNU|with BFD)' > /dev/null; then
856         test "$with_gnu_ld" != no && break
857       else
858         test "$with_gnu_ld" != yes && break
859       fi
860     fi
861   done
862   IFS="$ac_save_ifs"
863 else
864   acl_cv_path_LD="$LD" # Let the user override the test with a path.
865 fi])
866 LD="$acl_cv_path_LD"
867 if test -n "$LD"; then
868   AC_MSG_RESULT($LD)
869 else
870   AC_MSG_RESULT(no)
871 fi
872 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
873 AC_LIB_PROG_LD_GNU
874 ])
875 # lib-link.m4 serial 4 (gettext-0.12)
876 dnl Copyright (C) 2001-2003 Free Software Foundation, Inc.
877 dnl This file is free software, distributed under the terms of the GNU
878 dnl General Public License.  As a special exception to the GNU General
879 dnl Public License, this file may be distributed as part of a program
880 dnl that contains a configuration script generated by Autoconf, under
881 dnl the same distribution terms as the rest of that program.
882
883 dnl From Bruno Haible.
884
885 dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
886 dnl the libraries corresponding to explicit and implicit dependencies.
887 dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
888 dnl augments the CPPFLAGS variable.
889 AC_DEFUN([AC_LIB_LINKFLAGS],
890 [
891   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
892   AC_REQUIRE([AC_LIB_RPATH])
893   define([Name],[translit([$1],[./-], [___])])
894   define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
895                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
896   AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
897     AC_LIB_LINKFLAGS_BODY([$1], [$2])
898     ac_cv_lib[]Name[]_libs="$LIB[]NAME"
899     ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
900     ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
901   ])
902   LIB[]NAME="$ac_cv_lib[]Name[]_libs"
903   LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
904   INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
905   AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
906   AC_SUBST([LIB]NAME)
907   AC_SUBST([LTLIB]NAME)
908   dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
909   dnl results of this search when this library appears as a dependency.
910   HAVE_LIB[]NAME=yes
911   undefine([Name])
912   undefine([NAME])
913 ])
914
915 dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode)
916 dnl searches for libname and the libraries corresponding to explicit and
917 dnl implicit dependencies, together with the specified include files and
918 dnl the ability to compile and link the specified testcode. If found, it
919 dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and
920 dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and
921 dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
922 dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
923 AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
924 [
925   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
926   AC_REQUIRE([AC_LIB_RPATH])
927   define([Name],[translit([$1],[./-], [___])])
928   define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
929                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
930
931   dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
932   dnl accordingly.
933   AC_LIB_LINKFLAGS_BODY([$1], [$2])
934
935   dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
936   dnl because if the user has installed lib[]Name and not disabled its use
937   dnl via --without-lib[]Name-prefix, he wants to use it.
938   ac_save_CPPFLAGS="$CPPFLAGS"
939   AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
940
941   AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
942     ac_save_LIBS="$LIBS"
943     LIBS="$LIBS $LIB[]NAME"
944     AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no])
945     LIBS="$ac_save_LIBS"
946   ])
947   if test "$ac_cv_lib[]Name" = yes; then
948     HAVE_LIB[]NAME=yes
949     AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.])
950     AC_MSG_CHECKING([how to link with lib[]$1])
951     AC_MSG_RESULT([$LIB[]NAME])
952   else
953     HAVE_LIB[]NAME=no
954     dnl If $LIB[]NAME didn't lead to a usable library, we don't need
955     dnl $INC[]NAME either.
956     CPPFLAGS="$ac_save_CPPFLAGS"
957     LIB[]NAME=
958     LTLIB[]NAME=
959   fi
960   AC_SUBST([HAVE_LIB]NAME)
961   AC_SUBST([LIB]NAME)
962   AC_SUBST([LTLIB]NAME)
963   undefine([Name])
964   undefine([NAME])
965 ])
966
967 dnl Determine the platform dependent parameters needed to use rpath:
968 dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator,
969 dnl hardcode_direct, hardcode_minus_L.
970 AC_DEFUN([AC_LIB_RPATH],
971 [
972   AC_REQUIRE([AC_PROG_CC])                dnl we use $CC, $GCC, $LDFLAGS
973   AC_REQUIRE([AC_LIB_PROG_LD])            dnl we use $LD, $with_gnu_ld
974   AC_REQUIRE([AC_CANONICAL_HOST])         dnl we use $host
975   AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
976   AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [
977     CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
978     ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
979     . ./conftest.sh
980     rm -f ./conftest.sh
981     acl_cv_rpath=done
982   ])
983   wl="$acl_cv_wl"
984   libext="$acl_cv_libext"
985   shlibext="$acl_cv_shlibext"
986   hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
987   hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
988   hardcode_direct="$acl_cv_hardcode_direct"
989   hardcode_minus_L="$acl_cv_hardcode_minus_L"
990   dnl Determine whether the user wants rpath handling at all.
991   AC_ARG_ENABLE(rpath,
992     [  --disable-rpath         do not hardcode runtime library paths],
993     :, enable_rpath=yes)
994 ])
995
996 dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
997 dnl the libraries corresponding to explicit and implicit dependencies.
998 dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
999 AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
1000 [
1001   define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
1002                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
1003   dnl By default, look in $includedir and $libdir.
1004   use_additional=yes
1005   AC_LIB_WITH_FINAL_PREFIX([
1006     eval additional_includedir=\"$includedir\"
1007     eval additional_libdir=\"$libdir\"
1008   ])
1009   AC_LIB_ARG_WITH([lib$1-prefix],
1010 [  --with-lib$1-prefix[=DIR]  search for lib$1 in DIR/include and DIR/lib
1011   --without-lib$1-prefix     don't search for lib$1 in includedir and libdir],
1012 [
1013     if test "X$withval" = "Xno"; then
1014       use_additional=no
1015     else
1016       if test "X$withval" = "X"; then
1017         AC_LIB_WITH_FINAL_PREFIX([
1018           eval additional_includedir=\"$includedir\"
1019           eval additional_libdir=\"$libdir\"
1020         ])
1021       else
1022         additional_includedir="$withval/include"
1023         additional_libdir="$withval/lib"
1024       fi
1025     fi
1026 ])
1027   dnl Search the library and its dependencies in $additional_libdir and
1028   dnl $LDFLAGS. Using breadth-first-seach.
1029   LIB[]NAME=
1030   LTLIB[]NAME=
1031   INC[]NAME=
1032   rpathdirs=
1033   ltrpathdirs=
1034   names_already_handled=
1035   names_next_round='$1 $2'
1036   while test -n "$names_next_round"; do
1037     names_this_round="$names_next_round"
1038     names_next_round=
1039     for name in $names_this_round; do
1040       already_handled=
1041       for n in $names_already_handled; do
1042         if test "$n" = "$name"; then
1043           already_handled=yes
1044           break
1045         fi
1046       done
1047       if test -z "$already_handled"; then
1048         names_already_handled="$names_already_handled $name"
1049         dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
1050         dnl or AC_LIB_HAVE_LINKFLAGS call.
1051         uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
1052         eval value=\"\$HAVE_LIB$uppername\"
1053         if test -n "$value"; then
1054           if test "$value" = yes; then
1055             eval value=\"\$LIB$uppername\"
1056             test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
1057             eval value=\"\$LTLIB$uppername\"
1058             test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
1059           else
1060             dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
1061             dnl that this library doesn't exist. So just drop it.
1062             :
1063           fi
1064         else
1065           dnl Search the library lib$name in $additional_libdir and $LDFLAGS
1066           dnl and the already constructed $LIBNAME/$LTLIBNAME.
1067           found_dir=
1068           found_la=
1069           found_so=
1070           found_a=
1071           if test $use_additional = yes; then
1072             if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
1073               found_dir="$additional_libdir"
1074               found_so="$additional_libdir/lib$name.$shlibext"
1075               if test -f "$additional_libdir/lib$name.la"; then
1076                 found_la="$additional_libdir/lib$name.la"
1077               fi
1078             else
1079               if test -f "$additional_libdir/lib$name.$libext"; then
1080                 found_dir="$additional_libdir"
1081                 found_a="$additional_libdir/lib$name.$libext"
1082                 if test -f "$additional_libdir/lib$name.la"; then
1083                   found_la="$additional_libdir/lib$name.la"
1084                 fi
1085               fi
1086             fi
1087           fi
1088           if test "X$found_dir" = "X"; then
1089             for x in $LDFLAGS $LTLIB[]NAME; do
1090               AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
1091               case "$x" in
1092                 -L*)
1093                   dir=`echo "X$x" | sed -e 's/^X-L//'`
1094                   if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
1095                     found_dir="$dir"
1096                     found_so="$dir/lib$name.$shlibext"
1097                     if test -f "$dir/lib$name.la"; then
1098                       found_la="$dir/lib$name.la"
1099                     fi
1100                   else
1101                     if test -f "$dir/lib$name.$libext"; then
1102                       found_dir="$dir"
1103                       found_a="$dir/lib$name.$libext"
1104                       if test -f "$dir/lib$name.la"; then
1105                         found_la="$dir/lib$name.la"
1106                       fi
1107                     fi
1108                   fi
1109                   ;;
1110               esac
1111               if test "X$found_dir" != "X"; then
1112                 break
1113               fi
1114             done
1115           fi
1116           if test "X$found_dir" != "X"; then
1117             dnl Found the library.
1118             LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
1119             if test "X$found_so" != "X"; then
1120               dnl Linking with a shared library. We attempt to hardcode its
1121               dnl directory into the executable's runpath, unless it's the
1122               dnl standard /usr/lib.
1123               if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
1124                 dnl No hardcoding is needed.
1125                 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
1126               else
1127                 dnl Use an explicit option to hardcode DIR into the resulting
1128                 dnl binary.
1129                 dnl Potentially add DIR to ltrpathdirs.
1130                 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
1131                 haveit=
1132                 for x in $ltrpathdirs; do
1133                   if test "X$x" = "X$found_dir"; then
1134                     haveit=yes
1135                     break
1136                   fi
1137                 done
1138                 if test -z "$haveit"; then
1139                   ltrpathdirs="$ltrpathdirs $found_dir"
1140                 fi
1141                 dnl The hardcoding into $LIBNAME is system dependent.
1142                 if test "$hardcode_direct" = yes; then
1143                   dnl Using DIR/libNAME.so during linking hardcodes DIR into the
1144                   dnl resulting binary.
1145                   LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
1146                 else
1147                   if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
1148                     dnl Use an explicit option to hardcode DIR into the resulting
1149                     dnl binary.
1150                     LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
1151                     dnl Potentially add DIR to rpathdirs.
1152                     dnl The rpathdirs will be appended to $LIBNAME at the end.
1153                     haveit=
1154                     for x in $rpathdirs; do
1155                       if test "X$x" = "X$found_dir"; then
1156                         haveit=yes
1157                         break
1158                       fi
1159                     done
1160                     if test -z "$haveit"; then
1161                       rpathdirs="$rpathdirs $found_dir"
1162                     fi
1163                   else
1164                     dnl Rely on "-L$found_dir".
1165                     dnl But don't add it if it's already contained in the LDFLAGS
1166                     dnl or the already constructed $LIBNAME
1167                     haveit=
1168                     for x in $LDFLAGS $LIB[]NAME; do
1169                       AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
1170                       if test "X$x" = "X-L$found_dir"; then
1171                         haveit=yes
1172                         break
1173                       fi
1174                     done
1175                     if test -z "$haveit"; then
1176                       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
1177                     fi
1178                     if test "$hardcode_minus_L" != no; then
1179                       dnl FIXME: Not sure whether we should use
1180                       dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
1181                       dnl here.
1182                       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
1183                     else
1184                       dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH
1185                       dnl here, because this doesn't fit in flags passed to the
1186                       dnl compiler. So give up. No hardcoding. This affects only
1187                       dnl very old systems.
1188                       dnl FIXME: Not sure whether we should use
1189                       dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
1190                       dnl here.
1191                       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
1192                     fi
1193                   fi
1194                 fi
1195               fi
1196             else
1197               if test "X$found_a" != "X"; then
1198                 dnl Linking with a static library.
1199                 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
1200               else
1201                 dnl We shouldn't come here, but anyway it's good to have a
1202                 dnl fallback.
1203                 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
1204               fi
1205             fi
1206             dnl Assume the include files are nearby.
1207             additional_includedir=
1208             case "$found_dir" in
1209               */lib | */lib/)
1210                 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
1211                 additional_includedir="$basedir/include"
1212                 ;;
1213             esac
1214             if test "X$additional_includedir" != "X"; then
1215               dnl Potentially add $additional_includedir to $INCNAME.
1216               dnl But don't add it
1217               dnl   1. if it's the standard /usr/include,
1218               dnl   2. if it's /usr/local/include and we are using GCC on Linux,
1219               dnl   3. if it's already present in $CPPFLAGS or the already
1220               dnl      constructed $INCNAME,
1221               dnl   4. if it doesn't exist as a directory.
1222               if test "X$additional_includedir" != "X/usr/include"; then
1223                 haveit=
1224                 if test "X$additional_includedir" = "X/usr/local/include"; then
1225                   if test -n "$GCC"; then
1226                     case $host_os in
1227                       linux*) haveit=yes;;
1228                     esac
1229                   fi
1230                 fi
1231                 if test -z "$haveit"; then
1232                   for x in $CPPFLAGS $INC[]NAME; do
1233                     AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
1234                     if test "X$x" = "X-I$additional_includedir"; then
1235                       haveit=yes
1236                       break
1237                     fi
1238                   done
1239                   if test -z "$haveit"; then
1240                     if test -d "$additional_includedir"; then
1241                       dnl Really add $additional_includedir to $INCNAME.
1242                       INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
1243                     fi
1244                   fi
1245                 fi
1246               fi
1247             fi
1248             dnl Look for dependencies.
1249             if test -n "$found_la"; then
1250               dnl Read the .la file. It defines the variables
1251               dnl dlname, library_names, old_library, dependency_libs, current,
1252               dnl age, revision, installed, dlopen, dlpreopen, libdir.
1253               save_libdir="$libdir"
1254               case "$found_la" in
1255                 */* | *\\*) . "$found_la" ;;
1256                 *) . "./$found_la" ;;
1257               esac
1258               libdir="$save_libdir"
1259               dnl We use only dependency_libs.
1260               for dep in $dependency_libs; do
1261                 case "$dep" in
1262                   -L*)
1263                     additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
1264                     dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
1265                     dnl But don't add it
1266                     dnl   1. if it's the standard /usr/lib,
1267                     dnl   2. if it's /usr/local/lib and we are using GCC on Linux,
1268                     dnl   3. if it's already present in $LDFLAGS or the already
1269                     dnl      constructed $LIBNAME,
1270                     dnl   4. if it doesn't exist as a directory.
1271                     if test "X$additional_libdir" != "X/usr/lib"; then
1272                       haveit=
1273                       if test "X$additional_libdir" = "X/usr/local/lib"; then
1274                         if test -n "$GCC"; then
1275                           case $host_os in
1276                             linux*) haveit=yes;;
1277                           esac
1278                         fi
1279                       fi
1280                       if test -z "$haveit"; then
1281                         haveit=
1282                         for x in $LDFLAGS $LIB[]NAME; do
1283                           AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
1284                           if test "X$x" = "X-L$additional_libdir"; then
1285                             haveit=yes
1286                             break
1287                           fi
1288                         done
1289                         if test -z "$haveit"; then
1290                           if test -d "$additional_libdir"; then
1291                             dnl Really add $additional_libdir to $LIBNAME.
1292                             LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
1293                           fi
1294                         fi
1295                         haveit=
1296                         for x in $LDFLAGS $LTLIB[]NAME; do
1297                           AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
1298                           if test "X$x" = "X-L$additional_libdir"; then
1299                             haveit=yes
1300                             break
1301                           fi
1302                         done
1303                         if test -z "$haveit"; then
1304                           if test -d "$additional_libdir"; then
1305                             dnl Really add $additional_libdir to $LTLIBNAME.
1306                             LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
1307                           fi
1308                         fi
1309                       fi
1310                     fi
1311                     ;;
1312                   -R*)
1313                     dir=`echo "X$dep" | sed -e 's/^X-R//'`
1314                     if test "$enable_rpath" != no; then
1315                       dnl Potentially add DIR to rpathdirs.
1316                       dnl The rpathdirs will be appended to $LIBNAME at the end.
1317                       haveit=
1318                       for x in $rpathdirs; do
1319                         if test "X$x" = "X$dir"; then
1320                           haveit=yes
1321                           break
1322                         fi
1323                       done
1324                       if test -z "$haveit"; then
1325                         rpathdirs="$rpathdirs $dir"
1326                       fi
1327                       dnl Potentially add DIR to ltrpathdirs.
1328                       dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
1329                       haveit=
1330                       for x in $ltrpathdirs; do
1331                         if test "X$x" = "X$dir"; then
1332                           haveit=yes
1333                           break
1334                         fi
1335                       done
1336                       if test -z "$haveit"; then
1337                         ltrpathdirs="$ltrpathdirs $dir"
1338                       fi
1339                     fi
1340                     ;;
1341                   -l*)
1342                     dnl Handle this in the next round.
1343                     names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
1344                     ;;
1345                   *.la)
1346                     dnl Handle this in the next round. Throw away the .la's
1347                     dnl directory; it is already contained in a preceding -L
1348                     dnl option.
1349                     names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
1350                     ;;
1351                   *)
1352                     dnl Most likely an immediate library name.
1353                     LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
1354                     LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
1355                     ;;
1356                 esac
1357               done
1358             fi
1359           else
1360             dnl Didn't find the library; assume it is in the system directories
1361             dnl known to the linker and runtime loader. (All the system
1362             dnl directories known to the linker should also be known to the
1363             dnl runtime loader, otherwise the system is severely misconfigured.)
1364             LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
1365             LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
1366           fi
1367         fi
1368       fi
1369     done
1370   done
1371   if test "X$rpathdirs" != "X"; then
1372     if test -n "$hardcode_libdir_separator"; then
1373       dnl Weird platform: only the last -rpath option counts, the user must
1374       dnl pass all path elements in one option. We can arrange that for a
1375       dnl single library, but not when more than one $LIBNAMEs are used.
1376       alldirs=
1377       for found_dir in $rpathdirs; do
1378         alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
1379       done
1380       dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl.
1381       acl_save_libdir="$libdir"
1382       libdir="$alldirs"
1383       eval flag=\"$hardcode_libdir_flag_spec\"
1384       libdir="$acl_save_libdir"
1385       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
1386     else
1387       dnl The -rpath options are cumulative.
1388       for found_dir in $rpathdirs; do
1389         acl_save_libdir="$libdir"
1390         libdir="$found_dir"
1391         eval flag=\"$hardcode_libdir_flag_spec\"
1392         libdir="$acl_save_libdir"
1393         LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
1394       done
1395     fi
1396   fi
1397   if test "X$ltrpathdirs" != "X"; then
1398     dnl When using libtool, the option that works for both libraries and
1399     dnl executables is -R. The -R options are cumulative.
1400     for found_dir in $ltrpathdirs; do
1401       LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
1402     done
1403   fi
1404 ])
1405
1406 dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
1407 dnl unless already present in VAR.
1408 dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
1409 dnl contains two or three consecutive elements that belong together.
1410 AC_DEFUN([AC_LIB_APPENDTOVAR],
1411 [
1412   for element in [$2]; do
1413     haveit=
1414     for x in $[$1]; do
1415       AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
1416       if test "X$x" = "X$element"; then
1417         haveit=yes
1418         break
1419       fi
1420     done
1421     if test -z "$haveit"; then
1422       [$1]="${[$1]}${[$1]:+ }$element"
1423     fi
1424   done
1425 ])
1426 # lib-prefix.m4 serial 2 (gettext-0.12)
1427 dnl Copyright (C) 2001-2003 Free Software Foundation, Inc.
1428 dnl This file is free software, distributed under the terms of the GNU
1429 dnl General Public License.  As a special exception to the GNU General
1430 dnl Public License, this file may be distributed as part of a program
1431 dnl that contains a configuration script generated by Autoconf, under
1432 dnl the same distribution terms as the rest of that program.
1433
1434 dnl From Bruno Haible.
1435
1436 dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and
1437 dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't
1438 dnl require excessive bracketing.
1439 ifdef([AC_HELP_STRING],
1440 [AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])],
1441 [AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])])
1442
1443 dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
1444 dnl to access previously installed libraries. The basic assumption is that
1445 dnl a user will want packages to use other packages he previously installed
1446 dnl with the same --prefix option.
1447 dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
1448 dnl libraries, but is otherwise very convenient.
1449 AC_DEFUN([AC_LIB_PREFIX],
1450 [
1451   AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
1452   AC_REQUIRE([AC_PROG_CC])
1453   AC_REQUIRE([AC_CANONICAL_HOST])
1454   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
1455   dnl By default, look in $includedir and $libdir.
1456   use_additional=yes
1457   AC_LIB_WITH_FINAL_PREFIX([
1458     eval additional_includedir=\"$includedir\"
1459     eval additional_libdir=\"$libdir\"
1460   ])
1461   AC_LIB_ARG_WITH([lib-prefix],
1462 [  --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
1463   --without-lib-prefix    don't search for libraries in includedir and libdir],
1464 [
1465     if test "X$withval" = "Xno"; then
1466       use_additional=no
1467     else
1468       if test "X$withval" = "X"; then
1469         AC_LIB_WITH_FINAL_PREFIX([
1470           eval additional_includedir=\"$includedir\"
1471           eval additional_libdir=\"$libdir\"
1472         ])
1473       else
1474         additional_includedir="$withval/include"
1475         additional_libdir="$withval/lib"
1476       fi
1477     fi
1478 ])
1479   if test $use_additional = yes; then
1480     dnl Potentially add $additional_includedir to $CPPFLAGS.
1481     dnl But don't add it
1482     dnl   1. if it's the standard /usr/include,
1483     dnl   2. if it's already present in $CPPFLAGS,
1484     dnl   3. if it's /usr/local/include and we are using GCC on Linux,
1485     dnl   4. if it doesn't exist as a directory.
1486     if test "X$additional_includedir" != "X/usr/include"; then
1487       haveit=
1488       for x in $CPPFLAGS; do
1489         AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
1490         if test "X$x" = "X-I$additional_includedir"; then
1491           haveit=yes
1492           break
1493         fi
1494       done
1495       if test -z "$haveit"; then
1496         if test "X$additional_includedir" = "X/usr/local/include"; then
1497           if test -n "$GCC"; then
1498             case $host_os in
1499               linux*) haveit=yes;;
1500             esac
1501           fi
1502         fi
1503         if test -z "$haveit"; then
1504           if test -d "$additional_includedir"; then
1505             dnl Really add $additional_includedir to $CPPFLAGS.
1506             CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
1507           fi
1508         fi
1509       fi
1510     fi
1511     dnl Potentially add $additional_libdir to $LDFLAGS.
1512     dnl But don't add it
1513     dnl   1. if it's the standard /usr/lib,
1514     dnl   2. if it's already present in $LDFLAGS,
1515     dnl   3. if it's /usr/local/lib and we are using GCC on Linux,
1516     dnl   4. if it doesn't exist as a directory.
1517     if test "X$additional_libdir" != "X/usr/lib"; then
1518       haveit=
1519       for x in $LDFLAGS; do
1520         AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
1521         if test "X$x" = "X-L$additional_libdir"; then
1522           haveit=yes
1523           break
1524         fi
1525       done
1526       if test -z "$haveit"; then
1527         if test "X$additional_libdir" = "X/usr/local/lib"; then
1528           if test -n "$GCC"; then
1529             case $host_os in
1530               linux*) haveit=yes;;
1531             esac
1532           fi
1533         fi
1534         if test -z "$haveit"; then
1535           if test -d "$additional_libdir"; then
1536             dnl Really add $additional_libdir to $LDFLAGS.
1537             LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
1538           fi
1539         fi
1540       fi
1541     fi
1542   fi
1543 ])
1544
1545 dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
1546 dnl acl_final_exec_prefix, containing the values to which $prefix and
1547 dnl $exec_prefix will expand at the end of the configure script.
1548 AC_DEFUN([AC_LIB_PREPARE_PREFIX],
1549 [
1550   dnl Unfortunately, prefix and exec_prefix get only finally determined
1551   dnl at the end of configure.
1552   if test "X$prefix" = "XNONE"; then
1553     acl_final_prefix="$ac_default_prefix"
1554   else
1555     acl_final_prefix="$prefix"
1556   fi
1557   if test "X$exec_prefix" = "XNONE"; then
1558     acl_final_exec_prefix='${prefix}'
1559   else
1560     acl_final_exec_prefix="$exec_prefix"
1561   fi
1562   acl_save_prefix="$prefix"
1563   prefix="$acl_final_prefix"
1564   eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
1565   prefix="$acl_save_prefix"
1566 ])
1567
1568 dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
1569 dnl variables prefix and exec_prefix bound to the values they will have
1570 dnl at the end of the configure script.
1571 AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
1572 [
1573   acl_save_prefix="$prefix"
1574   prefix="$acl_final_prefix"
1575   acl_save_exec_prefix="$exec_prefix"
1576   exec_prefix="$acl_final_exec_prefix"
1577   $1
1578   exec_prefix="$acl_save_exec_prefix"
1579   prefix="$acl_save_prefix"
1580 ])
1581 # progtest.m4 serial 3 (gettext-0.12)
1582 dnl Copyright (C) 1996-2003 Free Software Foundation, Inc.
1583 dnl This file is free software, distributed under the terms of the GNU
1584 dnl General Public License.  As a special exception to the GNU General
1585 dnl Public License, this file may be distributed as part of a program
1586 dnl that contains a configuration script generated by Autoconf, under
1587 dnl the same distribution terms as the rest of that program.
1588 dnl
1589 dnl This file can can be used in projects which are not available under
1590 dnl the GNU General Public License or the GNU Library General Public
1591 dnl License but which still want to provide support for the GNU gettext
1592 dnl functionality.
1593 dnl Please note that the actual code of the GNU gettext library is covered
1594 dnl by the GNU Library General Public License, and the rest of the GNU
1595 dnl gettext package package is covered by the GNU General Public License.
1596 dnl They are *not* in the public domain.
1597
1598 dnl Authors:
1599 dnl   Ulrich Drepper <drepper@cygnus.com>, 1996.
1600
1601 # Search path for a program which passes the given test.
1602
1603 dnl AM_PATH_PROG_WITH_TEST(VARIABLE, PROG-TO-CHECK-FOR,
1604 dnl   TEST-PERFORMED-ON-FOUND_PROGRAM [, VALUE-IF-NOT-FOUND [, PATH]])
1605 AC_DEFUN([AM_PATH_PROG_WITH_TEST],
1606 [
1607 # Prepare PATH_SEPARATOR.
1608 # The user is always right.
1609 if test "${PATH_SEPARATOR+set}" != set; then
1610   echo "#! /bin/sh" >conf$$.sh
1611   echo  "exit 0"   >>conf$$.sh
1612   chmod +x conf$$.sh
1613   if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
1614     PATH_SEPARATOR=';'
1615   else
1616     PATH_SEPARATOR=:
1617   fi
1618   rm -f conf$$.sh
1619 fi
1620
1621 # Find out how to test for executable files. Don't use a zero-byte file,
1622 # as systems may use methods other than mode bits to determine executability.
1623 cat >conf$$.file <<_ASEOF
1624 #! /bin/sh
1625 exit 0
1626 _ASEOF
1627 chmod +x conf$$.file
1628 if test -x conf$$.file >/dev/null 2>&1; then
1629   ac_executable_p="test -x"
1630 else
1631   ac_executable_p="test -f"
1632 fi
1633 rm -f conf$$.file
1634
1635 # Extract the first word of "$2", so it can be a program name with args.
1636 set dummy $2; ac_word=[$]2
1637 AC_MSG_CHECKING([for $ac_word])
1638 AC_CACHE_VAL(ac_cv_path_$1,
1639 [case "[$]$1" in
1640   [[\\/]]* | ?:[[\\/]]*)
1641     ac_cv_path_$1="[$]$1" # Let the user override the test with a path.
1642     ;;
1643   *)
1644     ac_save_IFS="$IFS"; IFS=$PATH_SEPARATOR
1645     for ac_dir in ifelse([$5], , $PATH, [$5]); do
1646       IFS="$ac_save_IFS"
1647       test -z "$ac_dir" && ac_dir=.
1648       for ac_exec_ext in '' $ac_executable_extensions; do
1649         if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then
1650           if [$3]; then
1651             ac_cv_path_$1="$ac_dir/$ac_word$ac_exec_ext"
1652             break 2
1653           fi
1654         fi
1655       done
1656     done
1657     IFS="$ac_save_IFS"
1658 dnl If no 4th arg is given, leave the cache variable unset,
1659 dnl so AC_PATH_PROGS will keep looking.
1660 ifelse([$4], , , [  test -z "[$]ac_cv_path_$1" && ac_cv_path_$1="$4"
1661 ])dnl
1662     ;;
1663 esac])dnl
1664 $1="$ac_cv_path_$1"
1665 if test ifelse([$4], , [-n "[$]$1"], ["[$]$1" != "$4"]); then
1666   AC_MSG_RESULT([$]$1)
1667 else
1668   AC_MSG_RESULT(no)
1669 fi
1670 AC_SUBST($1)dnl
1671 ])