It seems like gcc-drivven shared library building on OpenUnix 8 requires
[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                 SHARE_FLAG='-G'; \
460                 (${CC} -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAGS='-shared'; \
461                 SHLIB=lib$(LIBNAME).so; \
462                 SHLIB_SUFFIX=; \
463                 LIBDEPS="$(LIBDEPS) -lc"; \
464                 ALLSYMSFLAGS='-z allextract'; \
465                 NOALLSYMSFLAGS=''; \
466                 SHAREDFLAGS="$${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
467                 SHAREDCMD='$(CC)'; \
468         fi; \
469         $(LINK_SO_O)
470 link_a.svr3:
471         @ if ${DETECT_GNU_LD}; then \
472                 $(DO_GNU_SO); \
473         else \
474                 $(CALC_VERSIONS); \
475                 SHARE_FLAG='-G'; \
476                 (${CC} -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAGS='-shared'; \
477                 SHLIB=lib$(LIBNAME).so; \
478                 SHLIB_SUFFIX=; \
479                 LIBDEPS="$(LIBDEPS) -lc"; \
480                 ALLSYMSFLAGS='-z allextract'; \
481                 NOALLSYMSFLAGS=''; \
482                 SHAREDFLAGS="$${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
483                 SHAREDCMD='$(CC)'; \
484         fi; \
485         $(LINK_SO_A_UNPACKED)
486 link_app.svr3:
487         @ if ${DETECT_GNU_LD}; then \
488                 $(DO_GNU_APP); \
489         else \
490                 LDCMD=$(CC);\
491                 LDFLAGS=""; \
492                 LIBDEPS="$(LIBDEPS) -lc"; \
493                 APPNAME="$(APPNAME)"; \
494         fi; \
495         $(LINK_APP)
496
497 link_o.irix:
498         @ if ${DETECT_GNU_LD}; then \
499                 $(DO_GNU_SO); \
500         else \
501                 $(CALC_VERSIONS); \
502                 SHLIB=lib$(LIBNAME).so; \
503                 SHLIB_SUFFIX=; \
504                 LIBDEPS="$(LIBDEPS) -lc"; \
505                 ALLSYMSFLAGS='-all'; \
506                 NOALLSYMSFLAGS=''; \
507                 SHAREDFLAGS="-shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-rpath,$(LIBRPATH)"; \
508                 SHAREDCMD='$(CC)'; \
509         fi; \
510         $(LINK_SO_O)
511 link_a.irix:
512         @ if ${DETECT_GNU_LD}; then \
513                 $(DO_GNU_SO); \
514         else \
515                 $(CALC_VERSIONS); \
516                 SHLIB=lib$(LIBNAME).so; \
517                 SHLIB_SUFFIX=; \
518                 LIBDEPS="$(LIBDEPS) -lc"; \
519                 ALLSYMSFLAGS='-all'; \
520                 NOALLSYMSFLAGS=''; \
521                 SHAREDFLAGS="-shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-rpath,$(LIBRPATH)"; \
522                 SHAREDCMD='$(CC)'; \
523         fi; \
524         $(LINK_SO_A)
525 link_app.irix:
526         @ if ${DETECT_GNU_LD}; then \
527                 $(DO_GNU_APP); \
528         else \
529                 LDCMD=$(CC);\
530                 LDFLAGS="-Wl,-rpath,$(LIBRPATH)"; \
531                 LIBDEPS="$(LIBDEPS) -lc"; \
532                 APPNAME="$(APPNAME)"; \
533         fi; \
534         $(LINK_APP)
535
536 # HP-UX includes the full pathname of libs we depend on, so we would get
537 # ./libcrypto (with ./ as path information) compiled into libssl, hence
538 # we omit the SHLIBDEPS. Applications must be linked with -lssl -lcrypto
539 # anyway.
540 # The object modules are loaded from lib$i.a using the undocumented -Fl
541 # option.
542 #
543 # WARNING: Until DSO is fixed to support a search path, we support SHLIB_PATH
544 #          by temporarily specifying "+s"!
545 #
546 link_o.hpux32:
547         @ $(CALC_VERSIONS); \
548         SHLIB=lib$(LIBNAME).sl; \
549         SHLIB_SUFFIX=; \
550         LIBDEPS="$(LIBDEPS) -lc"; \
551         ALLSYMSFLAGS='-Fl'; \
552         NOALLSYMSFLAGS=''; \
553         SHAREDFLAGS="+vnocompatwarnings -b -z +s +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX +b $(LIBRPATH)"; \
554         SHAREDCMD='/usr/ccs/bin/ld'; \
555         $(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
556 link_a.hpux32:
557         @ $(CALC_VERSIONS); \
558         SHLIB=lib$(LIBNAME).sl; \
559         SHLIB_SUFFIX=; \
560         LIBDEPS="$(LIBDEPS) -lc"; \
561         ALLSYMSFLAGS='-Fl'; \
562         NOALLSYMSFLAGS=''; \
563         SHAREDFLAGS="+vnocompatwarnings -b -z +s +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX +b $(LIBRPATH)"; \
564         SHAREDCMD='/usr/ccs/bin/ld'; \
565         $(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
566 link_app.hpux32:
567         LDCMD=$(CC);\
568         LDFLAGS="-Wl,+b,$(LIBRPATH)"; \
569         LIBDEPS="$(LIBDEPS) -lc"; \
570         APPNAME="$(APPNAME)"
571         $(LINK_APP)
572
573 # HP-UX includes the full pathname of libs we depend on, so we would get
574 # ./libcrypto (with ./ as path information) compiled into libssl, hence
575 # we omit the SHLIBDEPS. Applications must be linked with -lssl -lcrypto
576 # anyway.
577 #
578 # HP-UX in 64bit mode has "+s" enabled by default; it will search for
579 # shared libraries along LD_LIBRARY_PATH _and_ SHLIB_PATH.
580 #
581 link_o.hpux64:
582         @ $(CALC_VERSIONS); \
583         SHLIB=lib$(LIBNAME).sl; \
584         SHLIB_SUFFIX=; \
585         LIBDEPS="$(LIBDEPS) -lc"; \
586         ALLSYMSFLAGS='+forceload'; \
587         NOALLSYMSFLAGS=''; \
588         SHAREDFLAGS="-b -z +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX +b $(LIBRPATH)"; \
589         SHAREDCMD='/usr/ccs/bin/ld'; \
590         $(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
591 link_a.hpux64:
592         @ $(CALC_VERSIONS); \
593         SHLIB=lib$(LIBNAME).sl; \
594         SHLIB_SUFFIX=; \
595         LIBDEPS="$(LIBDEPS) -lc"; \
596         ALLSYMSFLAGS='+forceload'; \
597         NOALLSYMSFLAGS=''; \
598         SHAREDFLAGS="-b -z +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX +b $(LIBRPATH)"; \
599         SHAREDCMD='/usr/ccs/bin/ld'; \
600         $(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
601 link_app.hpux64:
602         LDCMD=$(CC);\
603         LDFLAGS="-Wl,+b,$(LIBRPATH)"; \
604         LIBDEPS="$(LIBDEPS) -lc"; \
605         APPNAME="$(APPNAME)"
606         $(LINK_APP)
607
608 link_o.aix:
609         @ $(CALC_VERSIONS); \
610         SHLIB=lib$(LIBNAME).so; \
611         SHLIB_SUFFIX=; \
612         LIBDEPS="$(LIBDEPS) -lc"; \
613         ALLSYMSFLAGS='-bnogc'; \
614         NOALLSYMSFLAGS=''; \
615         SHAREDFLAGS='-G -bE:lib$(LIBNAME).exp -bM:SRE -blibpath:$(LIBRPATH)'; \
616         SHAREDCMD='$(CC)'; \
617         $(LINK_SO_O)
618 link_a.aix:
619         @ $(CALC_VERSIONS); \
620         SHLIB=lib$(LIBNAME).so; \
621         SHLIB_SUFFIX=; \
622         LIBDEPS="$(LIBDEPS) -lc"; \
623         ALLSYMSFLAGS='-bnogc'; \
624         NOALLSYMSFLAGS=''; \
625         SHAREDFLAGS='-G -bE:lib$(LIBNAME).exp -bM:SRE -blibpath:$(LIBRPATH)'; \
626         SHAREDCMD='$(CC)'; \
627         $(LINK_SO_A_VIA_O)
628 link_app.aix:
629         LDCMD=$(CC);\
630         LDFLAGS="-blibpath:$(LIBRPATH)"; \
631         LIBDEPS="$(LIBDEPS) -lc"; \
632         APPNAME="$(APPNAME)"
633         $(LINK_APP)
634
635 link_o.reliantunix:
636         @ $(CALC_VERSIONS); \
637         SHLIB=lib$(LIBNAME).so; \
638         SHLIB_SUFFIX=; \
639         LIBDEPS="$(LIBDEPS) -lc"; \
640         ALLSYMSFLAGS=; \
641         NOALLSYMSFLAGS=''; \
642         SHAREDFLAGS='-G'; \
643         SHAREDCMD='$(CC)'; \
644         $(LINK_SO_O)
645 link_a.reliantunix:
646         @ $(CALC_VERSIONS); \
647         SHLIB=lib$(LIBNAME).so; \
648         SHLIB_SUFFIX=; \
649         LIBDEPS="$(LIBDEPS) -lc"; \
650         ALLSYMSFLAGS=; \
651         NOALLSYMSFLAGS=''; \
652         SHAREDFLAGS='-G'; \
653         SHAREDCMD='$(CC)'; \
654         $(LINK_SO_A_UNPACKED)
655 link_app.reliantunix:
656         LDCMD=$(CC);\
657         LDFLAGS=""; \
658         LIBDEPS="$(LIBDEPS) -lc"; \
659         APPNAME="$(APPNAME)"
660         $(LINK_APP)
661
662 # Targets to build symbolic links when needed
663 symlink.gnu symlink.solaris symlink.svr3 symlink.irix \
664 symlink.aix symlink.reliantunix:
665         @ $(CALC_VERSIONS); \
666         SHLIB=lib$(LIBNAME).so; \
667         $(SYMLINK_SO)
668 symlink.darwin:
669         @ $(CALC_VERSIONS); \
670         SHLIB=lib$(LIBNAME); \
671         SHLIB_SUFFIX=.dylib; \
672         $(SYMLINK_SO)
673 symlink.hpux32 symlink.hpux64:
674         @ $(CALC_VERSIONS); \
675         SHLIB=lib$(LIBNAME).sl; \
676         $(SYMLINK_SO)
677 # The following lines means those specific architectures do no symlinks
678 symlink.cygwin symlib.alpha-osf1 symlink.tru64 symlink.tru64-rpath:
679
680 # Compatibility targets
681 link_o.bsd-gcc-shared link_o.linux-shared link_o.gnu-shared: link_o.gnu
682 link_a.bsd-gcc-shared link_a.linux-shared link_a.gnu-shared: link_a.gnu
683 link_app.bsd-gcc-shared link_app.linux-shared link_app.gnu-shared: link_app.gnu
684 symlink.bsd-gcc-shared symlink.linux-shared symlink.gnu-shared: symlink.gnu
685 link_o.darwin-shared: link_o.darwin
686 link_a.darwin-shared: link_a.darwin
687 link_app.darwin-shared: link_app.darwin
688 symlink.darwin-shared: symlink.darwin
689 link_o.cygwin-shared: link_o.cygwin
690 link_a.cygwin-shared: link_a.cygwin
691 link_app.cygwin-shared: link_app.cygwin
692 symlink.cygwin-shared: symlink.cygwin
693 link_o.alpha-osf1-shared: link_o.alpha-osf1
694 link_a.alpha-osf1-shared: link_a.alpha-osf1
695 link_app.alpha-osf1-shared: link_app.alpha-osf1
696 symlink.alpha-osf1-shared: symlink.alpha-osf1
697 link_o.tru64-shared: link_o.tru64
698 link_a.tru64-shared: link_a.tru64
699 link_app.tru64-shared: link_app.tru64
700 symlink.tru64-shared: symlink.tru64
701 link_o.tru64-shared-rpath: link_o.tru64-rpath
702 link_a.tru64-shared-rpath: link_a.tru64-rpath
703 link_app.tru64-shared-rpath: link_app.tru64-rpath
704 symlink.tru64-shared-rpath: symlink.tru64-rpath
705 link_o.solaris-shared: link_o.solaris
706 link_a.solaris-shared: link_a.solaris
707 link_app.solaris-shared: link_app.solaris
708 symlink.solaris-shared: symlink.solaris
709 link_o.svr3-shared: link_o.svr3
710 link_a.svr3-shared: link_a.svr3
711 link_app.svr3-shared: link_app.svr3
712 symlink.svr3-shared: symlink.svr3
713 link_o.svr5-shared: link_o.svr3
714 link_a.svr5-shared: link_a.svr3
715 link_app.svr5-shared: link_app.svr3
716 symlink.svr5-shared: symlink.svr3
717 link_o.irix-shared: link_o.irix
718 link_a.irix-shared: link_a.irix
719 link_app.irix-shared: link_app.irix
720 symlink.irix-shared: symlink.irix
721 link_o.hpux-shared: link_o.hpux32
722 link_a.hpux-shared: link_a.hpux32
723 link_app.hpux-shared: link_app.hpux32
724 symlink.hpux-shared: symlink.hpux32
725 link_o.hpux64-shared: link_o.hpux64
726 link_a.hpux64-shared: link_a.hpux64
727 link_app.hpux64-shared: link_app.hpux64
728 symlink.hpux64-shared: symlink.hpux64
729 link_o.aix-shared: link_o.aix
730 link_a.aix-shared: link_a.aix
731 link_app.aix-shared: link_app.aix
732 symlink.aix-shared: symlink.aix
733 link_o.reliantunix-shared: link_o.reliantunix
734 link_a.reliantunix-shared: link_a.reliantunix
735 link_app.reliantunix-shared: link_app.reliantunix
736 symlink.reliantunix-shared: symlink.reliantunix