]>
Dogcows Code - chaz/yoink/blob - link.sh
5 # Run this script to link the executable with fewer direct dependencies.
7 # You shouldn't call this directly; instead, use the configure script's
8 # --enable-link-sh option and run make normally. This isn't enabled by
9 # default because there is the potential for runtime linking problems. If
10 # you have a newer version of GCC, you should prefer the --as-needed linker
11 # flag over this method, though they both should accomplish the same thing.
13 # This script was adapted from some public domain code written by Bram
14 # Moolenaar for Vim. The only input needed is the link command in the
15 # variable LINK. It is expected that the linker will return an error code
16 # or this will not work. The script caches the test results in the
17 # `.link/link.sed' file; delete that file if you want to redetermine the
18 # required direct dependencies.
22 # List here any libraries that are known to not be needed on some platform.
42 logfile
="$linkdir/link.log"
43 sedfile
="$linkdir/link.sed"
45 workdir
=$(mktemp -d tmp.XXXXXXXX)
46 cmdfile
="$workdir/link.cmd"
47 runfile
="$workdir/link.run"
49 tmpfile1
="$workdir/link.tmp1"
50 tmpfile2
="$workdir/link.tmp2"
51 tmpfile3
="$workdir/link.tmp3"
59 echo "$LINK " >$cmdfile
65 printlog
"The file $sedfile exists, which is now going to be used."
66 printlog
"If linking fails, try deleting the $sedfile file."
67 printlog
"If that fails, try creating an empty $sedfile file."
68 printlog
"If that fails, configure the package with --disable-link-sh."
76 for libname
in $libraries
81 if grep "l$libname " $runfile >/dev
/null
83 if test ! -f $tmpfile1
85 printlog
"Full linking works; now the fun begins."
86 printlog
"See $logfile for details."
89 echo "s/-l$libname *//" >$tmpfile1
90 sed -f $sedfile <$cmdfile | sed -f $tmpfile1 >$runfile
91 # keep the last -lm; this is supposedly needed by HP-UX
92 if test $libname != "m" || grep "lm " $runfile >/dev
/null
94 printlog
"Trying to remove the $libname library..."
95 cat $runfile >>$logfile
96 if sh
$runfile >>$logfile 2>&1
98 printlog
"We don't need the $libname library!"
99 cat $tmpfile1 >>$sedfile
102 printlog
"We DO need the $libname library."
110 if test ! -f $tmpfile1
112 printlog
"Linked fine, no libraries can be removed."
123 printlog
"Using $sedfile file to remove a few libraries."
124 sed -f $sedfile <$cmdfile >$runfile
129 printlog
"Linked fine with a few libraries removed."
132 printlog
"Linking failed, making $sedfile empty and trying again."
133 mv -f $sedfile $tmpfile2
138 if test -f $sedfile -a ! -s $sedfile -a ! -f $tmpfile3
140 printlog
"Using unmodified link command."
145 printlog
"Linked OK."
150 printlog
"Linking doesn't work at all, removing $sedfile."
This page took 0.03855 seconds and 4 git commands to generate.