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