OSDN Git Service

libcpp/ChangeLog:
[pf3gnuchains/gcc-fork.git] / libcpp / aclocal.m4
1 # generated automatically by aclocal 1.9.1 -*- Autoconf -*-
2
3 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004
4 # Free Software Foundation, Inc.
5 # This file is free software; the Free Software Foundation
6 # gives unlimited permission to copy and/or distribute it,
7 # with or without modifications, as long as this notice is preserved.
8
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY, to the extent permitted by law; without
11 # even the implied warranty of MERCHANTABILITY or FITNESS FOR A
12 # PARTICULAR PURPOSE.
13
14 # codeset.m4 serial AM1 (gettext-0.10.40)
15 dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
16 dnl This file is free software, distributed under the terms of the GNU
17 dnl General Public License.  As a special exception to the GNU General
18 dnl Public License, this file may be distributed as part of a program
19 dnl that contains a configuration script generated by Autoconf, under
20 dnl the same distribution terms as the rest of that program.
21
22 dnl From Bruno Haible.
23
24 AC_DEFUN([AM_LANGINFO_CODESET],
25 [
26   AC_CACHE_CHECK([for nl_langinfo and CODESET], am_cv_langinfo_codeset,
27     [AC_TRY_LINK([#include <langinfo.h>],
28       [char* cs = nl_langinfo(CODESET);],
29       am_cv_langinfo_codeset=yes,
30       am_cv_langinfo_codeset=no)
31     ])
32   if test $am_cv_langinfo_codeset = yes; then
33     AC_DEFINE(HAVE_LANGINFO_CODESET, 1,
34       [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
35   fi
36 ])
37
38 # iconv.m4 serial AM4 (gettext-0.11.3)
39 dnl Copyright (C) 2000-2002 Free Software Foundation, Inc.
40 dnl This file is free software, distributed under the terms of the GNU
41 dnl General Public License.  As a special exception to the GNU General
42 dnl Public License, this file may be distributed as part of a program
43 dnl that contains a configuration script generated by Autoconf, under
44 dnl the same distribution terms as the rest of that program.
45
46 dnl From Bruno Haible.
47
48 AC_DEFUN([AM_ICONV_LINKFLAGS_BODY],
49 [
50   dnl Prerequisites of AC_LIB_LINKFLAGS_BODY.
51   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
52   AC_REQUIRE([AC_LIB_RPATH])
53
54   dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
55   dnl accordingly.
56   AC_LIB_LINKFLAGS_BODY([iconv])
57 ])
58
59 AC_DEFUN([AM_ICONV_LINK],
60 [
61   dnl Some systems have iconv in libc, some have it in libiconv (OSF/1 and
62   dnl those with the standalone portable GNU libiconv installed).
63
64   dnl Search for libiconv and define LIBICONV, LTLIBICONV and INCICONV
65   dnl accordingly.
66   AC_REQUIRE([AM_ICONV_LINKFLAGS_BODY])
67
68   dnl Add $INCICONV to CPPFLAGS before performing the following checks,
69   dnl because if the user has installed libiconv and not disabled its use
70   dnl via --without-libiconv-prefix, he wants to use it. The first
71   dnl AC_TRY_LINK will then fail, the second AC_TRY_LINK will succeed.
72   am_save_CPPFLAGS="$CPPFLAGS"
73   AC_LIB_APPENDTOVAR([CPPFLAGS], [$INCICONV])
74
75   AC_CACHE_CHECK(for iconv, am_cv_func_iconv, [
76     am_cv_func_iconv="no, consider installing GNU libiconv"
77     am_cv_lib_iconv=no
78     AC_TRY_LINK([#include <stdlib.h>
79 #include <iconv.h>],
80       [iconv_t cd = iconv_open("","");
81        iconv(cd,NULL,NULL,NULL,NULL);
82        iconv_close(cd);],
83       am_cv_func_iconv=yes)
84     if test "$am_cv_func_iconv" != yes; then
85       am_save_LIBS="$LIBS"
86       LIBS="$LIBS $LIBICONV"
87       AC_TRY_LINK([#include <stdlib.h>
88 #include <iconv.h>],
89         [iconv_t cd = iconv_open("","");
90          iconv(cd,NULL,NULL,NULL,NULL);
91          iconv_close(cd);],
92         am_cv_lib_iconv=yes
93         am_cv_func_iconv=yes)
94       LIBS="$am_save_LIBS"
95     fi
96   ])
97   if test "$am_cv_func_iconv" = yes; then
98     AC_DEFINE(HAVE_ICONV, 1, [Define if you have the iconv() function.])
99   fi
100   if test "$am_cv_lib_iconv" = yes; then
101     AC_MSG_CHECKING([how to link with libiconv])
102     AC_MSG_RESULT([$LIBICONV])
103   else
104     dnl If $LIBICONV didn't lead to a usable library, we don't need $INCICONV
105     dnl either.
106     CPPFLAGS="$am_save_CPPFLAGS"
107     LIBICONV=
108     LTLIBICONV=
109   fi
110   AC_SUBST(LIBICONV)
111   AC_SUBST(LTLIBICONV)
112 ])
113
114 AC_DEFUN([AM_ICONV],
115 [
116   AM_ICONV_LINK
117   if test "$am_cv_func_iconv" = yes; then
118     AC_MSG_CHECKING([for iconv declaration])
119     AC_CACHE_VAL(am_cv_proto_iconv, [
120       AC_TRY_COMPILE([
121 #include <stdlib.h>
122 #include <iconv.h>
123 extern
124 #ifdef __cplusplus
125 "C"
126 #endif
127 #if defined(__STDC__) || defined(__cplusplus)
128 size_t iconv (iconv_t cd, char * *inbuf, size_t *inbytesleft, char * *outbuf, size_t *outbytesleft);
129 #else
130 size_t iconv();
131 #endif
132 ], [], am_cv_proto_iconv_arg1="", am_cv_proto_iconv_arg1="const")
133       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);"])
134     am_cv_proto_iconv=`echo "[$]am_cv_proto_iconv" | tr -s ' ' | sed -e 's/( /(/'`
135     AC_MSG_RESULT([$]{ac_t:-
136          }[$]am_cv_proto_iconv)
137     AC_DEFINE_UNQUOTED(ICONV_CONST, $am_cv_proto_iconv_arg1,
138       [Define as const if the declaration of iconv() needs const.])
139   fi
140 ])
141
142 # lib-ld.m4 serial 3 (gettext-0.13)
143 dnl Copyright (C) 1996-2003 Free Software Foundation, Inc.
144 dnl This file is free software, distributed under the terms of the GNU
145 dnl General Public License.  As a special exception to the GNU General
146 dnl Public License, this file may be distributed as part of a program
147 dnl that contains a configuration script generated by Autoconf, under
148 dnl the same distribution terms as the rest of that program.
149
150 dnl Subroutines of libtool.m4,
151 dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision
152 dnl with libtool.m4.
153
154 dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
155 AC_DEFUN([AC_LIB_PROG_LD_GNU],
156 [AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld,
157 [# I'd rather use --version here, but apparently some GNU ld's only accept -v.
158 case `$LD -v 2>&1 </dev/null` in
159 *GNU* | *'with BFD'*)
160   acl_cv_prog_gnu_ld=yes ;;
161 *)
162   acl_cv_prog_gnu_ld=no ;;
163 esac])
164 with_gnu_ld=$acl_cv_prog_gnu_ld
165 ])
166
167 dnl From libtool-1.4. Sets the variable LD.
168 AC_DEFUN([AC_LIB_PROG_LD],
169 [AC_ARG_WITH(gnu-ld,
170 [  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]],
171 test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
172 AC_REQUIRE([AC_PROG_CC])dnl
173 AC_REQUIRE([AC_CANONICAL_HOST])dnl
174 # Prepare PATH_SEPARATOR.
175 # The user is always right.
176 if test "${PATH_SEPARATOR+set}" != set; then
177   echo "#! /bin/sh" >conf$$.sh
178   echo  "exit 0"   >>conf$$.sh
179   chmod +x conf$$.sh
180   if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
181     PATH_SEPARATOR=';'
182   else
183     PATH_SEPARATOR=:
184   fi
185   rm -f conf$$.sh
186 fi
187 ac_prog=ld
188 if test "$GCC" = yes; then
189   # Check if gcc -print-prog-name=ld gives a path.
190   AC_MSG_CHECKING([for ld used by GCC])
191   case $host in
192   *-*-mingw*)
193     # gcc leaves a trailing carriage return which upsets mingw
194     ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
195   *)
196     ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
197   esac
198   case $ac_prog in
199     # Accept absolute paths.
200     [[\\/]* | [A-Za-z]:[\\/]*)]
201       [re_direlt='/[^/][^/]*/\.\./']
202       # Canonicalize the path of ld
203       ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
204       while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
205         ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
206       done
207       test -z "$LD" && LD="$ac_prog"
208       ;;
209   "")
210     # If it fails, then pretend we aren't using GCC.
211     ac_prog=ld
212     ;;
213   *)
214     # If it is relative, then search for the first ld in PATH.
215     with_gnu_ld=unknown
216     ;;
217   esac
218 elif test "$with_gnu_ld" = yes; then
219   AC_MSG_CHECKING([for GNU ld])
220 else
221   AC_MSG_CHECKING([for non-GNU ld])
222 fi
223 AC_CACHE_VAL(acl_cv_path_LD,
224 [if test -z "$LD"; then
225   IFS="${IFS=   }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
226   for ac_dir in $PATH; do
227     test -z "$ac_dir" && ac_dir=.
228     if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
229       acl_cv_path_LD="$ac_dir/$ac_prog"
230       # Check to see if the program is GNU ld.  I'd rather use --version,
231       # but apparently some GNU ld's only accept -v.
232       # Break only if it was the GNU/non-GNU ld that we prefer.
233       case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in
234       *GNU* | *'with BFD'*)
235         test "$with_gnu_ld" != no && break ;;
236       *)
237         test "$with_gnu_ld" != yes && break ;;
238       esac
239     fi
240   done
241   IFS="$ac_save_ifs"
242 else
243   acl_cv_path_LD="$LD" # Let the user override the test with a path.
244 fi])
245 LD="$acl_cv_path_LD"
246 if test -n "$LD"; then
247   AC_MSG_RESULT($LD)
248 else
249   AC_MSG_RESULT(no)
250 fi
251 test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
252 AC_LIB_PROG_LD_GNU
253 ])
254
255 # lib-link.m4 serial 4 (gettext-0.12)
256 dnl Copyright (C) 2001-2003 Free Software Foundation, Inc.
257 dnl This file is free software, distributed under the terms of the GNU
258 dnl General Public License.  As a special exception to the GNU General
259 dnl Public License, this file may be distributed as part of a program
260 dnl that contains a configuration script generated by Autoconf, under
261 dnl the same distribution terms as the rest of that program.
262
263 dnl From Bruno Haible.
264
265 dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
266 dnl the libraries corresponding to explicit and implicit dependencies.
267 dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
268 dnl augments the CPPFLAGS variable.
269 AC_DEFUN([AC_LIB_LINKFLAGS],
270 [
271   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
272   AC_REQUIRE([AC_LIB_RPATH])
273   define([Name],[translit([$1],[./-], [___])])
274   define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
275                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
276   AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
277     AC_LIB_LINKFLAGS_BODY([$1], [$2])
278     ac_cv_lib[]Name[]_libs="$LIB[]NAME"
279     ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
280     ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
281   ])
282   LIB[]NAME="$ac_cv_lib[]Name[]_libs"
283   LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
284   INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
285   AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
286   AC_SUBST([LIB]NAME)
287   AC_SUBST([LTLIB]NAME)
288   dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
289   dnl results of this search when this library appears as a dependency.
290   HAVE_LIB[]NAME=yes
291   undefine([Name])
292   undefine([NAME])
293 ])
294
295 dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode)
296 dnl searches for libname and the libraries corresponding to explicit and
297 dnl implicit dependencies, together with the specified include files and
298 dnl the ability to compile and link the specified testcode. If found, it
299 dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and
300 dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and
301 dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
302 dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
303 AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
304 [
305   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
306   AC_REQUIRE([AC_LIB_RPATH])
307   define([Name],[translit([$1],[./-], [___])])
308   define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
309                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
310
311   dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
312   dnl accordingly.
313   AC_LIB_LINKFLAGS_BODY([$1], [$2])
314
315   dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
316   dnl because if the user has installed lib[]Name and not disabled its use
317   dnl via --without-lib[]Name-prefix, he wants to use it.
318   ac_save_CPPFLAGS="$CPPFLAGS"
319   AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
320
321   AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
322     ac_save_LIBS="$LIBS"
323     LIBS="$LIBS $LIB[]NAME"
324     AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no])
325     LIBS="$ac_save_LIBS"
326   ])
327   if test "$ac_cv_lib[]Name" = yes; then
328     HAVE_LIB[]NAME=yes
329     AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.])
330     AC_MSG_CHECKING([how to link with lib[]$1])
331     AC_MSG_RESULT([$LIB[]NAME])
332   else
333     HAVE_LIB[]NAME=no
334     dnl If $LIB[]NAME didn't lead to a usable library, we don't need
335     dnl $INC[]NAME either.
336     CPPFLAGS="$ac_save_CPPFLAGS"
337     LIB[]NAME=
338     LTLIB[]NAME=
339   fi
340   AC_SUBST([HAVE_LIB]NAME)
341   AC_SUBST([LIB]NAME)
342   AC_SUBST([LTLIB]NAME)
343   undefine([Name])
344   undefine([NAME])
345 ])
346
347 dnl Determine the platform dependent parameters needed to use rpath:
348 dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator,
349 dnl hardcode_direct, hardcode_minus_L.
350 AC_DEFUN([AC_LIB_RPATH],
351 [
352   AC_REQUIRE([AC_PROG_CC])                dnl we use $CC, $GCC, $LDFLAGS
353   AC_REQUIRE([AC_LIB_PROG_LD])            dnl we use $LD, $with_gnu_ld
354   AC_REQUIRE([AC_CANONICAL_HOST])         dnl we use $host
355   AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
356   AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [
357     CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
358     ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
359     . ./conftest.sh
360     rm -f ./conftest.sh
361     acl_cv_rpath=done
362   ])
363   wl="$acl_cv_wl"
364   libext="$acl_cv_libext"
365   shlibext="$acl_cv_shlibext"
366   hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
367   hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
368   hardcode_direct="$acl_cv_hardcode_direct"
369   hardcode_minus_L="$acl_cv_hardcode_minus_L"
370   dnl Determine whether the user wants rpath handling at all.
371   AC_ARG_ENABLE(rpath,
372     [  --disable-rpath         do not hardcode runtime library paths],
373     :, enable_rpath=yes)
374 ])
375
376 dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
377 dnl the libraries corresponding to explicit and implicit dependencies.
378 dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
379 AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
380 [
381   define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
382                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
383   dnl By default, look in $includedir and $libdir.
384   use_additional=yes
385   AC_LIB_WITH_FINAL_PREFIX([
386     eval additional_includedir=\"$includedir\"
387     eval additional_libdir=\"$libdir\"
388   ])
389   AC_LIB_ARG_WITH([lib$1-prefix],
390 [  --with-lib$1-prefix[=DIR]  search for lib$1 in DIR/include and DIR/lib
391   --without-lib$1-prefix     don't search for lib$1 in includedir and libdir],
392 [
393     if test "X$withval" = "Xno"; then
394       use_additional=no
395     else
396       if test "X$withval" = "X"; then
397         AC_LIB_WITH_FINAL_PREFIX([
398           eval additional_includedir=\"$includedir\"
399           eval additional_libdir=\"$libdir\"
400         ])
401       else
402         additional_includedir="$withval/include"
403         additional_libdir="$withval/lib"
404       fi
405     fi
406 ])
407   dnl Search the library and its dependencies in $additional_libdir and
408   dnl $LDFLAGS. Using breadth-first-seach.
409   LIB[]NAME=
410   LTLIB[]NAME=
411   INC[]NAME=
412   rpathdirs=
413   ltrpathdirs=
414   names_already_handled=
415   names_next_round='$1 $2'
416   while test -n "$names_next_round"; do
417     names_this_round="$names_next_round"
418     names_next_round=
419     for name in $names_this_round; do
420       already_handled=
421       for n in $names_already_handled; do
422         if test "$n" = "$name"; then
423           already_handled=yes
424           break
425         fi
426       done
427       if test -z "$already_handled"; then
428         names_already_handled="$names_already_handled $name"
429         dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
430         dnl or AC_LIB_HAVE_LINKFLAGS call.
431         uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
432         eval value=\"\$HAVE_LIB$uppername\"
433         if test -n "$value"; then
434           if test "$value" = yes; then
435             eval value=\"\$LIB$uppername\"
436             test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
437             eval value=\"\$LTLIB$uppername\"
438             test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
439           else
440             dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
441             dnl that this library doesn't exist. So just drop it.
442             :
443           fi
444         else
445           dnl Search the library lib$name in $additional_libdir and $LDFLAGS
446           dnl and the already constructed $LIBNAME/$LTLIBNAME.
447           found_dir=
448           found_la=
449           found_so=
450           found_a=
451           if test $use_additional = yes; then
452             if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
453               found_dir="$additional_libdir"
454               found_so="$additional_libdir/lib$name.$shlibext"
455               if test -f "$additional_libdir/lib$name.la"; then
456                 found_la="$additional_libdir/lib$name.la"
457               fi
458             else
459               if test -f "$additional_libdir/lib$name.$libext"; then
460                 found_dir="$additional_libdir"
461                 found_a="$additional_libdir/lib$name.$libext"
462                 if test -f "$additional_libdir/lib$name.la"; then
463                   found_la="$additional_libdir/lib$name.la"
464                 fi
465               fi
466             fi
467           fi
468           if test "X$found_dir" = "X"; then
469             for x in $LDFLAGS $LTLIB[]NAME; do
470               AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
471               case "$x" in
472                 -L*)
473                   dir=`echo "X$x" | sed -e 's/^X-L//'`
474                   if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
475                     found_dir="$dir"
476                     found_so="$dir/lib$name.$shlibext"
477                     if test -f "$dir/lib$name.la"; then
478                       found_la="$dir/lib$name.la"
479                     fi
480                   else
481                     if test -f "$dir/lib$name.$libext"; then
482                       found_dir="$dir"
483                       found_a="$dir/lib$name.$libext"
484                       if test -f "$dir/lib$name.la"; then
485                         found_la="$dir/lib$name.la"
486                       fi
487                     fi
488                   fi
489                   ;;
490               esac
491               if test "X$found_dir" != "X"; then
492                 break
493               fi
494             done
495           fi
496           if test "X$found_dir" != "X"; then
497             dnl Found the library.
498             LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
499             if test "X$found_so" != "X"; then
500               dnl Linking with a shared library. We attempt to hardcode its
501               dnl directory into the executable's runpath, unless it's the
502               dnl standard /usr/lib.
503               if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
504                 dnl No hardcoding is needed.
505                 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
506               else
507                 dnl Use an explicit option to hardcode DIR into the resulting
508                 dnl binary.
509                 dnl Potentially add DIR to ltrpathdirs.
510                 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
511                 haveit=
512                 for x in $ltrpathdirs; do
513                   if test "X$x" = "X$found_dir"; then
514                     haveit=yes
515                     break
516                   fi
517                 done
518                 if test -z "$haveit"; then
519                   ltrpathdirs="$ltrpathdirs $found_dir"
520                 fi
521                 dnl The hardcoding into $LIBNAME is system dependent.
522                 if test "$hardcode_direct" = yes; then
523                   dnl Using DIR/libNAME.so during linking hardcodes DIR into the
524                   dnl resulting binary.
525                   LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
526                 else
527                   if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
528                     dnl Use an explicit option to hardcode DIR into the resulting
529                     dnl binary.
530                     LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
531                     dnl Potentially add DIR to rpathdirs.
532                     dnl The rpathdirs will be appended to $LIBNAME at the end.
533                     haveit=
534                     for x in $rpathdirs; do
535                       if test "X$x" = "X$found_dir"; then
536                         haveit=yes
537                         break
538                       fi
539                     done
540                     if test -z "$haveit"; then
541                       rpathdirs="$rpathdirs $found_dir"
542                     fi
543                   else
544                     dnl Rely on "-L$found_dir".
545                     dnl But don't add it if it's already contained in the LDFLAGS
546                     dnl or the already constructed $LIBNAME
547                     haveit=
548                     for x in $LDFLAGS $LIB[]NAME; do
549                       AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
550                       if test "X$x" = "X-L$found_dir"; then
551                         haveit=yes
552                         break
553                       fi
554                     done
555                     if test -z "$haveit"; then
556                       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
557                     fi
558                     if test "$hardcode_minus_L" != no; then
559                       dnl FIXME: Not sure whether we should use
560                       dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
561                       dnl here.
562                       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
563                     else
564                       dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH
565                       dnl here, because this doesn't fit in flags passed to the
566                       dnl compiler. So give up. No hardcoding. This affects only
567                       dnl very old systems.
568                       dnl FIXME: Not sure whether we should use
569                       dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
570                       dnl here.
571                       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
572                     fi
573                   fi
574                 fi
575               fi
576             else
577               if test "X$found_a" != "X"; then
578                 dnl Linking with a static library.
579                 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
580               else
581                 dnl We shouldn't come here, but anyway it's good to have a
582                 dnl fallback.
583                 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
584               fi
585             fi
586             dnl Assume the include files are nearby.
587             additional_includedir=
588             case "$found_dir" in
589               */lib | */lib/)
590                 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
591                 additional_includedir="$basedir/include"
592                 ;;
593             esac
594             if test "X$additional_includedir" != "X"; then
595               dnl Potentially add $additional_includedir to $INCNAME.
596               dnl But don't add it
597               dnl   1. if it's the standard /usr/include,
598               dnl   2. if it's /usr/local/include and we are using GCC on Linux,
599               dnl   3. if it's already present in $CPPFLAGS or the already
600               dnl      constructed $INCNAME,
601               dnl   4. if it doesn't exist as a directory.
602               if test "X$additional_includedir" != "X/usr/include"; then
603                 haveit=
604                 if test "X$additional_includedir" = "X/usr/local/include"; then
605                   if test -n "$GCC"; then
606                     case $host_os in
607                       linux*) haveit=yes;;
608                     esac
609                   fi
610                 fi
611                 if test -z "$haveit"; then
612                   for x in $CPPFLAGS $INC[]NAME; do
613                     AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
614                     if test "X$x" = "X-I$additional_includedir"; then
615                       haveit=yes
616                       break
617                     fi
618                   done
619                   if test -z "$haveit"; then
620                     if test -d "$additional_includedir"; then
621                       dnl Really add $additional_includedir to $INCNAME.
622                       INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
623                     fi
624                   fi
625                 fi
626               fi
627             fi
628             dnl Look for dependencies.
629             if test -n "$found_la"; then
630               dnl Read the .la file. It defines the variables
631               dnl dlname, library_names, old_library, dependency_libs, current,
632               dnl age, revision, installed, dlopen, dlpreopen, libdir.
633               save_libdir="$libdir"
634               case "$found_la" in
635                 */* | *\\*) . "$found_la" ;;
636                 *) . "./$found_la" ;;
637               esac
638               libdir="$save_libdir"
639               dnl We use only dependency_libs.
640               for dep in $dependency_libs; do
641                 case "$dep" in
642                   -L*)
643                     additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
644                     dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
645                     dnl But don't add it
646                     dnl   1. if it's the standard /usr/lib,
647                     dnl   2. if it's /usr/local/lib and we are using GCC on Linux,
648                     dnl   3. if it's already present in $LDFLAGS or the already
649                     dnl      constructed $LIBNAME,
650                     dnl   4. if it doesn't exist as a directory.
651                     if test "X$additional_libdir" != "X/usr/lib"; then
652                       haveit=
653                       if test "X$additional_libdir" = "X/usr/local/lib"; then
654                         if test -n "$GCC"; then
655                           case $host_os in
656                             linux*) haveit=yes;;
657                           esac
658                         fi
659                       fi
660                       if test -z "$haveit"; then
661                         haveit=
662                         for x in $LDFLAGS $LIB[]NAME; do
663                           AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
664                           if test "X$x" = "X-L$additional_libdir"; then
665                             haveit=yes
666                             break
667                           fi
668                         done
669                         if test -z "$haveit"; then
670                           if test -d "$additional_libdir"; then
671                             dnl Really add $additional_libdir to $LIBNAME.
672                             LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
673                           fi
674                         fi
675                         haveit=
676                         for x in $LDFLAGS $LTLIB[]NAME; do
677                           AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
678                           if test "X$x" = "X-L$additional_libdir"; then
679                             haveit=yes
680                             break
681                           fi
682                         done
683                         if test -z "$haveit"; then
684                           if test -d "$additional_libdir"; then
685                             dnl Really add $additional_libdir to $LTLIBNAME.
686                             LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
687                           fi
688                         fi
689                       fi
690                     fi
691                     ;;
692                   -R*)
693                     dir=`echo "X$dep" | sed -e 's/^X-R//'`
694                     if test "$enable_rpath" != no; then
695                       dnl Potentially add DIR to rpathdirs.
696                       dnl The rpathdirs will be appended to $LIBNAME at the end.
697                       haveit=
698                       for x in $rpathdirs; do
699                         if test "X$x" = "X$dir"; then
700                           haveit=yes
701                           break
702                         fi
703                       done
704                       if test -z "$haveit"; then
705                         rpathdirs="$rpathdirs $dir"
706                       fi
707                       dnl Potentially add DIR to ltrpathdirs.
708                       dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
709                       haveit=
710                       for x in $ltrpathdirs; do
711                         if test "X$x" = "X$dir"; then
712                           haveit=yes
713                           break
714                         fi
715                       done
716                       if test -z "$haveit"; then
717                         ltrpathdirs="$ltrpathdirs $dir"
718                       fi
719                     fi
720                     ;;
721                   -l*)
722                     dnl Handle this in the next round.
723                     names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
724                     ;;
725                   *.la)
726                     dnl Handle this in the next round. Throw away the .la's
727                     dnl directory; it is already contained in a preceding -L
728                     dnl option.
729                     names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
730                     ;;
731                   *)
732                     dnl Most likely an immediate library name.
733                     LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
734                     LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
735                     ;;
736                 esac
737               done
738             fi
739           else
740             dnl Didn't find the library; assume it is in the system directories
741             dnl known to the linker and runtime loader. (All the system
742             dnl directories known to the linker should also be known to the
743             dnl runtime loader, otherwise the system is severely misconfigured.)
744             LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
745             LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
746           fi
747         fi
748       fi
749     done
750   done
751   if test "X$rpathdirs" != "X"; then
752     if test -n "$hardcode_libdir_separator"; then
753       dnl Weird platform: only the last -rpath option counts, the user must
754       dnl pass all path elements in one option. We can arrange that for a
755       dnl single library, but not when more than one $LIBNAMEs are used.
756       alldirs=
757       for found_dir in $rpathdirs; do
758         alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
759       done
760       dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl.
761       acl_save_libdir="$libdir"
762       libdir="$alldirs"
763       eval flag=\"$hardcode_libdir_flag_spec\"
764       libdir="$acl_save_libdir"
765       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
766     else
767       dnl The -rpath options are cumulative.
768       for found_dir in $rpathdirs; do
769         acl_save_libdir="$libdir"
770         libdir="$found_dir"
771         eval flag=\"$hardcode_libdir_flag_spec\"
772         libdir="$acl_save_libdir"
773         LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
774       done
775     fi
776   fi
777   if test "X$ltrpathdirs" != "X"; then
778     dnl When using libtool, the option that works for both libraries and
779     dnl executables is -R. The -R options are cumulative.
780     for found_dir in $ltrpathdirs; do
781       LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
782     done
783   fi
784 ])
785
786 dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
787 dnl unless already present in VAR.
788 dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
789 dnl contains two or three consecutive elements that belong together.
790 AC_DEFUN([AC_LIB_APPENDTOVAR],
791 [
792   for element in [$2]; do
793     haveit=
794     for x in $[$1]; do
795       AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
796       if test "X$x" = "X$element"; then
797         haveit=yes
798         break
799       fi
800     done
801     if test -z "$haveit"; then
802       [$1]="${[$1]}${[$1]:+ }$element"
803     fi
804   done
805 ])
806
807 # lib-prefix.m4 serial 3 (gettext-0.13)
808 dnl Copyright (C) 2001-2003 Free Software Foundation, Inc.
809 dnl This file is free software, distributed under the terms of the GNU
810 dnl General Public License.  As a special exception to the GNU General
811 dnl Public License, this file may be distributed as part of a program
812 dnl that contains a configuration script generated by Autoconf, under
813 dnl the same distribution terms as the rest of that program.
814
815 dnl From Bruno Haible.
816
817 dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and
818 dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't
819 dnl require excessive bracketing.
820 ifdef([AC_HELP_STRING],
821 [AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])],
822 [AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])])
823
824 dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
825 dnl to access previously installed libraries. The basic assumption is that
826 dnl a user will want packages to use other packages he previously installed
827 dnl with the same --prefix option.
828 dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
829 dnl libraries, but is otherwise very convenient.
830 AC_DEFUN([AC_LIB_PREFIX],
831 [
832   AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
833   AC_REQUIRE([AC_PROG_CC])
834   AC_REQUIRE([AC_CANONICAL_HOST])
835   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
836   dnl By default, look in $includedir and $libdir.
837   use_additional=yes
838   AC_LIB_WITH_FINAL_PREFIX([
839     eval additional_includedir=\"$includedir\"
840     eval additional_libdir=\"$libdir\"
841   ])
842   AC_LIB_ARG_WITH([lib-prefix],
843 [  --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
844   --without-lib-prefix    don't search for libraries in includedir and libdir],
845 [
846     if test "X$withval" = "Xno"; then
847       use_additional=no
848     else
849       if test "X$withval" = "X"; then
850         AC_LIB_WITH_FINAL_PREFIX([
851           eval additional_includedir=\"$includedir\"
852           eval additional_libdir=\"$libdir\"
853         ])
854       else
855         additional_includedir="$withval/include"
856         additional_libdir="$withval/lib"
857       fi
858     fi
859 ])
860   if test $use_additional = yes; then
861     dnl Potentially add $additional_includedir to $CPPFLAGS.
862     dnl But don't add it
863     dnl   1. if it's the standard /usr/include,
864     dnl   2. if it's already present in $CPPFLAGS,
865     dnl   3. if it's /usr/local/include and we are using GCC on Linux,
866     dnl   4. if it doesn't exist as a directory.
867     if test "X$additional_includedir" != "X/usr/include"; then
868       haveit=
869       for x in $CPPFLAGS; do
870         AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
871         if test "X$x" = "X-I$additional_includedir"; then
872           haveit=yes
873           break
874         fi
875       done
876       if test -z "$haveit"; then
877         if test "X$additional_includedir" = "X/usr/local/include"; then
878           if test -n "$GCC"; then
879             case $host_os in
880               linux*) haveit=yes;;
881             esac
882           fi
883         fi
884         if test -z "$haveit"; then
885           if test -d "$additional_includedir"; then
886             dnl Really add $additional_includedir to $CPPFLAGS.
887             CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
888           fi
889         fi
890       fi
891     fi
892     dnl Potentially add $additional_libdir to $LDFLAGS.
893     dnl But don't add it
894     dnl   1. if it's the standard /usr/lib,
895     dnl   2. if it's already present in $LDFLAGS,
896     dnl   3. if it's /usr/local/lib and we are using GCC on Linux,
897     dnl   4. if it doesn't exist as a directory.
898     if test "X$additional_libdir" != "X/usr/lib"; then
899       haveit=
900       for x in $LDFLAGS; do
901         AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
902         if test "X$x" = "X-L$additional_libdir"; then
903           haveit=yes
904           break
905         fi
906       done
907       if test -z "$haveit"; then
908         if test "X$additional_libdir" = "X/usr/local/lib"; then
909           if test -n "$GCC"; then
910             case $host_os in
911               linux*) haveit=yes;;
912             esac
913           fi
914         fi
915         if test -z "$haveit"; then
916           if test -d "$additional_libdir"; then
917             dnl Really add $additional_libdir to $LDFLAGS.
918             LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
919           fi
920         fi
921       fi
922     fi
923   fi
924 ])
925
926 dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
927 dnl acl_final_exec_prefix, containing the values to which $prefix and
928 dnl $exec_prefix will expand at the end of the configure script.
929 AC_DEFUN([AC_LIB_PREPARE_PREFIX],
930 [
931   dnl Unfortunately, prefix and exec_prefix get only finally determined
932   dnl at the end of configure.
933   if test "X$prefix" = "XNONE"; then
934     acl_final_prefix="$ac_default_prefix"
935   else
936     acl_final_prefix="$prefix"
937   fi
938   if test "X$exec_prefix" = "XNONE"; then
939     acl_final_exec_prefix='${prefix}'
940   else
941     acl_final_exec_prefix="$exec_prefix"
942   fi
943   acl_save_prefix="$prefix"
944   prefix="$acl_final_prefix"
945   eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
946   prefix="$acl_save_prefix"
947 ])
948
949 dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
950 dnl variables prefix and exec_prefix bound to the values they will have
951 dnl at the end of the configure script.
952 AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
953 [
954   acl_save_prefix="$prefix"
955   prefix="$acl_final_prefix"
956   acl_save_exec_prefix="$exec_prefix"
957   exec_prefix="$acl_final_exec_prefix"
958   $1
959   exec_prefix="$acl_save_exec_prefix"
960   prefix="$acl_save_prefix"
961 ])
962
963 m4_include([../config/acx.m4])
964 m4_include([../config/gettext.m4])