Do not log an error for missing Video info in DefineVideo, as that's fine when Vide...
[gnash.git] / macros / lib-link.m4
blob974240883f7068342895ff098177330a23df24ea
1 # lib-link.m4 serial 6 (gettext-0.14.3)
2 dnl Copyright (C) 2001-2005, 2009, 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.50)
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 AC_DEFUN([AC_LIB_LINKFLAGS],
17   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
18   AC_REQUIRE([AC_LIB_RPATH])
19   define([Name],[translit([$1],[./-], [___])])
20   define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
21                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
22   AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
23     AC_LIB_LINKFLAGS_BODY([$1], [$2])
24     ac_cv_lib[]Name[]_libs="$LIB[]NAME"
25     ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
26     ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
27   ])
28   LIB[]NAME="$ac_cv_lib[]Name[]_libs"
29   LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
30   INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
31   AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
32   AC_SUBST([LIB]NAME)
33   AC_SUBST([LTLIB]NAME)
34   dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
35   dnl results of this search when this library appears as a dependency.
36   HAVE_LIB[]NAME=yes
37   undefine([Name])
38   undefine([NAME])
41 dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode)
42 dnl searches for libname and the libraries corresponding to explicit and
43 dnl implicit dependencies, together with the specified include files and
44 dnl the ability to compile and link the specified testcode. If found, it
45 dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and
46 dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and
47 dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
48 dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
49 AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
51   AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
52   AC_REQUIRE([AC_LIB_RPATH])
53   define([Name],[translit([$1],[./-], [___])])
54   define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
55                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
57   dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
58   dnl accordingly.
59   AC_LIB_LINKFLAGS_BODY([$1], [$2])
61   dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
62   dnl because if the user has installed lib[]Name and not disabled its use
63   dnl via --without-lib[]Name-prefix, he wants to use it.
64   ac_save_CPPFLAGS="$CPPFLAGS"
65   AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
67   AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
68     ac_save_LIBS="$LIBS"
69     LIBS="$LIBS $LIB[]NAME"
70     AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no])
71     LIBS="$ac_save_LIBS"
72   ])
73   if test "$ac_cv_lib[]Name" = yes; then
74     HAVE_LIB[]NAME=yes
75     AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.])
76     AC_MSG_CHECKING([how to link with lib[]$1])
77     AC_MSG_RESULT([$LIB[]NAME])
78   else
79     HAVE_LIB[]NAME=no
80     dnl If $LIB[]NAME didn't lead to a usable library, we don't need
81     dnl $INC[]NAME either.
82     CPPFLAGS="$ac_save_CPPFLAGS"
83     LIB[]NAME=
84     LTLIB[]NAME=
85   fi
86   AC_SUBST([HAVE_LIB]NAME)
87   AC_SUBST([LIB]NAME)
88   AC_SUBST([LTLIB]NAME)
89   undefine([Name])
90   undefine([NAME])
93 dnl Determine the platform dependent parameters needed to use rpath:
94 dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator,
95 dnl hardcode_direct, hardcode_minus_L.
96 AC_DEFUN([AC_LIB_RPATH],
98   AC_PATH_PROG(CONFIG_RPATH, config.rpath, config.rpath, [])
99   AC_REQUIRE([AC_PROG_CC])                dnl we use $CC, $GCC, $LDFLAGS
100   AC_REQUIRE([AC_PROG_LD])                dnl we use $LD, $with_gnu_ld
101   AC_REQUIRE([AC_CANONICAL_HOST])         dnl we use $host
102   ac_aux_dir=$srcdir
103   AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [
104     CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
105     ${CONFIG_SHELL-/bin/sh} "$srcdir/config.rpath" "$host" > conftest.sh
106     . ./conftest.sh
107     rm -f ./conftest.sh
108     acl_cv_rpath=done
109   ])
110   wl="$acl_cv_wl"
111   libext="$acl_cv_libext"
112   shlibext="$acl_cv_shlibext"
113   hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
114   hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
115   hardcode_direct="$acl_cv_hardcode_direct"
116   hardcode_minus_L="$acl_cv_hardcode_minus_L"
117   dnl Determine whether the user wants rpath handling at all.
118   AC_ARG_ENABLE(rpath,
119     [  --disable-rpath         do not hardcode runtime library paths],
120     :, enable_rpath=yes)
123 dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
124 dnl the libraries corresponding to explicit and implicit dependencies.
125 dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
126 AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
128   define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
129                                [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
130   dnl By default, look in $includedir and $libdir.
131   use_additional=yes
132   AC_LIB_WITH_FINAL_PREFIX([
133     eval additional_includedir=\"$includedir\"
134     eval additional_libdir=\"$libdir\"
135   ])
136   AC_LIB_ARG_WITH([lib$1-prefix],
137 [  --with-lib$1-prefix[=DIR]  search for lib$1 in DIR/include and DIR/lib
138   --without-lib$1-prefix     don't search for lib$1 in includedir and libdir],
140     if test "X$withval" = "Xno"; then
141       use_additional=no
142     else
143       if test "X$withval" = "X"; then
144         AC_LIB_WITH_FINAL_PREFIX([
145           eval additional_includedir=\"$includedir\"
146           eval additional_libdir=\"$libdir\"
147         ])
148       else
149         additional_includedir="$withval/include"
150         additional_libdir="$withval/lib"
151       fi
152     fi
154   dnl Search the library and its dependencies in $additional_libdir and
155   dnl $LDFLAGS. Using breadth-first-seach.
156   LIB[]NAME=
157   LTLIB[]NAME=
158   INC[]NAME=
159   rpathdirs=
160   ltrpathdirs=
161   names_already_handled=
162   names_next_round='$1 $2'
163   while test -n "$names_next_round"; do
164     names_this_round="$names_next_round"
165     names_next_round=
166     for name in $names_this_round; do
167       already_handled=
168       for n in $names_already_handled; do
169         if test "$n" = "$name"; then
170           already_handled=yes
171           break
172         fi
173       done
174       if test -z "$already_handled"; then
175         names_already_handled="$names_already_handled $name"
176         dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
177         dnl or AC_LIB_HAVE_LINKFLAGS call.
178         uppername="`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`"
179         eval value=\"\$HAVE_LIB$uppername\"
180         if test -n "$value"; then
181           if test "$value" = yes; then
182             eval value=\"\$LIB$uppername\"
183             test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
184             eval value=\"\$LTLIB$uppername\"
185             test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
186           else
187             dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
188             dnl that this library doesn't exist. So just drop it.
189             :
190           fi
191         else
192           dnl Search the library lib$name in $additional_libdir and $LDFLAGS
193           dnl and the already constructed $LIBNAME/$LTLIBNAME.
194           found_dir=
195           found_la=
196           found_so=
197           found_a=
198           if test $use_additional = yes; then
199             if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
200               found_dir="$additional_libdir"
201               found_so="$additional_libdir/lib$name.$shlibext"
202               if test -f "$additional_libdir/lib$name.la"; then
203                 found_la="$additional_libdir/lib$name.la"
204               fi
205             else
206               if test -f "$additional_libdir/lib$name.$libext"; then
207                 found_dir="$additional_libdir"
208                 found_a="$additional_libdir/lib$name.$libext"
209                 if test -f "$additional_libdir/lib$name.la"; then
210                   found_la="$additional_libdir/lib$name.la"
211                 fi
212               fi
213             fi
214           fi
215           if test "X$found_dir" = "X"; then
216             for x in $LDFLAGS $LTLIB[]NAME; do
217               AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
218               case "$x" in
219                 -L*)
220                   dir=`echo "X$x" | sed -e 's/^X-L//'`
221                   if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
222                     found_dir="$dir"
223                     found_so="$dir/lib$name.$shlibext"
224                     if test -f "$dir/lib$name.la"; then
225                       found_la="$dir/lib$name.la"
226                     fi
227                   else
228                     if test -f "$dir/lib$name.$libext"; then
229                       found_dir="$dir"
230                       found_a="$dir/lib$name.$libext"
231                       if test -f "$dir/lib$name.la"; then
232                         found_la="$dir/lib$name.la"
233                       fi
234                     fi
235                   fi
236                   ;;
237               esac
238               if test "X$found_dir" != "X"; then
239                 break
240               fi
241             done
242           fi
243           if test "X$found_dir" != "X"; then
244             dnl Found the library.
245             LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
246             if test "X$found_so" != "X"; then
247               dnl Linking with a shared library. We attempt to hardcode its
248               dnl directory into the executable's runpath, unless it's the
249               dnl standard /usr/lib.
250               if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
251                 dnl No hardcoding is needed.
252                 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
253               else
254                 dnl Use an explicit option to hardcode DIR into the resulting
255                 dnl binary.
256                 dnl Potentially add DIR to ltrpathdirs.
257                 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
258                 haveit=
259                 for x in $ltrpathdirs; do
260                   if test "X$x" = "X$found_dir"; then
261                     haveit=yes
262                     break
263                   fi
264                 done
265                 if test -z "$haveit"; then
266                   ltrpathdirs="$ltrpathdirs $found_dir"
267                 fi
268                 dnl The hardcoding into $LIBNAME is system dependent.
269                 if test "$hardcode_direct" = yes; then
270                   dnl Using DIR/libNAME.so during linking hardcodes DIR into the
271                   dnl resulting binary.
272                   LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
273                 else
274                   if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
275                     dnl Use an explicit option to hardcode DIR into the resulting
276                     dnl binary.
277                     LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
278                     dnl Potentially add DIR to rpathdirs.
279                     dnl The rpathdirs will be appended to $LIBNAME at the end.
280                     haveit=
281                     for x in $rpathdirs; do
282                       if test "X$x" = "X$found_dir"; then
283                         haveit=yes
284                         break
285                       fi
286                     done
287                     if test -z "$haveit"; then
288                       rpathdirs="$rpathdirs $found_dir"
289                     fi
290                   else
291                     dnl Rely on "-L$found_dir".
292                     dnl But don't add it if it's already contained in the LDFLAGS
293                     dnl or the already constructed $LIBNAME
294                     haveit=
295                     for x in $LDFLAGS $LIB[]NAME; do
296                       AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
297                       if test "X$x" = "X-L$found_dir"; then
298                         haveit=yes
299                         break
300                       fi
301                     done
302                     if test -z "$haveit"; then
303                       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
304                     fi
305                     if test "$hardcode_minus_L" != no; then
306                       dnl FIXME: Not sure whether we should use
307                       dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
308                       dnl here.
309                       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
310                     else
311                       dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH
312                       dnl here, because this doesn't fit in flags passed to the
313                       dnl compiler. So give up. No hardcoding. This affects only
314                       dnl very old systems.
315                       dnl FIXME: Not sure whether we should use
316                       dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
317                       dnl here.
318                       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
319                     fi
320                   fi
321                 fi
322               fi
323             else
324               if test "X$found_a" != "X"; then
325                 dnl Linking with a static library.
326                 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
327               else
328                 dnl We shouldn't come here, but anyway it's good to have a
329                 dnl fallback.
330                 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
331               fi
332             fi
333             dnl Assume the include files are nearby.
334             additional_includedir=
335             case "$found_dir" in
336               */lib | */lib/)
337                 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
338                 additional_includedir="$basedir/include"
339                 ;;
340             esac
341             if test "X$additional_includedir" != "X"; then
342               dnl Potentially add $additional_includedir to $INCNAME.
343               dnl But don't add it
344               dnl   1. if it's the standard /usr/include,
345               dnl   2. if it's /usr/local/include and we are using GCC on Linux,
346               dnl   3. if it's already present in $CPPFLAGS or the already
347               dnl      constructed $INCNAME,
348               dnl   4. if it doesn't exist as a directory.
349               if test "X$additional_includedir" != "X/usr/include"; then
350                 haveit=
351                 if test "X$additional_includedir" = "X/usr/local/include"; then
352                   if test -n "$GCC"; then
353                     case $host_os in
354                       linux* | gnu* | k*bsd*-gnu) haveit=yes;;
355                     esac
356                   fi
357                 fi
358                 if test -z "$haveit"; then
359                   for x in $CPPFLAGS $INC[]NAME; do
360                     AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
361                     if test "X$x" = "X-I$additional_includedir"; then
362                       haveit=yes
363                       break
364                     fi
365                   done
366                   if test -z "$haveit"; then
367                     if test -d "$additional_includedir"; then
368                       dnl Really add $additional_includedir to $INCNAME.
369                       INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
370                     fi
371                   fi
372                 fi
373               fi
374             fi
375             dnl Look for dependencies.
376             if test -n "$found_la"; then
377               dnl Read the .la file. It defines the variables
378               dnl dlname, library_names, old_library, dependency_libs, current,
379               dnl age, revision, installed, dlopen, dlpreopen, libdir.
380               save_libdir="$libdir"
381               case "$found_la" in
382                 */* | *\\*) . "$found_la" ;;
383                 *) . "./$found_la" ;;
384               esac
385               libdir="$save_libdir"
386               dnl We use only dependency_libs.
387               for dep in $dependency_libs; do
388                 case "$dep" in
389                   -L*)
390                     additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
391                     dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
392                     dnl But don't add it
393                     dnl   1. if it's the standard /usr/lib,
394                     dnl   2. if it's /usr/local/lib and we are using GCC on Linux,
395                     dnl   3. if it's already present in $LDFLAGS or the already
396                     dnl      constructed $LIBNAME,
397                     dnl   4. if it doesn't exist as a directory.
398                     if test "X$additional_libdir" != "X/usr/lib"; then
399                       haveit=
400                       if test "X$additional_libdir" = "X/usr/local/lib"; then
401                         if test -n "$GCC"; then
402                           case $host_os in
403                             linux* | gnu* | k*bsd*-gnu) haveit=yes;;
404                           esac
405                         fi
406                       fi
407                       if test -z "$haveit"; then
408                         haveit=
409                         for x in $LDFLAGS $LIB[]NAME; do
410                           AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
411                           if test "X$x" = "X-L$additional_libdir"; then
412                             haveit=yes
413                             break
414                           fi
415                         done
416                         if test -z "$haveit"; then
417                           if test -d "$additional_libdir"; then
418                             dnl Really add $additional_libdir to $LIBNAME.
419                             LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
420                           fi
421                         fi
422                         haveit=
423                         for x in $LDFLAGS $LTLIB[]NAME; do
424                           AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
425                           if test "X$x" = "X-L$additional_libdir"; then
426                             haveit=yes
427                             break
428                           fi
429                         done
430                         if test -z "$haveit"; then
431                           if test -d "$additional_libdir"; then
432                             dnl Really add $additional_libdir to $LTLIBNAME.
433                             LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
434                           fi
435                         fi
436                       fi
437                     fi
438                     ;;
439                   -R*)
440                     dir=`echo "X$dep" | sed -e 's/^X-R//'`
441                     if test "$enable_rpath" != no; then
442                       dnl Potentially add DIR to rpathdirs.
443                       dnl The rpathdirs will be appended to $LIBNAME at the end.
444                       haveit=
445                       for x in $rpathdirs; do
446                         if test "X$x" = "X$dir"; then
447                           haveit=yes
448                           break
449                         fi
450                       done
451                       if test -z "$haveit"; then
452                         rpathdirs="$rpathdirs $dir"
453                       fi
454                       dnl Potentially add DIR to ltrpathdirs.
455                       dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
456                       haveit=
457                       for x in $ltrpathdirs; do
458                         if test "X$x" = "X$dir"; then
459                           haveit=yes
460                           break
461                         fi
462                       done
463                       if test -z "$haveit"; then
464                         ltrpathdirs="$ltrpathdirs $dir"
465                       fi
466                     fi
467                     ;;
468                   -l*)
469                     dnl Handle this in the next round.
470                     names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
471                     ;;
472                   *.la)
473                     dnl Handle this in the next round. Throw away the .la's
474                     dnl directory; it is already contained in a preceding -L
475                     dnl option.
476                     names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
477                     ;;
478                   *)
479                     dnl Most likely an immediate library name.
480                     LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
481                     LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
482                     ;;
483                 esac
484               done
485             fi
486           else
487             dnl Didn't find the library; assume it is in the system directories
488             dnl known to the linker and runtime loader. (All the system
489             dnl directories known to the linker should also be known to the
490             dnl runtime loader, otherwise the system is severely misconfigured.)
491             LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
492             LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
493           fi
494         fi
495       fi
496     done
497   done
498   if test "X$rpathdirs" != "X"; then
499     if test -n "$hardcode_libdir_separator"; then
500       dnl Weird platform: only the last -rpath option counts, the user must
501       dnl pass all path elements in one option. We can arrange that for a
502       dnl single library, but not when more than one $LIBNAMEs are used.
503       alldirs=
504       for found_dir in $rpathdirs; do
505         alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
506       done
507       dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl.
508       acl_save_libdir="$libdir"
509       libdir="$alldirs"
510       eval flag=\"$hardcode_libdir_flag_spec\"
511       libdir="$acl_save_libdir"
512       LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
513     else
514       dnl The -rpath options are cumulative.
515       for found_dir in $rpathdirs; do
516         acl_save_libdir="$libdir"
517         libdir="$found_dir"
518         eval flag=\"$hardcode_libdir_flag_spec\"
519         libdir="$acl_save_libdir"
520         LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
521       done
522     fi
523   fi
524   if test "X$ltrpathdirs" != "X"; then
525     dnl When using libtool, the option that works for both libraries and
526     dnl executables is -R. The -R options are cumulative.
527     for found_dir in $ltrpathdirs; do
528       LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
529     done
530   fi
533 dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
534 dnl unless already present in VAR.
535 dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
536 dnl contains two or three consecutive elements that belong together.
537 AC_DEFUN([AC_LIB_APPENDTOVAR],
539   for element in [$2]; do
540     haveit=
541     for x in $[$1]; do
542       AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
543       if test "X$x" = "X$element"; then
544         haveit=yes
545         break
546       fi
547     done
548     if test -z "$haveit"; then
549       [$1]="${[$1]}${[$1]:+ }$element"
550     fi
551   done