* config/ltmain.m4sh (func_mode_link): Kill quadratic loop while renaming objects. Reported by Joe Buck . Index: config/ltmain.m4sh =================================================================== RCS file: /cvsroot/libtool/libtool/config/ltmain.m4sh,v retrieving revision 1.66 diff -u -r1.66 ltmain.m4sh --- config/ltmain.m4sh 27 Apr 2005 11:30:38 -0000 1.66 +++ config/ltmain.m4sh 5 May 2005 09:42:10 -0000 @@ -6298,43 +6298,31 @@ # static archive out of a convenience library, or when linking # the entirety of a libtool archive into another (currently # not supported by libtool). - if (for obj in $oldobjs - do - func_basename "$obj" - $ECHO "$func_basename_result" - done | sort | sort -uc >/dev/null 2>&1); then - : - else + gentop="$output_objdir/${outputname}x" + generated="$generated $gentop" + func_mkdir_p "$gentop" + objs_bnames="_objs_basenames" + objs_nonuniq="_objs_nonuniq" + $ECHO "$oldobjs" | $SP2NL | $SED -n -e "$basename" -e '/./p' >"$objs_bnames" + sort "$objs_bnames" | uniq -d > "$objs_nonuniq" + if test -s "$objs_nonuniq" + then $ECHO "copying selected object files to avoid basename conflicts..." - gentop="$output_objdir/${outputname}x" - generated="$generated $gentop" - func_mkdir_p "$gentop" save_oldobjs=$oldobjs - oldobjs= - counter=1 - for obj in $save_oldobjs + : >_replace_script + # make sure we use unique names + counter=`$SED -n '/^lt-[[0-9]][[0-9]]*/ { s/^lt-//; s/[[^0-9]].*//; p; }' _objs_basenames \ + | sort -n | $SED -n '$p'` + $ECHO "$oldobjs" | $SP2NL | $SED -n -e '/./p' >_objs + paste "$objs_bnames" _objs | sort >_objs_plus_bnames + join "$objs_nonuniq" _objs_plus_bnames | while read objbase obj do - func_basename "$obj" - objbase="$func_basename_result" - case " $oldobjs " in - " ") oldobjs=$obj ;; - *[[\ /]]"$objbase "*) - while :; do - # Make sure we don't pick an alternate name that also - # overlaps. - newobj=lt$counter-$objbase - counter=`expr $counter + 1` - case " $oldobjs " in - *[[\ /]]"$newobj "*) ;; - *) if test ! -f "$gentop/$newobj"; then break; fi ;; - esac - done - func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" - oldobjs="$oldobjs $gentop/$newobj" - ;; - *) oldobjs="$oldobjs $obj" ;; - esac + counter=`expr $counter + 1` + newobj=lt$counter-$objbase + func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" + $ECHO "s#^$obj\$#$gentop/$newobj#" >>_replace_script done + oldobjs=`$SED -f _replace_script _objs | $NL2SP` fi eval cmds=\"$old_archive_cmds\"