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