Add encoder support for Dirac using the Schroedinger library.
[vlc/asuraparaju-public.git] / m4 / lib-link.m4
blobc73bd8e3a478ce61292aaa298d42aad15c9d348a
1 # lib-link.m4 serial 21 (gettext-0.18)
2 dnl Copyright (C) 2001-2010 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 dnl From Bruno Haible.
9 AC_PREREQ([2.54])
11 dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
12 dnl the libraries corresponding to explicit and implicit dependencies.
13 dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
14 dnl augments the CPPFLAGS variable.
15 dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
16 dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
17 AC_DEFUN([AC_LIB_LINKFLAGS],
19   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
20   AC_REQUIRE([AC_LIB_RPATH])
21   pushdef([Name],[translit([$1],[./-], [___])])
22   pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
23                                 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
24   AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
25     AC_LIB_LINKFLAGS_BODY([$1], [$2])
26     ac_cv_lib[]Name[]_libs="$LIB[]NAME"
27     ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
28     ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
29     ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX"
30   ])
31   LIB[]NAME="$ac_cv_lib[]Name[]_libs"
32   LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
33   INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
34   LIB[]NAME[]_PREFIX="$ac_cv_lib[]Name[]_prefix"
35   AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
36   AC_SUBST([LIB]NAME)
37   AC_SUBST([LTLIB]NAME)
38   AC_SUBST([LIB]NAME[_PREFIX])
39   dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
40   dnl results of this search when this library appears as a dependency.
41   HAVE_LIB[]NAME=yes
42   popdef([NAME])
43   popdef([Name])
46 dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode, [missing-message])
47 dnl searches for libname and the libraries corresponding to explicit and
48 dnl implicit dependencies, together with the specified include files and
49 dnl the ability to compile and link the specified testcode. The missing-message
50 dnl defaults to 'no' and may contain additional hints for the user.
51 dnl If found, it sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME}
52 dnl and LTLIB${NAME} variables and augments the CPPFLAGS variable, and
53 dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
54 dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
55 dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname
56 dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
57 AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
59   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
60   AC_REQUIRE([AC_LIB_RPATH])
61   pushdef([Name],[translit([$1],[./-], [___])])
62   pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
63                                 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
65   dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
66   dnl accordingly.
67   AC_LIB_LINKFLAGS_BODY([$1], [$2])
69   dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
70   dnl because if the user has installed lib[]Name and not disabled its use
71   dnl via --without-lib[]Name-prefix, he wants to use it.
72   ac_save_CPPFLAGS="$CPPFLAGS"
73   AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
75   AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
76     ac_save_LIBS="$LIBS"
77     dnl If $LIB[]NAME contains some -l options, add it to the end of LIBS,
78     dnl because these -l options might require -L options that are present in
79     dnl LIBS. -l options benefit only from the -L options listed before it.
80     dnl Otherwise, add it to the front of LIBS, because it may be a static
81     dnl library that depends on another static library that is present in LIBS.
82     dnl Static libraries benefit only from the static libraries listed after
83     dnl it.
84     case " $LIB[]NAME" in
85       *" -l"*) LIBS="$LIBS $LIB[]NAME" ;;
86       *)       LIBS="$LIB[]NAME $LIBS" ;;
87     esac
88     AC_TRY_LINK([$3], [$4],
89       [ac_cv_lib[]Name=yes],
90       [ac_cv_lib[]Name='m4_if([$5], [], [no], [[$5]])'])
91     LIBS="$ac_save_LIBS"
92   ])
93   if test "$ac_cv_lib[]Name" = yes; then
94     HAVE_LIB[]NAME=yes
95     AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the lib][$1 library.])
96     AC_MSG_CHECKING([how to link with lib[]$1])
97     AC_MSG_RESULT([$LIB[]NAME])
98   else
99     HAVE_LIB[]NAME=no
100     dnl If $LIB[]NAME didn't lead to a usable library, we don't need
101     dnl $INC[]NAME either.
102     CPPFLAGS="$ac_save_CPPFLAGS"
103     LIB[]NAME=
104     LTLIB[]NAME=
105     LIB[]NAME[]_PREFIX=
106   fi
107   AC_SUBST([HAVE_LIB]NAME)
108   AC_SUBST([LIB]NAME)
109   AC_SUBST([LTLIB]NAME)
110   AC_SUBST([LIB]NAME[_PREFIX])
111   popdef([NAME])
112   popdef([Name])
115 dnl Determine the platform dependent parameters needed to use rpath:
116 dnl   acl_libext,
117 dnl   acl_shlibext,
118 dnl   acl_hardcode_libdir_flag_spec,
119 dnl   acl_hardcode_libdir_separator,
120 dnl   acl_hardcode_direct,
121 dnl   acl_hardcode_minus_L.
122 AC_DEFUN([AC_LIB_RPATH],
124   dnl Tell automake >= 1.10 to complain if config.rpath is missing.
125   m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])])
126   AC_REQUIRE([AC_PROG_CC])                dnl we use $CC, $GCC, $LDFLAGS
127   AC_REQUIRE([AC_LIB_PROG_LD])            dnl we use $LD, $with_gnu_ld
128   AC_REQUIRE([AC_CANONICAL_HOST])         dnl we use $host
129   AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
130   AC_CACHE_CHECK([for shared library run path origin], [acl_cv_rpath], [
131     CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
132     ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
133     . ./conftest.sh
134     rm -f ./conftest.sh
135     acl_cv_rpath=done
136   ])
137   wl="$acl_cv_wl"
138   acl_libext="$acl_cv_libext"
139   acl_shlibext="$acl_cv_shlibext"
140   acl_libname_spec="$acl_cv_libname_spec"
141   acl_library_names_spec="$acl_cv_library_names_spec"
142   acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
143   acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
144   acl_hardcode_direct="$acl_cv_hardcode_direct"
145   acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"
146   dnl Determine whether the user wants rpath handling at all.
147   AC_ARG_ENABLE([rpath],
148     [  --disable-rpath         do not hardcode runtime library paths],
149     :, enable_rpath=yes)
152 dnl AC_LIB_FROMPACKAGE(name, package)
153 dnl declares that libname comes from the given package. The configure file
154 dnl will then not have a --with-libname-prefix option but a
155 dnl --with-package-prefix option. Several libraries can come from the same
156 dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar
157 dnl macro call that searches for libname.
158 AC_DEFUN([AC_LIB_FROMPACKAGE],
160   pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
161                                 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
162   define([acl_frompackage_]NAME, [$2])
163   popdef([NAME])
164   pushdef([PACK],[$2])
165   pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-],
166                                   [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
167   define([acl_libsinpackage_]PACKUP,
168     m4_ifdef([acl_libsinpackage_]PACKUP, [acl_libsinpackage_]PACKUP[[, ]],)[lib$1])
169   popdef([PACKUP])
170   popdef([PACK])
173 dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
174 dnl the libraries corresponding to explicit and implicit dependencies.
175 dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
176 dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found
177 dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem.
178 AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
180   AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
181   pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
182                                 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
183   pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])])
184   pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-],
185                                   [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
186   pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])])
187   dnl Autoconf >= 2.61 supports dots in --with options.
188   pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit(PACK,[.],[_])],PACK)])
189   dnl By default, look in $includedir and $libdir.
190   use_additional=yes
191   AC_LIB_WITH_FINAL_PREFIX([
192     eval additional_includedir=\"$includedir\"
193     eval additional_libdir=\"$libdir\"
194   ])
195   AC_ARG_WITH(P_A_C_K[-prefix],
196 [[  --with-]]P_A_C_K[[-prefix[=DIR]  search for ]PACKLIBS[ in DIR/include and DIR/lib
197   --without-]]P_A_C_K[[-prefix     don't search for ]PACKLIBS[ in includedir and libdir]],
199     if test "X$withval" = "Xno"; then
200       use_additional=no
201     else
202       if test "X$withval" = "X"; then
203         AC_LIB_WITH_FINAL_PREFIX([
204           eval additional_includedir=\"$includedir\"
205           eval additional_libdir=\"$libdir\"
206         ])
207       else
208         additional_includedir="$withval/include"
209         additional_libdir="$withval/$acl_libdirstem"
210         if test "$acl_libdirstem2" != "$acl_libdirstem" \
211            && ! test -d "$withval/$acl_libdirstem"; then
212           additional_libdir="$withval/$acl_libdirstem2"
213         fi
214       fi
215     fi
217   dnl Search the library and its dependencies in $additional_libdir and
218   dnl $LDFLAGS. Using breadth-first-seach.
219   LIB[]NAME=
220   LTLIB[]NAME=
221   INC[]NAME=
222   LIB[]NAME[]_PREFIX=
223   dnl HAVE_LIB${NAME} is an indicator that LIB${NAME}, LTLIB${NAME} have been
224   dnl computed. So it has to be reset here.
225   HAVE_LIB[]NAME=
226   rpathdirs=
227   ltrpathdirs=
228   names_already_handled=
229   names_next_round='$1 $2'
230   while test -n "$names_next_round"; do
231     names_this_round="$names_next_round"
232     names_next_round=
233     for name in $names_this_round; do
234       already_handled=
235       for n in $names_already_handled; do
236         if test "$n" = "$name"; then
237           already_handled=yes
238           break
239         fi
240       done
241       if test -z "$already_handled"; then
242         names_already_handled="$names_already_handled $name"
243         dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
244         dnl or AC_LIB_HAVE_LINKFLAGS call.
245         uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
246         eval value=\"\$HAVE_LIB$uppername\"
247         if test -n "$value"; then
248           if test "$value" = yes; then
249             eval value=\"\$LIB$uppername\"
250             test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
251             eval value=\"\$LTLIB$uppername\"
252             test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
253           else
254             dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
255             dnl that this library doesn't exist. So just drop it.
256             :
257           fi
258         else
259           dnl Search the library lib$name in $additional_libdir and $LDFLAGS
260           dnl and the already constructed $LIBNAME/$LTLIBNAME.
261           found_dir=
262           found_la=
263           found_so=
264           found_a=
265           eval libname=\"$acl_libname_spec\"    # typically: libname=lib$name
266           if test -n "$acl_shlibext"; then
267             shrext=".$acl_shlibext"             # typically: shrext=.so
268           else
269             shrext=
270           fi
271           if test $use_additional = yes; then
272             dir="$additional_libdir"
273             dnl The same code as in the loop below:
274             dnl First look for a shared library.
275             if test -n "$acl_shlibext"; then
276               if test -f "$dir/$libname$shrext"; then
277                 found_dir="$dir"
278                 found_so="$dir/$libname$shrext"
279               else
280                 if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
281                   ver=`(cd "$dir" && \
282                         for f in "$libname$shrext".*; do echo "$f"; done \
283                         | sed -e "s,^$libname$shrext\\\\.,," \
284                         | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
285                         | sed 1q ) 2>/dev/null`
286                   if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
287                     found_dir="$dir"
288                     found_so="$dir/$libname$shrext.$ver"
289                   fi
290                 else
291                   eval library_names=\"$acl_library_names_spec\"
292                   for f in $library_names; do
293                     if test -f "$dir/$f"; then
294                       found_dir="$dir"
295                       found_so="$dir/$f"
296                       break
297                     fi
298                   done
299                 fi
300               fi
301             fi
302             dnl Then look for a static library.
303             if test "X$found_dir" = "X"; then
304               if test -f "$dir/$libname.$acl_libext"; then
305                 found_dir="$dir"
306                 found_a="$dir/$libname.$acl_libext"
307               fi
308             fi
309             if test "X$found_dir" != "X"; then
310               if test -f "$dir/$libname.la"; then
311                 found_la="$dir/$libname.la"
312               fi
313             fi
314           fi
315           if test "X$found_dir" = "X"; then
316             for x in $LDFLAGS $LTLIB[]NAME; do
317               AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
318               case "$x" in
319                 -L*)
320                   dir=`echo "X$x" | sed -e 's/^X-L//'`
321                   dnl First look for a shared library.
322                   if test -n "$acl_shlibext"; then
323                     if test -f "$dir/$libname$shrext"; then
324                       found_dir="$dir"
325                       found_so="$dir/$libname$shrext"
326                     else
327                       if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
328                         ver=`(cd "$dir" && \
329                               for f in "$libname$shrext".*; do echo "$f"; done \
330                               | sed -e "s,^$libname$shrext\\\\.,," \
331                               | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
332                               | sed 1q ) 2>/dev/null`
333                         if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
334                           found_dir="$dir"
335                           found_so="$dir/$libname$shrext.$ver"
336                         fi
337                       else
338                         eval library_names=\"$acl_library_names_spec\"
339                         for f in $library_names; do
340                           if test -f "$dir/$f"; then
341                             found_dir="$dir"
342                             found_so="$dir/$f"
343                             break
344                           fi
345                         done
346                       fi
347                     fi
348                   fi
349                   dnl Then look for a static library.
350                   if test "X$found_dir" = "X"; then
351                     if test -f "$dir/$libname.$acl_libext"; then
352                       found_dir="$dir"
353                       found_a="$dir/$libname.$acl_libext"
354                     fi
355                   fi
356                   if test "X$found_dir" != "X"; then
357                     if test -f "$dir/$libname.la"; then
358                       found_la="$dir/$libname.la"
359                     fi
360                   fi
361                   ;;
362               esac
363               if test "X$found_dir" != "X"; then
364                 break
365               fi
366             done
367           fi
368           if test "X$found_dir" != "X"; then
369             dnl Found the library.
370             LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
371             if test "X$found_so" != "X"; then
372               dnl Linking with a shared library. We attempt to hardcode its
373               dnl directory into the executable's runpath, unless it's the
374               dnl standard /usr/lib.
375               if test "$enable_rpath" = no \
376                  || test "X$found_dir" = "X/usr/$acl_libdirstem" \
377                  || test "X$found_dir" = "X/usr/$acl_libdirstem2"; then
378                 dnl No hardcoding is needed.
379                 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
380               else
381                 dnl Use an explicit option to hardcode DIR into the resulting
382                 dnl binary.
383                 dnl Potentially add DIR to ltrpathdirs.
384                 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
385                 haveit=
386                 for x in $ltrpathdirs; do
387                   if test "X$x" = "X$found_dir"; then
388                     haveit=yes
389                     break
390                   fi
391                 done
392                 if test -z "$haveit"; then
393                   ltrpathdirs="$ltrpathdirs $found_dir"
394                 fi
395                 dnl The hardcoding into $LIBNAME is system dependent.
396                 if test "$acl_hardcode_direct" = yes; then
397                   dnl Using DIR/libNAME.so during linking hardcodes DIR into the
398                   dnl resulting binary.
399                   LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
400                 else
401                   if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
402                     dnl Use an explicit option to hardcode DIR into the resulting
403                     dnl binary.
404                     LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
405                     dnl Potentially add DIR to rpathdirs.
406                     dnl The rpathdirs will be appended to $LIBNAME at the end.
407                     haveit=
408                     for x in $rpathdirs; do
409                       if test "X$x" = "X$found_dir"; then
410                         haveit=yes
411                         break
412                       fi
413                     done
414                     if test -z "$haveit"; then
415                       rpathdirs="$rpathdirs $found_dir"
416                     fi
417                   else
418                     dnl Rely on "-L$found_dir".
419                     dnl But don't add it if it's already contained in the LDFLAGS
420                     dnl or the already constructed $LIBNAME
421                     haveit=
422                     for x in $LDFLAGS $LIB[]NAME; do
423                       AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
424                       if test "X$x" = "X-L$found_dir"; then
425                         haveit=yes
426                         break
427                       fi
428                     done
429                     if test -z "$haveit"; then
430                       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
431                     fi
432                     if test "$acl_hardcode_minus_L" != no; then
433                       dnl FIXME: Not sure whether we should use
434                       dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
435                       dnl here.
436                       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
437                     else
438                       dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH
439                       dnl here, because this doesn't fit in flags passed to the
440                       dnl compiler. So give up. No hardcoding. This affects only
441                       dnl very old systems.
442                       dnl FIXME: Not sure whether we should use
443                       dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
444                       dnl here.
445                       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
446                     fi
447                   fi
448                 fi
449               fi
450             else
451               if test "X$found_a" != "X"; then
452                 dnl Linking with a static library.
453                 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
454               else
455                 dnl We shouldn't come here, but anyway it's good to have a
456                 dnl fallback.
457                 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
458               fi
459             fi
460             dnl Assume the include files are nearby.
461             additional_includedir=
462             case "$found_dir" in
463               */$acl_libdirstem | */$acl_libdirstem/)
464                 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`
465                 if test "$name" = '$1'; then
466                   LIB[]NAME[]_PREFIX="$basedir"
467                 fi
468                 additional_includedir="$basedir/include"
469                 ;;
470               */$acl_libdirstem2 | */$acl_libdirstem2/)
471                 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'`
472                 if test "$name" = '$1'; then
473                   LIB[]NAME[]_PREFIX="$basedir"
474                 fi
475                 additional_includedir="$basedir/include"
476                 ;;
477             esac
478             if test "X$additional_includedir" != "X"; then
479               dnl Potentially add $additional_includedir to $INCNAME.
480               dnl But don't add it
481               dnl   1. if it's the standard /usr/include,
482               dnl   2. if it's /usr/local/include and we are using GCC on Linux,
483               dnl   3. if it's already present in $CPPFLAGS or the already
484               dnl      constructed $INCNAME,
485               dnl   4. if it doesn't exist as a directory.
486               if test "X$additional_includedir" != "X/usr/include"; then
487                 haveit=
488                 if test "X$additional_includedir" = "X/usr/local/include"; then
489                   if test -n "$GCC"; then
490                     case $host_os in
491                       linux* | gnu* | k*bsd*-gnu) haveit=yes;;
492                     esac
493                   fi
494                 fi
495                 if test -z "$haveit"; then
496                   for x in $CPPFLAGS $INC[]NAME; do
497                     AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
498                     if test "X$x" = "X-I$additional_includedir"; then
499                       haveit=yes
500                       break
501                     fi
502                   done
503                   if test -z "$haveit"; then
504                     if test -d "$additional_includedir"; then
505                       dnl Really add $additional_includedir to $INCNAME.
506                       INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
507                     fi
508                   fi
509                 fi
510               fi
511             fi
512             dnl Look for dependencies.
513             if test -n "$found_la"; then
514               dnl Read the .la file. It defines the variables
515               dnl dlname, library_names, old_library, dependency_libs, current,
516               dnl age, revision, installed, dlopen, dlpreopen, libdir.
517               save_libdir="$libdir"
518               case "$found_la" in
519                 */* | *\\*) . "$found_la" ;;
520                 *) . "./$found_la" ;;
521               esac
522               libdir="$save_libdir"
523               dnl We use only dependency_libs.
524               for dep in $dependency_libs; do
525                 case "$dep" in
526                   -L*)
527                     additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
528                     dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
529                     dnl But don't add it
530                     dnl   1. if it's the standard /usr/lib,
531                     dnl   2. if it's /usr/local/lib and we are using GCC on Linux,
532                     dnl   3. if it's already present in $LDFLAGS or the already
533                     dnl      constructed $LIBNAME,
534                     dnl   4. if it doesn't exist as a directory.
535                     if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \
536                        && test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then
537                       haveit=
538                       if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \
539                          || test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then
540                         if test -n "$GCC"; then
541                           case $host_os in
542                             linux* | gnu* | k*bsd*-gnu) haveit=yes;;
543                           esac
544                         fi
545                       fi
546                       if test -z "$haveit"; then
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$additional_libdir"; then
551                             haveit=yes
552                             break
553                           fi
554                         done
555                         if test -z "$haveit"; then
556                           if test -d "$additional_libdir"; then
557                             dnl Really add $additional_libdir to $LIBNAME.
558                             LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
559                           fi
560                         fi
561                         haveit=
562                         for x in $LDFLAGS $LTLIB[]NAME; do
563                           AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
564                           if test "X$x" = "X-L$additional_libdir"; then
565                             haveit=yes
566                             break
567                           fi
568                         done
569                         if test -z "$haveit"; then
570                           if test -d "$additional_libdir"; then
571                             dnl Really add $additional_libdir to $LTLIBNAME.
572                             LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
573                           fi
574                         fi
575                       fi
576                     fi
577                     ;;
578                   -R*)
579                     dir=`echo "X$dep" | sed -e 's/^X-R//'`
580                     if test "$enable_rpath" != no; then
581                       dnl Potentially add DIR to rpathdirs.
582                       dnl The rpathdirs will be appended to $LIBNAME at the end.
583                       haveit=
584                       for x in $rpathdirs; do
585                         if test "X$x" = "X$dir"; then
586                           haveit=yes
587                           break
588                         fi
589                       done
590                       if test -z "$haveit"; then
591                         rpathdirs="$rpathdirs $dir"
592                       fi
593                       dnl Potentially add DIR to ltrpathdirs.
594                       dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
595                       haveit=
596                       for x in $ltrpathdirs; do
597                         if test "X$x" = "X$dir"; then
598                           haveit=yes
599                           break
600                         fi
601                       done
602                       if test -z "$haveit"; then
603                         ltrpathdirs="$ltrpathdirs $dir"
604                       fi
605                     fi
606                     ;;
607                   -l*)
608                     dnl Handle this in the next round.
609                     names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
610                     ;;
611                   *.la)
612                     dnl Handle this in the next round. Throw away the .la's
613                     dnl directory; it is already contained in a preceding -L
614                     dnl option.
615                     names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
616                     ;;
617                   *)
618                     dnl Most likely an immediate library name.
619                     LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
620                     LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
621                     ;;
622                 esac
623               done
624             fi
625           else
626             dnl Didn't find the library; assume it is in the system directories
627             dnl known to the linker and runtime loader. (All the system
628             dnl directories known to the linker should also be known to the
629             dnl runtime loader, otherwise the system is severely misconfigured.)
630             LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
631             LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
632           fi
633         fi
634       fi
635     done
636   done
637   if test "X$rpathdirs" != "X"; then
638     if test -n "$acl_hardcode_libdir_separator"; then
639       dnl Weird platform: only the last -rpath option counts, the user must
640       dnl pass all path elements in one option. We can arrange that for a
641       dnl single library, but not when more than one $LIBNAMEs are used.
642       alldirs=
643       for found_dir in $rpathdirs; do
644         alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir"
645       done
646       dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl.
647       acl_save_libdir="$libdir"
648       libdir="$alldirs"
649       eval flag=\"$acl_hardcode_libdir_flag_spec\"
650       libdir="$acl_save_libdir"
651       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
652     else
653       dnl The -rpath options are cumulative.
654       for found_dir in $rpathdirs; do
655         acl_save_libdir="$libdir"
656         libdir="$found_dir"
657         eval flag=\"$acl_hardcode_libdir_flag_spec\"
658         libdir="$acl_save_libdir"
659         LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
660       done
661     fi
662   fi
663   if test "X$ltrpathdirs" != "X"; then
664     dnl When using libtool, the option that works for both libraries and
665     dnl executables is -R. The -R options are cumulative.
666     for found_dir in $ltrpathdirs; do
667       LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
668     done
669   fi
670   popdef([P_A_C_K])
671   popdef([PACKLIBS])
672   popdef([PACKUP])
673   popdef([PACK])
674   popdef([NAME])
677 dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
678 dnl unless already present in VAR.
679 dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
680 dnl contains two or three consecutive elements that belong together.
681 AC_DEFUN([AC_LIB_APPENDTOVAR],
683   for element in [$2]; do
684     haveit=
685     for x in $[$1]; do
686       AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
687       if test "X$x" = "X$element"; then
688         haveit=yes
689         break
690       fi
691     done
692     if test -z "$haveit"; then
693       [$1]="${[$1]}${[$1]:+ }$element"
694     fi
695   done
698 dnl For those cases where a variable contains several -L and -l options
699 dnl referring to unknown libraries and directories, this macro determines the
700 dnl necessary additional linker options for the runtime path.
701 dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL])
702 dnl sets LDADDVAR to linker options needed together with LIBSVALUE.
703 dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed,
704 dnl otherwise linking without libtool is assumed.
705 AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS],
707   AC_REQUIRE([AC_LIB_RPATH])
708   AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
709   $1=
710   if test "$enable_rpath" != no; then
711     if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
712       dnl Use an explicit option to hardcode directories into the resulting
713       dnl binary.
714       rpathdirs=
715       next=
716       for opt in $2; do
717         if test -n "$next"; then
718           dir="$next"
719           dnl No need to hardcode the standard /usr/lib.
720           if test "X$dir" != "X/usr/$acl_libdirstem" \
721              && test "X$dir" != "X/usr/$acl_libdirstem2"; then
722             rpathdirs="$rpathdirs $dir"
723           fi
724           next=
725         else
726           case $opt in
727             -L) next=yes ;;
728             -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
729                  dnl No need to hardcode the standard /usr/lib.
730                  if test "X$dir" != "X/usr/$acl_libdirstem" \
731                     && test "X$dir" != "X/usr/$acl_libdirstem2"; then
732                    rpathdirs="$rpathdirs $dir"
733                  fi
734                  next= ;;
735             *) next= ;;
736           esac
737         fi
738       done
739       if test "X$rpathdirs" != "X"; then
740         if test -n ""$3""; then
741           dnl libtool is used for linking. Use -R options.
742           for dir in $rpathdirs; do
743             $1="${$1}${$1:+ }-R$dir"
744           done
745         else
746           dnl The linker is used for linking directly.
747           if test -n "$acl_hardcode_libdir_separator"; then
748             dnl Weird platform: only the last -rpath option counts, the user
749             dnl must pass all path elements in one option.
750             alldirs=
751             for dir in $rpathdirs; do
752               alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir"
753             done
754             acl_save_libdir="$libdir"
755             libdir="$alldirs"
756             eval flag=\"$acl_hardcode_libdir_flag_spec\"
757             libdir="$acl_save_libdir"
758             $1="$flag"
759           else
760             dnl The -rpath options are cumulative.
761             for dir in $rpathdirs; do
762               acl_save_libdir="$libdir"
763               libdir="$dir"
764               eval flag=\"$acl_hardcode_libdir_flag_spec\"
765               libdir="$acl_save_libdir"
766               $1="${$1}${$1:+ }$flag"
767             done
768           fi
769         fi
770       fi
771     fi
772   fi
773   AC_SUBST([$1])