8 $debug && echo "Trying: $* $added"
9 "$@" $added >busybox.map 2>busybox_ld.err
12 # Sanitize lib list (dups, extra spaces etc)
13 #echo "BBOX_LIB_LIST=$BBOX_LIB_LIST"
14 BBOX_LIB_LIST=`echo "$BBOX_LIB_LIST" | xargs -n1 | sort | uniq | xargs`
16 # First link with all libs. If it fails, bail out
17 l_list=`echo "$BBOX_LIB_LIST" | sed -e 's/ / -l/g' -e 's/^/-l/'`
18 echo "Trying libraries: $BBOX_LIB_LIST"
19 try "-Wl,--start-group $l_list -Wl,--end-group" "$@" \
21 echo "Failed: $* -Wl,--start-group $l_list -Wl,--end-group"
26 # Now try to remove each lib and build without.
27 # Stop when no lib can be removed.
28 while test "$BBOX_LIB_LIST"; do
29 $debug && echo "Trying libraries: $BBOX_LIB_LIST"
31 for one in $BBOX_LIB_LIST; do
32 without_one=`echo " $BBOX_LIB_LIST " | sed "s/ $one / /g" | xargs`
33 l_list=`echo "$without_one" | sed -e 's/ / -l/g' -e 's/^/-l/'`
34 $debug && echo "Trying -l options: $l_list"
35 if try "-Wl,--start-group $l_list -Wl,--end-group" "$@"; then
36 echo "Library $one is not needed"
37 BBOX_LIB_LIST="$without_one"
40 echo "Library $one is needed"
43 # All libs were needed, can't remove any
45 # If there is no space, the list has just one lib.
46 # I'm not sure that in this case lib really is 100% needed.
47 # Let's try linking without it anyway... thus commented out.
48 #echo "$BBOX_LIB_LIST" | grep -q ' ' || break
52 echo "Final link with: $BBOX_LIB_LIST"
53 l_list=`echo "$BBOX_LIB_LIST" | sed -e 's/ / -l/g' -e 's/^/-l/'`
54 try "-Wl,--start-group $l_list -Wl,--end-group" "$@"