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