annotate src/link.sh @ 49:000769ce6c9d default tip

Added tag v7-3-618 for changeset 67300faee616
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 01 Aug 2012 18:08:37 +0900
parents c16898406ff2
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
1 #! /bin/sh
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
2 #
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
3 # link.sh -- try linking Vim with different sets of libraries, finding the
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
4 # minimal set for fastest startup. The problem is that configure adds a few
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
5 # libraries when they exist, but this doesn't mean they are needed for Vim.
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
6 #
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
7 # Author: Bram Moolenaar
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
8 # Last change: 2010 Nov 03
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
9 # License: Public domain
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
10 #
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
11 # Warning: This fails miserably if the linker doesn't return an error code!
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
12 #
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
13 # Otherwise this script is fail-safe, falling back to the original full link
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
14 # command if anything fails.
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
15
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
16 echo "$LINK " >link.cmd
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
17 exit_value=0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
18
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
19 if test "$LINK_AS_NEEDED" = yes; then
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
20 echo "link.sh: \$LINK_AS_NEEDED set to 'yes': invoking linker directly."
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
21 cat link.cmd
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
22 if sh link.cmd; then
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
23 exit_value=0
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
24 echo "link.sh: Linked fine"
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
25 else
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
26 exit_value=$?
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
27 echo "link.sh: Linking failed"
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
28 fi
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
29 else
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
30 if test -f auto/link.sed; then
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
31
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
32 #
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
33 # If auto/link.sed already exists, use it. We assume a previous run of
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
34 # link.sh has found the correct set of libraries.
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
35 #
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
36 echo "link.sh: The file 'auto/link.sed' exists, which is going to be used now."
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
37 echo "link.sh: If linking fails, try deleting the auto/link.sed file."
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
38 echo "link.sh: If this fails too, try creating an empty auto/link.sed file."
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
39 else
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
40
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
41 # If linking works with the full link command, try removing some libraries,
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
42 # that are known not to be needed on at least one system.
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
43 # Remove auto/pathdef.c if there is a new link command and compile it again.
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
44 # There is a loop to remove libraries that appear several times.
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
45 #
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
46 # Notes:
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
47 # - Can't remove Xext; It links fine but will give an error when running gvim
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
48 # with Motif.
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
49 # - Don't remove the last -lm: On HP-UX Vim links OK but crashes when the GTK
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
50 # GUI is started, because the "floor" symbol could not be resolved.
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
51 #
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
52 cat link.cmd
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
53 if sh link.cmd; then
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
54 touch auto/link.sed
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
55 cp link.cmd linkit.sh
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
56 for libname in SM ICE nsl dnet dnet_stub inet socket dir elf iconv Xt Xmu Xp Xpm X11 Xdmcp x w perl dl pthread thread readline m crypt attr; do
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
57 cont=yes
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
58 while test -n "$cont"; do
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
59 if grep "l$libname " linkit.sh >/dev/null; then
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
60 if test ! -f link1.sed; then
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
61 echo "link.sh: OK, linking works, let's try omitting a few libraries."
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
62 echo "link.sh: See auto/link.log for details."
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
63 rm -f auto/link.log
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
64 fi
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
65 echo "s/-l$libname *//" >link1.sed
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
66 sed -f auto/link.sed <link.cmd >linkit2.sh
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
67 sed -f link1.sed <linkit2.sh >linkit.sh
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
68 # keep the last -lm
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
69 if test $libname != "m" || grep "lm " linkit.sh >/dev/null; then
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
70 echo "link.sh: Trying to omit the $libname library..."
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
71 cat linkit.sh >>auto/link.log
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
72 # Redirect this link output, it may contain error messages which
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
73 # should be ignored.
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
74 if sh linkit.sh >>auto/link.log 2>&1; then
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
75 echo "link.sh: Vim doesn't need the $libname library!"
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
76 cat link1.sed >>auto/link.sed
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
77 rm -f auto/pathdef.c
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
78 else
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
79 echo "link.sh: Vim DOES need the $libname library."
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
80 cont=
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
81 cp link.cmd linkit.sh
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
82 fi
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
83 else
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
84 cont=
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
85 cp link.cmd linkit.sh
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
86 fi
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
87 else
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
88 cont=
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
89 cp link.cmd linkit.sh
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
90 fi
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
91 done
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
92 done
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
93 if test ! -f auto/pathdef.c; then
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
94 $MAKE objects/pathdef.o
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
95 fi
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
96 if test ! -f link1.sed; then
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
97 echo "link.sh: Linked fine, no libraries can be omitted"
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
98 touch link3.sed
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
99 fi
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
100 else
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
101 exit_value=$?
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
102 fi
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
103 fi
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
104
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
105 #
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
106 # Now do the real linking.
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
107 #
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
108 if test -s auto/link.sed; then
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
109 echo "link.sh: Using auto/link.sed file to omit a few libraries"
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
110 sed -f auto/link.sed <link.cmd >linkit.sh
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
111 cat linkit.sh
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
112 if sh linkit.sh; then
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
113 exit_value=0
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
114 echo "link.sh: Linked fine with a few libraries omitted"
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
115 else
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
116 exit_value=$?
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
117 echo "link.sh: Linking failed, making auto/link.sed empty and trying again"
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
118 mv -f auto/link.sed link2.sed
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
119 touch auto/link.sed
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
120 rm -f auto/pathdef.c
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
121 $MAKE objects/pathdef.o
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
122 fi
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
123 fi
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
124 if test -f auto/link.sed -a ! -s auto/link.sed -a ! -f link3.sed; then
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
125 echo "link.sh: Using unmodified link command"
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
126 cat link.cmd
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
127 if sh link.cmd; then
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
128 exit_value=0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
129 echo "link.sh: Linked OK"
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
130 else
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
131 exit_value=$?
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
132 if test -f link2.sed; then
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
133 echo "link.sh: Linking doesn't work at all, removing auto/link.sed"
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
134 rm -f auto/link.sed
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
135 fi
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
136 fi
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
137 fi
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
138
39
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
139 fi
c16898406ff2 synchorinize version 7.3.081
one@zeus.cr.ie.u-ryukyu.ac.jp
parents: 0
diff changeset
140
0
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
141 #
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
142 # cleanup
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
143 #
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
144 rm -f link.cmd linkit.sh link1.sed link2.sed link3.sed linkit2.sh
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
145
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
146 #
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
147 # return an error code if something went wrong
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
148 #
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
149 exit $exit_value
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
150
76efa0be13f1 Initial revision
atsuki
parents:
diff changeset
151 # vim:set sw=2 et: