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