aboutsummaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/trylink14
1 files changed, 9 insertions, 5 deletions
diff --git a/scripts/trylink b/scripts/trylink
index c24d49d52..adc045ad8 100755
--- a/scripts/trylink
+++ b/scripts/trylink
@@ -126,11 +126,12 @@ try $CC $CFLAGS $LDFLAGS \
126while test "$LDLIBS"; do 126while test "$LDLIBS"; do
127 $debug && echo "Trying libraries: $LDLIBS" 127 $debug && echo "Trying libraries: $LDLIBS"
128 all_needed=true 128 all_needed=true
129 last_needed=false
129 for one in $LDLIBS; do 130 for one in $LDLIBS; do
130 without_one=`echo " $LDLIBS " | sed "s/ $one / /g" | xargs` 131 without_one=`echo " $LDLIBS " | sed "s/ $one / /g" | xargs`
131 # "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3" 132 # "lib1 lib2 lib3" -> "-llib1 -llib2 -llib3"
132 l_list=`echo "$without_one" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'` 133 l_list=`echo "$without_one" | sed -e 's/ / -l/g' -e 's/^/-l/' -e 's/^-l$//'`
133 test "x$l_list" != "x" && l_list="-Wl,--start-group $l_list -Wl,--end-group" 134 test x"$l_list" != x"" && l_list="-Wl,--start-group $l_list -Wl,--end-group"
134 $debug && echo "Trying -l options: '$l_list'" 135 $debug && echo "Trying -l options: '$l_list'"
135 try $CC $CFLAGS $LDFLAGS \ 136 try $CC $CFLAGS $LDFLAGS \
136 -o $EXE \ 137 -o $EXE \
@@ -143,16 +144,19 @@ while test "$LDLIBS"; do
143 echo " Library $one is not needed" 144 echo " Library $one is not needed"
144 LDLIBS="$without_one" 145 LDLIBS="$without_one"
145 all_needed=false 146 all_needed=false
147 last_needed=false
146 else 148 else
147 echo " Library $one is needed" 149 echo " Library $one is needed"
150 last_needed=true
148 fi 151 fi
149 done 152 done
150 # All libs were needed, can't remove any 153 # All libs were needed, can't remove any
151 $all_needed && break 154 $all_needed && break
152 # If there is no space char, the list has just one lib. 155 # Optimization: was the last tried lib needed?
153 # I'm not sure that in this case lib really is 100% needed. 156 if $last_needed; then
154 # Let's try linking without it anyway... thus commented out. 157 # Was it the only one lib left? Don't test again then.
155 #{ echo "$LDLIBS" | grep -q ' '; } || break 158 { echo "$LDLIBS" | grep -q ' '; } || break
159 fi
156done 160done
157 161
158# Make the binary with final, minimal list of libs 162# Make the binary with final, minimal list of libs