annotate src/link.sh @ 2611:5b154df6fcd8 v7.3.033

updated for version 7.3.033 Problem: Can't build without FEAT_LOCALMAP. Solution: Add an #ifdef. (John Marriott)
author Bram Moolenaar <bram@vim.org>
date Fri, 22 Oct 2010 22:13:52 +0200
parents 454f314d0e61
children 1ccc1ace9e5b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
1 #! /bin/sh
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
2 #
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
3 # link.sh -- try linking Vim with different sets of libraries, finding the
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
4 # minimal set for fastest startup. The problem is that configure adds a few
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
5 # libraries when they exist, but this doesn't mean they are needed for Vim.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
6 #
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
7 # Author: Bram Moolenaar
1125
96cd8222a819 updated for version 7.1a
vimboss
parents: 137
diff changeset
8 # Last change: 2006 Sep 26
96cd8222a819 updated for version 7.1a
vimboss
parents: 137
diff changeset
9 # License: Public domain
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
10 #
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
11 # Warning: This fails miserably if the linker doesn't return an error code!
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
12 #
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
13 # Otherwise this script is fail-safe, falling back to the original full link
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
14 # command if anything fails.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
15
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
16 echo "$LINK " >link.cmd
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
17 exit_value=0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
18
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
19 #
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
20 # If auto/link.sed already exists, use it. We assume a previous run of
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
21 # link.sh has found the correct set of libraries.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
22 #
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
23 if test -f auto/link.sed; then
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
24 echo "link.sh: The file 'auto/link.sed' exists, which is going to be used now."
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
25 echo "link.sh: If linking fails, try deleting the auto/link.sed file."
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
26 echo "link.sh: If this fails too, try creating an empty auto/link.sed file."
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
27 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
28
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
29 # If linking works with the full link command, try removing some libraries,
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
30 # that are known not to be needed on at least one system.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
31 # Remove auto/pathdef.c if there is a new link command and compile it again.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
32 # There is a loop to remove libraries that appear several times.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
33 #
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
34 # Notes:
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
35 # - Can't remove Xext; It links fine but will give an error when running gvim
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
36 # with Motif.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
37 # - Don't remove the last -lm: On HP-UX Vim links OK but crashes when the GTK
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
38 # GUI is started, because the "floor" symbol could not be resolved.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
39 #
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
40 cat link.cmd
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
41 if sh link.cmd; then
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
42 touch auto/link.sed
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
43 cp link.cmd linkit.sh
2370
454f314d0e61 Make it possible to load Perl dynamically on Unix. (James Vega)
Bram Moolenaar <bram@vim.org>
parents: 2196
diff changeset
44 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
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
45 cont=yes
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
46 while test -n "$cont"; do
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
47 if grep "l$libname " linkit.sh >/dev/null; then
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
48 if test ! -f link1.sed; then
2196
99e5a139e67a Change wording in link.sh: "remove" -> "omit"
Bram Moolenaar <bram@vim.org>
parents: 1125
diff changeset
49 echo "link.sh: OK, linking works, let's try omitting a few libraries."
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
50 echo "link.sh: See auto/link.log for details."
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
51 rm -f auto/link.log
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
52 fi
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
53 echo "s/-l$libname *//" >link1.sed
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
54 sed -f auto/link.sed <link.cmd >linkit2.sh
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
55 sed -f link1.sed <linkit2.sh >linkit.sh
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
56 # keep the last -lm
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
57 if test $libname != "m" || grep "lm " linkit.sh >/dev/null; then
2196
99e5a139e67a Change wording in link.sh: "remove" -> "omit"
Bram Moolenaar <bram@vim.org>
parents: 1125
diff changeset
58 echo "link.sh: Trying to omit the $libname library..."
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
59 cat linkit.sh >>auto/link.log
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
60 # Redirect this link output, it may contain error messages which
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
61 # should be ignored.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
62 if sh linkit.sh >>auto/link.log 2>&1; then
2196
99e5a139e67a Change wording in link.sh: "remove" -> "omit"
Bram Moolenaar <bram@vim.org>
parents: 1125
diff changeset
63 echo "link.sh: Vim doesn't need the $libname library!"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
64 cat link1.sed >>auto/link.sed
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
65 rm -f auto/pathdef.c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
66 else
2196
99e5a139e67a Change wording in link.sh: "remove" -> "omit"
Bram Moolenaar <bram@vim.org>
parents: 1125
diff changeset
67 echo "link.sh: Vim DOES need the $libname library."
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
68 cont=
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
69 cp link.cmd linkit.sh
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
70 fi
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
71 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
72 cont=
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
73 cp link.cmd linkit.sh
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
74 fi
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
75 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
76 cont=
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
77 cp link.cmd linkit.sh
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
78 fi
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
79 done
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
80 done
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
81 if test ! -f auto/pathdef.c; then
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
82 $MAKE objects/pathdef.o
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
83 fi
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
84 if test ! -f link1.sed; then
2196
99e5a139e67a Change wording in link.sh: "remove" -> "omit"
Bram Moolenaar <bram@vim.org>
parents: 1125
diff changeset
85 echo "link.sh: Linked fine, no libraries can be omitted"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
86 touch link3.sed
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
87 fi
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
88 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
89 exit_value=$?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
90 fi
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
91 fi
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
92
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
93 #
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
94 # Now do the real linking.
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
95 #
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
96 if test -s auto/link.sed; then
2196
99e5a139e67a Change wording in link.sh: "remove" -> "omit"
Bram Moolenaar <bram@vim.org>
parents: 1125
diff changeset
97 echo "link.sh: Using auto/link.sed file to omit a few libraries"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
98 sed -f auto/link.sed <link.cmd >linkit.sh
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
99 cat linkit.sh
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
100 if sh linkit.sh; then
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
101 exit_value=0
2196
99e5a139e67a Change wording in link.sh: "remove" -> "omit"
Bram Moolenaar <bram@vim.org>
parents: 1125
diff changeset
102 echo "link.sh: Linked fine with a few libraries omitted"
7
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
103 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
104 exit_value=$?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
105 echo "link.sh: Linking failed, making auto/link.sed empty and trying again"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
106 mv -f auto/link.sed link2.sed
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
107 touch auto/link.sed
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
108 rm -f auto/pathdef.c
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
109 $MAKE objects/pathdef.o
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
110 fi
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
111 fi
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
112 if test -f auto/link.sed -a ! -s auto/link.sed -a ! -f link3.sed; then
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
113 echo "link.sh: Using unmodified link command"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
114 cat link.cmd
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
115 if sh link.cmd; then
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
116 exit_value=0
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
117 echo "link.sh: Linked OK"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
118 else
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
119 exit_value=$?
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
120 if test -f link2.sed; then
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
121 echo "link.sh: Linking doesn't work at all, removing auto/link.sed"
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
122 rm -f auto/link.sed
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
123 fi
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
124 fi
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
125 fi
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
126
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
127 #
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
128 # cleanup
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
129 #
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
130 rm -f link.cmd linkit.sh link1.sed link2.sed link3.sed linkit2.sh
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
131
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
132 #
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
133 # return an error code if something went wrong
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
134 #
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
135 exit $exit_value
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
136
3fc0f57ecb91 updated for version 7.0001
vimboss
parents:
diff changeset
137 # vim:set sw=2 et: