File tree Expand file tree Collapse file tree 1 file changed +30
-2
lines changed Expand file tree Collapse file tree 1 file changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -191,6 +191,7 @@ for item; do
191191 short_name=" ${item: 2} "
192192 if [[ $exclude_libs != * " ;$short_name ;" * && $LD_LIBS_SEARCH != * " lib$short_name .a" * ]]; then
193193 LD_LIBS_SEARCH+=" lib$short_name .a "
194+ # echo "lib add: $item"
194195 fi
195196 elif [ " $item " = " -o" ]; then
196197 add_next=0
@@ -225,8 +226,35 @@ for item; do
225226 if [[ " $lname " != " main" && " $lname " != " arduino" ]]; then
226227 lsize=$( $SSTAT " $item " )
227228 if (( lsize > 8 )) ; then
228- LD_LIBS+=" -l$lname "
229- LD_LIB_FILES+=" $item "
229+ # do we already have this file?
230+ if [[ $LD_LIB_FILES != * " $item " * ]]; then
231+ # do we already have lib with the same name?
232+ if [[ $LD_LIBS != * " -l$lname " * ]]; then
233+ # echo "collecting lib '$lname' and file: $item"
234+ LD_LIB_FILES+=" $item "
235+ LD_LIBS+=" -l$lname "
236+ else
237+ # echo "!!! need to rename: '$lname'"
238+ for i in {2..9}; do
239+ n_item=" ${item: 0: ${# item} -2} _$i .a"
240+ n_name=$lname " _$i "
241+ if [ -f " $n_item " ]; then
242+ # echo "renamed add: -l$n_name"
243+ LD_LIBS+=" -l$n_name "
244+ break
245+ elif [[ $LD_LIB_FILES != * " $n_item " * && $LD_LIBS != * " -l$n_name " * ]]; then
246+ echo " Renaming '$lname ' to '$n_name ': $item "
247+ cp -f " $item " " $n_item "
248+ LD_LIB_FILES+=" $n_item "
249+ LD_LIBS+=" -l$n_name "
250+ break
251+ fi
252+ done
253+ fi
254+ else
255+ # echo "just add: -l$lname"
256+ LD_LIBS+=" -l$lname "
257+ fi
230258 else
231259 echo " *** Skipping $( basename $item ) : size too small $lsize "
232260 fi
You can’t perform that action at this time.
0 commit comments