242 |
} |
} |
243 |
|
|
244 |
|
|
245 |
|
# func_extract_an_archive dir oldlib |
246 |
|
func_extract_an_archive () { |
247 |
|
f_ex_an_ar_dir="$1"; shift |
248 |
|
f_ex_an_ar_oldlib="$1" |
249 |
|
f_ex_an_ar_lib=`$echo "X$f_ex_an_ar_oldlib" | $Xsed -e 's%^.*/%%'` |
250 |
|
|
251 |
|
$show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)" |
252 |
|
$run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $? |
253 |
|
if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then |
254 |
|
: |
255 |
|
else |
256 |
|
$echo "$modename: warning: object name conflicts; renaming object files" 1>&2 |
257 |
|
$echo "$modename: warning: to ensure that they will not overwrite" 1>&2 |
258 |
|
$show "cp $f_ex_an_ar_oldlib $f_ex_an_ar_dir/$f_ex_an_ar_lib" |
259 |
|
$run eval "cp \$f_ex_an_ar_oldlib \$f_ex_an_ar_dir/\$f_ex_an_ar_lib" |
260 |
|
$AR t "$f_ex_an_ar_oldlib" | sort | uniq -c \ |
261 |
|
| $EGREP -v '^[ ]*1[ ]' | while read -r count name |
262 |
|
do |
263 |
|
i=1 |
264 |
|
while test "$i" -le "$count" |
265 |
|
do |
266 |
|
# Put our $i before any first dot (extension) |
267 |
|
# Never overwrite any file |
268 |
|
name_to="$name" |
269 |
|
while test "X$name_to" = "X$name" || test -f "$f_ex_an_ar_dir/$name_to" |
270 |
|
do |
271 |
|
name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"` |
272 |
|
done |
273 |
|
$show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_lib '$name' && $mv '$name' '$name_to')" |
274 |
|
$run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_lib '$name' && $mv '$name' '$name_to' && $AR -d \$f_ex_an_ar_lib '$name')" || exit $? |
275 |
|
i=`expr $i + 1` |
276 |
|
done |
277 |
|
done |
278 |
|
$show "$rm $f_ex_an_ar_dir/$f_ex_an_ar_lib" |
279 |
|
$run eval "$rm \$f_ex_an_ar_dir/\$f_ex_an_ar_lib" |
280 |
|
fi |
281 |
|
} |
282 |
|
|
283 |
# func_extract_archives gentop oldlib ... |
# func_extract_archives gentop oldlib ... |
284 |
func_extract_archives () { |
func_extract_archives () { |
285 |
my_gentop="$1"; shift |
my_gentop="$1"; shift |
325 |
cd $my_xdir || exit $? |
cd $my_xdir || exit $? |
326 |
darwin_archive=$my_xabs |
darwin_archive=$my_xabs |
327 |
darwin_curdir=`pwd` |
darwin_curdir=`pwd` |
328 |
darwin_base_archive=`basename $darwin_archive` |
darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'` |
329 |
darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null` |
darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null` |
330 |
if test -n "$darwin_arches"; then |
if test -n "$darwin_arches"; then |
331 |
darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'` |
darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'` |
337 |
# Remove the table of contents from the thin files. |
# Remove the table of contents from the thin files. |
338 |
$AR -d "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" __.SYMDEF 2>/dev/null || true |
$AR -d "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" __.SYMDEF 2>/dev/null || true |
339 |
$AR -d "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" __.SYMDEF\ SORTED 2>/dev/null || true |
$AR -d "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" __.SYMDEF\ SORTED 2>/dev/null || true |
340 |
cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" |
func_extract_an_archive "unfat-$$/${darwin_base_archive}-${darwin_arch}" "${darwin_base_archive}" |
341 |
$AR -xo "${darwin_base_archive}" |
$rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" |
|
rm "${darwin_base_archive}" |
|
|
cd "$darwin_curdir" |
|
342 |
done # $darwin_arches |
done # $darwin_arches |
343 |
## Okay now we have a bunch of thin objects, gotta fatten them up :) |
## Okay now we have a bunch of thin objects, gotta fatten them up :) |
344 |
darwin_filelist=`find unfat-$$ -type f | xargs basename | sort -u | $NL2SP` |
darwin_filelist=`find unfat-$$ -type f | xargs basename | sort -u | $NL2SP` |
348 |
darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP` |
darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP` |
349 |
lipo -create -output "$darwin_file" $darwin_files |
lipo -create -output "$darwin_file" $darwin_files |
350 |
done # $darwin_filelist |
done # $darwin_filelist |
351 |
rm -rf unfat-$$ |
${rm}f unfat-$$ |
352 |
cd "$darwin_orig_dir" |
cd "$darwin_orig_dir" |
353 |
else |
else |
354 |
cd $darwin_orig_dir |
cd "$darwin_orig_dir" |
355 |
(cd $my_xdir && $AR x $my_xabs) || exit $? |
func_extract_an_archive "$my_xdir" "$my_xabs" |
356 |
fi # $darwin_arches |
fi # $darwin_arches |
357 |
fi # $run |
fi # $run |
358 |
;; |
;; |
359 |
*) |
*) |
360 |
# We will extract separately just the conflicting names and we will |
func_extract_an_archive "$my_xdir" "$my_xabs" |
361 |
# no longer touch any unique names. It is faster to leave these |
;; |
|
# extract automatically by $AR in one run. |
|
|
$show "(cd $my_xdir && $AR x $my_xabs)" |
|
|
$run eval "(cd \$my_xdir && $AR x \$my_xabs)" || exit $? |
|
|
if ($AR t "$my_xabs" | sort | sort -uc >/dev/null 2>&1); then |
|
|
: |
|
|
else |
|
|
$echo "$modename: warning: object name conflicts; renaming object files" 1>&2 |
|
|
$echo "$modename: warning: to ensure that they will not overwrite" 1>&2 |
|
|
$AR t "$my_xabs" | sort | uniq -cd | while read -r count name |
|
|
do |
|
|
i=1 |
|
|
while test "$i" -le "$count" |
|
|
do |
|
|
# Put our $i before any first dot (extension) |
|
|
# Never overwrite any file |
|
|
name_to="$name" |
|
|
while test "X$name_to" = "X$name" || test -f "$my_xdir/$name_to" |
|
|
do |
|
|
name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"` |
|
|
done |
|
|
$show "(cd $my_xdir && $AR xN $i $my_xabs '$name' && $mv '$name' '$name_to')" |
|
|
$run eval "(cd \$my_xdir && $AR xN $i \$my_xabs '$name' && $mv '$name' '$name_to')" || exit $? |
|
|
i=`expr $i + 1` |
|
|
done |
|
|
done |
|
|
fi |
|
|
;; |
|
362 |
esac |
esac |
363 |
my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` |
my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` |
364 |
done |
done |
|
|
|
365 |
func_extract_archives_result="$my_oldobjs" |
func_extract_archives_result="$my_oldobjs" |
366 |
} |
} |
367 |
# End of Shell function definitions |
# End of Shell function definitions |