diff options
Diffstat (limited to 'm4/lib-link.m4')
-rw-r--r-- | m4/lib-link.m4 | 274 |
1 files changed, 216 insertions, 58 deletions
diff --git a/m4/lib-link.m4 b/m4/lib-link.m4 index eeb200d2..e3d26fc4 100644 --- a/m4/lib-link.m4 +++ b/m4/lib-link.m4 | |||
@@ -1,17 +1,19 @@ | |||
1 | # lib-link.m4 serial 4 (gettext-0.12) | 1 | # lib-link.m4 serial 13 (gettext-0.17) |
2 | dnl Copyright (C) 2001-2003 Free Software Foundation, Inc. | 2 | dnl Copyright (C) 2001-2007 Free Software Foundation, Inc. |
3 | dnl This file is free software, distributed under the terms of the GNU | 3 | dnl This file is free software; the Free Software Foundation |
4 | dnl General Public License. As a special exception to the GNU General | 4 | dnl gives unlimited permission to copy and/or distribute it, |
5 | dnl Public License, this file may be distributed as part of a program | 5 | dnl with or without modifications, as long as this notice is preserved. |
6 | dnl that contains a configuration script generated by Autoconf, under | ||
7 | dnl the same distribution terms as the rest of that program. | ||
8 | 6 | ||
9 | dnl From Bruno Haible. | 7 | dnl From Bruno Haible. |
10 | 8 | ||
9 | AC_PREREQ(2.54) | ||
10 | |||
11 | dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and | 11 | dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and |
12 | dnl the libraries corresponding to explicit and implicit dependencies. | 12 | dnl the libraries corresponding to explicit and implicit dependencies. |
13 | dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and | 13 | dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and |
14 | dnl augments the CPPFLAGS variable. | 14 | dnl augments the CPPFLAGS variable. |
15 | dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname | ||
16 | dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem. | ||
15 | AC_DEFUN([AC_LIB_LINKFLAGS], | 17 | AC_DEFUN([AC_LIB_LINKFLAGS], |
16 | [ | 18 | [ |
17 | AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) | 19 | AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) |
@@ -24,13 +26,16 @@ AC_DEFUN([AC_LIB_LINKFLAGS], | |||
24 | ac_cv_lib[]Name[]_libs="$LIB[]NAME" | 26 | ac_cv_lib[]Name[]_libs="$LIB[]NAME" |
25 | ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME" | 27 | ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME" |
26 | ac_cv_lib[]Name[]_cppflags="$INC[]NAME" | 28 | ac_cv_lib[]Name[]_cppflags="$INC[]NAME" |
29 | ac_cv_lib[]Name[]_prefix="$LIB[]NAME[]_PREFIX" | ||
27 | ]) | 30 | ]) |
28 | LIB[]NAME="$ac_cv_lib[]Name[]_libs" | 31 | LIB[]NAME="$ac_cv_lib[]Name[]_libs" |
29 | LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs" | 32 | LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs" |
30 | INC[]NAME="$ac_cv_lib[]Name[]_cppflags" | 33 | INC[]NAME="$ac_cv_lib[]Name[]_cppflags" |
34 | LIB[]NAME[]_PREFIX="$ac_cv_lib[]Name[]_prefix" | ||
31 | AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) | 35 | AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME) |
32 | AC_SUBST([LIB]NAME) | 36 | AC_SUBST([LIB]NAME) |
33 | AC_SUBST([LTLIB]NAME) | 37 | AC_SUBST([LTLIB]NAME) |
38 | AC_SUBST([LIB]NAME[_PREFIX]) | ||
34 | dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the | 39 | 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. | 40 | dnl results of this search when this library appears as a dependency. |
36 | HAVE_LIB[]NAME=yes | 41 | HAVE_LIB[]NAME=yes |
@@ -46,6 +51,8 @@ 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 | 51 | dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and |
47 | dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs | 52 | 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. | 53 | dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty. |
54 | dnl Sets and AC_SUBSTs the LIB${NAME}_PREFIX variable to nonempty if libname | ||
55 | dnl was found in ${LIB${NAME}_PREFIX}/$acl_libdirstem. | ||
49 | AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], | 56 | AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], |
50 | [ | 57 | [ |
51 | AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) | 58 | AC_REQUIRE([AC_LIB_PREPARE_PREFIX]) |
@@ -82,19 +89,27 @@ AC_DEFUN([AC_LIB_HAVE_LINKFLAGS], | |||
82 | CPPFLAGS="$ac_save_CPPFLAGS" | 89 | CPPFLAGS="$ac_save_CPPFLAGS" |
83 | LIB[]NAME= | 90 | LIB[]NAME= |
84 | LTLIB[]NAME= | 91 | LTLIB[]NAME= |
92 | LIB[]NAME[]_PREFIX= | ||
85 | fi | 93 | fi |
86 | AC_SUBST([HAVE_LIB]NAME) | 94 | AC_SUBST([HAVE_LIB]NAME) |
87 | AC_SUBST([LIB]NAME) | 95 | AC_SUBST([LIB]NAME) |
88 | AC_SUBST([LTLIB]NAME) | 96 | AC_SUBST([LTLIB]NAME) |
97 | AC_SUBST([LIB]NAME[_PREFIX]) | ||
89 | undefine([Name]) | 98 | undefine([Name]) |
90 | undefine([NAME]) | 99 | undefine([NAME]) |
91 | ]) | 100 | ]) |
92 | 101 | ||
93 | dnl Determine the platform dependent parameters needed to use rpath: | 102 | dnl Determine the platform dependent parameters needed to use rpath: |
94 | dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator, | 103 | dnl acl_libext, |
95 | dnl hardcode_direct, hardcode_minus_L. | 104 | dnl acl_shlibext, |
105 | dnl acl_hardcode_libdir_flag_spec, | ||
106 | dnl acl_hardcode_libdir_separator, | ||
107 | dnl acl_hardcode_direct, | ||
108 | dnl acl_hardcode_minus_L. | ||
96 | AC_DEFUN([AC_LIB_RPATH], | 109 | AC_DEFUN([AC_LIB_RPATH], |
97 | [ | 110 | [ |
111 | dnl Tell automake >= 1.10 to complain if config.rpath is missing. | ||
112 | m4_ifdef([AC_REQUIRE_AUX_FILE], [AC_REQUIRE_AUX_FILE([config.rpath])]) | ||
98 | AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS | 113 | AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS |
99 | AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld | 114 | AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld |
100 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host | 115 | AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host |
@@ -107,12 +122,14 @@ AC_DEFUN([AC_LIB_RPATH], | |||
107 | acl_cv_rpath=done | 122 | acl_cv_rpath=done |
108 | ]) | 123 | ]) |
109 | wl="$acl_cv_wl" | 124 | wl="$acl_cv_wl" |
110 | libext="$acl_cv_libext" | 125 | acl_libext="$acl_cv_libext" |
111 | shlibext="$acl_cv_shlibext" | 126 | acl_shlibext="$acl_cv_shlibext" |
112 | hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" | 127 | acl_libname_spec="$acl_cv_libname_spec" |
113 | hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" | 128 | acl_library_names_spec="$acl_cv_library_names_spec" |
114 | hardcode_direct="$acl_cv_hardcode_direct" | 129 | acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec" |
115 | hardcode_minus_L="$acl_cv_hardcode_minus_L" | 130 | acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator" |
131 | acl_hardcode_direct="$acl_cv_hardcode_direct" | ||
132 | acl_hardcode_minus_L="$acl_cv_hardcode_minus_L" | ||
116 | dnl Determine whether the user wants rpath handling at all. | 133 | dnl Determine whether the user wants rpath handling at all. |
117 | AC_ARG_ENABLE(rpath, | 134 | AC_ARG_ENABLE(rpath, |
118 | [ --disable-rpath do not hardcode runtime library paths], | 135 | [ --disable-rpath do not hardcode runtime library paths], |
@@ -122,19 +139,24 @@ AC_DEFUN([AC_LIB_RPATH], | |||
122 | dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and | 139 | dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and |
123 | dnl the libraries corresponding to explicit and implicit dependencies. | 140 | dnl the libraries corresponding to explicit and implicit dependencies. |
124 | dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. | 141 | dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables. |
142 | dnl Also, sets the LIB${NAME}_PREFIX variable to nonempty if libname was found | ||
143 | dnl in ${LIB${NAME}_PREFIX}/$acl_libdirstem. | ||
125 | AC_DEFUN([AC_LIB_LINKFLAGS_BODY], | 144 | AC_DEFUN([AC_LIB_LINKFLAGS_BODY], |
126 | [ | 145 | [ |
146 | AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) | ||
127 | define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], | 147 | define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-], |
128 | [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) | 148 | [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])]) |
149 | dnl Autoconf >= 2.61 supports dots in --with options. | ||
150 | define([N_A_M_E],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit([$1],[.],[_])],[$1])]) | ||
129 | dnl By default, look in $includedir and $libdir. | 151 | dnl By default, look in $includedir and $libdir. |
130 | use_additional=yes | 152 | use_additional=yes |
131 | AC_LIB_WITH_FINAL_PREFIX([ | 153 | AC_LIB_WITH_FINAL_PREFIX([ |
132 | eval additional_includedir=\"$includedir\" | 154 | eval additional_includedir=\"$includedir\" |
133 | eval additional_libdir=\"$libdir\" | 155 | eval additional_libdir=\"$libdir\" |
134 | ]) | 156 | ]) |
135 | AC_LIB_ARG_WITH([lib$1-prefix], | 157 | AC_LIB_ARG_WITH([lib]N_A_M_E[-prefix], |
136 | [ --with-lib$1-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib | 158 | [ --with-lib]N_A_M_E[-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib |
137 | --without-lib$1-prefix don't search for lib$1 in includedir and libdir], | 159 | --without-lib]N_A_M_E[-prefix don't search for lib$1 in includedir and libdir], |
138 | [ | 160 | [ |
139 | if test "X$withval" = "Xno"; then | 161 | if test "X$withval" = "Xno"; then |
140 | use_additional=no | 162 | use_additional=no |
@@ -146,7 +168,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], | |||
146 | ]) | 168 | ]) |
147 | else | 169 | else |
148 | additional_includedir="$withval/include" | 170 | additional_includedir="$withval/include" |
149 | additional_libdir="$withval/lib" | 171 | additional_libdir="$withval/$acl_libdirstem" |
150 | fi | 172 | fi |
151 | fi | 173 | fi |
152 | ]) | 174 | ]) |
@@ -155,6 +177,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], | |||
155 | LIB[]NAME= | 177 | LIB[]NAME= |
156 | LTLIB[]NAME= | 178 | LTLIB[]NAME= |
157 | INC[]NAME= | 179 | INC[]NAME= |
180 | LIB[]NAME[]_PREFIX= | ||
158 | rpathdirs= | 181 | rpathdirs= |
159 | ltrpathdirs= | 182 | ltrpathdirs= |
160 | names_already_handled= | 183 | names_already_handled= |
@@ -194,22 +217,55 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], | |||
194 | found_la= | 217 | found_la= |
195 | found_so= | 218 | found_so= |
196 | found_a= | 219 | found_a= |
220 | eval libname=\"$acl_libname_spec\" # typically: libname=lib$name | ||
221 | if test -n "$acl_shlibext"; then | ||
222 | shrext=".$acl_shlibext" # typically: shrext=.so | ||
223 | else | ||
224 | shrext= | ||
225 | fi | ||
197 | if test $use_additional = yes; then | 226 | if test $use_additional = yes; then |
198 | if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then | 227 | dir="$additional_libdir" |
199 | found_dir="$additional_libdir" | 228 | dnl The same code as in the loop below: |
200 | found_so="$additional_libdir/lib$name.$shlibext" | 229 | dnl First look for a shared library. |
201 | if test -f "$additional_libdir/lib$name.la"; then | 230 | if test -n "$acl_shlibext"; then |
202 | found_la="$additional_libdir/lib$name.la" | 231 | if test -f "$dir/$libname$shrext"; then |
203 | fi | 232 | found_dir="$dir" |
204 | else | 233 | found_so="$dir/$libname$shrext" |
205 | if test -f "$additional_libdir/lib$name.$libext"; then | 234 | else |
206 | found_dir="$additional_libdir" | 235 | if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then |
207 | found_a="$additional_libdir/lib$name.$libext" | 236 | ver=`(cd "$dir" && \ |
208 | if test -f "$additional_libdir/lib$name.la"; then | 237 | for f in "$libname$shrext".*; do echo "$f"; done \ |
209 | found_la="$additional_libdir/lib$name.la" | 238 | | sed -e "s,^$libname$shrext\\\\.,," \ |
239 | | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | ||
240 | | sed 1q ) 2>/dev/null` | ||
241 | if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then | ||
242 | found_dir="$dir" | ||
243 | found_so="$dir/$libname$shrext.$ver" | ||
244 | fi | ||
245 | else | ||
246 | eval library_names=\"$acl_library_names_spec\" | ||
247 | for f in $library_names; do | ||
248 | if test -f "$dir/$f"; then | ||
249 | found_dir="$dir" | ||
250 | found_so="$dir/$f" | ||
251 | break | ||
252 | fi | ||
253 | done | ||
210 | fi | 254 | fi |
211 | fi | 255 | fi |
212 | fi | 256 | fi |
257 | dnl Then look for a static library. | ||
258 | if test "X$found_dir" = "X"; then | ||
259 | if test -f "$dir/$libname.$acl_libext"; then | ||
260 | found_dir="$dir" | ||
261 | found_a="$dir/$libname.$acl_libext" | ||
262 | fi | ||
263 | fi | ||
264 | if test "X$found_dir" != "X"; then | ||
265 | if test -f "$dir/$libname.la"; then | ||
266 | found_la="$dir/$libname.la" | ||
267 | fi | ||
268 | fi | ||
213 | fi | 269 | fi |
214 | if test "X$found_dir" = "X"; then | 270 | if test "X$found_dir" = "X"; then |
215 | for x in $LDFLAGS $LTLIB[]NAME; do | 271 | for x in $LDFLAGS $LTLIB[]NAME; do |
@@ -217,21 +273,46 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], | |||
217 | case "$x" in | 273 | case "$x" in |
218 | -L*) | 274 | -L*) |
219 | dir=`echo "X$x" | sed -e 's/^X-L//'` | 275 | dir=`echo "X$x" | sed -e 's/^X-L//'` |
220 | if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then | 276 | dnl First look for a shared library. |
221 | found_dir="$dir" | 277 | if test -n "$acl_shlibext"; then |
222 | found_so="$dir/lib$name.$shlibext" | 278 | if test -f "$dir/$libname$shrext"; then |
223 | if test -f "$dir/lib$name.la"; then | ||
224 | found_la="$dir/lib$name.la" | ||
225 | fi | ||
226 | else | ||
227 | if test -f "$dir/lib$name.$libext"; then | ||
228 | found_dir="$dir" | 279 | found_dir="$dir" |
229 | found_a="$dir/lib$name.$libext" | 280 | found_so="$dir/$libname$shrext" |
230 | if test -f "$dir/lib$name.la"; then | 281 | else |
231 | found_la="$dir/lib$name.la" | 282 | if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then |
283 | ver=`(cd "$dir" && \ | ||
284 | for f in "$libname$shrext".*; do echo "$f"; done \ | ||
285 | | sed -e "s,^$libname$shrext\\\\.,," \ | ||
286 | | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \ | ||
287 | | sed 1q ) 2>/dev/null` | ||
288 | if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then | ||
289 | found_dir="$dir" | ||
290 | found_so="$dir/$libname$shrext.$ver" | ||
291 | fi | ||
292 | else | ||
293 | eval library_names=\"$acl_library_names_spec\" | ||
294 | for f in $library_names; do | ||
295 | if test -f "$dir/$f"; then | ||
296 | found_dir="$dir" | ||
297 | found_so="$dir/$f" | ||
298 | break | ||
299 | fi | ||
300 | done | ||
232 | fi | 301 | fi |
233 | fi | 302 | fi |
234 | fi | 303 | fi |
304 | dnl Then look for a static library. | ||
305 | if test "X$found_dir" = "X"; then | ||
306 | if test -f "$dir/$libname.$acl_libext"; then | ||
307 | found_dir="$dir" | ||
308 | found_a="$dir/$libname.$acl_libext" | ||
309 | fi | ||
310 | fi | ||
311 | if test "X$found_dir" != "X"; then | ||
312 | if test -f "$dir/$libname.la"; then | ||
313 | found_la="$dir/$libname.la" | ||
314 | fi | ||
315 | fi | ||
235 | ;; | 316 | ;; |
236 | esac | 317 | esac |
237 | if test "X$found_dir" != "X"; then | 318 | if test "X$found_dir" != "X"; then |
@@ -246,7 +327,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], | |||
246 | dnl Linking with a shared library. We attempt to hardcode its | 327 | dnl Linking with a shared library. We attempt to hardcode its |
247 | dnl directory into the executable's runpath, unless it's the | 328 | dnl directory into the executable's runpath, unless it's the |
248 | dnl standard /usr/lib. | 329 | dnl standard /usr/lib. |
249 | if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then | 330 | if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/$acl_libdirstem"; then |
250 | dnl No hardcoding is needed. | 331 | dnl No hardcoding is needed. |
251 | LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" | 332 | LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" |
252 | else | 333 | else |
@@ -265,12 +346,12 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], | |||
265 | ltrpathdirs="$ltrpathdirs $found_dir" | 346 | ltrpathdirs="$ltrpathdirs $found_dir" |
266 | fi | 347 | fi |
267 | dnl The hardcoding into $LIBNAME is system dependent. | 348 | dnl The hardcoding into $LIBNAME is system dependent. |
268 | if test "$hardcode_direct" = yes; then | 349 | if test "$acl_hardcode_direct" = yes; then |
269 | dnl Using DIR/libNAME.so during linking hardcodes DIR into the | 350 | dnl Using DIR/libNAME.so during linking hardcodes DIR into the |
270 | dnl resulting binary. | 351 | dnl resulting binary. |
271 | LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" | 352 | LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" |
272 | else | 353 | else |
273 | if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then | 354 | if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then |
274 | dnl Use an explicit option to hardcode DIR into the resulting | 355 | dnl Use an explicit option to hardcode DIR into the resulting |
275 | dnl binary. | 356 | dnl binary. |
276 | LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" | 357 | LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" |
@@ -301,13 +382,13 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], | |||
301 | if test -z "$haveit"; then | 382 | if test -z "$haveit"; then |
302 | LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir" | 383 | LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir" |
303 | fi | 384 | fi |
304 | if test "$hardcode_minus_L" != no; then | 385 | if test "$acl_hardcode_minus_L" != no; then |
305 | dnl FIXME: Not sure whether we should use | 386 | dnl FIXME: Not sure whether we should use |
306 | dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" | 387 | dnl "-L$found_dir -l$name" or "-L$found_dir $found_so" |
307 | dnl here. | 388 | dnl here. |
308 | LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" | 389 | LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so" |
309 | else | 390 | else |
310 | dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH | 391 | dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH |
311 | dnl here, because this doesn't fit in flags passed to the | 392 | dnl here, because this doesn't fit in flags passed to the |
312 | dnl compiler. So give up. No hardcoding. This affects only | 393 | dnl compiler. So give up. No hardcoding. This affects only |
313 | dnl very old systems. | 394 | dnl very old systems. |
@@ -332,8 +413,9 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], | |||
332 | dnl Assume the include files are nearby. | 413 | dnl Assume the include files are nearby. |
333 | additional_includedir= | 414 | additional_includedir= |
334 | case "$found_dir" in | 415 | case "$found_dir" in |
335 | */lib | */lib/) | 416 | */$acl_libdirstem | */$acl_libdirstem/) |
336 | basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'` | 417 | basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'` |
418 | LIB[]NAME[]_PREFIX="$basedir" | ||
337 | additional_includedir="$basedir/include" | 419 | additional_includedir="$basedir/include" |
338 | ;; | 420 | ;; |
339 | esac | 421 | esac |
@@ -350,7 +432,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], | |||
350 | if test "X$additional_includedir" = "X/usr/local/include"; then | 432 | if test "X$additional_includedir" = "X/usr/local/include"; then |
351 | if test -n "$GCC"; then | 433 | if test -n "$GCC"; then |
352 | case $host_os in | 434 | case $host_os in |
353 | linux*) haveit=yes;; | 435 | linux* | gnu* | k*bsd*-gnu) haveit=yes;; |
354 | esac | 436 | esac |
355 | fi | 437 | fi |
356 | fi | 438 | fi |
@@ -394,12 +476,12 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], | |||
394 | dnl 3. if it's already present in $LDFLAGS or the already | 476 | dnl 3. if it's already present in $LDFLAGS or the already |
395 | dnl constructed $LIBNAME, | 477 | dnl constructed $LIBNAME, |
396 | dnl 4. if it doesn't exist as a directory. | 478 | dnl 4. if it doesn't exist as a directory. |
397 | if test "X$additional_libdir" != "X/usr/lib"; then | 479 | if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then |
398 | haveit= | 480 | haveit= |
399 | if test "X$additional_libdir" = "X/usr/local/lib"; then | 481 | if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then |
400 | if test -n "$GCC"; then | 482 | if test -n "$GCC"; then |
401 | case $host_os in | 483 | case $host_os in |
402 | linux*) haveit=yes;; | 484 | linux* | gnu* | k*bsd*-gnu) haveit=yes;; |
403 | esac | 485 | esac |
404 | fi | 486 | fi |
405 | fi | 487 | fi |
@@ -495,18 +577,18 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], | |||
495 | done | 577 | done |
496 | done | 578 | done |
497 | if test "X$rpathdirs" != "X"; then | 579 | if test "X$rpathdirs" != "X"; then |
498 | if test -n "$hardcode_libdir_separator"; then | 580 | if test -n "$acl_hardcode_libdir_separator"; then |
499 | dnl Weird platform: only the last -rpath option counts, the user must | 581 | dnl Weird platform: only the last -rpath option counts, the user must |
500 | dnl pass all path elements in one option. We can arrange that for a | 582 | dnl pass all path elements in one option. We can arrange that for a |
501 | dnl single library, but not when more than one $LIBNAMEs are used. | 583 | dnl single library, but not when more than one $LIBNAMEs are used. |
502 | alldirs= | 584 | alldirs= |
503 | for found_dir in $rpathdirs; do | 585 | for found_dir in $rpathdirs; do |
504 | alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir" | 586 | alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir" |
505 | done | 587 | done |
506 | dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl. | 588 | dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl. |
507 | acl_save_libdir="$libdir" | 589 | acl_save_libdir="$libdir" |
508 | libdir="$alldirs" | 590 | libdir="$alldirs" |
509 | eval flag=\"$hardcode_libdir_flag_spec\" | 591 | eval flag=\"$acl_hardcode_libdir_flag_spec\" |
510 | libdir="$acl_save_libdir" | 592 | libdir="$acl_save_libdir" |
511 | LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" | 593 | LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" |
512 | else | 594 | else |
@@ -514,7 +596,7 @@ AC_DEFUN([AC_LIB_LINKFLAGS_BODY], | |||
514 | for found_dir in $rpathdirs; do | 596 | for found_dir in $rpathdirs; do |
515 | acl_save_libdir="$libdir" | 597 | acl_save_libdir="$libdir" |
516 | libdir="$found_dir" | 598 | libdir="$found_dir" |
517 | eval flag=\"$hardcode_libdir_flag_spec\" | 599 | eval flag=\"$acl_hardcode_libdir_flag_spec\" |
518 | libdir="$acl_save_libdir" | 600 | libdir="$acl_save_libdir" |
519 | LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" | 601 | LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag" |
520 | done | 602 | done |
@@ -549,3 +631,79 @@ AC_DEFUN([AC_LIB_APPENDTOVAR], | |||
549 | fi | 631 | fi |
550 | done | 632 | done |
551 | ]) | 633 | ]) |
634 | |||
635 | dnl For those cases where a variable contains several -L and -l options | ||
636 | dnl referring to unknown libraries and directories, this macro determines the | ||
637 | dnl necessary additional linker options for the runtime path. | ||
638 | dnl AC_LIB_LINKFLAGS_FROM_LIBS([LDADDVAR], [LIBSVALUE], [USE-LIBTOOL]) | ||
639 | dnl sets LDADDVAR to linker options needed together with LIBSVALUE. | ||
640 | dnl If USE-LIBTOOL evaluates to non-empty, linking with libtool is assumed, | ||
641 | dnl otherwise linking without libtool is assumed. | ||
642 | AC_DEFUN([AC_LIB_LINKFLAGS_FROM_LIBS], | ||
643 | [ | ||
644 | AC_REQUIRE([AC_LIB_RPATH]) | ||
645 | AC_REQUIRE([AC_LIB_PREPARE_MULTILIB]) | ||
646 | $1= | ||
647 | if test "$enable_rpath" != no; then | ||
648 | if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then | ||
649 | dnl Use an explicit option to hardcode directories into the resulting | ||
650 | dnl binary. | ||
651 | rpathdirs= | ||
652 | next= | ||
653 | for opt in $2; do | ||
654 | if test -n "$next"; then | ||
655 | dir="$next" | ||
656 | dnl No need to hardcode the standard /usr/lib. | ||
657 | if test "X$dir" != "X/usr/$acl_libdirstem"; then | ||
658 | rpathdirs="$rpathdirs $dir" | ||
659 | fi | ||
660 | next= | ||
661 | else | ||
662 | case $opt in | ||
663 | -L) next=yes ;; | ||
664 | -L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'` | ||
665 | dnl No need to hardcode the standard /usr/lib. | ||
666 | if test "X$dir" != "X/usr/$acl_libdirstem"; then | ||
667 | rpathdirs="$rpathdirs $dir" | ||
668 | fi | ||
669 | next= ;; | ||
670 | *) next= ;; | ||
671 | esac | ||
672 | fi | ||
673 | done | ||
674 | if test "X$rpathdirs" != "X"; then | ||
675 | if test -n ""$3""; then | ||
676 | dnl libtool is used for linking. Use -R options. | ||
677 | for dir in $rpathdirs; do | ||
678 | $1="${$1}${$1:+ }-R$dir" | ||
679 | done | ||
680 | else | ||
681 | dnl The linker is used for linking directly. | ||
682 | if test -n "$acl_hardcode_libdir_separator"; then | ||
683 | dnl Weird platform: only the last -rpath option counts, the user | ||
684 | dnl must pass all path elements in one option. | ||
685 | alldirs= | ||
686 | for dir in $rpathdirs; do | ||
687 | alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir" | ||
688 | done | ||
689 | acl_save_libdir="$libdir" | ||
690 | libdir="$alldirs" | ||
691 | eval flag=\"$acl_hardcode_libdir_flag_spec\" | ||
692 | libdir="$acl_save_libdir" | ||
693 | $1="$flag" | ||
694 | else | ||
695 | dnl The -rpath options are cumulative. | ||
696 | for dir in $rpathdirs; do | ||
697 | acl_save_libdir="$libdir" | ||
698 | libdir="$dir" | ||
699 | eval flag=\"$acl_hardcode_libdir_flag_spec\" | ||
700 | libdir="$acl_save_libdir" | ||
701 | $1="${$1}${$1:+ }$flag" | ||
702 | done | ||
703 | fi | ||
704 | fi | ||
705 | fi | ||
706 | fi | ||
707 | fi | ||
708 | AC_SUBST([$1]) | ||
709 | ]) | ||