Add a suffix for Darwin's sake, since it seems like .dylib comes after
[openssl.git] / Makefile.shared
1 #
2 # Helper makefile to link shared libraries in a portable way.
3 # This is much simpler than libtool, and hopefully not too error-prone.
4 #
5 # The following variables need to be set on the command line to build
6 # properly
7
8 # CC contains the current compiler.  This one MUST be defined
9 CC=cc
10 # LDFLAGS contains flags to be used when the temporary object file is
11 # created.  SHARED_LDFLAGS contains flags to be used when the shared
12 # library is created.
13 LDFLAGS=
14 SHARED_LDFLAGS=
15
16 # LIBNAME contains just the name of thhe library, without prefix ("lib"
17 # on Unix, "cyg" for certain forms under Cygwin...) or suffix (.a, .so,
18 # .dll, ...).  This one MUST have a value when using this makefile.
19 # For example, to build libfoo.so, you need to do the following:
20 #LIBNAME=foo
21 LIBNAME=
22
23 # LIBEXTRAS contains extra modules to link together with the library.
24 # For example, if a seond library, say libbar.a needs to be linked into
25 # libfoo.so, you need to do the following:
26 #LIBEXTRAS=libbar.a
27 # Note that this MUST be used when using the link_o targets, to hold the
28 # names of all object files that go into the target library.
29 LIBEXTRAS=
30
31 # LIBVERSION contains the current version of the library.
32 # For example, to build libfoo.so.1.2, you need to do the following:
33 #LIBVERSION=1.2
34 LIBVERSION=
35
36 # LIBCOMPATVERSIONS contains the compatibility versions (a list) of
37 # the library.  They MUST be in decreasing order.
38 # For example, if libfoo.so.1.2.1 is backward compatible with libfoo.so.1.2
39 # and libfoo.so.1, you need to do the following:
40 #LIBCOMPATVERSIONS=1.2 1
41 # Note that on systems that use sonames, the last number will appear as
42 # part of it.
43 # It's also possible, for systems that support it (Tru64, for example),
44 # to add extra compatibility info with more precision, by adding a second
45 # list of versions, separated from the first with a semicolon, like this:
46 #LIBCOMPATVERSIONS=1.2 1;1.2.0 1.1.2 1.1.1 1.1.0 1.0.0
47 LIBCOMPATVERSIONS=
48
49 # LIBDEPS contains all the flags necessary to cover all necessary
50 # dependencies to other libraries.
51 LIBDEPS=
52
53 #------------------------------------------------------------------------------
54 # The rest is private to this makefile.
55
56 #DEBUG=:
57 DEBUG=set -x
58
59 top:
60         echo "Trying to use this makefile interactively?  Don't."
61
62 CALC_VERSIONS=  \
63         SHLIB_COMPAT=; SHLIB_SOVER=; \
64         if [ -n "$(LIBVERSION) $(LIBCOMPATVERSIONS)" ]; then \
65                 prev=""; \
66                 for v in `echo "$(LIBVERSION) $(LIBCOMPATVERSIONS)" | cut -d';' -f1`; do \
67                         SHLIB_SOVER=.$$v; \
68                         if [ -n "$$prev" ]; then \
69                                 SHLIB_COMPAT=$$SHLIB_COMPAT .$$prev; \
70                         fi; \
71                         prev=$$v; \
72                 done; \
73         fi
74
75 LINK_SO=        \
76   ( $(DEBUG); \
77     nm -Pg $$SHOBJECTS | grep ' [BDT] ' | cut -f1 -d' ' > lib$(LIBNAME).exp; \
78     $$SHAREDCMD $(SHARED_LDFLAGS) $$SHAREDFLAGS -o $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \
79         $$ALLSYMSFLAGS $$SHOBJECTS $$NOALLSYMSFLAGS $$LIBDEPS ) && \
80   $(SYMLINK_SO); ( $(DEBUG); rm -f lib$(LIBNAME).exp )
81 SYMLINK_SO=     \
82         if [ -n "$$SHLIB_COMPAT"]; then \
83                 prev=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \
84                 for x in $$SHLIB_COMPAT; do \
85                         ( $(DEBUG); rm -f $$SHLIB$$x$$SHLIB_SUFFIX; \
86                           ln -s $$prev $$SHLIB$$x$$SHLIB_SUFFIX ); \
87                         prev=$$SHLIB$$x$$SHLIB_SUFFIX; \
88                 done; \
89         fi
90 LINK_SO_A=      SHOBJECTS="lib$(LIBNAME).a $(LIBEXTRAS)"; $(LINK_SO)
91 LINK_SO_O=      SHOBJECTS="$(LIBEXTRAS)"; $(LINK_SO)
92 LINK_SO_A_VIA_O=        \
93   SHOBJECTS=lib$(LIBNAME).o ALL=$$ALLSYMSFLAGS ALLSYMSFLAGS= NOALLSYMSFLAGS=; \
94   ( $(DEBUG); \
95     ld $(LDFLAGS) -r -o lib$(LIBNAME).o $$ALL lib$(LIBNAME).a $(LIBEXTRAS) ); \
96   $(LINK_SO) && rm -f $(LIBNAME).o
97 LINK_SO_A_UNPACKED=     \
98   UNPACKDIR=link_tmp.$$$$; rm -rf $$UNPACKDIR; mkdir $$UNPACKDIR; \
99   (cd $$UNPACKDIR; ar x ../lib$(LIBNAME).a) && cp $(LIBEXTRAS) $$UNPACKDIR && \
100   SHOBJECTS=$$UNPACKDIR/*.o; \
101   $(LINK_SO) && rm -rf $$UNPACKDIR
102
103 DETECT_GNU_LD=${CC} -v 2>&1 | grep '^gcc' >/dev/null 2>&1 && \
104         my_ld=`gcc -print-prog-name=ld 2>&1` && \
105         [ -n "$$my_ld" ] && \
106         $$my_ld -v 2>&1 | grep 'GNU ld' >/dev/null 2>&1
107
108 link_o.gnu:
109         @ $(CALC_VERSIONS); \
110         SHLIB=lib$(LIBNAME).so \
111         SHLIB_SUFFIX= \
112         LIBDEPS="$(LIBDEPS)" \
113         NOALLSYMSFLAGS='-Wl,--no-whole-archive' \
114         SHAREDFLAGS="-shared -Wl,-Bsymbolic -Wl,-soname=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX" \
115         SHAREDCMD='$(CC)'; \
116         $(LINK_SO_O)
117 link_a.gnu:
118         @ $(CALC_VERSIONS); \
119         SHLIB=lib$(LIBNAME).so \
120         SHLIB_SUFFIX= \
121         LIBDEPS="$(LIBDEPS)" \
122         ALLSYMSFLAGS='-Wl,--whole-archive' \
123         NOALLSYMSFLAGS='-Wl,--no-whole-archive' \
124         SHAREDFLAGS="-shared -Wl,-Bsymbolic -Wl,-soname=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX" \
125         SHAREDCMD='$(CC)'; \
126         $(LINK_SO_A)
127
128 # For Darwin AKA Mac OS/X (dyld)
129 link_o.darwin:
130         @ $(CALC_VERSIONS); \
131         SHLIB=lib$(LIBNAME) \
132         SHLIB_SUFFIX=.dylib \
133         LIBDEPS="$(LIBDEPS)" \
134         ALLSYMSFLAGS='-all_load' \
135         NOALLSYMSFLAGS='' \
136         SHAREDFLAGS="-current_version $(LIBVERSION) -compatibility_version $$SHLIB_SOVER" \
137         SHAREDCMD='$(CC)'; \
138         $(LINK_SO_O)
139 link_a.darwin:
140         @ $(CALC_VERSIONS); \
141         SHLIB=lib$(LIBNAME)$$SHLIB_SOVER.dylib \
142         SHLIB_SUFFIX=.dylib \
143         LIBDEPS="$(LIBDEPS)" \
144         ALLSYMSFLAGS='-all_load' \
145         NOALLSYMSFLAGS='' \
146         SHAREDFLAGS="-dynamiclib -current_version $(LIBVERSION) -compatibility_version $$SHLIB_SOVER" \
147         SHAREDCMD='$(CC)'; \
148         $(LINK_SO_A)
149
150 link_o.cygwin:
151         @ SHLIB=cyg$(LIBNAME).dll \
152         SHLIB_SUFFIX= \
153         LIBDEPS="$(LIBDEPS)" \
154         SHLIB_SOVER= \
155         ALLSYMSFLAGS='-Wl,--whole-archive' \
156         NOALLSYMSFLAGS='-Wl,--no-whole-archive' \
157         SHAREDFLAGS="-shared -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a" \
158         SHAREDCMD='${CC}'; \
159         $(LINK_SO_O)
160 link_a.cygwin:
161         @ SHLIB=cyg$(LIBNAME).dll \
162         SHLIB_SUFFIX= \
163         LIBDEPS="$(LIBDEPS)" \
164         SHLIB_SOVER= \
165         ALLSYMSFLAGS='-Wl,--whole-archive' \
166         NOALLSYMSFLAGS='-Wl,--no-whole-archive' \
167         SHAREDFLAGS="-shared -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a" \
168         SHAREDCMD='${CC}'; \
169         $(LINK_SO_A)
170
171 link_o.alpha-osf1:
172         @ if ${DETECT_GNU_LD}; then \
173                 $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
174                         SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
175                         LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
176                         LIBVERSION="$(LIBVERSION)"
177                         LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
178                         LIBDEPS="$(LIBDEPS)" link_o.gnu; \
179         else \
180                 SHLIB=lib$(LIBNAME).so \
181                 SHLIB_SUFFIX= \
182                 LIBDEPS="$(LIBDEPS)" \
183                 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
184                 if [ -n "$$SHLIB_HIST" ]; then \
185                         SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
186                 else \
187                         SHLIB_HIST="$(LIBVERSION)"; \
188                 fi
189                 SHLIB_SOVER= \
190                 ALLSYMSFLAGS='-all' \
191                 NOALLSYMSFLAGS='-none' \
192                 SHAREDFLAGS="-shared -set_version \"$$SHLIB_HIST\"" \
193                 SHAREDCMD='$(CC)'; \
194                 $(LINK_SO_O); \
195         fi
196 link_a.alpha-osf1:
197         @ if ${DETECT_GNU_LD}; then \
198                 $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
199                         SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
200                         LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
201                         LIBVERSION="$(LIBVERSION)"
202                         LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
203                         LIBDEPS="$(LIBDEPS)" link_o.gnu; \
204         else \
205                 SHLIB=lib$(LIBNAME).so \
206                 SHLIB_SUFFIX= \
207                 LIBDEPS="$(LIBDEPS)" \
208                 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
209                 if [ -n "$$SHLIB_HIST" ]; then \
210                         SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
211                 else \
212                         SHLIB_HIST="$(LIBVERSION)"; \
213                 fi
214                 SHLIB_SOVER= \
215                 ALLSYMSFLAGS='-all' \
216                 NOALLSYMSFLAGS='-none' \
217                 SHAREDFLAGS="-shared -set_version \"$$SHLIB_HIST\"" \
218                 SHAREDCMD='$(CC)'; \
219                 $(LINK_SO_A); \
220         fi
221
222 # The difference between alpha-osf1-shared and tru64-shared is the `-msym'
223 # option passed to the linker.
224 link_o.tru64:
225         @ if ${DETECT_GNU_LD}; then \
226                 $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
227                         SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
228                         LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
229                         LIBVERSION="$(LIBVERSION)"
230                         LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
231                         LIBDEPS="$(LIBDEPS)" link_o.gnu; \
232         else \
233                 SHLIB=lib$(LIBNAME).so \
234                 SHLIB_SUFFIX= \
235                 LIBDEPS="$(LIBDEPS)" \
236                 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
237                 if [ -n "$$SHLIB_HIST" ]; then \
238                         SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
239                 else \
240                         SHLIB_HIST="$(LIBVERSION)"; \
241                 fi
242                 SHLIB_SOVER= \
243                 ALLSYMSFLAGS='-all' \
244                 NOALLSYMSFLAGS='-none' \
245                 SHAREDFLAGS="-shared -msym -set_version \"$$SHLIB_HIST\"" \
246                 SHAREDCMD='$(CC)'; \
247                 $(LINK_SO_O); \
248         fi
249 link_a.tru64:
250         @ if ${DETECT_GNU_LD}; then \
251                 $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
252                         SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
253                         LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
254                         LIBVERSION="$(LIBVERSION)"
255                         LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
256                         LIBDEPS="$(LIBDEPS)" link_o.gnu; \
257         else \
258                 SHLIB=lib$(LIBNAME).so \
259                 SHLIB_SUFFIX= \
260                 LIBDEPS="$(LIBDEPS)" \
261                 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
262                 if [ -n "$$SHLIB_HIST" ]; then \
263                         SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
264                 else \
265                         SHLIB_HIST="$(LIBVERSION)"; \
266                 fi
267                 SHLIB_SOVER= \
268                 ALLSYMSFLAGS='-all' \
269                 NOALLSYMSFLAGS='-none' \
270                 SHAREDFLAGS="-shared -msym -set_version \"$$SHLIB_HIST\"" \
271                 SHAREDCMD='$(CC)'; \
272                 $(LINK_SO_A); \
273         fi
274
275 # The difference between tru64-shared and tru64-shared-rpath is the
276 # -rpath ${LIBRPATH} passed to the linker.
277 link_o.tru64-rpath:
278         @ if ${DETECT_GNU_LD}; then \
279                 $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
280                         SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
281                         LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
282                         LIBVERSION="$(LIBVERSION)"
283                         LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
284                         LIBDEPS="$(LIBDEPS)" link_o.gnu; \
285         else \
286                 SHLIB=lib$(LIBNAME).so \
287                 SHLIB_SUFFIX= \
288                 LIBDEPS="$(LIBDEPS)" \
289                 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
290                 if [ -n "$$SHLIB_HIST" ]; then \
291                         SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
292                 else \
293                         SHLIB_HIST="$(LIBVERSION)"; \
294                 fi
295                 SHLIB_SOVER= \
296                 ALLSYMSFLAGS='-all' \
297                 NOALLSYMSFLAGS='-none' \
298                 SHAREDFLAGS="-shared -msym -rpath $(LIBRPATH) -set_version \"$$SHLIB_HIST\"" \
299                 SHAREDCMD='$(CC)'; \
300                 $(LINK_SO_O); \
301         fi
302 link_a.tru64-rpath:
303         @ if ${DETECT_GNU_LD}; then \
304                 $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
305                         SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
306                         LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
307                         LIBVERSION="$(LIBVERSION)"
308                         LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
309                         LIBDEPS="$(LIBDEPS)" link_o.gnu; \
310         else \
311                 SHLIB=lib$(LIBNAME).so \
312                 SHLIB_SUFFIX= \
313                 LIBDEPS="$(LIBDEPS)" \
314                 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
315                 if [ -n "$$SHLIB_HIST" ]; then \
316                         SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
317                 else \
318                         SHLIB_HIST="$(LIBVERSION)"; \
319                 fi
320                 SHLIB_SOVER= \
321                 ALLSYMSFLAGS='-all' \
322                 NOALLSYMSFLAGS='-none' \
323                 SHAREDFLAGS="-shared -msym -rpath $(LIBRPATH) -set_version \"$$SHLIB_HIST\"" \
324                 SHAREDCMD='$(CC)'; \
325                 $(LINK_SO_A); \
326         fi
327
328 link_o.solaris:
329         @ if ${DETECT_GNU_LD}; then \
330                 $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
331                         SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
332                         LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
333                         LIBVERSION="$(LIBVERSION)"
334                         LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
335                         LIBDEPS="$(LIBDEPS)" link_o.gnu; \
336         else \
337                 $(CALC_VERSIONS); \
338                 SHLIB=lib$(LIBNAME).so \
339                 SHLIB_SUFFIX= \
340                 LIBDEPS="$(LIBDEPS)" \
341                 ALLSYMSFLAGS='-z allextract' \
342                 NOALLSYMSFLAGS='' \
343                 SHAREDFLAGS='-G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
344                 SHAREDCMD='$(CC)'; \
345                 $(LINK_SO_O); \
346         fi
347 link_a.solaris:
348         @ if ${DETECT_GNU_LD}; then \
349                 $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
350                         SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
351                         LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
352                         LIBVERSION="$(LIBVERSION)"
353                         LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
354                         LIBDEPS="$(LIBDEPS)" link_o.gnu; \
355         else \
356                 $(CALC_VERSIONS); \
357                 SHLIB=lib$(LIBNAME).so \
358                 SHLIB_SUFFIX= \
359                 LIBDEPS="$(LIBDEPS)" \
360                 ALLSYMSFLAGS='-z allextract' \
361                 NOALLSYMSFLAGS='' \
362                 SHAREDFLAGS='-G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
363                 SHAREDCMD='$(CC)'; \
364                 $(LINK_SO_A); \
365         fi
366
367 # OpenServer 5 native compilers used
368 # UnixWare 7 and OpenUNIX 8 native compilers used
369 link_o.svr3:
370         @ if ${DETECT_GNU_LD}; then \
371                 $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
372                         SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
373                         LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
374                         LIBVERSION="$(LIBVERSION)"
375                         LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
376                         LIBDEPS="$(LIBDEPS)" link_o.gnu; \
377         else \
378                 $(CALC_VERSIONS); \
379                 SHLIB=lib$(LIBNAME).so \
380                 SHLIB_SUFFIX= \
381                 LIBDEPS="$(LIBDEPS)" \
382                 ALLSYMSFLAGS='-z allextract' \
383                 NOALLSYMSFLAGS='' \
384                 SHAREDFLAGS='-G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
385                 SHAREDCMD='$(CC)'; \
386                 $(LINK_SO_O); \
387         fi
388 link_a.svr3:
389         @ if ${DETECT_GNU_LD}; then \
390                 $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
391                         SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
392                         LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
393                         LIBVERSION="$(LIBVERSION)"
394                         LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
395                         LIBDEPS="$(LIBDEPS)" link_o.gnu; \
396         else \
397                 $(CALC_VERSIONS); \
398                 SHLIB=lib$(LIBNAME).so \
399                 SHLIB_SUFFIX= \
400                 LIBDEPS="$(LIBDEPS)" \
401                 ALLSYMSFLAGS='-z allextract' \
402                 NOALLSYMSFLAGS='' \
403                 SHAREDFLAGS='-G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
404                 SHAREDCMD='$(CC)'; \
405                 $(LINK_SO_A_UNPACKED); \
406         fi
407
408 link_o.irix:
409         @ if ${DETECT_GNU_LD}; then \
410                 $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
411                         SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
412                         LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
413                         LIBVERSION="$(LIBVERSION)"
414                         LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
415                         LIBDEPS="$(LIBDEPS)" link_o.gnu; \
416         else \
417                 $(CALC_VERSIONS); \
418                 SHLIB=lib$(LIBNAME).so \
419                 SHLIB_SUFFIX= \
420                 LIBDEPS="$(LIBDEPS)" \
421                 ALLSYMSFLAGS='-all' \
422                 NOALLSYMSFLAGS='' \
423                 SHAREDFLAGS='-shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
424                 SHAREDCMD='$(CC)'; \
425                 $(LINK_SO_O); \
426         fi
427 link_a.irix:
428         @ if ${DETECT_GNU_LD}; then \
429                 $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
430                         SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
431                         LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
432                         LIBVERSION="$(LIBVERSION)"
433                         LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
434                         LIBDEPS="$(LIBDEPS)" link_o.gnu; \
435         else \
436                 $(CALC_VERSIONS); \
437                 SHLIB=lib$(LIBNAME).so \
438                 SHLIB_SUFFIX= \
439                 LIBDEPS="$(LIBDEPS)" \
440                 ALLSYMSFLAGS='-all' \
441                 NOALLSYMSFLAGS='' \
442                 SHAREDFLAGS='-shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
443                 SHAREDCMD='$(CC)'; \
444                 $(LINK_SO_A); \
445         fi
446
447 # HP-UX includes the full pathname of libs we depend on, so we would get
448 # ./libcrypto (with ./ as path information) compiled into libssl, hence
449 # we omit the SHLIBDEPS. Applications must be linked with -lssl -lcrypto
450 # anyway.
451 # The object modules are loaded from lib$i.a using the undocumented -Fl
452 # option.
453 #
454 # WARNING: Until DSO is fixed to support a search path, we support SHLIB_PATH
455 #          by temporarily specifying "+s"!
456 #
457 link_o.hpux32:
458         @ $(CALC_VERSIONS); \
459         SHLIB=lib$(LIBNAME).sl \
460         SHLIB_SUFFIX= \
461         LIBDEPS="$(LIBDEPS) -lc" \
462         ALLSYMSFLAGS='-Fl' \
463         NOALLSYMSFLAGS='' \
464         SHAREDFLAGS='+vnocompatwarnings -b -z +s +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
465         SHAREDCMD='/usr/ccs/bin/ld'; \
466         $(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
467 link_a.hpux32:
468         @ $(CALC_VERSIONS); \
469         SHLIB=lib$(LIBNAME).sl \
470         SHLIB_SUFFIX= \
471         LIBDEPS="$(LIBDEPS) -lc" \
472         ALLSYMSFLAGS='-Fl' \
473         NOALLSYMSFLAGS='' \
474         SHAREDFLAGS='+vnocompatwarnings -b -z +s +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
475         SHAREDCMD='/usr/ccs/bin/ld'; \
476         $(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
477
478 # HP-UX includes the full pathname of libs we depend on, so we would get
479 # ./libcrypto (with ./ as path information) compiled into libssl, hence
480 # we omit the SHLIBDEPS. Applications must be linked with -lssl -lcrypto
481 # anyway.
482 #
483 # HP-UX in 64bit mode has "+s" enabled by default; it will search for
484 # shared libraries along LD_LIBRARY_PATH _and_ SHLIB_PATH.
485 #
486 link_o.hpux64:
487         @ $(CALC_VERSIONS); \
488         SHLIB=lib$(LIBNAME).sl \
489         SHLIB_SUFFIX= \
490         LIBDEPS="$(LIBDEPS) -lc" \
491         ALLSYMSFLAGS='+forceload' \
492         NOALLSYMSFLAGS='' \
493         SHAREDFLAGS='-b -z +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
494         SHAREDCMD='/usr/ccs/bin/ld'; \
495         $(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
496 link_a.hpux64:
497         @ $(CALC_VERSIONS); \
498         SHLIB=lib$(LIBNAME).sl \
499         SHLIB_SUFFIX= \
500         LIBDEPS="$(LIBDEPS) -lc" \
501         ALLSYMSFLAGS='+forceload' \
502         NOALLSYMSFLAGS='' \
503         SHAREDFLAGS='-b -z +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
504         SHAREDCMD='/usr/ccs/bin/ld'; \
505         $(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
506
507 link_o.aix:
508         @ $(CALC_VERSIONS); \
509         SHLIB=lib$(LIBNAME).so \
510         SHLIB_SUFFIX= \
511         LIBDEPS="$(LIBDEPS)" \
512         ALLSYMSFLAGS='-bnogc' \
513         NOALLSYMSFLAGS='' \
514         SHAREDFLAGS='-G -bE:lib$(LIBNAME).exp -bM:SRE' \
515         SHAREDCMD='$(CC)'; \
516         $(LINK_SO_O)
517 link_a.aix:
518         @ $(CALC_VERSIONS); \
519         SHLIB=lib$(LIBNAME).so \
520         SHLIB_SUFFIX= \
521         LIBDEPS="$(LIBDEPS)" \
522         ALLSYMSFLAGS='-bnogc' \
523         NOALLSYMSFLAGS='' \
524         SHAREDFLAGS='-G -bE:lib$(LIBNAME).exp -bM:SRE' \
525         SHAREDCMD='$(CC)'; \
526         $(LINK_SO_A_VIA_O)
527
528 link_o.reliantunix:
529         @ $(CALC_VERSIONS); \
530         SHLIB=lib$(LIBNAME).so \
531         SHLIB_SUFFIX= \
532         LIBDEPS="$(LIBDEPS)" \
533         ALLSYMSFLAGS= \
534         NOALLSYMSFLAGS='' \
535         SHAREDFLAGS='-G' \
536         SHAREDCMD='$(CC)'; \
537         $(LINK_SO_O)
538 link_a.reliantunix:
539         @ $(CALC_VERSIONS); \
540         SHLIB=lib$(LIBNAME).so \
541         SHLIB_SUFFIX= \
542         LIBDEPS="$(LIBDEPS)" \
543         ALLSYMSFLAGS= \
544         NOALLSYMSFLAGS='' \
545         SHAREDFLAGS='-G' \
546         SHAREDCMD='$(CC)'; \
547         $(LINK_SO_A_UNPACKED)
548
549 # Targets to build symbolic links when needed
550 symlink.gnu symlink.solaris symlink.svr3 symlink.irix \
551 symlink.aix symlink.reliantunix:
552         @ $(CALC_VERSIONS); \
553         SHLIB=lib$(LIBNAME).so \
554         $(SYMLINK_SO)
555 symlink.darwin:
556         @ $(CALC_VERSIONS); \
557         SHLIB=lib$(LIBNAME) \
558         SHLIB_SUFFIX=.dylib \
559         $(SYMLINK_SO)
560 symlink.cygwin symlib.alpha-osf1 symlink.tru64 symlink.tru64-rpath:
561 symlink.hpux32 symlink.hpux64:
562         @ $(CALC_VERSIONS); \
563         SHLIB=lib$(LIBNAME).sl \
564         $(SYMLINK_SO)
565
566 # Compatibility targets
567 link_o.bsd-gcc-shared link_o.linux-shared link_o.gnu-shared: link_o.gnu
568 link_a.bsd-gcc-shared link_a.linux-shared link_a.gnu-shared: link_a.gnu
569 symlink.bsd-gcc-shared symlink.linux-shared symlink.gnu-shared: symlink.gnu
570 link_o.darwin-shared: link_o.darwin
571 link_a.darwin-shared: link_a.darwin
572 symlink.darwin-shared: symlink.darwin
573 link_o.cygwin-shared: link_o.cygwin
574 link_a.cygwin-shared: link_a.cygwin
575 symlink.cygwin-shared: symlink.cygwin
576 link_o.alpha-osf1-shared: link_o.alpha-osf1
577 link_a.alpha-osf1-shared: link_a.alpha-osf1
578 symlink.alpha-osf1-shared: symlink.alpha-osf1
579 link_o.tru64-shared: link_o.tru64
580 link_a.tru64-shared: link_a.tru64
581 symlink.tru64-shared: symlink.tru64
582 link_o.tru64-shared-rpath: link_o.tru64-rpath
583 link_a.tru64-shared-rpath: link_a.tru64-rpath
584 symlink.tru64-shared-rpath: symlink.tru64-rpath
585 link_o.solaris-shared: link_o.solaris
586 link_a.solaris-shared: link_a.solaris
587 symlink.solaris-shared: symlink.solaris
588 link_o.svr3-shared: link_o.svr3
589 link_a.svr3-shared: link_a.svr3
590 symlink.svr3-shared: symlink.svr3
591 link_o.svr5-shared: link_o.svr3
592 link_a.svr5-shared: link_a.svr3
593 symlink.svr5-shared: symlink.svr3
594 link_o.irix-shared: link_o.irix
595 link_a.irix-shared: link_a.irix
596 symlink.irix-shared: symlink.irix
597 link_o.hpux-shared: link_o.hpux32
598 link_a.hpux-shared: link_a.hpux32
599 symlink.hpux-shared: symlink.hpux32
600 link_o.hpux64-shared: link_o.hpux64
601 link_a.hpux64-shared: link_a.hpux64
602 symlink.hpux64-shared: symlink.hpux64
603 link_o.aix-shared: link_o.aix
604 link_a.aix-shared: link_a.aix
605 symlink.aix-shared: symlink.aix
606 link_o.reliantunix-shared: link_o.reliantunix
607 link_a.reliantunix-shared: link_a.reliantunix
608 symlink.reliantunix-shared: symlink.reliantunix