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