Chase down the missing backslashes.
[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_NODOT=$$v \
68                         SHLIB_SOVER=.$$v; \
69                         if [ -n "$$prev" ]; then \
70                                 SHLIB_COMPAT=$$SHLIB_COMPAT .$$prev; \
71                         fi; \
72                         prev=$$v; \
73                 done; \
74         fi
75
76 LINK_SO=        \
77   ( $(DEBUG); \
78     nm -Pg $$SHOBJECTS | grep ' [BDT] ' | cut -f1 -d' ' > lib$(LIBNAME).exp; \
79     $$SHAREDCMD $(SHARED_LDFLAGS) $$SHAREDFLAGS -o $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \
80         $$ALLSYMSFLAGS $$SHOBJECTS $$NOALLSYMSFLAGS $$LIBDEPS ) && \
81   $(SYMLINK_SO); ( $(DEBUG); rm -f lib$(LIBNAME).exp )
82 SYMLINK_SO=     \
83         prev=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \
84         if [ -n "$$SHLIB_COMPAT"]; then \
85                 for x in $$SHLIB_COMPAT; do \
86                         ( $(DEBUG); rm -f $$SHLIB$$x$$SHLIB_SUFFIX; \
87                           ln -s $$prev $$SHLIB$$x$$SHLIB_SUFFIX ); \
88                         prev=$$SHLIB$$x$$SHLIB_SUFFIX; \
89                 done; \
90         fi; \
91         if [ -n "$$SHLIB_SOVER" ]; then \
92                 ( $(DEBUG); rm -f $$SHLIB$$SHLIB_SUFFIX; \
93                   ln -s $$prev $$SHLIB$$SHLIB_SUFFIX ); \
94         fi
95
96 LINK_SO_A=      SHOBJECTS="lib$(LIBNAME).a $(LIBEXTRAS)"; $(LINK_SO)
97 LINK_SO_O=      SHOBJECTS="$(LIBEXTRAS)"; $(LINK_SO)
98 LINK_SO_A_VIA_O=        \
99   SHOBJECTS=lib$(LIBNAME).o ALL=$$ALLSYMSFLAGS ALLSYMSFLAGS= NOALLSYMSFLAGS=; \
100   ( $(DEBUG); \
101     ld $(LDFLAGS) -r -o lib$(LIBNAME).o $$ALL lib$(LIBNAME).a $(LIBEXTRAS) ); \
102   $(LINK_SO) && rm -f $(LIBNAME).o
103 LINK_SO_A_UNPACKED=     \
104   UNPACKDIR=link_tmp.$$$$; rm -rf $$UNPACKDIR; mkdir $$UNPACKDIR; \
105   (cd $$UNPACKDIR; ar x ../lib$(LIBNAME).a) && cp $(LIBEXTRAS) $$UNPACKDIR && \
106   SHOBJECTS=$$UNPACKDIR/*.o; \
107   $(LINK_SO) && rm -rf $$UNPACKDIR
108
109 DETECT_GNU_LD=${CC} -v 2>&1 | grep '^gcc' >/dev/null 2>&1 && \
110         my_ld=`gcc -print-prog-name=ld 2>&1` && \
111         [ -n "$$my_ld" ] && \
112         $$my_ld -v 2>&1 | grep 'GNU ld' >/dev/null 2>&1
113
114 link_o.gnu:
115         @ $(CALC_VERSIONS); \
116         SHLIB=lib$(LIBNAME).so \
117         SHLIB_SUFFIX= \
118         LIBDEPS="$(LIBDEPS)" \
119         NOALLSYMSFLAGS='-Wl,--no-whole-archive' \
120         SHAREDFLAGS="-shared -Wl,-Bsymbolic -Wl,-soname=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX" \
121         SHAREDCMD='$(CC)'; \
122         $(LINK_SO_O)
123 link_a.gnu:
124         @ $(CALC_VERSIONS); \
125         SHLIB=lib$(LIBNAME).so \
126         SHLIB_SUFFIX= \
127         LIBDEPS="$(LIBDEPS)" \
128         ALLSYMSFLAGS='-Wl,--whole-archive' \
129         NOALLSYMSFLAGS='-Wl,--no-whole-archive' \
130         SHAREDFLAGS="-shared -Wl,-Bsymbolic -Wl,-soname=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX" \
131         SHAREDCMD='$(CC)'; \
132         $(LINK_SO_A)
133
134 # For Darwin AKA Mac OS/X (dyld)
135 link_o.darwin:
136         @ $(CALC_VERSIONS); \
137         SHLIB=lib$(LIBNAME) \
138         SHLIB_SUFFIX=.dylib \
139         LIBDEPS="$(LIBDEPS)" \
140         ALLSYMSFLAGS='-all_load' \
141         NOALLSYMSFLAGS='' \
142         SHAREDFLAGS="-dynamiclib" \
143         SHAREDCMD='$(CC)'; \
144         if [ -n "$(LIBVERSION)" ]; then \
145                 SHAREDFLAGS="$SHAREDFLAGS -current_version $(LIBVERSION)"; \
146         fi; \
147         if [ -n "$$SHLIB_SOVER_NODOT" ]; then \
148                 SHAREDFLAGS="$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \
149         fi; \
150         $(LINK_SO_O)
151 link_a.darwin:
152         @ $(CALC_VERSIONS); \
153         SHLIB=lib$(LIBNAME) \
154         SHLIB_SUFFIX=.dylib \
155         LIBDEPS="$(LIBDEPS)" \
156         ALLSYMSFLAGS='-all_load' \
157         NOALLSYMSFLAGS='' \
158         SHAREDFLAGS="-dynamiclib" \
159         SHAREDCMD='$(CC)'; \
160         if [ -n "$(LIBVERSION)" ]; then \
161                 SHAREDFLAGS="$SHAREDFLAGS -current_version $(LIBVERSION)"; \
162         fi; \
163         if [ -n "$$SHLIB_SOVER_NODOT" ]; then \
164                 SHAREDFLAGS="$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \
165         fi; \
166         $(LINK_SO_A)
167
168 link_o.cygwin:
169         @ SHLIB=cyg$(LIBNAME).dll \
170         SHLIB_SUFFIX= \
171         LIBDEPS="$(LIBDEPS)" \
172         SHLIB_SOVER= \
173         ALLSYMSFLAGS='-Wl,--whole-archive' \
174         NOALLSYMSFLAGS='-Wl,--no-whole-archive' \
175         SHAREDFLAGS="-shared -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a" \
176         SHAREDCMD='${CC}'; \
177         $(LINK_SO_O)
178 link_a.cygwin:
179         @ SHLIB=cyg$(LIBNAME).dll \
180         SHLIB_SUFFIX= \
181         LIBDEPS="$(LIBDEPS)" \
182         SHLIB_SOVER= \
183         ALLSYMSFLAGS='-Wl,--whole-archive' \
184         NOALLSYMSFLAGS='-Wl,--no-whole-archive' \
185         SHAREDFLAGS="-shared -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a" \
186         SHAREDCMD='${CC}'; \
187         $(LINK_SO_A)
188
189 link_o.alpha-osf1:
190         @ if ${DETECT_GNU_LD}; then \
191                 $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
192                         SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
193                         LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
194                         LIBVERSION=$(LIBVERSION) \
195                         LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
196                         LIBDEPS="$(LIBDEPS)" link_o.gnu; \
197         else \
198                 SHLIB=lib$(LIBNAME).so \
199                 SHLIB_SUFFIX= \
200                 LIBDEPS="$(LIBDEPS)" \
201                 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
202                 if [ -n "$$SHLIB_HIST" ]; then \
203                         SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
204                 else \
205                         SHLIB_HIST="$(LIBVERSION)"; \
206                 fi
207                 SHLIB_SOVER= \
208                 ALLSYMSFLAGS='-all' \
209                 NOALLSYMSFLAGS='-none' \
210                 SHAREDFLAGS="-shared" \
211                 SHAREDCMD='$(CC)'; \
212                 if [ -n "$$SHLIB_HIST" ]; then \
213                         SHAREDFLAGS="$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
214                 fi; \
215                 $(LINK_SO_O); \
216         fi
217 link_a.alpha-osf1:
218         @ if ${DETECT_GNU_LD}; then \
219                 $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
220                         SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
221                         LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
222                         LIBVERSION=$(LIBVERSION) \
223                         LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
224                         LIBDEPS="$(LIBDEPS)" link_o.gnu; \
225         else \
226                 SHLIB=lib$(LIBNAME).so \
227                 SHLIB_SUFFIX= \
228                 LIBDEPS="$(LIBDEPS)" \
229                 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
230                 if [ -n "$$SHLIB_HIST" ]; then \
231                         SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
232                 else \
233                         SHLIB_HIST="$(LIBVERSION)"; \
234                 fi
235                 SHLIB_SOVER= \
236                 ALLSYMSFLAGS='-all' \
237                 NOALLSYMSFLAGS='-none' \
238                 SHAREDFLAGS="-shared" \
239                 SHAREDCMD='$(CC)'; \
240                 if [ -n "$$SHLIB_HIST" ]; then \
241                         SHAREDFLAGS="$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
242                 fi; \
243                 $(LINK_SO_A); \
244         fi
245
246 # The difference between alpha-osf1-shared and tru64-shared is the `-msym'
247 # option passed to the linker.
248 link_o.tru64:
249         @ if ${DETECT_GNU_LD}; then \
250                 $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
251                         SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
252                         LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
253                         LIBVERSION=$(LIBVERSION) \
254                         LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
255                         LIBDEPS="$(LIBDEPS)" link_o.gnu; \
256         else \
257                 SHLIB=lib$(LIBNAME).so \
258                 SHLIB_SUFFIX= \
259                 LIBDEPS="$(LIBDEPS)" \
260                 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
261                 if [ -n "$$SHLIB_HIST" ]; then \
262                         SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
263                 else \
264                         SHLIB_HIST="$(LIBVERSION)"; \
265                 fi
266                 SHLIB_SOVER= \
267                 ALLSYMSFLAGS='-all' \
268                 NOALLSYMSFLAGS='-none' \
269                 SHAREDFLAGS="-shared -msym" \
270                 SHAREDCMD='$(CC)'; \
271                 if [ -n "$$SHLIB_HIST" ]; then \
272                         SHAREDFLAGS="$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
273                 fi; \
274                 $(LINK_SO_O); \
275         fi
276 link_a.tru64:
277         @ if ${DETECT_GNU_LD}; then \
278                 $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
279                         SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
280                         LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
281                         LIBVERSION=$(LIBVERSION) \
282                         LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
283                         LIBDEPS="$(LIBDEPS)" link_o.gnu; \
284         else \
285                 SHLIB=lib$(LIBNAME).so \
286                 SHLIB_SUFFIX= \
287                 LIBDEPS="$(LIBDEPS)" \
288                 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
289                 if [ -n "$$SHLIB_HIST" ]; then \
290                         SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
291                 else \
292                         SHLIB_HIST="$(LIBVERSION)"; \
293                 fi
294                 SHLIB_SOVER= \
295                 ALLSYMSFLAGS='-all' \
296                 NOALLSYMSFLAGS='-none' \
297                 SHAREDFLAGS="-shared -msym" \
298                 SHAREDCMD='$(CC)'; \
299                 if [ -n "$$SHLIB_HIST" ]; then \
300                         SHAREDFLAGS="$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
301                 fi; \
302                 $(LINK_SO_A); \
303         fi
304
305 # The difference between tru64-shared and tru64-shared-rpath is the
306 # -rpath ${LIBRPATH} passed to the linker.
307 link_o.tru64-rpath:
308         @ if ${DETECT_GNU_LD}; then \
309                 $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
310                         SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
311                         LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
312                         LIBVERSION=$(LIBVERSION) \
313                         LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
314                         LIBDEPS="$(LIBDEPS)" link_o.gnu; \
315         else \
316                 SHLIB=lib$(LIBNAME).so \
317                 SHLIB_SUFFIX= \
318                 LIBDEPS="$(LIBDEPS)" \
319                 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
320                 if [ -n "$$SHLIB_HIST" ]; then \
321                         SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
322                 else \
323                         SHLIB_HIST="$(LIBVERSION)"; \
324                 fi
325                 SHLIB_SOVER= \
326                 ALLSYMSFLAGS='-all' \
327                 NOALLSYMSFLAGS='-none' \
328                 SHAREDFLAGS="-shared -msym -rpath $(LIBRPATH)" \
329                 SHAREDCMD='$(CC)'; \
330                 if [ -n "$$SHLIB_HIST" ]; then \
331                         SHAREDFLAGS="$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
332                 fi; \
333                 $(LINK_SO_O); \
334         fi
335 link_a.tru64-rpath:
336         @ if ${DETECT_GNU_LD}; then \
337                 $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
338                         SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
339                         LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
340                         LIBVERSION=$(LIBVERSION) \
341                         LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
342                         LIBDEPS="$(LIBDEPS)" link_o.gnu; \
343         else \
344                 SHLIB=lib$(LIBNAME).so \
345                 SHLIB_SUFFIX= \
346                 LIBDEPS="$(LIBDEPS)" \
347                 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
348                 if [ -n "$$SHLIB_HIST" ]; then \
349                         SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
350                 else \
351                         SHLIB_HIST="$(LIBVERSION)"; \
352                 fi
353                 SHLIB_SOVER= \
354                 ALLSYMSFLAGS='-all' \
355                 NOALLSYMSFLAGS='-none' \
356                 SHAREDFLAGS="-shared -msym -rpath $(LIBRPATH)" \
357                 SHAREDCMD='$(CC)'; \
358                 if [ -n "$$SHLIB_HIST" ]; then \
359                         SHAREDFLAGS="$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
360                 fi; \
361                 $(LINK_SO_A); \
362         fi
363
364 link_o.solaris:
365         @ if ${DETECT_GNU_LD}; then \
366                 $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
367                         SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
368                         LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
369                         LIBVERSION="$(LIBVERSION)" \
370                         LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
371                         LIBDEPS="$(LIBDEPS)" link_o.gnu; \
372         else \
373                 $(CALC_VERSIONS); \
374                 SHLIB=lib$(LIBNAME).so \
375                 SHLIB_SUFFIX= \
376                 LIBDEPS="$(LIBDEPS)" \
377                 ALLSYMSFLAGS='-z allextract' \
378                 NOALLSYMSFLAGS='' \
379                 SHAREDFLAGS='-G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
380                 SHAREDCMD='$(CC)'; \
381                 $(LINK_SO_O); \
382         fi
383 link_a.solaris:
384         @ if ${DETECT_GNU_LD}; then \
385                 $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
386                         SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
387                         LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
388                         LIBVERSION="$(LIBVERSION)" \
389                         LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
390                         LIBDEPS="$(LIBDEPS)" link_o.gnu; \
391         else \
392                 $(CALC_VERSIONS); \
393                 SHLIB=lib$(LIBNAME).so \
394                 SHLIB_SUFFIX= \
395                 LIBDEPS="$(LIBDEPS)" \
396                 ALLSYMSFLAGS='-z allextract' \
397                 NOALLSYMSFLAGS='' \
398                 SHAREDFLAGS='-G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
399                 SHAREDCMD='$(CC)'; \
400                 $(LINK_SO_A); \
401         fi
402
403 # OpenServer 5 native compilers used
404 # UnixWare 7 and OpenUNIX 8 native compilers used
405 link_o.svr3:
406         @ if ${DETECT_GNU_LD}; then \
407                 $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
408                         SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
409                         LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
410                         LIBVERSION=$(LIBVERSION) \
411                         LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
412                         LIBDEPS="$(LIBDEPS)" link_o.gnu; \
413         else \
414                 $(CALC_VERSIONS); \
415                 SHLIB=lib$(LIBNAME).so \
416                 SHLIB_SUFFIX= \
417                 LIBDEPS="$(LIBDEPS)" \
418                 ALLSYMSFLAGS='-z allextract' \
419                 NOALLSYMSFLAGS='' \
420                 SHAREDFLAGS='-G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
421                 SHAREDCMD='$(CC)'; \
422                 $(LINK_SO_O); \
423         fi
424 link_a.svr3:
425         @ if ${DETECT_GNU_LD}; then \
426                 $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
427                         SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
428                         LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
429                         LIBVERSION=$(LIBVERSION) \
430                         LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
431                         LIBDEPS="$(LIBDEPS)" link_o.gnu; \
432         else \
433                 $(CALC_VERSIONS); \
434                 SHLIB=lib$(LIBNAME).so \
435                 SHLIB_SUFFIX= \
436                 LIBDEPS="$(LIBDEPS)" \
437                 ALLSYMSFLAGS='-z allextract' \
438                 NOALLSYMSFLAGS='' \
439                 SHAREDFLAGS='-G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
440                 SHAREDCMD='$(CC)'; \
441                 $(LINK_SO_A_UNPACKED); \
442         fi
443
444 link_o.irix:
445         @ if ${DETECT_GNU_LD}; then \
446                 $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
447                         SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
448                         LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
449                         LIBVERSION=$(LIBVERSION) \
450                         LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
451                         LIBDEPS="$(LIBDEPS)" link_o.gnu; \
452         else \
453                 $(CALC_VERSIONS); \
454                 SHLIB=lib$(LIBNAME).so \
455                 SHLIB_SUFFIX= \
456                 LIBDEPS="$(LIBDEPS)" \
457                 ALLSYMSFLAGS='-all' \
458                 NOALLSYMSFLAGS='' \
459                 SHAREDFLAGS='-shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
460                 SHAREDCMD='$(CC)'; \
461                 $(LINK_SO_O); \
462         fi
463 link_a.irix:
464         @ if ${DETECT_GNU_LD}; then \
465                 $(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS) \
466                         SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
467                         LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
468                         LIBVERSION=$(LIBVERSION) \
469                         LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
470                         LIBDEPS="$(LIBDEPS)" link_o.gnu; \
471         else \
472                 $(CALC_VERSIONS); \
473                 SHLIB=lib$(LIBNAME).so \
474                 SHLIB_SUFFIX= \
475                 LIBDEPS="$(LIBDEPS)" \
476                 ALLSYMSFLAGS='-all' \
477                 NOALLSYMSFLAGS='' \
478                 SHAREDFLAGS='-shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
479                 SHAREDCMD='$(CC)'; \
480                 $(LINK_SO_A); \
481         fi
482
483 # HP-UX includes the full pathname of libs we depend on, so we would get
484 # ./libcrypto (with ./ as path information) compiled into libssl, hence
485 # we omit the SHLIBDEPS. Applications must be linked with -lssl -lcrypto
486 # anyway.
487 # The object modules are loaded from lib$i.a using the undocumented -Fl
488 # option.
489 #
490 # WARNING: Until DSO is fixed to support a search path, we support SHLIB_PATH
491 #          by temporarily specifying "+s"!
492 #
493 link_o.hpux32:
494         @ $(CALC_VERSIONS); \
495         SHLIB=lib$(LIBNAME).sl \
496         SHLIB_SUFFIX= \
497         LIBDEPS="$(LIBDEPS) -lc" \
498         ALLSYMSFLAGS='-Fl' \
499         NOALLSYMSFLAGS='' \
500         SHAREDFLAGS='+vnocompatwarnings -b -z +s +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
501         SHAREDCMD='/usr/ccs/bin/ld'; \
502         $(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
503 link_a.hpux32:
504         @ $(CALC_VERSIONS); \
505         SHLIB=lib$(LIBNAME).sl \
506         SHLIB_SUFFIX= \
507         LIBDEPS="$(LIBDEPS) -lc" \
508         ALLSYMSFLAGS='-Fl' \
509         NOALLSYMSFLAGS='' \
510         SHAREDFLAGS='+vnocompatwarnings -b -z +s +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
511         SHAREDCMD='/usr/ccs/bin/ld'; \
512         $(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
513
514 # HP-UX includes the full pathname of libs we depend on, so we would get
515 # ./libcrypto (with ./ as path information) compiled into libssl, hence
516 # we omit the SHLIBDEPS. Applications must be linked with -lssl -lcrypto
517 # anyway.
518 #
519 # HP-UX in 64bit mode has "+s" enabled by default; it will search for
520 # shared libraries along LD_LIBRARY_PATH _and_ SHLIB_PATH.
521 #
522 link_o.hpux64:
523         @ $(CALC_VERSIONS); \
524         SHLIB=lib$(LIBNAME).sl \
525         SHLIB_SUFFIX= \
526         LIBDEPS="$(LIBDEPS) -lc" \
527         ALLSYMSFLAGS='+forceload' \
528         NOALLSYMSFLAGS='' \
529         SHAREDFLAGS='-b -z +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
530         SHAREDCMD='/usr/ccs/bin/ld'; \
531         $(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
532 link_a.hpux64:
533         @ $(CALC_VERSIONS); \
534         SHLIB=lib$(LIBNAME).sl \
535         SHLIB_SUFFIX= \
536         LIBDEPS="$(LIBDEPS) -lc" \
537         ALLSYMSFLAGS='+forceload' \
538         NOALLSYMSFLAGS='' \
539         SHAREDFLAGS='-b -z +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
540         SHAREDCMD='/usr/ccs/bin/ld'; \
541         $(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
542
543 link_o.aix:
544         @ $(CALC_VERSIONS); \
545         SHLIB=lib$(LIBNAME).so \
546         SHLIB_SUFFIX= \
547         LIBDEPS="$(LIBDEPS)" \
548         ALLSYMSFLAGS='-bnogc' \
549         NOALLSYMSFLAGS='' \
550         SHAREDFLAGS='-G -bE:lib$(LIBNAME).exp -bM:SRE' \
551         SHAREDCMD='$(CC)'; \
552         $(LINK_SO_O)
553 link_a.aix:
554         @ $(CALC_VERSIONS); \
555         SHLIB=lib$(LIBNAME).so \
556         SHLIB_SUFFIX= \
557         LIBDEPS="$(LIBDEPS)" \
558         ALLSYMSFLAGS='-bnogc' \
559         NOALLSYMSFLAGS='' \
560         SHAREDFLAGS='-G -bE:lib$(LIBNAME).exp -bM:SRE' \
561         SHAREDCMD='$(CC)'; \
562         $(LINK_SO_A_VIA_O)
563
564 link_o.reliantunix:
565         @ $(CALC_VERSIONS); \
566         SHLIB=lib$(LIBNAME).so \
567         SHLIB_SUFFIX= \
568         LIBDEPS="$(LIBDEPS)" \
569         ALLSYMSFLAGS= \
570         NOALLSYMSFLAGS='' \
571         SHAREDFLAGS='-G' \
572         SHAREDCMD='$(CC)'; \
573         $(LINK_SO_O)
574 link_a.reliantunix:
575         @ $(CALC_VERSIONS); \
576         SHLIB=lib$(LIBNAME).so \
577         SHLIB_SUFFIX= \
578         LIBDEPS="$(LIBDEPS)" \
579         ALLSYMSFLAGS= \
580         NOALLSYMSFLAGS='' \
581         SHAREDFLAGS='-G' \
582         SHAREDCMD='$(CC)'; \
583         $(LINK_SO_A_UNPACKED)
584
585 # Targets to build symbolic links when needed
586 symlink.gnu symlink.solaris symlink.svr3 symlink.irix \
587 symlink.aix symlink.reliantunix:
588         @ $(CALC_VERSIONS); \
589         SHLIB=lib$(LIBNAME).so \
590         $(SYMLINK_SO)
591 symlink.darwin:
592         @ $(CALC_VERSIONS); \
593         SHLIB=lib$(LIBNAME) \
594         SHLIB_SUFFIX=.dylib \
595         $(SYMLINK_SO)
596 symlink.cygwin symlib.alpha-osf1 symlink.tru64 symlink.tru64-rpath:
597 symlink.hpux32 symlink.hpux64:
598         @ $(CALC_VERSIONS); \
599         SHLIB=lib$(LIBNAME).sl \
600         $(SYMLINK_SO)
601
602 # Compatibility targets
603 link_o.bsd-gcc-shared link_o.linux-shared link_o.gnu-shared: link_o.gnu
604 link_a.bsd-gcc-shared link_a.linux-shared link_a.gnu-shared: link_a.gnu
605 symlink.bsd-gcc-shared symlink.linux-shared symlink.gnu-shared: symlink.gnu
606 link_o.darwin-shared: link_o.darwin
607 link_a.darwin-shared: link_a.darwin
608 symlink.darwin-shared: symlink.darwin
609 link_o.cygwin-shared: link_o.cygwin
610 link_a.cygwin-shared: link_a.cygwin
611 symlink.cygwin-shared: symlink.cygwin
612 link_o.alpha-osf1-shared: link_o.alpha-osf1
613 link_a.alpha-osf1-shared: link_a.alpha-osf1
614 symlink.alpha-osf1-shared: symlink.alpha-osf1
615 link_o.tru64-shared: link_o.tru64
616 link_a.tru64-shared: link_a.tru64
617 symlink.tru64-shared: symlink.tru64
618 link_o.tru64-shared-rpath: link_o.tru64-rpath
619 link_a.tru64-shared-rpath: link_a.tru64-rpath
620 symlink.tru64-shared-rpath: symlink.tru64-rpath
621 link_o.solaris-shared: link_o.solaris
622 link_a.solaris-shared: link_a.solaris
623 symlink.solaris-shared: symlink.solaris
624 link_o.svr3-shared: link_o.svr3
625 link_a.svr3-shared: link_a.svr3
626 symlink.svr3-shared: symlink.svr3
627 link_o.svr5-shared: link_o.svr3
628 link_a.svr5-shared: link_a.svr3
629 symlink.svr5-shared: symlink.svr3
630 link_o.irix-shared: link_o.irix
631 link_a.irix-shared: link_a.irix
632 symlink.irix-shared: symlink.irix
633 link_o.hpux-shared: link_o.hpux32
634 link_a.hpux-shared: link_a.hpux32
635 symlink.hpux-shared: symlink.hpux32
636 link_o.hpux64-shared: link_o.hpux64
637 link_a.hpux64-shared: link_a.hpux64
638 symlink.hpux64-shared: symlink.hpux64
639 link_o.aix-shared: link_o.aix
640 link_a.aix-shared: link_a.aix
641 symlink.aix-shared: symlink.aix
642 link_o.reliantunix-shared: link_o.reliantunix
643 link_a.reliantunix-shared: link_a.reliantunix
644 symlink.reliantunix-shared: symlink.reliantunix