]>
Dogcows Code - chaz/yoink/blob - tools/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 on
10 # some platforms. If you have a newer version of GCC, you should prefer
11 # the --as-needed linker flag over this method, though they both should
12 # accomplish the same thing.
14 # This script was adapted from some public domain code written by Bram
15 # Moolenaar for Vim. The only input needed is the link command in the
16 # variable LINK. It is expected that the linker will return an error code
17 # or this will not work. The script caches the test results in the
18 # `.link/link.sed' file; delete that file if you want to redetermine the
19 # required direct dependencies.
23 # List here any libraries that are known to not be needed on some platform.
43 logfile
="$linkdir/link.log"
44 sedfile
="$linkdir/link.sed"
46 workdir
=$(mktemp -d tmp.XXXXXXXX)
47 cmdfile
="$workdir/link.cmd"
48 runfile
="$workdir/link.run"
50 tmpfile1
="$workdir/link.tmp1"
51 tmpfile2
="$workdir/link.tmp2"
52 tmpfile3
="$workdir/link.tmp3"
60 echo "$LINK " >$cmdfile
66 printlog
"The file $sedfile exists, which is now going to be used."
67 printlog
"If linking fails, try deleting the $sedfile file."
68 printlog
"If that fails, try creating an empty $sedfile file."
69 printlog
"If that fails, configure the package with --disable-link-sh."
77 for libname
in $libraries
82 if grep "l$libname " $runfile >/dev
/null
84 if test ! -f $tmpfile1
86 printlog
"Full linking works; now the fun begins."
87 printlog
"See $logfile for details."
90 echo "s/-l$libname *//" >$tmpfile1
91 sed -f $sedfile <$cmdfile | sed -f $tmpfile1 >$runfile
92 # keep the last -lm; this is supposedly needed by HP-UX
93 if test $libname != "m" || grep "lm " $runfile >/dev
/null
95 printlog
"Trying to remove the $libname library..."
96 cat $runfile >>$logfile
97 if sh
$runfile >>$logfile 2>&1
99 printlog
"We don't need the $libname library!"
100 cat $tmpfile1 >>$sedfile
103 printlog
"We DO need the $libname library."
111 if test ! -f $tmpfile1
113 printlog
"Linked fine, no libraries can be removed."
124 printlog
"Using $sedfile file to remove a few libraries."
125 sed -f $sedfile <$cmdfile >$runfile
130 printlog
"Linked fine with a few libraries removed."
133 printlog
"Linking failed, making $sedfile empty and trying again."
134 mv -f $sedfile $tmpfile2
139 if test -f $sedfile -a ! -s $sedfile -a ! -f $tmpfile3
141 printlog
"Using unmodified link command."
146 printlog
"Linked OK."
151 printlog
"Linking doesn't work at all, removing $sedfile."
This page took 0.046405 seconds and 4 git commands to generate.