1
# lib-link.m4 serial 10 (gettext-0.16.1)
2
dnl Copyright (C) 2001-2006 Free Software Foundation, Inc.
1
# lib-link.m4 serial 16 (gettext-0.18)
2
dnl Copyright (C) 2001-2008 Free Software Foundation, Inc.
3
3
dnl This file is free software; the Free Software Foundation
4
4
dnl gives unlimited permission to copy and/or distribute it,
5
5
dnl with or without modifications, as long as this notice is preserved.
19
19
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
20
20
AC_REQUIRE([AC_LIB_RPATH])
21
define([Name],[translit([$1],[./-], [___])])
22
define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
23
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
21
pushdef([Name],[translit([$1],[./-], [___])])
22
pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
23
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
24
24
AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
25
25
AC_LIB_LINKFLAGS_BODY([$1], [$2])
26
26
ac_cv_lib[]Name[]_libs="$LIB[]NAME"
58
58
AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
59
59
AC_REQUIRE([AC_LIB_RPATH])
60
define([Name],[translit([$1],[./-], [___])])
61
define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
62
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
60
pushdef([Name],[translit([$1],[./-], [___])])
61
pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
62
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
64
64
dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
95
95
AC_SUBST([LIB]NAME)
96
96
AC_SUBST([LTLIB]NAME)
97
97
AC_SUBST([LIB]NAME[_PREFIX])
102
102
dnl Determine the platform dependent parameters needed to use rpath:
103
dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator,
104
dnl hardcode_direct, hardcode_minus_L.
105
dnl acl_hardcode_libdir_flag_spec,
106
dnl acl_hardcode_libdir_separator,
107
dnl acl_hardcode_direct,
108
dnl acl_hardcode_minus_L.
105
109
AC_DEFUN([AC_LIB_RPATH],
107
111
dnl Tell automake >= 1.10 to complain if config.rpath is missing.
118
122
acl_cv_rpath=done
121
libext="$acl_cv_libext"
122
shlibext="$acl_cv_shlibext"
123
hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
124
hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
125
hardcode_direct="$acl_cv_hardcode_direct"
126
hardcode_minus_L="$acl_cv_hardcode_minus_L"
125
acl_libext="$acl_cv_libext"
126
acl_shlibext="$acl_cv_shlibext"
127
acl_libname_spec="$acl_cv_libname_spec"
128
acl_library_names_spec="$acl_cv_library_names_spec"
129
acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
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"
127
133
dnl Determine whether the user wants rpath handling at all.
128
134
AC_ARG_ENABLE(rpath,
129
135
[ --disable-rpath do not hardcode runtime library paths],
130
136
:, enable_rpath=yes)
139
dnl AC_LIB_FROMPACKAGE(name, package)
140
dnl declares that libname comes from the given package. The configure file
141
dnl will then not have a --with-libname-prefix option but a
142
dnl --with-package-prefix option. Several libraries can come from the same
143
dnl package. This declaration must occur before an AC_LIB_LINKFLAGS or similar
144
dnl macro call that searches for libname.
145
AC_DEFUN([AC_LIB_FROMPACKAGE],
147
pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
148
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
149
define([acl_frompackage_]NAME, [$2])
152
pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-],
153
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
154
define([acl_libsinpackage_]PACKUP,
155
m4_ifdef([acl_libsinpackage_]PACKUP, [acl_libsinpackage_]PACKUP[[, ]],)[lib$1])
133
160
dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
134
161
dnl the libraries corresponding to explicit and implicit dependencies.
135
162
dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
138
165
AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
140
167
AC_REQUIRE([AC_LIB_PREPARE_MULTILIB])
141
define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
142
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
168
pushdef([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
169
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
170
pushdef([PACK],[m4_ifdef([acl_frompackage_]NAME, [acl_frompackage_]NAME, lib[$1])])
171
pushdef([PACKUP],[translit(PACK,[abcdefghijklmnopqrstuvwxyz./-],
172
[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
173
pushdef([PACKLIBS],[m4_ifdef([acl_frompackage_]NAME, [acl_libsinpackage_]PACKUP, lib[$1])])
143
174
dnl Autoconf >= 2.61 supports dots in --with options.
144
define([N_A_M_E],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit([$1],[.],[_])],[$1])])
175
pushdef([P_A_C_K],[m4_if(m4_version_compare(m4_defn([m4_PACKAGE_VERSION]),[2.61]),[-1],[translit(PACK,[.],[_])],PACK)])
145
176
dnl By default, look in $includedir and $libdir.
146
177
use_additional=yes
147
178
AC_LIB_WITH_FINAL_PREFIX([
148
179
eval additional_includedir=\"$includedir\"
149
180
eval additional_libdir=\"$libdir\"
151
AC_LIB_ARG_WITH([lib]N_A_M_E[-prefix],
152
[ --with-lib]N_A_M_E[-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib
153
--without-lib]N_A_M_E[-prefix don't search for lib$1 in includedir and libdir],
182
AC_ARG_WITH(P_A_C_K[-prefix],
183
[[ --with-]]P_A_C_K[[-prefix[=DIR] search for ]PACKLIBS[ in DIR/include and DIR/lib
184
--without-]]P_A_C_K[[-prefix don't search for ]PACKLIBS[ in includedir and libdir]],
155
186
if test "X$withval" = "Xno"; then
156
187
use_additional=no
249
eval libname=\"$acl_libname_spec\" # typically: libname=lib$name
250
if test -n "$acl_shlibext"; then
251
shrext=".$acl_shlibext" # typically: shrext=.so
214
255
if test $use_additional = yes; then
215
if test -n "$shlibext" \
216
&& { test -f "$additional_libdir/lib$name.$shlibext" \
217
|| { test "$shlibext" = dll \
218
&& test -f "$additional_libdir/lib$name.dll.a"; }; }; then
219
found_dir="$additional_libdir"
220
if test -f "$additional_libdir/lib$name.$shlibext"; then
221
found_so="$additional_libdir/lib$name.$shlibext"
256
dir="$additional_libdir"
257
dnl The same code as in the loop below:
258
dnl First look for a shared library.
259
if test -n "$acl_shlibext"; then
260
if test -f "$dir/$libname$shrext"; then
262
found_so="$dir/$libname$shrext"
223
found_so="$additional_libdir/lib$name.dll.a"
225
if test -f "$additional_libdir/lib$name.la"; then
226
found_la="$additional_libdir/lib$name.la"
229
if test -f "$additional_libdir/lib$name.$libext"; then
230
found_dir="$additional_libdir"
231
found_a="$additional_libdir/lib$name.$libext"
232
if test -f "$additional_libdir/lib$name.la"; then
233
found_la="$additional_libdir/lib$name.la"
264
if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
266
for f in "$libname$shrext".*; do echo "$f"; done \
267
| sed -e "s,^$libname$shrext\\\\.,," \
268
| sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
269
| sed 1q ) 2>/dev/null`
270
if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
272
found_so="$dir/$libname$shrext.$ver"
275
eval library_names=\"$acl_library_names_spec\"
276
for f in $library_names; do
277
if test -f "$dir/$f"; then
286
dnl Then look for a static library.
287
if test "X$found_dir" = "X"; then
288
if test -f "$dir/$libname.$acl_libext"; then
290
found_a="$dir/$libname.$acl_libext"
293
if test "X$found_dir" != "X"; then
294
if test -f "$dir/$libname.la"; then
295
found_la="$dir/$libname.la"
238
299
if test "X$found_dir" = "X"; then
239
300
for x in $LDFLAGS $LTLIB[]NAME; do
243
304
dir=`echo "X$x" | sed -e 's/^X-L//'`
244
if test -n "$shlibext" \
245
&& { test -f "$dir/lib$name.$shlibext" \
246
|| { test "$shlibext" = dll \
247
&& test -f "$dir/lib$name.dll.a"; }; }; then
249
if test -f "$dir/lib$name.$shlibext"; then
250
found_so="$dir/lib$name.$shlibext"
305
dnl First look for a shared library.
306
if test -n "$acl_shlibext"; then
307
if test -f "$dir/$libname$shrext"; then
309
found_so="$dir/$libname$shrext"
252
found_so="$dir/lib$name.dll.a"
254
if test -f "$dir/lib$name.la"; then
255
found_la="$dir/lib$name.la"
258
if test -f "$dir/lib$name.$libext"; then
260
found_a="$dir/lib$name.$libext"
261
if test -f "$dir/lib$name.la"; then
262
found_la="$dir/lib$name.la"
311
if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then
313
for f in "$libname$shrext".*; do echo "$f"; done \
314
| sed -e "s,^$libname$shrext\\\\.,," \
315
| sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \
316
| sed 1q ) 2>/dev/null`
317
if test -n "$ver" && test -f "$dir/$libname$shrext.$ver"; then
319
found_so="$dir/$libname$shrext.$ver"
322
eval library_names=\"$acl_library_names_spec\"
323
for f in $library_names; do
324
if test -f "$dir/$f"; then
333
dnl Then look for a static library.
334
if test "X$found_dir" = "X"; then
335
if test -f "$dir/$libname.$acl_libext"; then
337
found_a="$dir/$libname.$acl_libext"
340
if test "X$found_dir" != "X"; then
341
if test -f "$dir/$libname.la"; then
342
found_la="$dir/$libname.la"
268
347
if test "X$found_dir" != "X"; then
277
356
dnl Linking with a shared library. We attempt to hardcode its
278
357
dnl directory into the executable's runpath, unless it's the
279
358
dnl standard /usr/lib.
280
if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/$acl_libdirstem"; then
359
if test "$enable_rpath" = no \
360
|| test "X$found_dir" = "X/usr/$acl_libdirstem" \
361
|| test "X$found_dir" = "X/usr/$acl_libdirstem2"; then
281
362
dnl No hardcoding is needed.
282
363
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
296
377
ltrpathdirs="$ltrpathdirs $found_dir"
298
379
dnl The hardcoding into $LIBNAME is system dependent.
299
if test "$hardcode_direct" = yes; then
380
if test "$acl_hardcode_direct" = yes; then
300
381
dnl Using DIR/libNAME.so during linking hardcodes DIR into the
301
382
dnl resulting binary.
302
383
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
304
if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
385
if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then
305
386
dnl Use an explicit option to hardcode DIR into the resulting
307
388
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
332
413
if test -z "$haveit"; then
333
414
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
335
if test "$hardcode_minus_L" != no; then
416
if test "$acl_hardcode_minus_L" != no; then
336
417
dnl FIXME: Not sure whether we should use
337
418
dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
339
420
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
341
dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH
422
dnl We cannot use $acl_hardcode_runpath_var and LD_RUN_PATH
342
423
dnl here, because this doesn't fit in flags passed to the
343
424
dnl compiler. So give up. No hardcoding. This affects only
344
425
dnl very old systems.
368
449
LIB[]NAME[]_PREFIX="$basedir"
369
450
additional_includedir="$basedir/include"
452
*/$acl_libdirstem2 | */$acl_libdirstem2/)
453
basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'`
454
LIB[]NAME[]_PREFIX="$basedir"
455
additional_includedir="$basedir/include"
372
458
if test "X$additional_includedir" != "X"; then
373
459
dnl Potentially add $additional_includedir to $INCNAME.
426
512
dnl 3. if it's already present in $LDFLAGS or the already
427
513
dnl constructed $LIBNAME,
428
514
dnl 4. if it doesn't exist as a directory.
429
if test "X$additional_libdir" != "X/usr/$acl_libdirstem"; then
515
if test "X$additional_libdir" != "X/usr/$acl_libdirstem" \
516
&& test "X$additional_libdir" != "X/usr/$acl_libdirstem2"; then
431
if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem"; then
518
if test "X$additional_libdir" = "X/usr/local/$acl_libdirstem" \
519
|| test "X$additional_libdir" = "X/usr/local/$acl_libdirstem2"; then
432
520
if test -n "$GCC"; then
434
522
linux* | gnu* | k*bsd*-gnu) haveit=yes;;
529
617
if test "X$rpathdirs" != "X"; then
530
if test -n "$hardcode_libdir_separator"; then
618
if test -n "$acl_hardcode_libdir_separator"; then
531
619
dnl Weird platform: only the last -rpath option counts, the user must
532
620
dnl pass all path elements in one option. We can arrange that for a
533
621
dnl single library, but not when more than one $LIBNAMEs are used.
535
623
for found_dir in $rpathdirs; do
536
alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
624
alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir"
538
dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl.
626
dnl Note: acl_hardcode_libdir_flag_spec uses $libdir and $wl.
539
627
acl_save_libdir="$libdir"
540
628
libdir="$alldirs"
541
eval flag=\"$hardcode_libdir_flag_spec\"
629
eval flag=\"$acl_hardcode_libdir_flag_spec\"
542
630
libdir="$acl_save_libdir"
543
631
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
546
634
for found_dir in $rpathdirs; do
547
635
acl_save_libdir="$libdir"
548
636
libdir="$found_dir"
549
eval flag=\"$hardcode_libdir_flag_spec\"
637
eval flag=\"$acl_hardcode_libdir_flag_spec\"
550
638
libdir="$acl_save_libdir"
551
639
LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
614
708
-L*) dir=`echo "X$opt" | sed -e 's,^X-L,,'`
615
709
dnl No need to hardcode the standard /usr/lib.
616
if test "X$dir" != "X/usr/$acl_libdirstem"; then
710
if test "X$dir" != "X/usr/$acl_libdirstem" \
711
&& test "X$dir" != "X/usr/$acl_libdirstem2"; then
617
712
rpathdirs="$rpathdirs $dir"
631
726
dnl The linker is used for linking directly.
632
if test -n "$hardcode_libdir_separator"; then
727
if test -n "$acl_hardcode_libdir_separator"; then
633
728
dnl Weird platform: only the last -rpath option counts, the user
634
729
dnl must pass all path elements in one option.
636
731
for dir in $rpathdirs; do
637
alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$dir"
732
alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$dir"
639
734
acl_save_libdir="$libdir"
640
735
libdir="$alldirs"
641
eval flag=\"$hardcode_libdir_flag_spec\"
736
eval flag=\"$acl_hardcode_libdir_flag_spec\"
642
737
libdir="$acl_save_libdir"