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