1
1
# ltmain.sh - Provide generalized library-building support services.
2
2
# NOTE: Changing this file will not affect anything until you rerun configure.
4
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
4
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004
5
5
# Free Software Foundation, Inc.
6
6
# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
18
18
# You should have received a copy of the GNU General Public License
19
19
# along with this program; if not, write to the Free Software
20
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22
22
# As a special exception to the GNU General Public License, if you
23
23
# distribute this file as part of a program that contains a
249
# func_extract_an_archive dir oldlib
250
func_extract_an_archive ()
252
f_ex_an_ar_dir="$1"; shift
253
f_ex_an_ar_oldlib="$1"
255
$show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
256
$run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
257
if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
260
$echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
265
# func_extract_archives gentop oldlib ...
266
func_extract_archives ()
268
my_gentop="$1"; shift
276
$show "${rm}r $my_gentop"
277
$run ${rm}r "$my_gentop"
278
$show "$mkdir $my_gentop"
279
$run $mkdir "$my_gentop"
281
if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
285
for my_xlib in $my_oldlibs; do
286
# Extract the objects.
288
[\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
289
*) my_xabs=`pwd`"/$my_xlib" ;;
291
my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
292
my_xdir="$my_gentop/$my_xlib"
294
$show "${rm}r $my_xdir"
295
$run ${rm}r "$my_xdir"
296
$show "$mkdir $my_xdir"
297
$run $mkdir "$my_xdir"
299
if test "$status" -ne 0 && test ! -d "$my_xdir"; then
304
$show "Extracting $my_xabs"
305
# Do not bother doing anything if just a dry run
306
if test -z "$run"; then
307
darwin_orig_dir=`pwd`
308
cd $my_xdir || exit $?
309
darwin_archive=$my_xabs
311
darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
312
darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
313
if test -n "$darwin_arches"; then
314
darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
316
$show "$darwin_base_archive has multiple architectures $darwin_arches"
317
for darwin_arch in $darwin_arches ; do
318
mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
319
lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
320
cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
321
func_extract_an_archive "`pwd`" "${darwin_base_archive}"
323
$rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
324
done # $darwin_arches
325
## Okay now we have a bunch of thin objects, gotta fatten them up :)
326
darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
329
for darwin_file in $darwin_filelist; do
330
darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
331
lipo -create -output "$darwin_file" $darwin_files
332
done # $darwin_filelist
334
cd "$darwin_orig_dir"
336
cd "$darwin_orig_dir"
337
func_extract_an_archive "$my_xdir" "$my_xabs"
342
func_extract_an_archive "$my_xdir" "$my_xabs"
345
my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
347
func_extract_archives_result="$my_oldobjs"
349
241
# End of Shell function definitions
350
242
#####################################
659
551
# Double-quote args containing other shell metacharacters.
660
552
# Many Bourne shells cannot handle close brackets correctly
661
# in scan sets, and some SunOS ksh mistreat backslash-escaping
662
# in scan sets (worked around with variable expansion),
663
# and furthermore cannot handle '|' '&' '(' ')' in scan sets
664
# at all, so we specify them separately.
665
*$quote_scanset* | *]* | *\|* | *\&* | *\(* | *\)* | "")
553
# in scan sets, so we specify it separately.
554
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
666
555
lastarg="\"$lastarg\""
1512
# Tru64 UNIX uses -model [arg] to determine the layout of C++
1513
# classes, name mangling, and exception handling.
1515
compile_command="$compile_command $arg"
1516
compiler_flags="$compiler_flags $arg"
1517
finalize_command="$finalize_command $arg"
1522
1372
-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
1523
compiler_flags="$compiler_flags $arg"
1524
compile_command="$compile_command $arg"
1525
finalize_command="$finalize_command $arg"
1373
deplibs="$deplibs $arg"
1534
# -64, -mips[0-9] enable 64-bit mode on the SGI compiler
1535
# -r[0-9][0-9]* specifies the processor on the SGI compiler
1536
# -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
1537
# +DA*, +DD* enable 64-bit mode on the HP compiler
1538
# -q* pass through compiler args for the IBM compiler
1539
# -m* pass through architecture-specific compiler args for GCC
1540
-64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*)
1382
# gcc -m* arguments should be passed to the linker via $compiler_flags
1383
# in order to pass architecture information to the linker
1384
# (e.g. 32 vs 64-bit). This may also be accomplished via -Wl,-mfoo
1385
# but this is not reliable with gcc because gcc may use -mfoo to
1386
# select a different linker, different libraries, etc, while
1387
# -Wl,-mfoo simply passes -mfoo to the linker.
1542
1389
# Unknown arguments in both finalize_command and compile_command need
1543
1390
# to be aesthetically quoted because they are evaled later.
1544
1391
arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1546
*$quote_scanset* | *]* | *\|* | *\&* | *\(* | *\)* | "")
1393
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
2131
1982
case $linkmode in
2134
case $deplibs_check_method in
2136
set dummy $deplibs_check_method
2137
match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
2138
if eval $echo \"$deplib\" 2>/dev/null \
2140
| $EGREP "$match_pattern_regex" > /dev/null; then
2148
if test "$valid_a_lib" != yes; then
1984
if test "$deplibs_check_method" != pass_all; then
2150
1986
$echo "*** Warning: Trying to link with static lib archive $deplib."
2151
1987
$echo "*** I have the capability to make that library automatically link in when"
2320
2154
absdir="$libdir"
2322
test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
2324
if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
2327
# Remove this search path later
2328
notinst_path="$notinst_path $abs_ladir"
2330
dir="$ladir/$objdir"
2331
absdir="$abs_ladir/$objdir"
2332
# Remove this search path later
2333
notinst_path="$notinst_path $abs_ladir"
2157
dir="$ladir/$objdir"
2158
absdir="$abs_ladir/$objdir"
2159
# Remove this search path later
2160
notinst_path="$notinst_path $abs_ladir"
2335
2161
fi # $installed = yes
2336
2162
name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
3119
2945
# Check that each of the things are valid numbers.
3120
2946
case $current in
3121
0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
3123
$echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2
2949
$echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2
3124
2950
$echo "$modename: \`$vinfo' is not valid version information" 1>&2
3125
2951
exit $EXIT_FAILURE
3129
2955
case $revision in
3130
0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
3132
$echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2
2958
$echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2
3133
2959
$echo "$modename: \`$vinfo' is not valid version information" 1>&2
3134
2960
exit $EXIT_FAILURE
3139
0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
3141
$echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2
2967
$echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2
3142
2968
$echo "$modename: \`$vinfo' is not valid version information" 1>&2
3143
2969
exit $EXIT_FAILURE
3852
3678
eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
3854
3680
gentop="$output_objdir/${outputname}x"
3681
$show "${rm}r $gentop"
3682
$run ${rm}r "$gentop"
3683
$show "$mkdir $gentop"
3684
$run $mkdir "$gentop"
3686
if test "$status" -ne 0 && test ! -d "$gentop"; then
3855
3689
generated="$generated $gentop"
3857
func_extract_archives $gentop $convenience
3858
libobjs="$libobjs $func_extract_archives_result"
3691
for xlib in $convenience; do
3692
# Extract the objects.
3694
[\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
3695
*) xabs=`pwd`"/$xlib" ;;
3697
xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
3698
xdir="$gentop/$xlib"
3700
$show "${rm}r $xdir"
3702
$show "$mkdir $xdir"
3705
if test "$status" -ne 0 && test ! -d "$xdir"; then
3708
# We will extract separately just the conflicting names and we will no
3709
# longer touch any unique names. It is faster to leave these extract
3710
# automatically by $AR in one run.
3711
$show "(cd $xdir && $AR x $xabs)"
3712
$run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
3713
if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
3716
$echo "$modename: warning: object name conflicts; renaming object files" 1>&2
3717
$echo "$modename: warning: to ensure that they will not overwrite" 1>&2
3718
$AR t "$xabs" | sort | uniq -cd | while read -r count name
3721
while test "$i" -le "$count"
3723
# Put our $i before any first dot (extension)
3724
# Never overwrite any file
3726
while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
3728
name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
3730
$show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')"
3731
$run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $?
3737
libobjs="$libobjs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
3862
3742
if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
3863
3743
eval flag=\"$thread_safe_flag_spec\"
3864
3744
linker_flags="$linker_flags $flag"
4097
3976
eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
4099
3978
gentop="$output_objdir/${obj}x"
3979
$show "${rm}r $gentop"
3980
$run ${rm}r "$gentop"
3981
$show "$mkdir $gentop"
3982
$run $mkdir "$gentop"
3984
if test "$status" -ne 0 && test ! -d "$gentop"; then
4100
3987
generated="$generated $gentop"
4102
func_extract_archives $gentop $convenience
4103
reload_conv_objs="$reload_objs $func_extract_archives_result"
3989
for xlib in $convenience; do
3990
# Extract the objects.
3992
[\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
3993
*) xabs=`pwd`"/$xlib" ;;
3995
xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
3996
xdir="$gentop/$xlib"
3998
$show "${rm}r $xdir"
4000
$show "$mkdir $xdir"
4003
if test "$status" -ne 0 && test ! -d "$xdir"; then
4006
# We will extract separately just the conflicting names and we will no
4007
# longer touch any unique names. It is faster to leave these extract
4008
# automatically by $AR in one run.
4009
$show "(cd $xdir && $AR x $xabs)"
4010
$run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
4011
if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
4014
$echo "$modename: warning: object name conflicts; renaming object files" 1>&2
4015
$echo "$modename: warning: to ensure that they will not overwrite" 1>&2
4016
$AR t "$xabs" | sort | uniq -cd | while read -r count name
4019
while test "$i" -le "$count"
4021
# Put our $i before any first dot (extension)
4022
# Never overwrite any file
4024
while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
4026
name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
4028
$show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')"
4029
$run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $?
4035
reload_conv_objs="$reload_objs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
4363
4296
# Prepare the list of exported symbols
4364
4297
if test -z "$export_symbols"; then
4365
export_symbols="$output_objdir/$outputname.exp"
4298
export_symbols="$output_objdir/$output.exp"
4366
4299
$run $rm $export_symbols
4367
4300
$run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4369
$run eval "${SED} -e 's/\([ ][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
4370
$run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
4302
$run eval "${SED} -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"'
4303
$run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T'
4371
4304
$run eval 'mv "$nlist"T "$nlist"'
5078
4992
if test -n "$addlibs"; then
5079
4993
gentop="$output_objdir/${outputname}x"
4994
$show "${rm}r $gentop"
4995
$run ${rm}r "$gentop"
4996
$show "$mkdir $gentop"
4997
$run $mkdir "$gentop"
4999
if test "$status" -ne 0 && test ! -d "$gentop"; then
5080
5002
generated="$generated $gentop"
5082
func_extract_archives $gentop $addlibs
5083
oldobjs="$oldobjs $func_extract_archives_result"
5004
# Add in members from convenience archives.
5005
for xlib in $addlibs; do
5006
# Extract the objects.
5008
[\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
5009
*) xabs=`pwd`"/$xlib" ;;
5011
xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
5012
xdir="$gentop/$xlib"
5014
$show "${rm}r $xdir"
5016
$show "$mkdir $xdir"
5019
if test "$status" -ne 0 && test ! -d "$xdir"; then
5022
# We will extract separately just the conflicting names and we will no
5023
# longer touch any unique names. It is faster to leave these extract
5024
# automatically by $AR in one run.
5025
$show "(cd $xdir && $AR x $xabs)"
5026
$run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
5027
if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
5030
$echo "$modename: warning: object name conflicts; renaming object files" 1>&2
5031
$echo "$modename: warning: to ensure that they will not overwrite" 1>&2
5032
$AR t "$xabs" | sort | uniq -cd | while read -r count name
5035
while test "$i" -le "$count"
5037
# Put our $i before any first dot (extension)
5038
# Never overwrite any file
5040
while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
5042
name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
5044
$show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')"
5045
$run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $?
5051
oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP`
5086
5055
# Do each command in the archive commands.
5087
5056
if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
5088
5057
cmds=$old_archive_from_new_cmds
5090
# POSIX demands no paths to be encoded in archives. We have
5091
# to avoid creating archives with duplicate basenames if we
5092
# might have to extract them afterwards, e.g., when creating a
5093
# static archive out of a convenience library, or when linking
5094
# the entirety of a libtool archive into another (currently
5095
# not supported by libtool).
5096
if (for obj in $oldobjs
5098
$echo "X$obj" | $Xsed -e 's%^.*/%%'
5099
done | sort | sort -uc >/dev/null 2>&1); then
5102
$echo "copying selected object files to avoid basename conflicts..."
5104
if test -z "$gentop"; then
5105
gentop="$output_objdir/${outputname}x"
5106
generated="$generated $gentop"
5108
$show "${rm}r $gentop"
5109
$run ${rm}r "$gentop"
5110
$show "$mkdir $gentop"
5111
$run $mkdir "$gentop"
5113
if test "$status" -ne 0 && test ! -d "$gentop"; then
5118
save_oldobjs=$oldobjs
5121
for obj in $save_oldobjs
5123
objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
5124
case " $oldobjs " in
5125
" ") oldobjs=$obj ;;
5128
# Make sure we don't pick an alternate name that also
5130
newobj=lt$counter-$objbase
5131
counter=`expr $counter + 1`
5132
case " $oldobjs " in
5133
*[\ /]"$newobj "*) ;;
5134
*) if test ! -f "$gentop/$newobj"; then break; fi ;;
5137
$show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
5138
$run ln "$obj" "$gentop/$newobj" ||
5139
$run cp "$obj" "$gentop/$newobj"
5140
oldobjs="$oldobjs $gentop/$newobj"
5142
*) oldobjs="$oldobjs $obj" ;;
5147
5059
eval cmds=\"$old_archive_cmds\"
5149
5061
if len=`expr "X$cmds" : ".*"` &&
5159
5071
save_oldobjs=$oldobjs
5072
# GNU ar 2.10+ was changed to match POSIX; thus no paths are
5073
# encoded into archives. This makes 'ar r' malfunction in
5074
# this piecewise linking case whenever conflicting object
5075
# names appear in distinct ar calls; check, warn and compensate.
5076
if (for obj in $save_oldobjs
5078
$echo "X$obj" | $Xsed -e 's%^.*/%%'
5079
done | sort | sort -uc >/dev/null 2>&1); then
5082
$echo "$modename: warning: object name conflicts; overriding AR_FLAGS to 'cq'" 1>&2
5083
$echo "$modename: warning: to ensure that POSIX-compatible ar will work" 1>&2
5161
5086
# Is there a better way of finding the last object in the list?
5162
5087
for obj in $save_oldobjs