Attempt to unify hpux-shared rules. More adjustments might be required
[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 temporary object files (when building
11 # shared libraries) are created, or when an application is linked.
12 # SHARED_LDFLAGS contains flags to be used when the shared library is created.
13 LDFLAGS=
14 SHARED_LDFLAGS=
15
16 # LIBNAME contains just the name of the 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 to
19 # build shared libraries.
20 # For example, to build libfoo.so, you need to do the following:
21 #LIBNAME=foo
22 LIBNAME=
23
24 # APPNAME contains just the name of the application, without suffix (""
25 # on Unix, ".exe" on Windows, ...).  This one MUST have a value when using
26 # this makefile to build applications.
27 # For example, to build foo, you need to do the following:
28 #APPNAME=foo
29 APPNAME=
30
31 # OBJECTS contains all the object files to link together into the application.
32 # This must contain at least one object file.
33 #OBJECTS=foo.o
34 OBJECTS=
35
36 # LIBEXTRAS contains extra modules to link together with the library.
37 # For example, if a second library, say libbar.a needs to be linked into
38 # libfoo.so, you need to do the following:
39 #LIBEXTRAS=libbar.a
40 # Note that this MUST be used when using the link_o targets, to hold the
41 # names of all object files that go into the target library.
42 LIBEXTRAS=
43
44 # LIBVERSION contains the current version of the library.
45 # For example, to build libfoo.so.1.2, you need to do the following:
46 #LIBVERSION=1.2
47 LIBVERSION=
48
49 # LIBCOMPATVERSIONS contains the compatibility versions (a list) of
50 # the library.  They MUST be in decreasing order.
51 # For example, if libfoo.so.1.2.1 is backward compatible with libfoo.so.1.2
52 # and libfoo.so.1, you need to do the following:
53 #LIBCOMPATVERSIONS=1.2 1
54 # Note that on systems that use sonames, the last number will appear as
55 # part of it.
56 # It's also possible, for systems that support it (Tru64, for example),
57 # to add extra compatibility info with more precision, by adding a second
58 # list of versions, separated from the first with a semicolon, like this:
59 #LIBCOMPATVERSIONS=1.2 1;1.2.0 1.1.2 1.1.1 1.1.0 1.0.0
60 LIBCOMPATVERSIONS=
61
62 # LIBDEPS contains all the flags necessary to cover all necessary
63 # dependencies to other libraries.
64 LIBDEPS=
65
66 #------------------------------------------------------------------------------
67 # The rest is private to this makefile.
68
69 #DEBUG=:
70 DEBUG=set -x
71
72 top:
73         echo "Trying to use this makefile interactively?  Don't."
74
75 CALC_VERSIONS=  \
76         SHLIB_COMPAT=; SHLIB_SOVER=; \
77         if [ -n "$(LIBVERSION)$(LIBCOMPATVERSIONS)" ]; then \
78                 prev=""; \
79                 for v in `echo "$(LIBVERSION) $(LIBCOMPATVERSIONS)" | cut -d';' -f1`; do \
80                         SHLIB_SOVER_NODOT=$$v; \
81                         SHLIB_SOVER=.$$v; \
82                         if [ -n "$$prev" ]; then \
83                                 SHLIB_COMPAT="$$SHLIB_COMPAT .$$prev"; \
84                         fi; \
85                         prev=$$v; \
86                 done; \
87         fi
88
89 LINK_APP=       \
90   ( $(DEBUG);   \
91     LIBPATH=`for x in $$LIBDEPS; do if echo $$x | grep '^ *-L' > /dev/null 2>&1; then echo $$x | sed -e 's/^ *-L//'; fi; done | uniq`; \
92     LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \
93     LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
94     $$LDCMD $(LDFLAGS) $$LDFLAGS -o $$APPNAME $(OBJECTS) $$LIBDEPS )
95
96 LINK_SO=        \
97   ( $(DEBUG);   \
98     nm -Pg $$SHOBJECTS | grep ' [BDT] ' | cut -f1 -d' ' > lib$(LIBNAME).exp; \
99     LIBPATH=`for x in $$LIBDEPS; do if echo $$x | grep '^ *-L' > /dev/null 2>&1; then echo $$x | sed -e 's/^ *-L//'; fi; done | uniq`; \
100     LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \
101     LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
102     $$SHAREDCMD $(SHARED_LDFLAGS) $$SHAREDFLAGS -o $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \
103         $$ALLSYMSFLAGS $$SHOBJECTS $$NOALLSYMSFLAGS $$LIBDEPS ) && \
104   $(SYMLINK_SO); ( $(DEBUG); rm -f lib$(LIBNAME).exp )
105 SYMLINK_SO=     \
106         if [ -n "$$INHIBIT_SYMLINKS" ]; then :; else \
107                 prev=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \
108                 if [ -n "$$SHLIB_COMPAT" ]; then \
109                         for x in $$SHLIB_COMPAT; do \
110                                 ( $(DEBUG); rm -f $$SHLIB$$x$$SHLIB_SUFFIX; \
111                                   ln -s $$prev $$SHLIB$$x$$SHLIB_SUFFIX ); \
112                                 prev=$$SHLIB$$x$$SHLIB_SUFFIX; \
113                         done; \
114                 fi; \
115                 if [ -n "$$SHLIB_SOVER" ]; then \
116                         ( $(DEBUG); rm -f $$SHLIB$$SHLIB_SUFFIX; \
117                           ln -s $$prev $$SHLIB$$SHLIB_SUFFIX ); \
118                 fi; \
119         fi
120
121 LINK_SO_A=      SHOBJECTS="lib$(LIBNAME).a $(LIBEXTRAS)"; $(LINK_SO)
122 LINK_SO_O=      SHOBJECTS="$(LIBEXTRAS)"; $(LINK_SO)
123 LINK_SO_A_VIA_O=        \
124   SHOBJECTS=lib$(LIBNAME).o; \
125   ALL=$$ALLSYMSFLAGS; ALLSYMSFLAGS=; NOALLSYMSFLAGS=; \
126   ( $(DEBUG); \
127     ld $(LDFLAGS) -r -o lib$(LIBNAME).o $$ALL lib$(LIBNAME).a $(LIBEXTRAS) ); \
128   $(LINK_SO) && rm -f $(LIBNAME).o
129 LINK_SO_A_UNPACKED=     \
130   UNPACKDIR=link_tmp.$$$$; rm -rf $$UNPACKDIR; mkdir $$UNPACKDIR; \
131   (cd $$UNPACKDIR; ar x ../lib$(LIBNAME).a) && \
132   ([ -z "$(LIBEXTRAS)" ] || cp $(LIBEXTRAS) $$UNPACKDIR) && \
133   SHOBJECTS=$$UNPACKDIR/*.o; \
134   $(LINK_SO) && rm -rf $$UNPACKDIR
135
136 DETECT_GNU_LD=(${CC} -Wl,-V /dev/null 2>&1 | grep '^GNU ld' )>/dev/null
137
138 DO_GNU_SO=$(CALC_VERSIONS); \
139         SHLIB=lib$(LIBNAME).so; \
140         SHLIB_SUFFIX=; \
141         LIBDEPS="$(LIBDEPS) -lc"; \
142         ALLSYMSFLAGS='-Wl,--whole-archive'; \
143         NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
144         SHAREDFLAGS="-shared -Wl,-Bsymbolic -Wl,-soname=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-rpath,$(LIBRPATH)"; \
145         SHAREDCMD='$(CC)'
146 DO_GNU_APP=LDCMD=$(CC);\
147         LDFLAGS="-Wl,-rpath,$(LIBRPATH)"; \
148         LIBDEPS="$(LIBDEPS) -lc"; \
149         APPNAME=$(APPNAME)
150
151 #This is rather special.  It's a special target with which one can link
152 #applications without bothering with any features that have anything to
153 #do with shared libraries, for example when linking against static
154 #libraries.  It's mostly here to avoid a lot of conditionals everywhere
155 #else...
156 link_app.:
157         LDCMD=$(CC); \
158         LDFLAGS=""; \
159         LIBDEPS="$(LIBDEPS)"; \
160         APPNAME="$(APPNAME)"; \
161         $(LINK_APP)
162
163 link_o.gnu:
164         @ $(DO_GNU_SO); $(LINK_SO_O)
165 link_a.gnu:
166         @ $(DO_GNU_SO); $(LINK_SO_A)
167 link_app.gnu:
168         @ $(DO_GNU_APP); $(LINK_APP)
169
170 # For Darwin AKA Mac OS/X (dyld)
171 link_o.darwin:
172         @ $(CALC_VERSIONS); \
173         SHLIB=lib$(LIBNAME); \
174         SHLIB_SUFFIX=.dylib; \
175         LIBDEPS="$(LIBDEPS) -lc"; \
176         ALLSYMSFLAGS='-all_load'; \
177         NOALLSYMSFLAGS=''; \
178         SHAREDFLAGS="-dynamiclib"; \
179         SHAREDCMD='$(CC)'; \
180         if [ -n "$(LIBVERSION)" ]; then \
181                 SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
182         fi; \
183         if [ -n "$$SHLIB_SOVER_NODOT" ]; then \
184                 SHAREDFLAGS="$$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \
185         fi; \
186         $(LINK_SO_O)
187 link_a.darwin:
188         @ $(CALC_VERSIONS); \
189         SHLIB=lib$(LIBNAME); \
190         SHLIB_SUFFIX=.dylib; \
191         LIBDEPS="$(LIBDEPS) -lc"; \
192         ALLSYMSFLAGS='-all_load'; \
193         NOALLSYMSFLAGS=''; \
194         SHAREDFLAGS="-dynamiclib"; \
195         SHAREDCMD='$(CC)'; \
196         if [ -n "$(LIBVERSION)" ]; then \
197                 SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
198         fi; \
199         if [ -n "$$SHLIB_SOVER_NODOT" ]; then \
200                 SHAREDFLAGS="$$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \
201         fi; \
202         $(LINK_SO_A)
203 link_app.darwin:
204         LDCMD=$(CC);\
205         LDFLAGS=""; \
206         LIBDEPS="$(LIBDEPS) -lc"; \
207         APPNAME="$(APPNAME)"; \
208         $(LINK_APP)
209
210 link_o.cygwin:
211         @ $(CALC_VERSIONS); \
212         INHIBIT_SYMLINKS=yes; \
213         SHLIB=cyg$(LIBNAME); \
214         SHLIB_SUFFIX=.dll; \
215         LIBDEPS="$(LIBDEPS) -lc"; \
216         SHLIB_SOVER=-$(LIBVERSION); \
217         ALLSYMSFLAGS='-Wl,--whole-archive'; \
218         NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
219         SHAREDFLAGS="-shared -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a"; \
220         SHAREDCMD='${CC}'; \
221         $(LINK_SO_O)
222 link_a.cygwin:
223         @ $(CALC_VERSIONS); \
224         INHIBIT_SYMLINKS=yes; \
225         SHLIB=cyg$(LIBNAME); \
226         SHLIB_SUFFIX=.dll; \
227         LIBDEPS="$(LIBDEPS) -lc"; \
228         SHLIB_SOVER=; \
229         ALLSYMSFLAGS='-Wl,--whole-archive'; \
230         NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
231         SHAREDFLAGS="-shared -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a"; \
232         SHAREDCMD='${CC}'; \
233         $(LINK_SO_A)
234 link_app.cygwin:
235         LDCMD=$(CC);\
236         LDFLAGS=""; \
237         LIBDEPS="$(LIBDEPS) -lc"; \
238         APPNAME="$(APPNAME).exe"
239         $(LINK_APP)
240
241 link_o.alpha-osf1:
242         @ if ${DETECT_GNU_LD}; then \
243                 $(DO_GNU_SO); \
244         else \
245                 SHLIB=lib$(LIBNAME).so; \
246                 SHLIB_SUFFIX=; \
247                 LIBDEPS="$(LIBDEPS) -lc"; \
248                 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
249                 if [ -n "$$SHLIB_HIST" ]; then \
250                         SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
251                 else \
252                         SHLIB_HIST="$(LIBVERSION)"; \
253                 fi; \
254                 SHLIB_SOVER=; \
255                 ALLSYMSFLAGS='-all'; \
256                 NOALLSYMSFLAGS='-none'; \
257                 SHAREDFLAGS="-shared"; \
258                 SHAREDCMD='$(CC)'; \
259                 if [ -n "$$SHLIB_HIST" ]; then \
260                         SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
261                 fi; \
262         fi; \
263         $(LINK_SO_O)
264 link_a.alpha-osf1:
265         @ if ${DETECT_GNU_LD}; then \
266                 $(DO_GNU_SO); \
267         else \
268                 SHLIB=lib$(LIBNAME).so; \
269                 SHLIB_SUFFIX=; \
270                 LIBDEPS="$(LIBDEPS) -lc"; \
271                 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
272                 if [ -n "$$SHLIB_HIST" ]; then \
273                         SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
274                 else \
275                         SHLIB_HIST="$(LIBVERSION)"; \
276                 fi; \
277                 SHLIB_SOVER=; \
278                 ALLSYMSFLAGS='-all'; \
279                 NOALLSYMSFLAGS='-none'; \
280                 SHAREDFLAGS="-shared"; \
281                 SHAREDCMD='$(CC)'; \
282                 if [ -n "$$SHLIB_HIST" ]; then \
283                         SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
284                 fi; \
285         fi; \
286         $(LINK_SO_A)
287 link_app.alpha-osf1:
288         @ if ${DETECT_GNU_LD}; then \
289                 $(DO_GNU_APP); \
290         else \
291                 LDCMD=$(CC);\
292                 LDFLAGS=""; \
293                 LIBDEPS="$(LIBDEPS) -lc"; \
294                 APPNAME="$(APPNAME)"
295         fi; \
296         $(LINK_APP)
297
298 # The difference between alpha-osf1-shared and tru64-shared is the `-msym'
299 # option passed to the linker.
300 link_o.tru64:
301         @ if ${DETECT_GNU_LD}; then \
302                 $(DO_GNU_SO); \
303         else \
304                 SHLIB=lib$(LIBNAME).so; \
305                 SHLIB_SUFFIX=; \
306                 LIBDEPS="$(LIBDEPS) -lc"; \
307                 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
308                 if [ -n "$$SHLIB_HIST" ]; then \
309                         SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
310                 else \
311                         SHLIB_HIST="$(LIBVERSION)"; \
312                 fi; \
313                 SHLIB_SOVER=; \
314                 ALLSYMSFLAGS='-all'; \
315                 NOALLSYMSFLAGS='-none'; \
316                 SHAREDFLAGS="-shared -msym -rpath $(LIBRPATH)"; \
317                 SHAREDCMD='$(CC)'; \
318                 if [ -n "$$SHLIB_HIST" ]; then \
319                         SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
320                 fi; \
321         fi; \
322         $(LINK_SO_O)
323 link_a.tru64:
324         @ if ${DETECT_GNU_LD}; then \
325                 $(DO_GNU_SO); \
326         else \
327                 SHLIB=lib$(LIBNAME).so; \
328                 SHLIB_SUFFIX=; \
329                 LIBDEPS="$(LIBDEPS) -lc"; \
330                 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
331                 if [ -n "$$SHLIB_HIST" ]; then \
332                         SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
333                 else \
334                         SHLIB_HIST="$(LIBVERSION)"; \
335                 fi; \
336                 SHLIB_SOVER=; \
337                 ALLSYMSFLAGS='-all'; \
338                 NOALLSYMSFLAGS='-none'; \
339                 SHAREDFLAGS="-shared -msym -rpath $(LIBRPATH)"; \
340                 SHAREDCMD='$(CC)'; \
341                 if [ -n "$$SHLIB_HIST" ]; then \
342                         SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
343                 fi; \
344         fi; \
345         $(LINK_SO_A)
346 link_app.tru64:
347         @ if ${DETECT_GNU_LD}; then \
348                 $(DO_GNU_APP); \
349         else \
350                 LDCMD=$(CC);\
351                 LDFLAGS="-rpath $(LIBRPATH)"; \
352                 LIBDEPS="$(LIBDEPS) -lc"; \
353                 APPNAME="$(APPNAME)"; \
354         fi; \
355         $(LINK_APP)
356
357 # The difference between tru64-shared and tru64-shared-rpath is the
358 # -rpath ${LIBRPATH} passed to the linker.
359 link_o.tru64-rpath:
360         @ if ${DETECT_GNU_LD}; then \
361                 $(DO_GNU_SO); \
362         else \
363                 SHLIB=lib$(LIBNAME).so; \
364                 SHLIB_SUFFIX=; \
365                 LIBDEPS="$(LIBDEPS) -lc"; \
366                 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
367                 if [ -n "$$SHLIB_HIST" ]; then \
368                         SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
369                 else \
370                         SHLIB_HIST="$(LIBVERSION)"; \
371                 fi; \
372                 SHLIB_SOVER=; \
373                 ALLSYMSFLAGS='-all'; \
374                 NOALLSYMSFLAGS='-none'; \
375                 SHAREDFLAGS="-shared -msym -rpath $(LIBRPATH)"; \
376                 SHAREDCMD='$(CC)'; \
377                 if [ -n "$$SHLIB_HIST" ]; then \
378                         SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
379                 fi; \
380         fi; \
381         $(LINK_SO_O)
382 link_a.tru64-rpath:
383         @ if ${DETECT_GNU_LD}; then \
384                 $(DO_GNU_SO); \
385         else \
386                 SHLIB=lib$(LIBNAME).so; \
387                 SHLIB_SUFFIX=; \
388                 LIBDEPS="$(LIBDEPS) -lc"; \
389                 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
390                 if [ -n "$$SHLIB_HIST" ]; then \
391                         SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
392                 else \
393                         SHLIB_HIST="$(LIBVERSION)"; \
394                 fi; \
395                 SHLIB_SOVER=; \
396                 ALLSYMSFLAGS='-all'; \
397                 NOALLSYMSFLAGS='-none'; \
398                 SHAREDFLAGS="-shared -msym -rpath $(LIBRPATH)"; \
399                 SHAREDCMD='$(CC)'; \
400                 if [ -n "$$SHLIB_HIST" ]; then \
401                         SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
402                 fi; \
403         fi; \
404         $(LINK_SO_A)
405 link_app.tru64-rpath:
406         @ if ${DETECT_GNU_LD}; then \
407                 $(DO_GNU_APP); \
408         else \
409                 LDCMD=$(CC);\
410                 LDFLAGS="-rpath $(LIBRPATH)"; \
411                 LIBDEPS="$(LIBDEPS) -lc"; \
412                 APPNAME="$(APPNAME)"; \
413         fi; \
414         $(LINK_APP)
415
416 link_o.solaris:
417         @ if ${DETECT_GNU_LD}; then \
418                 $(DO_GNU_SO); \
419         else \
420                 $(CALC_VERSIONS); \
421                 MINUSZ='-z '; \
422                 (${CC} -v 2>&1 | grep gcc) > /dev/null && MINUSZ='-Wl,-z,'; \
423                 SHLIB=lib$(LIBNAME).so; \
424                 SHLIB_SUFFIX=; \
425                 LIBDEPS="$(LIBDEPS) -lc"; \
426                 ALLSYMSFLAGS="$${MINUSZ}allextract"; \
427                 NOALLSYMSFLAGS="$${MINUSZ}defaultextract"; \
428                 SHAREDFLAGS="-G -dy -z text -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -R $(LIBRPATH)"; \
429                 SHAREDCMD='$(CC)'; \
430         fi; \
431         $(LINK_SO_O)
432 link_a.solaris:
433         @ if ${DETECT_GNU_LD}; then \
434                 $(DO_GNU_SO); \
435         else \
436                 $(CALC_VERSIONS); \
437                 MINUSZ='-z '; \
438                 (${CC} -v 2>&1 | grep gcc) > /dev/null && MINUSZ='-Wl,-z,'; \
439                 SHLIB=lib$(LIBNAME).so; \
440                 SHLIB_SUFFIX=;\
441                 LIBDEPS="$(LIBDEPS) -lc"; \
442                 ALLSYMSFLAGS="$${MINUSZ}allextract"; \
443                 NOALLSYMSFLAGS="$${MINUSZ}defaultextract"; \
444                 SHAREDFLAGS="-G -dy -z text -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -R $(LIBRPATH)"; \
445                 SHAREDCMD='$(CC)'; \
446         fi; \
447         $(LINK_SO_A)
448 link_app.solaris:
449         @ if ${DETECT_GNU_LD}; then \
450                 $(DO_GNU_APP); \
451         else \
452                 LDCMD=$(CC);\
453                 LDFLAGS="-R $(LIBRPATH)"; \
454                 LIBDEPS="$(LIBDEPS) -lc"; \
455                 APPNAME="$(APPNAME)"; \
456         fi; \
457         $(LINK_APP)
458
459 # OpenServer 5 native compilers used
460 link_o.svr3:
461         @ if ${DETECT_GNU_LD}; then \
462                 $(DO_GNU_SO); \
463         else \
464                 $(CALC_VERSIONS); \
465                 SHLIB=lib$(LIBNAME).so; \
466                 SHLIB_SUFFIX=; \
467                 LIBDEPS="$(LIBDEPS) -lc"; \
468                 ALLSYMSFLAGS=''; \
469                 NOALLSYMSFLAGS=''; \
470                 SHAREDFLAGS="-G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
471                 SHAREDCMD='$(CC)'; \
472         fi; \
473         $(LINK_SO_O)
474 link_a.svr3:
475         @ if ${DETECT_GNU_LD}; then \
476                 $(DO_GNU_SO); \
477         else \
478                 $(CALC_VERSIONS); \
479                 SHLIB=lib$(LIBNAME).so; \
480                 SHLIB_SUFFIX=; \
481                 LIBDEPS="$(LIBDEPS) -lc"; \
482                 ALLSYMSFLAGS=''; \
483                 NOALLSYMSFLAGS=''; \
484                 SHAREDFLAGS="-G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
485                 SHAREDCMD='$(CC)'; \
486         fi; \
487         $(LINK_SO_A_UNPACKED)
488 link_app.svr3:
489         @ if ${DETECT_GNU_LD}; then \
490                 $(DO_GNU_APP); \
491         else \
492                 LDCMD=$(CC);\
493                 LDFLAGS=""; \
494                 LIBDEPS="$(LIBDEPS) -lc"; \
495                 APPNAME="$(APPNAME)"; \
496         fi; \
497         $(LINK_APP)
498
499 # UnixWare 7 and OpenUNIX 8 native compilers used
500 link_o.svr5:
501         @ if ${DETECT_GNU_LD}; then \
502                 $(DO_GNU_SO); \
503         else \
504                 $(CALC_VERSIONS); \
505                 SHARE_FLAG='-G'; \
506                 (${CC} -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
507                 SHLIB=lib$(LIBNAME).so; \
508                 SHLIB_SUFFIX=; \
509                 LIBDEPS="$(LIBDEPS) -lc"; \
510                 ALLSYMSFLAGS=''; \
511                 NOALLSYMSFLAGS=''; \
512                 SHAREDFLAGS="$${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
513                 SHAREDCMD='$(CC)'; \
514         fi; \
515         $(LINK_SO_O)
516 link_a.svr5:
517         @ if ${DETECT_GNU_LD}; then \
518                 $(DO_GNU_SO); \
519         else \
520                 $(CALC_VERSIONS); \
521                 SHARE_FLAG='-G'; \
522                 (${CC} -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
523                 SHLIB=lib$(LIBNAME).so; \
524                 SHLIB_SUFFIX=; \
525                 LIBDEPS="$(LIBDEPS) -lc"; \
526                 ALLSYMSFLAGS=''; \
527                 NOALLSYMSFLAGS=''; \
528                 SHAREDFLAGS="$${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
529                 SHAREDCMD='$(CC)'; \
530         fi; \
531         $(LINK_SO_A_UNPACKED)
532 link_app.svr5:
533         @ if ${DETECT_GNU_LD}; then \
534                 $(DO_GNU_APP); \
535         else \
536                 LDCMD=$(CC);\
537                 LDFLAGS=""; \
538                 LIBDEPS="$(LIBDEPS) -lc"; \
539                 APPNAME="$(APPNAME)"; \
540         fi; \
541         $(LINK_APP)
542
543 link_o.irix:
544         @ if ${DETECT_GNU_LD}; then \
545                 $(DO_GNU_SO); \
546         else \
547                 $(CALC_VERSIONS); \
548                 SHLIB=lib$(LIBNAME).so; \
549                 SHLIB_SUFFIX=; \
550                 LIBDEPS="$(LIBDEPS) -lc"; \
551                 MINUSWL=""; \
552                 ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSWL="-Wl,"; \
553                 ALLSYMSFLAGS="$${MINUSWL}-all"; \
554                 NOALLSYMSFLAGS="$${MINUSWL}-notall"; \
555                 SHAREDFLAGS="-shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-rpath,$(LIBRPATH)"; \
556                 SHAREDCMD='$(CC)'; \
557         fi; \
558         $(LINK_SO_O)
559 link_a.irix:
560         @ if ${DETECT_GNU_LD}; then \
561                 $(DO_GNU_SO); \
562         else \
563                 $(CALC_VERSIONS); \
564                 SHLIB=lib$(LIBNAME).so; \
565                 SHLIB_SUFFIX=; \
566                 LIBDEPS="$(LIBDEPS) -lc"; \
567                 MINUSWL=""; \
568                 ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSWL="-Wl,"; \
569                 ALLSYMSFLAGS="$${MINUSWL}-all"; \
570                 NOALLSYMSFLAGS="$${MINUSWL}-notall"; \
571                 SHAREDFLAGS="-shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-rpath,$(LIBRPATH)"; \
572                 SHAREDCMD='$(CC)'; \
573         fi; \
574         $(LINK_SO_A)
575 link_app.irix:
576         @ if ${DETECT_GNU_LD}; then \
577                 $(DO_GNU_APP); \
578         else \
579                 LDCMD=$(CC);\
580                 LDFLAGS="-Wl,-rpath,$(LIBRPATH)"; \
581                 LIBDEPS="$(LIBDEPS) -lc"; \
582                 APPNAME="$(APPNAME)"; \
583         fi; \
584         $(LINK_APP)
585
586 # HP-UX includes the full pathname of libs we depend on, so we would get
587 # ./libcrypto (with ./ as path information) compiled into libssl, hence
588 # we omit the SHLIBDEPS. Applications must be linked with -lssl -lcrypto
589 # anyway.
590 # The object modules are loaded from lib$i.a using the undocumented -Fl
591 # option.
592 #
593 # WARNING: Until DSO is fixed to support a search path, we support SHLIB_PATH
594 #          by temporarily specifying "+s"!
595 #
596 link_o.hpux32:
597         @ $(CALC_VERSIONS); \
598         SHLIB=lib$(LIBNAME).sl; \
599         SHLIB_SUFFIX=; \
600         LIBDEPS="$(LIBDEPS)"; \
601         ALLSYMSFLAGS='-Wl,-Fl'; \
602         NOALLSYMSFLAGS=''; \
603         expr $(PLATFORM) : '.*64' > /dev/null && ALLSYMFLAGS='-Wl,+forceload'; \
604         SHAREDFLAGS="-Wl,+vnocompatwarnings,-z,+s,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,+b,$(LIBRPATH)"; \
605         SHAREDCMD=$(CC); \
606         $(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
607 link_a.hpux32:
608         @ $(CALC_VERSIONS); \
609         SHLIB=lib$(LIBNAME).sl; \
610         SHLIB_SUFFIX=; \
611         LIBDEPS="$(LIBDEPS)"; \
612         ALLSYMSFLAGS='-Wl,-Fl'; \
613         NOALLSYMSFLAGS=''; \
614         expr $(PLATFORM) : '.*64' > /dev/null && ALLSYMFLAGS='-Wl,+forceload'; \
615         SHAREDFLAGS="-Wl,+vnocompatwarnings,-z,+s,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,+b,$(LIBRPATH)"; \
616         SHAREDCMD='$(CC)'; \
617         $(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
618 link_app.hpux32:
619         LDCMD=$(CC);\
620         LDFLAGS="-Wl,+b,$(LIBRPATH)"; \
621         LIBDEPS="$(LIBDEPS)"; \
622         APPNAME="$(APPNAME)"; \
623         $(LINK_APP)
624
625 # HP-UX includes the full pathname of libs we depend on, so we would get
626 # ./libcrypto (with ./ as path information) compiled into libssl, hence
627 # we omit the SHLIBDEPS. Applications must be linked with -lssl -lcrypto
628 # anyway.
629 #
630 # HP-UX in 64bit mode has "+s" enabled by default; it will search for
631 # shared libraries along LD_LIBRARY_PATH _and_ SHLIB_PATH.
632 #
633 link_o.hpux64:
634         @ $(CALC_VERSIONS); \
635         SHLIB=lib$(LIBNAME).sl; \
636         SHLIB_SUFFIX=; \
637         LIBDEPS="$(LIBDEPS) -lc"; \
638         ALLSYMSFLAGS='+forceload'; \
639         NOALLSYMSFLAGS=''; \
640         SHAREDFLAGS="-b -z +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX +b $(LIBRPATH)"; \
641         SHAREDCMD='/usr/ccs/bin/ld'; \
642         $(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
643 link_a.hpux64:
644         @ $(CALC_VERSIONS); \
645         SHLIB=lib$(LIBNAME).sl; \
646         SHLIB_SUFFIX=; \
647         LIBDEPS="$(LIBDEPS) -lc"; \
648         ALLSYMSFLAGS='+forceload'; \
649         NOALLSYMSFLAGS=''; \
650         SHAREDFLAGS="-b -z +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX +b $(LIBRPATH)"; \
651         SHAREDCMD='/usr/ccs/bin/ld'; \
652         $(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
653 link_app.hpux64:
654         LDCMD=$(CC);\
655         LDFLAGS="-Wl,+b,$(LIBRPATH)"; \
656         LIBDEPS="$(LIBDEPS) -lc"; \
657         APPNAME="$(APPNAME)"
658         $(LINK_APP)
659
660 link_o.aix:
661         @ $(CALC_VERSIONS); \
662         SHLIB=lib$(LIBNAME).so; \
663         SHLIB_SUFFIX=; \
664         LIBDEPS="$(LIBDEPS) -lc"; \
665         ALLSYMSFLAGS='-bnogc'; \
666         NOALLSYMSFLAGS=''; \
667         SHAREDFLAGS='-G -bE:lib$(LIBNAME).exp -bM:SRE -blibpath:$(LIBRPATH)'; \
668         SHAREDCMD='$(CC)'; \
669         $(LINK_SO_O)
670 link_a.aix:
671         @ $(CALC_VERSIONS); \
672         SHLIB=lib$(LIBNAME).so; \
673         SHLIB_SUFFIX=; \
674         LIBDEPS="$(LIBDEPS) -lc"; \
675         ALLSYMSFLAGS='-bnogc'; \
676         NOALLSYMSFLAGS=''; \
677         SHAREDFLAGS='-G -bE:lib$(LIBNAME).exp -bM:SRE -blibpath:$(LIBRPATH)'; \
678         SHAREDCMD='$(CC)'; \
679         $(LINK_SO_A_VIA_O)
680 link_app.aix:
681         LDCMD=$(CC);\
682         LDFLAGS="-blibpath:$(LIBRPATH)"; \
683         LIBDEPS="$(LIBDEPS) -lc"; \
684         APPNAME="$(APPNAME)"
685         $(LINK_APP)
686
687 link_o.reliantunix:
688         @ $(CALC_VERSIONS); \
689         SHLIB=lib$(LIBNAME).so; \
690         SHLIB_SUFFIX=; \
691         LIBDEPS="$(LIBDEPS) -lc"; \
692         ALLSYMSFLAGS=; \
693         NOALLSYMSFLAGS=''; \
694         SHAREDFLAGS='-G'; \
695         SHAREDCMD='$(CC)'; \
696         $(LINK_SO_O)
697 link_a.reliantunix:
698         @ $(CALC_VERSIONS); \
699         SHLIB=lib$(LIBNAME).so; \
700         SHLIB_SUFFIX=; \
701         LIBDEPS="$(LIBDEPS) -lc"; \
702         ALLSYMSFLAGS=; \
703         NOALLSYMSFLAGS=''; \
704         SHAREDFLAGS='-G'; \
705         SHAREDCMD='$(CC)'; \
706         $(LINK_SO_A_UNPACKED)
707 link_app.reliantunix:
708         LDCMD=$(CC);\
709         LDFLAGS=""; \
710         LIBDEPS="$(LIBDEPS) -lc"; \
711         APPNAME="$(APPNAME)"
712         $(LINK_APP)
713
714 # Targets to build symbolic links when needed
715 symlink.gnu symlink.solaris symlink.svr3 symlink.svr5 symlink.irix \
716 symlink.aix symlink.reliantunix:
717         @ $(CALC_VERSIONS); \
718         SHLIB=lib$(LIBNAME).so; \
719         $(SYMLINK_SO)
720 symlink.darwin:
721         @ $(CALC_VERSIONS); \
722         SHLIB=lib$(LIBNAME); \
723         SHLIB_SUFFIX=.dylib; \
724         $(SYMLINK_SO)
725 symlink.hpux32 symlink.hpux64:
726         @ $(CALC_VERSIONS); \
727         SHLIB=lib$(LIBNAME).sl; \
728         $(SYMLINK_SO)
729 # The following lines means those specific architectures do no symlinks
730 symlink.cygwin symlib.alpha-osf1 symlink.tru64 symlink.tru64-rpath:
731
732 # Compatibility targets
733 link_o.bsd-gcc-shared link_o.linux-shared link_o.gnu-shared: link_o.gnu
734 link_a.bsd-gcc-shared link_a.linux-shared link_a.gnu-shared: link_a.gnu
735 link_app.bsd-gcc-shared link_app.linux-shared link_app.gnu-shared: link_app.gnu
736 symlink.bsd-gcc-shared symlink.linux-shared symlink.gnu-shared: symlink.gnu
737 link_o.darwin-shared: link_o.darwin
738 link_a.darwin-shared: link_a.darwin
739 link_app.darwin-shared: link_app.darwin
740 symlink.darwin-shared: symlink.darwin
741 link_o.cygwin-shared: link_o.cygwin
742 link_a.cygwin-shared: link_a.cygwin
743 link_app.cygwin-shared: link_app.cygwin
744 symlink.cygwin-shared: symlink.cygwin
745 link_o.alpha-osf1-shared: link_o.alpha-osf1
746 link_a.alpha-osf1-shared: link_a.alpha-osf1
747 link_app.alpha-osf1-shared: link_app.alpha-osf1
748 symlink.alpha-osf1-shared: symlink.alpha-osf1
749 link_o.tru64-shared: link_o.tru64
750 link_a.tru64-shared: link_a.tru64
751 link_app.tru64-shared: link_app.tru64
752 symlink.tru64-shared: symlink.tru64
753 link_o.tru64-shared-rpath: link_o.tru64-rpath
754 link_a.tru64-shared-rpath: link_a.tru64-rpath
755 link_app.tru64-shared-rpath: link_app.tru64-rpath
756 symlink.tru64-shared-rpath: symlink.tru64-rpath
757 link_o.solaris-shared: link_o.solaris
758 link_a.solaris-shared: link_a.solaris
759 link_app.solaris-shared: link_app.solaris
760 symlink.solaris-shared: symlink.solaris
761 link_o.svr3-shared: link_o.svr3
762 link_a.svr3-shared: link_a.svr3
763 link_app.svr3-shared: link_app.svr3
764 symlink.svr3-shared: symlink.svr3
765 link_o.svr5-shared: link_o.svr5
766 link_a.svr5-shared: link_a.svr5
767 link_app.svr5-shared: link_app.svr5
768 symlink.svr5-shared: symlink.svr5
769 link_o.irix-shared: link_o.irix
770 link_a.irix-shared: link_a.irix
771 link_app.irix-shared: link_app.irix
772 symlink.irix-shared: symlink.irix
773 link_o.hpux-shared: link_o.hpux32
774 link_a.hpux-shared: link_a.hpux32
775 link_app.hpux-shared: link_app.hpux32
776 symlink.hpux-shared: symlink.hpux32
777 link_o.hpux64-shared: link_o.hpux64
778 link_a.hpux64-shared: link_a.hpux64
779 link_app.hpux64-shared: link_app.hpux64
780 symlink.hpux64-shared: symlink.hpux64
781 link_o.aix-shared: link_o.aix
782 link_a.aix-shared: link_a.aix
783 link_app.aix-shared: link_app.aix
784 symlink.aix-shared: symlink.aix
785 link_o.reliantunix-shared: link_o.reliantunix
786 link_a.reliantunix-shared: link_a.reliantunix
787 link_app.reliantunix-shared: link_app.reliantunix
788 symlink.reliantunix-shared: symlink.reliantunix