Fix Solaris 10_x86 shared build. -Bsymbolic is required to avoid
[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 link_o.bsd:
171         @if ${DETECT_GNU_LD}; then $(DO_GNU_SO); else \
172         $(CALC_VERSIONS); \
173         SHLIB=lib$(LIBNAME).so; \
174         SHLIB_SUFFIX=; \
175         LIBDEPS=; \
176         ALLSYMSFLAGS="-Wl,-Bforcearchive"; \
177         NOALLSYMSFLAGS=; \
178         SHAREDFLAGS="-shared -nostdlib"; \
179         SHAREDCMD=$(CC); \
180         fi; $(LINK_SO_O)
181 link_a.bsd:
182         @if ${DETECT_GNU_LD}; then $(DO_GNU_SO); else \
183         $(CALC_VERSIONS); \
184         SHLIB=lib$(LIBNAME).so; \
185         SHLIB_SUFFIX=; \
186         LIBDEPS=; \
187         ALLSYMSFLAGS="-Wl,-Bforcearchive"; \
188         NOALLSYMSFLAGS=; \
189         SHAREDFLAGS="-shared -nostdlib"; \
190         SHAREDCMD=$(CC); \
191         fi; $(LINK_SO_A)
192 link_app.bsd:
193         @if ${DETECT_GNU_LD}; then $(DO_GNU_APP); else \
194         LDCMD=$(CC); \
195         LDFLAGS="-Wl,-rpath,$(LIBPATH)"; \
196         LIBDEPS="$(LIBDEPS)"; \
197         APPNAME="$(APPNAME)"; \
198         fi; $(LINK_APP)
199
200 # For Darwin AKA Mac OS/X (dyld)
201 link_o.darwin:
202         @ $(CALC_VERSIONS); \
203         SHLIB=lib$(LIBNAME); \
204         SHLIB_SUFFIX=.dylib; \
205         LIBDEPS="$(LIBDEPS) -lc"; \
206         ALLSYMSFLAGS='-all_load'; \
207         NOALLSYMSFLAGS=''; \
208         SHAREDFLAGS="-dynamiclib"; \
209         SHAREDCMD='$(CC)'; \
210         if [ -n "$(LIBVERSION)" ]; then \
211                 SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
212         fi; \
213         if [ -n "$$SHLIB_SOVER_NODOT" ]; then \
214                 SHAREDFLAGS="$$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \
215         fi; \
216         $(LINK_SO_O)
217 link_a.darwin:
218         @ $(CALC_VERSIONS); \
219         SHLIB=lib$(LIBNAME); \
220         SHLIB_SUFFIX=.dylib; \
221         LIBDEPS="$(LIBDEPS) -lc"; \
222         ALLSYMSFLAGS='-all_load'; \
223         NOALLSYMSFLAGS=''; \
224         SHAREDFLAGS="-dynamiclib"; \
225         SHAREDCMD='$(CC)'; \
226         if [ -n "$(LIBVERSION)" ]; then \
227                 SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
228         fi; \
229         if [ -n "$$SHLIB_SOVER_NODOT" ]; then \
230                 SHAREDFLAGS="$$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \
231         fi; \
232         $(LINK_SO_A)
233 link_app.darwin:
234         LDCMD=$(CC);\
235         LDFLAGS=""; \
236         LIBDEPS="$(LIBDEPS) -lc"; \
237         APPNAME="$(APPNAME)"; \
238         $(LINK_APP)
239
240 link_o.cygwin:
241         @ $(CALC_VERSIONS); \
242         INHIBIT_SYMLINKS=yes; \
243         SHLIB=cyg$(LIBNAME); \
244         expr $(PLATFORM) : 'mingw' > /dev/null && SHLIB=$(LIBNAME)eay32; \
245         SHLIB_SUFFIX=.dll; \
246         LIBDEPS="$(LIBDEPS)"; \
247         SHLIB_SOVER=-$(LIBVERSION); \
248         ALLSYMSFLAGS='-Wl,--whole-archive'; \
249         NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
250         SHAREDFLAGS="-Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a"; \
251         SHAREDCMD='${CC}'; \
252         $(LINK_SO_O)
253 link_a.cygwin:
254         @ $(CALC_VERSIONS); \
255         INHIBIT_SYMLINKS=yes; \
256         SHLIB=cyg$(LIBNAME); \
257         expr $(PLATFORM) : 'mingw' > /dev/null && SHLIB=$(LIBNAME)eay32; \
258         SHLIB_SUFFIX=.dll; \
259         LIBDEPS="$(LIBDEPS)"; \
260         SHLIB_SOVER=; \
261         ALLSYMSFLAGS='-Wl,--whole-archive'; \
262         NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
263         SHAREDFLAGS="-Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a"; \
264         SHAREDCMD='${CC}'; \
265         $(LINK_SO_A)
266 link_app.cygwin:
267         LDCMD=$(CC);\
268         LDFLAGS=""; \
269         LIBDEPS="$(LIBDEPS)"; \
270         APPNAME="$(APPNAME)"; \
271         $(LINK_APP)
272
273 link_o.alpha-osf1:
274         @ if ${DETECT_GNU_LD}; then \
275                 $(DO_GNU_SO); \
276         else \
277                 SHLIB=lib$(LIBNAME).so; \
278                 SHLIB_SUFFIX=; \
279                 LIBDEPS="$(LIBDEPS) -lc"; \
280                 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
281                 if [ -n "$$SHLIB_HIST" ]; then \
282                         SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
283                 else \
284                         SHLIB_HIST="$(LIBVERSION)"; \
285                 fi; \
286                 SHLIB_SOVER=; \
287                 ALLSYMSFLAGS='-all'; \
288                 NOALLSYMSFLAGS='-none'; \
289                 SHAREDFLAGS="-shared"; \
290                 SHAREDCMD='$(CC)'; \
291                 if [ -n "$$SHLIB_HIST" ]; then \
292                         SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
293                 fi; \
294         fi; \
295         $(LINK_SO_O)
296 link_a.alpha-osf1:
297         @ if ${DETECT_GNU_LD}; then \
298                 $(DO_GNU_SO); \
299         else \
300                 SHLIB=lib$(LIBNAME).so; \
301                 SHLIB_SUFFIX=; \
302                 LIBDEPS="$(LIBDEPS) -lc"; \
303                 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
304                 if [ -n "$$SHLIB_HIST" ]; then \
305                         SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
306                 else \
307                         SHLIB_HIST="$(LIBVERSION)"; \
308                 fi; \
309                 SHLIB_SOVER=; \
310                 ALLSYMSFLAGS='-all'; \
311                 NOALLSYMSFLAGS='-none'; \
312                 SHAREDFLAGS="-shared"; \
313                 SHAREDCMD='$(CC)'; \
314                 if [ -n "$$SHLIB_HIST" ]; then \
315                         SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
316                 fi; \
317         fi; \
318         $(LINK_SO_A)
319 link_app.alpha-osf1:
320         @ if ${DETECT_GNU_LD}; then \
321                 $(DO_GNU_APP); \
322         else \
323                 LDCMD=$(CC);\
324                 LDFLAGS=""; \
325                 LIBDEPS="$(LIBDEPS) -lc"; \
326                 APPNAME="$(APPNAME)"
327         fi; \
328         $(LINK_APP)
329
330 # The difference between alpha-osf1-shared and tru64-shared is the `-msym'
331 # option passed to the linker.
332 link_o.tru64:
333         @ if ${DETECT_GNU_LD}; then \
334                 $(DO_GNU_SO); \
335         else \
336                 SHLIB=lib$(LIBNAME).so; \
337                 SHLIB_SUFFIX=; \
338                 LIBDEPS="$(LIBDEPS) -lc"; \
339                 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
340                 if [ -n "$$SHLIB_HIST" ]; then \
341                         SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
342                 else \
343                         SHLIB_HIST="$(LIBVERSION)"; \
344                 fi; \
345                 SHLIB_SOVER=; \
346                 ALLSYMSFLAGS='-all'; \
347                 NOALLSYMSFLAGS='-none'; \
348                 SHAREDFLAGS="-shared -msym -rpath $(LIBRPATH)"; \
349                 SHAREDCMD='$(CC)'; \
350                 if [ -n "$$SHLIB_HIST" ]; then \
351                         SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
352                 fi; \
353         fi; \
354         $(LINK_SO_O)
355 link_a.tru64:
356         @ if ${DETECT_GNU_LD}; then \
357                 $(DO_GNU_SO); \
358         else \
359                 SHLIB=lib$(LIBNAME).so; \
360                 SHLIB_SUFFIX=; \
361                 LIBDEPS="$(LIBDEPS) -lc"; \
362                 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
363                 if [ -n "$$SHLIB_HIST" ]; then \
364                         SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
365                 else \
366                         SHLIB_HIST="$(LIBVERSION)"; \
367                 fi; \
368                 SHLIB_SOVER=; \
369                 ALLSYMSFLAGS='-all'; \
370                 NOALLSYMSFLAGS='-none'; \
371                 SHAREDFLAGS="-shared -msym -rpath $(LIBRPATH)"; \
372                 SHAREDCMD='$(CC)'; \
373                 if [ -n "$$SHLIB_HIST" ]; then \
374                         SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
375                 fi; \
376         fi; \
377         $(LINK_SO_A)
378 link_app.tru64:
379         @ if ${DETECT_GNU_LD}; then \
380                 $(DO_GNU_APP); \
381         else \
382                 LDCMD=$(CC);\
383                 LDFLAGS="-rpath $(LIBRPATH)"; \
384                 LIBDEPS="$(LIBDEPS) -lc"; \
385                 APPNAME="$(APPNAME)"; \
386         fi; \
387         $(LINK_APP)
388
389 # The difference between tru64-shared and tru64-shared-rpath is the
390 # -rpath ${LIBRPATH} passed to the linker.
391 link_o.tru64-rpath:
392         @ if ${DETECT_GNU_LD}; then \
393                 $(DO_GNU_SO); \
394         else \
395                 SHLIB=lib$(LIBNAME).so; \
396                 SHLIB_SUFFIX=; \
397                 LIBDEPS="$(LIBDEPS) -lc"; \
398                 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
399                 if [ -n "$$SHLIB_HIST" ]; then \
400                         SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
401                 else \
402                         SHLIB_HIST="$(LIBVERSION)"; \
403                 fi; \
404                 SHLIB_SOVER=; \
405                 ALLSYMSFLAGS='-all'; \
406                 NOALLSYMSFLAGS='-none'; \
407                 SHAREDFLAGS="-shared -msym -rpath $(LIBRPATH)"; \
408                 SHAREDCMD='$(CC)'; \
409                 if [ -n "$$SHLIB_HIST" ]; then \
410                         SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
411                 fi; \
412         fi; \
413         $(LINK_SO_O)
414 link_a.tru64-rpath:
415         @ if ${DETECT_GNU_LD}; then \
416                 $(DO_GNU_SO); \
417         else \
418                 SHLIB=lib$(LIBNAME).so; \
419                 SHLIB_SUFFIX=; \
420                 LIBDEPS="$(LIBDEPS) -lc"; \
421                 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
422                 if [ -n "$$SHLIB_HIST" ]; then \
423                         SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
424                 else \
425                         SHLIB_HIST="$(LIBVERSION)"; \
426                 fi; \
427                 SHLIB_SOVER=; \
428                 ALLSYMSFLAGS='-all'; \
429                 NOALLSYMSFLAGS='-none'; \
430                 SHAREDFLAGS="-shared -msym -rpath $(LIBRPATH)"; \
431                 SHAREDCMD='$(CC)'; \
432                 if [ -n "$$SHLIB_HIST" ]; then \
433                         SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
434                 fi; \
435         fi; \
436         $(LINK_SO_A)
437 link_app.tru64-rpath:
438         @ if ${DETECT_GNU_LD}; then \
439                 $(DO_GNU_APP); \
440         else \
441                 LDCMD=$(CC);\
442                 LDFLAGS="-rpath $(LIBRPATH)"; \
443                 LIBDEPS="$(LIBDEPS) -lc"; \
444                 APPNAME="$(APPNAME)"; \
445         fi; \
446         $(LINK_APP)
447
448 link_o.solaris:
449         @ if ${DETECT_GNU_LD}; then \
450                 $(DO_GNU_SO); \
451         else \
452                 $(CALC_VERSIONS); \
453                 MINUSZ='-z '; \
454                 (${CC} -v 2>&1 | grep gcc) > /dev/null && MINUSZ='-Wl,-z,'; \
455                 SHLIB=lib$(LIBNAME).so; \
456                 SHLIB_SUFFIX=; \
457                 LIBDEPS="$(LIBDEPS) -lc"; \
458                 ALLSYMSFLAGS="$${MINUSZ}allextract"; \
459                 NOALLSYMSFLAGS="$${MINUSZ}defaultextract"; \
460                 SHAREDFLAGS="-G -dy -z text -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -R $(LIBRPATH) -Wl,-Bsymbolic"; \
461                 SHAREDCMD='$(CC)'; \
462         fi; \
463         $(LINK_SO_O)
464 link_a.solaris:
465         @ if ${DETECT_GNU_LD}; then \
466                 $(DO_GNU_SO); \
467         else \
468                 $(CALC_VERSIONS); \
469                 MINUSZ='-z '; \
470                 (${CC} -v 2>&1 | grep gcc) > /dev/null && MINUSZ='-Wl,-z,'; \
471                 SHLIB=lib$(LIBNAME).so; \
472                 SHLIB_SUFFIX=;\
473                 LIBDEPS="$(LIBDEPS) -lc"; \
474                 ALLSYMSFLAGS="$${MINUSZ}allextract"; \
475                 NOALLSYMSFLAGS="$${MINUSZ}defaultextract"; \
476                 SHAREDFLAGS="-G -dy -z text -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -R $(LIBRPATH) -Wl,-Bsymbolic"; \
477                 SHAREDCMD='$(CC)'; \
478         fi; \
479         $(LINK_SO_A)
480 link_app.solaris:
481         @ if ${DETECT_GNU_LD}; then \
482                 $(DO_GNU_APP); \
483         else \
484                 LDCMD=$(CC);\
485                 LDFLAGS="-R $(LIBRPATH)"; \
486                 LIBDEPS="$(LIBDEPS) -lc"; \
487                 APPNAME="$(APPNAME)"; \
488         fi; \
489         $(LINK_APP)
490
491 # OpenServer 5 native compilers used
492 link_o.svr3:
493         @ if ${DETECT_GNU_LD}; then \
494                 $(DO_GNU_SO); \
495         else \
496                 $(CALC_VERSIONS); \
497                 SHLIB=lib$(LIBNAME).so; \
498                 SHLIB_SUFFIX=; \
499                 LIBDEPS="$(LIBDEPS) -lc"; \
500                 ALLSYMSFLAGS=''; \
501                 NOALLSYMSFLAGS=''; \
502                 SHAREDFLAGS="-G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
503                 SHAREDCMD='$(CC)'; \
504         fi; \
505         $(LINK_SO_O)
506 link_a.svr3:
507         @ if ${DETECT_GNU_LD}; then \
508                 $(DO_GNU_SO); \
509         else \
510                 $(CALC_VERSIONS); \
511                 SHLIB=lib$(LIBNAME).so; \
512                 SHLIB_SUFFIX=; \
513                 LIBDEPS="$(LIBDEPS) -lc"; \
514                 ALLSYMSFLAGS=''; \
515                 NOALLSYMSFLAGS=''; \
516                 SHAREDFLAGS="-G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
517                 SHAREDCMD='$(CC)'; \
518         fi; \
519         $(LINK_SO_A_UNPACKED)
520 link_app.svr3:
521         @ if ${DETECT_GNU_LD}; then \
522                 $(DO_GNU_APP); \
523         else \
524                 LDCMD=$(CC);\
525                 LDFLAGS=""; \
526                 LIBDEPS="$(LIBDEPS) -lc"; \
527                 APPNAME="$(APPNAME)"; \
528         fi; \
529         $(LINK_APP)
530
531 # UnixWare 7 and OpenUNIX 8 native compilers used
532 link_o.svr5:
533         @ if ${DETECT_GNU_LD}; then \
534                 $(DO_GNU_SO); \
535         else \
536                 $(CALC_VERSIONS); \
537                 SHARE_FLAG='-G'; \
538                 (${CC} -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
539                 SHLIB=lib$(LIBNAME).so; \
540                 SHLIB_SUFFIX=; \
541                 LIBDEPS="$(LIBDEPS) -lc"; \
542                 ALLSYMSFLAGS=''; \
543                 NOALLSYMSFLAGS=''; \
544                 SHAREDFLAGS="$${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
545                 SHAREDCMD='$(CC)'; \
546         fi; \
547         $(LINK_SO_O)
548 link_a.svr5:
549         @ if ${DETECT_GNU_LD}; then \
550                 $(DO_GNU_SO); \
551         else \
552                 $(CALC_VERSIONS); \
553                 SHARE_FLAG='-G'; \
554                 (${CC} -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
555                 SHLIB=lib$(LIBNAME).so; \
556                 SHLIB_SUFFIX=; \
557                 LIBDEPS="$(LIBDEPS) -lc"; \
558                 ALLSYMSFLAGS=''; \
559                 NOALLSYMSFLAGS=''; \
560                 SHAREDFLAGS="$${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
561                 SHAREDCMD='$(CC)'; \
562         fi; \
563         $(LINK_SO_A_UNPACKED)
564 link_app.svr5:
565         @ if ${DETECT_GNU_LD}; then \
566                 $(DO_GNU_APP); \
567         else \
568                 LDCMD=$(CC);\
569                 LDFLAGS=""; \
570                 LIBDEPS="$(LIBDEPS) -lc"; \
571                 APPNAME="$(APPNAME)"; \
572         fi; \
573         $(LINK_APP)
574
575 link_o.irix:
576         @ if ${DETECT_GNU_LD}; then \
577                 $(DO_GNU_SO); \
578         else \
579                 $(CALC_VERSIONS); \
580                 SHLIB=lib$(LIBNAME).so; \
581                 SHLIB_SUFFIX=; \
582                 LIBDEPS="$(LIBDEPS) -lc"; \
583                 MINUSWL=""; \
584                 ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSWL="-Wl,"; \
585                 ALLSYMSFLAGS="$${MINUSWL}-all"; \
586                 NOALLSYMSFLAGS="$${MINUSWL}-notall"; \
587                 SHAREDFLAGS="-shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-rpath,$(LIBRPATH)"; \
588                 SHAREDCMD='$(CC)'; \
589         fi; \
590         $(LINK_SO_O)
591 link_a.irix:
592         @ if ${DETECT_GNU_LD}; then \
593                 $(DO_GNU_SO); \
594         else \
595                 $(CALC_VERSIONS); \
596                 SHLIB=lib$(LIBNAME).so; \
597                 SHLIB_SUFFIX=; \
598                 LIBDEPS="$(LIBDEPS) -lc"; \
599                 MINUSWL=""; \
600                 ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSWL="-Wl,"; \
601                 ALLSYMSFLAGS="$${MINUSWL}-all"; \
602                 NOALLSYMSFLAGS="$${MINUSWL}-notall"; \
603                 SHAREDFLAGS="-shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-rpath,$(LIBRPATH)"; \
604                 SHAREDCMD='$(CC)'; \
605         fi; \
606         $(LINK_SO_A)
607 link_app.irix:
608         @ if ${DETECT_GNU_LD}; then \
609                 $(DO_GNU_APP); \
610         else \
611                 LDCMD=$(CC);\
612                 LDFLAGS="-Wl,-rpath,$(LIBRPATH)"; \
613                 LIBDEPS="$(LIBDEPS) -lc"; \
614                 APPNAME="$(APPNAME)"; \
615         fi; \
616         $(LINK_APP)
617
618 # 32-bit PA-RISC HP-UX embeds the -L pathname of libs we link with, so
619 # we compensate for it with +cdp ../: and +cdp ./:. Yes, these rewrite
620 # rules imply that we can only link one level down in catalog structure,
621 # but that's what takes place for the moment of this writing. +cdp option
622 # was introduced in HP-UX 11.x and applies in 32-bit PA-RISC link
623 # editor context only [it's simply ignored in other cases, which are all
624 # ELFs by the way].
625 #
626 link_o.hpux:
627         @if ${DETECT_GNU_LD}; then $(DO_GNU_SO); else \
628         $(CALC_VERSIONS); \
629         SHLIB=lib$(LIBNAME).sl; \
630         expr $(PLATFORM) : '.*ia64' > /dev/null && SHLIB=lib$(LIBNAME).so; \
631         SHLIB_SUFFIX=; \
632         LIBDEPS="$(LIBDEPS)"; \
633         ALLSYMSFLAGS='-Wl,-Fl'; \
634         NOALLSYMSFLAGS=''; \
635         expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \
636         SHAREDFLAGS="-Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+cdp,../:,+cdp,./:,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,+b,$(LIBRPATH)"; \
637         SHAREDCMD=$(CC); \
638         fi; \
639         $(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
640 link_a.hpux:
641         @if ${DETECT_GNU_LD}; then $(DO_GNU_SO); else \
642         $(CALC_VERSIONS); \
643         SHLIB=lib$(LIBNAME).sl; \
644         expr $(PLATFORM) : '.*ia64' > /dev/null && SHLIB=lib$(LIBNAME).so; \
645         SHLIB_SUFFIX=; \
646         LIBDEPS="$(LIBDEPS)"; \
647         ALLSYMSFLAGS='-Wl,-Fl'; \
648         NOALLSYMSFLAGS=''; \
649         expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \
650         SHAREDFLAGS="-Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+cdp,../:,+cdp,./:,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,+b,$(LIBRPATH)"; \
651         SHAREDCMD='$(CC)'; \
652         fi; \
653         $(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
654 link_app.hpux:
655         @if ${DETECT_GNU_LD}; then $(DO_GNU_APP); else \
656         LDCMD=$(CC);\
657         LDFLAGS="-Wl,+s,+cdp,../:,+cdp,./:,+b,$(LIBRPATH)"; \
658         LIBDEPS="$(LIBDEPS)"; \
659         APPNAME="$(APPNAME)"; \
660         fi; \
661         $(LINK_APP)
662
663 link_o.aix:
664         @ $(CALC_VERSIONS); \
665         SHLIB=lib$(LIBNAME).so; \
666         SHLIB_SUFFIX=; \
667         LIBDEPS="$(LIBDEPS) -lc"; \
668         ALLSYMSFLAGS='-bnogc'; \
669         NOALLSYMSFLAGS=''; \
670         SHAREDFLAGS='-G -bE:lib$(LIBNAME).exp -bM:SRE -blibpath:$(LIBRPATH)'; \
671         SHAREDCMD='$(CC)'; \
672         $(LINK_SO_O)
673 link_a.aix:
674         @ $(CALC_VERSIONS); \
675         SHLIB=lib$(LIBNAME).so; \
676         SHLIB_SUFFIX=; \
677         LIBDEPS="$(LIBDEPS) -lc"; \
678         ALLSYMSFLAGS='-bnogc'; \
679         NOALLSYMSFLAGS=''; \
680         SHAREDFLAGS='-G -bE:lib$(LIBNAME).exp -bM:SRE -blibpath:$(LIBRPATH)'; \
681         SHAREDCMD='$(CC)'; \
682         $(LINK_SO_A_VIA_O)
683 link_app.aix:
684         LDCMD=$(CC);\
685         LDFLAGS="-blibpath:$(LIBRPATH)"; \
686         LIBDEPS="$(LIBDEPS) -lc"; \
687         APPNAME="$(APPNAME)"
688         $(LINK_APP)
689
690 link_o.reliantunix:
691         @ $(CALC_VERSIONS); \
692         SHLIB=lib$(LIBNAME).so; \
693         SHLIB_SUFFIX=; \
694         LIBDEPS="$(LIBDEPS) -lc"; \
695         ALLSYMSFLAGS=; \
696         NOALLSYMSFLAGS=''; \
697         SHAREDFLAGS='-G'; \
698         SHAREDCMD='$(CC)'; \
699         $(LINK_SO_O)
700 link_a.reliantunix:
701         @ $(CALC_VERSIONS); \
702         SHLIB=lib$(LIBNAME).so; \
703         SHLIB_SUFFIX=; \
704         LIBDEPS="$(LIBDEPS) -lc"; \
705         ALLSYMSFLAGS=; \
706         NOALLSYMSFLAGS=''; \
707         SHAREDFLAGS='-G'; \
708         SHAREDCMD='$(CC)'; \
709         $(LINK_SO_A_UNPACKED)
710 link_app.reliantunix:
711         LDCMD=$(CC);\
712         LDFLAGS=""; \
713         LIBDEPS="$(LIBDEPS) -lc"; \
714         APPNAME="$(APPNAME)"
715         $(LINK_APP)
716
717 # Targets to build symbolic links when needed
718 symlink.gnu symlink.solaris symlink.svr3 symlink.svr5 symlink.irix \
719 symlink.aix symlink.reliantunix:
720         @ $(CALC_VERSIONS); \
721         SHLIB=lib$(LIBNAME).so; \
722         $(SYMLINK_SO)
723 symlink.darwin:
724         @ $(CALC_VERSIONS); \
725         SHLIB=lib$(LIBNAME); \
726         SHLIB_SUFFIX=.dylib; \
727         $(SYMLINK_SO)
728 symlink.hpux:
729         @ $(CALC_VERSIONS); \
730         SHLIB=lib$(LIBNAME).sl; \
731         expr $(PLATFORM) : '.*ia64' > /dev/null && SHLIB=lib$(LIBNAME).so; \
732         $(SYMLINK_SO)
733 # The following lines means those specific architectures do no symlinks
734 symlink.cygwin symlib.alpha-osf1 symlink.tru64 symlink.tru64-rpath:
735
736 # Compatibility targets
737 link_o.bsd-gcc-shared link_o.linux-shared link_o.gnu-shared: link_o.gnu
738 link_a.bsd-gcc-shared link_a.linux-shared link_a.gnu-shared: link_a.gnu
739 link_app.bsd-gcc-shared link_app.linux-shared link_app.gnu-shared: link_app.gnu
740 symlink.bsd-gcc-shared symlink.bsd-shared symlink.linux-shared symlink.gnu-shared: symlink.gnu
741 link_o.bsd-shared: link_o.bsd
742 link_a.bsd-shared: link_a.bsd
743 link_app.bsd-shared: link_app.bsd
744 link_o.darwin-shared: link_o.darwin
745 link_a.darwin-shared: link_a.darwin
746 link_app.darwin-shared: link_app.darwin
747 symlink.darwin-shared: symlink.darwin
748 link_o.cygwin-shared: link_o.cygwin
749 link_a.cygwin-shared: link_a.cygwin
750 link_app.cygwin-shared: link_app.cygwin
751 symlink.cygwin-shared: symlink.cygwin
752 link_o.alpha-osf1-shared: link_o.alpha-osf1
753 link_a.alpha-osf1-shared: link_a.alpha-osf1
754 link_app.alpha-osf1-shared: link_app.alpha-osf1
755 symlink.alpha-osf1-shared: symlink.alpha-osf1
756 link_o.tru64-shared: link_o.tru64
757 link_a.tru64-shared: link_a.tru64
758 link_app.tru64-shared: link_app.tru64
759 symlink.tru64-shared: symlink.tru64
760 link_o.tru64-shared-rpath: link_o.tru64-rpath
761 link_a.tru64-shared-rpath: link_a.tru64-rpath
762 link_app.tru64-shared-rpath: link_app.tru64-rpath
763 symlink.tru64-shared-rpath: symlink.tru64-rpath
764 link_o.solaris-shared: link_o.solaris
765 link_a.solaris-shared: link_a.solaris
766 link_app.solaris-shared: link_app.solaris
767 symlink.solaris-shared: symlink.solaris
768 link_o.svr3-shared: link_o.svr3
769 link_a.svr3-shared: link_a.svr3
770 link_app.svr3-shared: link_app.svr3
771 symlink.svr3-shared: symlink.svr3
772 link_o.svr5-shared: link_o.svr5
773 link_a.svr5-shared: link_a.svr5
774 link_app.svr5-shared: link_app.svr5
775 symlink.svr5-shared: symlink.svr5
776 link_o.irix-shared: link_o.irix
777 link_a.irix-shared: link_a.irix
778 link_app.irix-shared: link_app.irix
779 symlink.irix-shared: symlink.irix
780 link_o.hpux-shared: link_o.hpux
781 link_a.hpux-shared: link_a.hpux
782 link_app.hpux-shared: link_app.hpux
783 symlink.hpux-shared: symlink.hpux
784 link_o.aix-shared: link_o.aix
785 link_a.aix-shared: link_a.aix
786 link_app.aix-shared: link_app.aix
787 symlink.aix-shared: symlink.aix
788 link_o.reliantunix-shared: link_o.reliantunix
789 link_a.reliantunix-shared: link_a.reliantunix
790 link_app.reliantunix-shared: link_app.reliantunix
791 symlink.reliantunix-shared: symlink.reliantunix