Commit | Line | Data |
---|---|---|
33a01fd2 | 1 | ?RCS: $Id$ |
d8875586 MBT |
2 | ?RCS: |
3 | ?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi | |
cf39bd7e | 4 | ?RCS: |
33a01fd2 | 5 | ?RCS: You may redistribute only under the terms of the Artistic License, |
d8875586 MBT |
6 | ?RCS: as specified in the README file that comes with the distribution. |
7 | ?RCS: You may reuse parts of this distribution only within the terms of | |
33a01fd2 | 8 | ?RCS: that same Artistic License; a copy of which may be found at the root |
d8875586 MBT |
9 | ?RCS: of the source tree for dist 4.0. |
10 | ?RCS: | |
11 | ?RCS: $Log: libs.U,v $ | |
12 | ?RCS: Revision 3.0.1.6 1997/02/28 16:09:11 ram | |
13 | ?RCS: patch61: replaced .a with $_a all over the place | |
14 | ?RCS: | |
15 | ?RCS: Revision 3.0.1.5 1995/07/25 14:12:05 ram | |
16 | ?RCS: patch56: now knows about OS/2 platforms | |
17 | ?RCS: | |
18 | ?RCS: Revision 3.0.1.4 1994/10/29 16:24:22 ram | |
19 | ?RCS: patch36: removed old broken thislib/thatlib processing (ADO) | |
20 | ?RCS: | |
21 | ?RCS: Revision 3.0.1.3 1994/06/20 07:05:44 ram | |
22 | ?RCS: patch30: code cleanup with if/elif by ADO and RAM | |
23 | ?RCS: patch30: undone patch23 for libswanted default setting | |
24 | ?RCS: | |
25 | ?RCS: Revision 3.0.1.2 1994/05/06 15:08:45 ram | |
26 | ?RCS: patch23: now includes ordered default libswanted variable (ADO) | |
27 | ?RCS: patch23: major cleanup for library lookups (ADO) | |
28 | ?RCS: | |
29 | ?RCS: Revision 3.0.1.1 1993/08/25 14:02:31 ram | |
30 | ?RCS: patch6: added default for libs | |
31 | ?RCS: | |
32 | ?RCS: Revision 3.0 1993/08/18 12:09:03 ram | |
33 | ?RCS: Baseline for dist 3.0 netwide release. | |
34 | ?RCS: | |
35 | ?MAKE:libs libsfound libsfiles libsdirs libspath libscheck: \ | |
36 | test cat Myread Oldconfig Loc libpth package xlibpth so _a \ | |
37 | +usesocks sed +cc +ccflags +ldflags rm | |
38 | ?MAKE: -pick add $@ %< | |
39 | ?S:libs: | |
40 | ?S: This variable holds the additional libraries we want to use. | |
41 | ?S: It is up to the Makefile to deal with it. The list can be empty. | |
42 | ?S:. | |
43 | ?S:libsfound: | |
44 | ?S: This variable holds the full pathnames of the libraries | |
45 | ?S: we found and accepted. | |
46 | ?S:. | |
47 | ?S:libsfiles: | |
48 | ?S: This variable holds the filenames aka basenames of the libraries | |
49 | ?S: we found and accepted. | |
50 | ?S:. | |
51 | ?S:libsdirs: | |
52 | ?S: This variable holds the directory names aka dirnames of the libraries | |
53 | ?S: we found and accepted, duplicates are removed. | |
54 | ?S:. | |
55 | ?S:libspath: | |
56 | ?S: This variable holds the directory names probed for libraries. | |
57 | ?S:. | |
58 | ?S:libscheck: | |
59 | ?S: This variable is intended to be set by hint files, if needed. | |
60 | ?S: It should contain shell code that will be eval'ed with $xxx holding | |
61 | ?S: some library file. It may change $xxx if needed. | |
62 | ?S: For instance, on an Irix platform, you may make sure the right | |
63 | ?S: library file is used depending on the cc command line, so that the | |
64 | ?S: correct library is used depending on the selected ABI (for 32 and | |
65 | ?S: 64-bit compilations). | |
cf39bd7e | 66 | ?S: |
d8875586 MBT |
67 | ?S: Here is an example of code that could be found in a hint file on Irix |
68 | ?S: when the selected compiler was for 32-bit -- that code is put in the | |
69 | ?S: cc.cbu call-back unit to be invoked AFTER the C compiler and its | |
70 | ?S: flags have been chosen: | |
cf39bd7e | 71 | ?S: |
d8875586 MBT |
72 | ?S: libscheck='case "$xxx" in |
73 | ?S: *.a) /bin/ar p $xxx `/bin/ar t $xxx | sed q` >$$.o; | |
74 | ?S: case "`/usr/bin/file $$.o`" in | |
cf39bd7e | 75 | ?S: *N32*) rm -f $$.o ;; |
d8875586 MBT |
76 | ?S: *) rm -f $$.o; xxx=/no/n32$xxx ;; |
77 | ?S: esac ;; | |
78 | ?S: *) case "`/usr/bin/file $xxx`" in | |
79 | ?S: *N32*) ;; | |
80 | ?S: *) xxx=/no/n32$xxx ;; | |
81 | ?S: esac ;; | |
82 | ?S: esac' | |
83 | ?S:. | |
84 | ?D:libs='' | |
85 | ?LINT:extern libswanted | |
86 | ?LINT:change libswanted | |
87 | ?INIT:: default library list | |
88 | ?INIT:libswanted='' | |
89 | ?X: This order is chosen so that libraries -lndir, -ldir, -lucb, -lbsd, | |
90 | ?X: -lBSD, -lPW, and -lx only get used if there are unresolved | |
91 | ?X: routines at link time. Usually, these are backwards compatability | |
92 | ?X: libraries, and may not be as reliable as the standard c library. | |
93 | ?X: | |
94 | ?X: The -lsocket -linet -lnsl order has been reported to be necessary | |
95 | ?X: for at least one SVR4 implementation. | |
96 | ?X: -lc must proceed -lucb or -lbsd for most Solaris applications. | |
97 | ?X: -lc_s proceeds -lc so we pick up the shared library version, if | |
98 | ?X: it is available. | |
99 | ?X: | |
100 | ?X: The ordering of c, posix, and cposix is a guess and almost | |
101 | ?X: certainly wrong on about half of all systems. | |
102 | ?X: | |
103 | ?X: Set proper libswanted in your private Myinit.U if needed. | |
104 | ?X: | |
105 | ?X:: default ordered library list | |
106 | ?X:libswanted='net socket inet bind nsl nm sdbm gdbm ndbm dbm malloc dl' | |
107 | ?X:libswanted="$libswanted dld sun m c_s c posix cposix ndir dir ucb" | |
108 | ?X:libswanted="$libswanted bsd BSD PW x" | |
109 | ?X: | |
110 | ?INIT:: should be set by hint files if needed | |
111 | ?INIT:libscheck='' | |
112 | ?T:xxx yyy thislib thisdir libstyle linkmsg | |
113 | ?F:lt.c lt | |
114 | : Looking for optional libraries | |
115 | echo " " | |
116 | echo "Checking for optional libraries..." >&4 | |
117 | case "$libs" in | |
118 | ' '|'') dflt='';; | |
119 | *) dflt="$libs";; | |
120 | esac | |
121 | case "$libswanted" in | |
122 | '') libswanted='c_s';; | |
123 | esac | |
124 | ?X: libsocks has nasty naming scheme. | |
cf39bd7e | 125 | ?X: This does not work if somebody wants SOCKS 4. |
d8875586 MBT |
126 | case "$usesocks" in |
127 | "$define") libswanted="$libswanted socks5 socks5_sh" ;; | |
128 | esac | |
129 | ?X: Used later for link checks | |
130 | echo "extern char printf(); int main() { printf(); return 0; }" > lt.c | |
131 | libsfound='' | |
132 | libsfiles='' | |
133 | libsdirs='' | |
134 | libspath='' | |
135 | for thisdir in $libpth $xlibpth; do | |
136 | test -d $thisdir && libspath="$libspath $thisdir" | |
137 | done | |
138 | for thislib in $libswanted; do | |
139 | for thisdir in $libspath; do | |
140 | xxx='' | |
141 | if $test ! -f "$xxx" ; then | |
142 | xxx=`ls $thisdir/lib$thislib.$so.[0-9]* 2>/dev/null | $sed -n '1p'` | |
143 | $test -f "$xxx" && eval $libscheck | |
144 | $test -f "$xxx" && libstyle=shared | |
145 | fi | |
146 | if test ! -f "$xxx"; then | |
147 | xxx=$thisdir/lib$thislib.$so | |
148 | $test -f "$xxx" && eval $libscheck | |
149 | $test -f "$xxx" && libstyle=shared | |
150 | fi | |
151 | if test ! -f "$xxx"; then | |
152 | xxx=$thisdir/lib$thislib$_a | |
153 | $test -f "$xxx" && eval $libscheck | |
154 | $test -f "$xxx" && libstyle=static | |
155 | fi | |
156 | if test ! -f "$xxx"; then | |
157 | xxx=$thisdir/$thislib$_a | |
158 | $test -f "$xxx" && eval $libscheck | |
159 | $test -f "$xxx" && libstyle=static | |
160 | fi | |
161 | if test ! -f "$xxx"; then | |
162 | xxx=$thisdir/lib${thislib}_s$_a | |
163 | $test -f "$xxx" && eval $libscheck | |
164 | $test -f "$xxx" && libstyle=static | |
165 | $test -f "$xxx" && thislib=${thislib}_s | |
166 | fi | |
167 | if test ! -f "$xxx"; then | |
168 | xxx=$thisdir/Slib$thislib$_a | |
169 | $test -f "$xxx" && eval $libscheck | |
170 | $test -f "$xxx" && libstyle=static | |
171 | fi | |
172 | if $test -f "$xxx"; then | |
173 | ?X: | |
174 | ?X: It is not sufficient to find a .so on the disk. We must make sure | |
175 | ?X: that we can indeed supply the -lfoo line on the cc line to link against | |
176 | ?X: that library. On Linux for instance, a versionned .so will not be | |
177 | ?X: implicitly linked against, whereas it will work fine on Solaris 2.6. | |
178 | ?X: --RAM, 10/10/2003 | |
179 | ?X: | |
180 | if $cc -o lt $ccflags $ldflags lt.c -l$thislib >/dev/null 2>&1; | |
181 | then | |
182 | linkmsg="" | |
183 | else | |
184 | linkmsg=" but I can't link against it" | |
185 | fi | |
186 | case "$libstyle" in | |
187 | shared) echo "Found -l$thislib (shared)$linkmsg." ;; | |
188 | static) echo "Found -l$thislib$linkmsg." ;; | |
189 | *) echo "Found -l$thislib ($libstyle)$linkmsg." ;; | |
190 | esac | |
191 | case " $dflt " in | |
192 | *"-l$thislib "*) ;; | |
193 | *) | |
194 | case "$linkmsg" in | |
195 | '') | |
196 | dflt="$dflt -l$thislib" | |
197 | libsfound="$libsfound $xxx" | |
198 | yyy=`basename $xxx` | |
199 | libsfiles="$libsfiles $yyy" | |
200 | yyy=`echo $xxx|$sed -e "s%/$yyy\\$%%"` | |
201 | case " $libsdirs " in | |
202 | *" $yyy "*) ;; | |
203 | *) libsdirs="$libsdirs $yyy" ;; | |
204 | esac | |
205 | ;; | |
206 | esac | |
207 | ;; | |
208 | esac | |
209 | break | |
210 | fi | |
211 | done | |
212 | if $test ! -f "$xxx"; then | |
213 | echo "No -l$thislib." | |
214 | fi | |
215 | done | |
216 | set X $dflt | |
217 | shift | |
218 | dflt="$*" | |
219 | case "$libs" in | |
220 | '') dflt="$dflt";; | |
221 | *) dflt="$libs";; | |
222 | esac | |
223 | case "$dflt" in | |
224 | ' '|'') dflt='none';; | |
225 | esac | |
226 | $rm -f lt.c lt | |
227 | ||
228 | $cat <<EOM | |
229 | ||
230 | In order to compile $package on your machine, a number of libraries | |
231 | are usually needed. Include any other special libraries here as well. | |
232 | Say "none" for none. The default list is almost always right. | |
233 | EOM | |
234 | ||
235 | echo " " | |
236 | rp="Which libraries to use?" | |
237 | . ./myread | |
238 | case "$ans" in | |
239 | none) libs=' ';; | |
240 | *) libs="$ans";; | |
241 | esac | |
242 |