Avoid "empty source file" warnings.
[oweals/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                 ALLSYMSFLAGS='-all'; \
552                 NOALLSYMSFLAGS=''; \
553                 SHAREDFLAGS="-shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-rpath,$(LIBRPATH)"; \
554                 SHAREDCMD='$(CC)'; \
555         fi; \
556         $(LINK_SO_O)
557 link_a.irix:
558         @ if ${DETECT_GNU_LD}; then \
559                 $(DO_GNU_SO); \
560         else \
561                 $(CALC_VERSIONS); \
562                 SHLIB=lib$(LIBNAME).so; \
563                 SHLIB_SUFFIX=; \
564                 LIBDEPS="$(LIBDEPS) -lc"; \
565                 ALLSYMSFLAGS='-all'; \
566                 NOALLSYMSFLAGS=''; \
567                 SHAREDFLAGS="-shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-rpath,$(LIBRPATH)"; \
568                 SHAREDCMD='$(CC)'; \
569         fi; \
570         $(LINK_SO_A)
571 link_app.irix:
572         @ if ${DETECT_GNU_LD}; then \
573                 $(DO_GNU_APP); \
574         else \
575                 LDCMD=$(CC);\
576                 LDFLAGS="-Wl,-rpath,$(LIBRPATH)"; \
577                 LIBDEPS="$(LIBDEPS) -lc"; \
578                 APPNAME="$(APPNAME)"; \
579         fi; \
580         $(LINK_APP)
581
582 # HP-UX includes the full pathname of libs we depend on, so we would get
583 # ./libcrypto (with ./ as path information) compiled into libssl, hence
584 # we omit the SHLIBDEPS. Applications must be linked with -lssl -lcrypto
585 # anyway.
586 # The object modules are loaded from lib$i.a using the undocumented -Fl
587 # option.
588 #
589 # WARNING: Until DSO is fixed to support a search path, we support SHLIB_PATH
590 #          by temporarily specifying "+s"!
591 #
592 link_o.hpux32:
593         @ $(CALC_VERSIONS); \
594         SHLIB=lib$(LIBNAME).sl; \
595         SHLIB_SUFFIX=; \
596         LIBDEPS="$(LIBDEPS) -lc"; \
597         ALLSYMSFLAGS='-Fl'; \
598         NOALLSYMSFLAGS=''; \
599         SHAREDFLAGS="+vnocompatwarnings -b -z +s +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX +b $(LIBRPATH)"; \
600         SHAREDCMD='/usr/ccs/bin/ld'; \
601         $(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
602 link_a.hpux32:
603         @ $(CALC_VERSIONS); \
604         SHLIB=lib$(LIBNAME).sl; \
605         SHLIB_SUFFIX=; \
606         LIBDEPS="$(LIBDEPS) -lc"; \
607         ALLSYMSFLAGS='-Fl'; \
608         NOALLSYMSFLAGS=''; \
609         SHAREDFLAGS="+vnocompatwarnings -b -z +s +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX +b $(LIBRPATH)"; \
610         SHAREDCMD='/usr/ccs/bin/ld'; \
611         $(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
612 link_app.hpux32:
613         LDCMD=$(CC);\
614         LDFLAGS="-Wl,+b,$(LIBRPATH)"; \
615         LIBDEPS="$(LIBDEPS) -lc"; \
616         APPNAME="$(APPNAME)"
617         $(LINK_APP)
618
619 # HP-UX includes the full pathname of libs we depend on, so we would get
620 # ./libcrypto (with ./ as path information) compiled into libssl, hence
621 # we omit the SHLIBDEPS. Applications must be linked with -lssl -lcrypto
622 # anyway.
623 #
624 # HP-UX in 64bit mode has "+s" enabled by default; it will search for
625 # shared libraries along LD_LIBRARY_PATH _and_ SHLIB_PATH.
626 #
627 link_o.hpux64:
628         @ $(CALC_VERSIONS); \
629         SHLIB=lib$(LIBNAME).sl; \
630         SHLIB_SUFFIX=; \
631         LIBDEPS="$(LIBDEPS) -lc"; \
632         ALLSYMSFLAGS='+forceload'; \
633         NOALLSYMSFLAGS=''; \
634         SHAREDFLAGS="-b -z +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX +b $(LIBRPATH)"; \
635         SHAREDCMD='/usr/ccs/bin/ld'; \
636         $(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
637 link_a.hpux64:
638         @ $(CALC_VERSIONS); \
639         SHLIB=lib$(LIBNAME).sl; \
640         SHLIB_SUFFIX=; \
641         LIBDEPS="$(LIBDEPS) -lc"; \
642         ALLSYMSFLAGS='+forceload'; \
643         NOALLSYMSFLAGS=''; \
644         SHAREDFLAGS="-b -z +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX +b $(LIBRPATH)"; \
645         SHAREDCMD='/usr/ccs/bin/ld'; \
646         $(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
647 link_app.hpux64:
648         LDCMD=$(CC);\
649         LDFLAGS="-Wl,+b,$(LIBRPATH)"; \
650         LIBDEPS="$(LIBDEPS) -lc"; \
651         APPNAME="$(APPNAME)"
652         $(LINK_APP)
653
654 link_o.aix:
655         @ $(CALC_VERSIONS); \
656         SHLIB=lib$(LIBNAME).so; \
657         SHLIB_SUFFIX=; \
658         LIBDEPS="$(LIBDEPS) -lc"; \
659         ALLSYMSFLAGS='-bnogc'; \
660         NOALLSYMSFLAGS=''; \
661         SHAREDFLAGS='-G -bE:lib$(LIBNAME).exp -bM:SRE -blibpath:$(LIBRPATH)'; \
662         SHAREDCMD='$(CC)'; \
663         $(LINK_SO_O)
664 link_a.aix:
665         @ $(CALC_VERSIONS); \
666         SHLIB=lib$(LIBNAME).so; \
667         SHLIB_SUFFIX=; \
668         LIBDEPS="$(LIBDEPS) -lc"; \
669         ALLSYMSFLAGS='-bnogc'; \
670         NOALLSYMSFLAGS=''; \
671         SHAREDFLAGS='-G -bE:lib$(LIBNAME).exp -bM:SRE -blibpath:$(LIBRPATH)'; \
672         SHAREDCMD='$(CC)'; \
673         $(LINK_SO_A_VIA_O)
674 link_app.aix:
675         LDCMD=$(CC);\
676         LDFLAGS="-blibpath:$(LIBRPATH)"; \
677         LIBDEPS="$(LIBDEPS) -lc"; \
678         APPNAME="$(APPNAME)"
679         $(LINK_APP)
680
681 link_o.reliantunix:
682         @ $(CALC_VERSIONS); \
683         SHLIB=lib$(LIBNAME).so; \
684         SHLIB_SUFFIX=; \
685         LIBDEPS="$(LIBDEPS) -lc"; \
686         ALLSYMSFLAGS=; \
687         NOALLSYMSFLAGS=''; \
688         SHAREDFLAGS='-G'; \
689         SHAREDCMD='$(CC)'; \
690         $(LINK_SO_O)
691 link_a.reliantunix:
692         @ $(CALC_VERSIONS); \
693         SHLIB=lib$(LIBNAME).so; \
694         SHLIB_SUFFIX=; \
695         LIBDEPS="$(LIBDEPS) -lc"; \
696         ALLSYMSFLAGS=; \
697         NOALLSYMSFLAGS=''; \
698         SHAREDFLAGS='-G'; \
699         SHAREDCMD='$(CC)'; \
700         $(LINK_SO_A_UNPACKED)
701 link_app.reliantunix:
702         LDCMD=$(CC);\
703         LDFLAGS=""; \
704         LIBDEPS="$(LIBDEPS) -lc"; \
705         APPNAME="$(APPNAME)"
706         $(LINK_APP)
707
708 # Targets to build symbolic links when needed
709 symlink.gnu symlink.solaris symlink.svr3 symlink.svr5 symlink.irix \
710 symlink.aix symlink.reliantunix:
711         @ $(CALC_VERSIONS); \
712         SHLIB=lib$(LIBNAME).so; \
713         $(SYMLINK_SO)
714 symlink.darwin:
715         @ $(CALC_VERSIONS); \
716         SHLIB=lib$(LIBNAME); \
717         SHLIB_SUFFIX=.dylib; \
718         $(SYMLINK_SO)
719 symlink.hpux32 symlink.hpux64:
720         @ $(CALC_VERSIONS); \
721         SHLIB=lib$(LIBNAME).sl; \
722         $(SYMLINK_SO)
723 # The following lines means those specific architectures do no symlinks
724 symlink.cygwin symlib.alpha-osf1 symlink.tru64 symlink.tru64-rpath:
725
726 # Compatibility targets
727 link_o.bsd-gcc-shared link_o.linux-shared link_o.gnu-shared: link_o.gnu
728 link_a.bsd-gcc-shared link_a.linux-shared link_a.gnu-shared: link_a.gnu
729 link_app.bsd-gcc-shared link_app.linux-shared link_app.gnu-shared: link_app.gnu
730 symlink.bsd-gcc-shared symlink.linux-shared symlink.gnu-shared: symlink.gnu
731 link_o.darwin-shared: link_o.darwin
732 link_a.darwin-shared: link_a.darwin
733 link_app.darwin-shared: link_app.darwin
734 symlink.darwin-shared: symlink.darwin
735 link_o.cygwin-shared: link_o.cygwin
736 link_a.cygwin-shared: link_a.cygwin
737 link_app.cygwin-shared: link_app.cygwin
738 symlink.cygwin-shared: symlink.cygwin
739 link_o.alpha-osf1-shared: link_o.alpha-osf1
740 link_a.alpha-osf1-shared: link_a.alpha-osf1
741 link_app.alpha-osf1-shared: link_app.alpha-osf1
742 symlink.alpha-osf1-shared: symlink.alpha-osf1
743 link_o.tru64-shared: link_o.tru64
744 link_a.tru64-shared: link_a.tru64
745 link_app.tru64-shared: link_app.tru64
746 symlink.tru64-shared: symlink.tru64
747 link_o.tru64-shared-rpath: link_o.tru64-rpath
748 link_a.tru64-shared-rpath: link_a.tru64-rpath
749 link_app.tru64-shared-rpath: link_app.tru64-rpath
750 symlink.tru64-shared-rpath: symlink.tru64-rpath
751 link_o.solaris-shared: link_o.solaris
752 link_a.solaris-shared: link_a.solaris
753 link_app.solaris-shared: link_app.solaris
754 symlink.solaris-shared: symlink.solaris
755 link_o.svr3-shared: link_o.svr3
756 link_a.svr3-shared: link_a.svr3
757 link_app.svr3-shared: link_app.svr3
758 symlink.svr3-shared: symlink.svr3
759 link_o.svr5-shared: link_o.svr5
760 link_a.svr5-shared: link_a.svr5
761 link_app.svr5-shared: link_app.svr5
762 symlink.svr5-shared: symlink.svr5
763 link_o.irix-shared: link_o.irix
764 link_a.irix-shared: link_a.irix
765 link_app.irix-shared: link_app.irix
766 symlink.irix-shared: symlink.irix
767 link_o.hpux-shared: link_o.hpux32
768 link_a.hpux-shared: link_a.hpux32
769 link_app.hpux-shared: link_app.hpux32
770 symlink.hpux-shared: symlink.hpux32
771 link_o.hpux64-shared: link_o.hpux64
772 link_a.hpux64-shared: link_a.hpux64
773 link_app.hpux64-shared: link_app.hpux64
774 symlink.hpux64-shared: symlink.hpux64
775 link_o.aix-shared: link_o.aix
776 link_a.aix-shared: link_a.aix
777 link_app.aix-shared: link_app.aix
778 symlink.aix-shared: symlink.aix
779 link_o.reliantunix-shared: link_o.reliantunix
780 link_a.reliantunix-shared: link_a.reliantunix
781 link_app.reliantunix-shared: link_app.reliantunix
782 symlink.reliantunix-shared: symlink.reliantunix