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
4
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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"
238
349
# End of Shell function definitions
239
350
#####################################
548
659
# Double-quote args containing other shell metacharacters.
549
660
# Many Bourne shells cannot handle close brackets correctly
550
# in scan sets, so we specify it separately.
551
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
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* | *]* | *\|* | *\&* | *\(* | *\)* | "")
552
666
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"
1369
1522
-mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
1370
deplibs="$deplibs $arg"
1523
compiler_flags="$compiler_flags $arg"
1524
compile_command="$compile_command $arg"
1525
finalize_command="$finalize_command $arg"
1379
# gcc -m* arguments should be passed to the linker via $compiler_flags
1380
# in order to pass architecture information to the linker
1381
# (e.g. 32 vs 64-bit). This may also be accomplished via -Wl,-mfoo
1382
# but this is not reliable with gcc because gcc may use -mfoo to
1383
# select a different linker, different libraries, etc, while
1384
# -Wl,-mfoo simply passes -mfoo to the linker.
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*)
1386
1542
# Unknown arguments in both finalize_command and compile_command need
1387
1543
# to be aesthetically quoted because they are evaled later.
1388
1544
arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1390
*[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
1546
*$quote_scanset* | *]* | *\|* | *\&* | *\(* | *\)* | "")
1978
2131
case $linkmode in
1980
if test "$deplibs_check_method" != pass_all; then
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
1982
2150
$echo "*** Warning: Trying to link with static lib archive $deplib."
1983
2151
$echo "*** I have the capability to make that library automatically link in when"
2150
2320
absdir="$libdir"
2322
test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
2153
dir="$ladir/$objdir"
2154
absdir="$abs_ladir/$objdir"
2155
# Remove this search path later
2156
notinst_path="$notinst_path $abs_ladir"
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
2335
fi # $installed = yes
2158
2336
name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
3679
3852
eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
3681
3854
gentop="$output_objdir/${outputname}x"
3682
$show "${rm}r $gentop"
3683
$run ${rm}r "$gentop"
3684
$show "$mkdir $gentop"
3685
$run $mkdir "$gentop"
3687
if test "$status" -ne 0 && test ! -d "$gentop"; then
3690
3855
generated="$generated $gentop"
3692
for xlib in $convenience; do
3693
# Extract the objects.
3695
[\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
3696
*) xabs=`pwd`"/$xlib" ;;
3698
xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
3699
xdir="$gentop/$xlib"
3701
$show "${rm}r $xdir"
3703
$show "$mkdir $xdir"
3706
if test "$status" -ne 0 && test ! -d "$xdir"; then
3709
# We will extract separately just the conflicting names and we will no
3710
# longer touch any unique names. It is faster to leave these extract
3711
# automatically by $AR in one run.
3712
$show "(cd $xdir && $AR x $xabs)"
3713
$run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
3714
if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
3717
$echo "$modename: warning: object name conflicts; renaming object files" 1>&2
3718
$echo "$modename: warning: to ensure that they will not overwrite" 1>&2
3719
$AR t "$xabs" | sort | uniq -cd | while read -r count name
3722
while test "$i" -le "$count"
3724
# Put our $i before any first dot (extension)
3725
# Never overwrite any file
3727
while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
3729
name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
3731
$show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')"
3732
$run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $?
3738
libobjs="$libobjs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
3857
func_extract_archives $gentop $convenience
3858
libobjs="$libobjs $func_extract_archives_result"
3743
3862
if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
3744
3863
eval flag=\"$thread_safe_flag_spec\"
3745
3864
linker_flags="$linker_flags $flag"
3977
4097
eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
3979
4099
gentop="$output_objdir/${obj}x"
3980
$show "${rm}r $gentop"
3981
$run ${rm}r "$gentop"
3982
$show "$mkdir $gentop"
3983
$run $mkdir "$gentop"
3985
if test "$status" -ne 0 && test ! -d "$gentop"; then
3988
4100
generated="$generated $gentop"
3990
for xlib in $convenience; do
3991
# Extract the objects.
3993
[\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
3994
*) xabs=`pwd`"/$xlib" ;;
3996
xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
3997
xdir="$gentop/$xlib"
3999
$show "${rm}r $xdir"
4001
$show "$mkdir $xdir"
4004
if test "$status" -ne 0 && test ! -d "$xdir"; then
4007
# We will extract separately just the conflicting names and we will no
4008
# longer touch any unique names. It is faster to leave these extract
4009
# automatically by $AR in one run.
4010
$show "(cd $xdir && $AR x $xabs)"
4011
$run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
4012
if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
4015
$echo "$modename: warning: object name conflicts; renaming object files" 1>&2
4016
$echo "$modename: warning: to ensure that they will not overwrite" 1>&2
4017
$AR t "$xabs" | sort | uniq -cd | while read -r count name
4020
while test "$i" -le "$count"
4022
# Put our $i before any first dot (extension)
4023
# Never overwrite any file
4025
while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
4027
name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
4029
$show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')"
4030
$run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $?
4036
reload_conv_objs="$reload_objs "`find $xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
4102
func_extract_archives $gentop $convenience
4103
reload_conv_objs="$reload_objs $func_extract_archives_result"
4297
4363
# Prepare the list of exported symbols
4298
4364
if test -z "$export_symbols"; then
4299
export_symbols="$output_objdir/$output.exp"
4365
export_symbols="$output_objdir/$outputname.exp"
4300
4366
$run $rm $export_symbols
4301
4367
$run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4303
$run eval "${SED} -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"'
4304
$run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T'
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'
4305
4371
$run eval 'mv "$nlist"T "$nlist"'
4993
5078
if test -n "$addlibs"; then
4994
5079
gentop="$output_objdir/${outputname}x"
4995
$show "${rm}r $gentop"
4996
$run ${rm}r "$gentop"
4997
$show "$mkdir $gentop"
4998
$run $mkdir "$gentop"
5000
if test "$status" -ne 0 && test ! -d "$gentop"; then
5003
5080
generated="$generated $gentop"
5005
# Add in members from convenience archives.
5006
for xlib in $addlibs; do
5007
# Extract the objects.
5009
[\\/]* | [A-Za-z]:[\\/]*) xabs="$xlib" ;;
5010
*) xabs=`pwd`"/$xlib" ;;
5012
xlib=`$echo "X$xlib" | $Xsed -e 's%^.*/%%'`
5013
xdir="$gentop/$xlib"
5015
$show "${rm}r $xdir"
5017
$show "$mkdir $xdir"
5020
if test "$status" -ne 0 && test ! -d "$xdir"; then
5023
# We will extract separately just the conflicting names and we will no
5024
# longer touch any unique names. It is faster to leave these extract
5025
# automatically by $AR in one run.
5026
$show "(cd $xdir && $AR x $xabs)"
5027
$run eval "(cd \$xdir && $AR x \$xabs)" || exit $?
5028
if ($AR t "$xabs" | sort | sort -uc >/dev/null 2>&1); then
5031
$echo "$modename: warning: object name conflicts; renaming object files" 1>&2
5032
$echo "$modename: warning: to ensure that they will not overwrite" 1>&2
5033
$AR t "$xabs" | sort | uniq -cd | while read -r count name
5036
while test "$i" -le "$count"
5038
# Put our $i before any first dot (extension)
5039
# Never overwrite any file
5041
while test "X$name_to" = "X$name" || test -f "$xdir/$name_to"
5043
name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
5045
$show "(cd $xdir && $AR xN $i $xabs '$name' && $mv '$name' '$name_to')"
5046
$run eval "(cd \$xdir && $AR xN $i \$xabs '$name' && $mv '$name' '$name_to')" || exit $?
5052
oldobjs="$oldobjs "`find $xdir -name \*.${objext} -print -o -name \*.lo -print | $NL2SP`
5082
func_extract_archives $gentop $addlibs
5083
oldobjs="$oldobjs $func_extract_archives_result"
5056
5086
# Do each command in the archive commands.
5057
5087
if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
5058
5088
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" ;;
5060
5147
eval cmds=\"$old_archive_cmds\"
5062
5149
if len=`expr "X$cmds" : ".*"` &&
5072
5159
save_oldobjs=$oldobjs
5073
# GNU ar 2.10+ was changed to match POSIX; thus no paths are
5074
# encoded into archives. This makes 'ar r' malfunction in
5075
# this piecewise linking case whenever conflicting object
5076
# names appear in distinct ar calls; check, warn and compensate.
5077
if (for obj in $save_oldobjs
5079
$echo "X$obj" | $Xsed -e 's%^.*/%%'
5080
done | sort | sort -uc >/dev/null 2>&1); then
5083
$echo "$modename: warning: object name conflicts; overriding AR_FLAGS to 'cq'" 1>&2
5084
$echo "$modename: warning: to ensure that POSIX-compatible ar will work" 1>&2
5087
5161
# Is there a better way of finding the last object in the list?
5088
5162
for obj in $save_oldobjs