Probably fix travis (wine build).
[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 CFLAGS=$(CFLAG)
11 # LDFLAGS contains flags to be used when temporary object files (when building
12 # shared libraries) are created, or when an application is linked.
13 # SHARED_LDFLAGS contains flags to be used when the shared library is created.
14 LDFLAGS=
15 SHARED_LDFLAGS=
16
17 NM=nm
18
19 # LIBNAME contains just the name of the library, without prefix ("lib"
20 # on Unix, "cyg" for certain forms under Cygwin...) or suffix (.a, .so,
21 # .dll, ...).  This one MUST have a value when using this makefile to
22 # build shared libraries.
23 # For example, to build libfoo.so, you need to do the following:
24 #LIBNAME=foo
25 LIBNAME=
26
27 # APPNAME contains just the name of the application, without suffix (""
28 # on Unix, ".exe" on Windows, ...).  This one MUST have a value when using
29 # this makefile to build applications.
30 # For example, to build foo, you need to do the following:
31 #APPNAME=foo
32 APPNAME=
33
34 # OBJECTS contains all the object files to link together into the application.
35 # This must contain at least one object file.
36 #OBJECTS=foo.o
37 OBJECTS=
38
39 # LIBEXTRAS contains extra modules to link together with the library.
40 # For example, if a second library, say libbar.a needs to be linked into
41 # libfoo.so, you need to do the following:
42 #LIBEXTRAS=libbar.a
43 # Note that this MUST be used when using the link_o targets, to hold the
44 # names of all object files that go into the target library.
45 LIBEXTRAS=
46
47 # LIBVERSION contains the current version of the library.
48 # For example, to build libfoo.so.1.2, you need to do the following:
49 #LIBVERSION=1.2
50 LIBVERSION=
51
52 # LIBCOMPATVERSIONS contains the compatibility versions (a list) of
53 # the library.  They MUST be in decreasing order.
54 # For example, if libfoo.so.1.2.1 is backward compatible with libfoo.so.1.2
55 # and libfoo.so.1, you need to do the following:
56 #LIBCOMPATVERSIONS=1.2 1
57 # Note that on systems that use sonames, the last number will appear as
58 # part of it.
59 # It's also possible, for systems that support it (Tru64, for example),
60 # to add extra compatibility info with more precision, by adding a second
61 # list of versions, separated from the first with a semicolon, like this:
62 #LIBCOMPATVERSIONS=1.2 1;1.2.0 1.1.2 1.1.1 1.1.0 1.0.0
63 LIBCOMPATVERSIONS=
64
65 # LIBDEPS contains all the flags necessary to cover all necessary
66 # dependencies to other libraries.
67 LIBDEPS=
68
69 #------------------------------------------------------------------------------
70 # The rest is private to this makefile.
71
72 SET_X=:
73 #SET_X=set -x
74
75 top:
76         echo "Trying to use this makefile interactively?  Don't."
77
78 CALC_VERSIONS=  \
79         SHLIB_COMPAT=; SHLIB_SOVER=; \
80         if [ -n "$(LIBVERSION)$(LIBCOMPATVERSIONS)" ]; then \
81                 prev=""; \
82                 for v in `echo "$(LIBVERSION) $(LIBCOMPATVERSIONS)" | cut -d';' -f1`; do \
83                         SHLIB_SOVER_NODOT=$$v; \
84                         SHLIB_SOVER=.$$v; \
85                         if [ -n "$$prev" ]; then \
86                                 SHLIB_COMPAT="$$SHLIB_COMPAT .$$prev"; \
87                         fi; \
88                         prev=$$v; \
89                 done; \
90         fi
91
92 LINK_APP=       \
93   ( $(SET_X);   \
94     LIBDEPS="$${LIBDEPS:-$(LIBDEPS)}"; \
95     LDCMD="$${LDCMD:-$(CC)}"; LDFLAGS="$${LDFLAGS:-$(CFLAGS)}"; \
96     LIBPATH=`for x in $$LIBDEPS; do echo $$x; done | sed -e 's/^ *-L//;t' -e d | uniq`; \
97     LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \
98     LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
99     $${LDCMD} $${LDFLAGS} -o $${APPNAME:=$(APPNAME)} $(OBJECTS) $${LIBDEPS} )
100
101 LINK_SO=        \
102   ( $(SET_X);   \
103     LIBDEPS="$${LIBDEPS:-$(LIBDEPS)}"; \
104     SHAREDCMD="$${SHAREDCMD:-$(CC)}"; \
105     SHAREDFLAGS="$${SHAREDFLAGS:-$(CFLAGS) $(SHARED_LDFLAGS)}"; \
106     LIBPATH=`for x in $$LIBDEPS; do echo $$x; done | sed -e 's/^ *-L//;t' -e d | uniq`; \
107     LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \
108     LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
109     $${SHAREDCMD} $${SHAREDFLAGS} \
110         -o $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \
111         $$ALLSYMSFLAGS $$SHOBJECTS $$NOALLSYMSFLAGS $$LIBDEPS \
112   ) && $(SYMLINK_SO)
113
114 SYMLINK_SO=     \
115         if [ -n "$$INHIBIT_SYMLINKS" ]; then :; else \
116                 prev=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \
117                 if [ -n "$$SHLIB_COMPAT" ]; then \
118                         for x in $$SHLIB_COMPAT; do \
119                                 ( $(SET_X); rm -f $$SHLIB$$x$$SHLIB_SUFFIX; \
120                                   ln -s $$prev $$SHLIB$$x$$SHLIB_SUFFIX ); \
121                                 prev=$$SHLIB$$x$$SHLIB_SUFFIX; \
122                         done; \
123                 fi; \
124                 if [ -n "$$SHLIB_SOVER" ]; then \
125                         ( $(SET_X); rm -f $$SHLIB$$SHLIB_SUFFIX; \
126                           ln -s $$prev $$SHLIB$$SHLIB_SUFFIX ); \
127                 fi; \
128         fi
129
130 LINK_SO_A=      SHOBJECTS="lib$(LIBNAME).a $(LIBEXTRAS)"; $(LINK_SO)
131 LINK_SO_O=      SHOBJECTS="$(LIBEXTRAS)"; $(LINK_SO)
132
133 LINK_SO_A_VIA_O=        \
134   SHOBJECTS=lib$(LIBNAME).o; \
135   ALL=$$ALLSYMSFLAGS; ALLSYMSFLAGS=; NOALLSYMSFLAGS=; \
136   ( $(SET_X); \
137     ld $(LDFLAGS) -r -o lib$(LIBNAME).o $$ALL lib$(LIBNAME).a $(LIBEXTRAS) ); \
138   $(LINK_SO) && rm -f lib$(LIBNAME).o
139
140 LINK_SO_A_UNPACKED=     \
141   UNPACKDIR=link_tmp.$$$$; rm -rf $$UNPACKDIR; mkdir $$UNPACKDIR; \
142   (cd $$UNPACKDIR; ar x ../lib$(LIBNAME).a) && \
143   ([ -z "$(LIBEXTRAS)" ] || cp $(LIBEXTRAS) $$UNPACKDIR) && \
144   SHOBJECTS=$$UNPACKDIR/*.o; \
145   $(LINK_SO) && rm -rf $$UNPACKDIR
146
147 DETECT_GNU_LD=($(CC) -Wl,-V /dev/null 2>&1 | grep '^GNU ld' )>/dev/null
148
149 DO_GNU_SO=$(CALC_VERSIONS); \
150         SHLIB=lib$(LIBNAME).so; \
151         SHLIB_SUFFIX=; \
152         ALLSYMSFLAGS='-Wl,--whole-archive'; \
153         NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
154         SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-Bsymbolic -Wl,-soname=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"
155
156 DO_GNU_APP=LDFLAGS="$(CFLAGS) -Wl,-rpath,$(LIBRPATH)"
157
158 #This is rather special.  It's a special target with which one can link
159 #applications without bothering with any features that have anything to
160 #do with shared libraries, for example when linking against static
161 #libraries.  It's mostly here to avoid a lot of conditionals everywhere
162 #else...
163 link_app.:
164         $(LINK_APP)
165
166 link_o.gnu:
167         @ $(DO_GNU_SO); $(LINK_SO_O)
168 link_a.gnu:
169         @ $(DO_GNU_SO); $(LINK_SO_A)
170 link_app.gnu:
171         @ $(DO_GNU_APP); $(LINK_APP)
172
173 link_o.bsd:
174         @if $(DETECT_GNU_LD); then $(DO_GNU_SO); else \
175         $(CALC_VERSIONS); \
176         SHLIB=lib$(LIBNAME).so; \
177         SHLIB_SUFFIX=; \
178         LIBDEPS=" "; \
179         ALLSYMSFLAGS="-Wl,-Bforcearchive"; \
180         NOALLSYMSFLAGS=; \
181         SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -nostdlib"; \
182         fi; $(LINK_SO_O)
183 link_a.bsd:
184         @if $(DETECT_GNU_LD); then $(DO_GNU_SO); else \
185         $(CALC_VERSIONS); \
186         SHLIB=lib$(LIBNAME).so; \
187         SHLIB_SUFFIX=; \
188         LIBDEPS=" "; \
189         ALLSYMSFLAGS="-Wl,-Bforcearchive"; \
190         NOALLSYMSFLAGS=; \
191         SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -nostdlib"; \
192         fi; $(LINK_SO_A)
193 link_app.bsd:
194         @if $(DETECT_GNU_LD); then $(DO_GNU_APP); else \
195         LDFLAGS="$(CFLAGS) -Wl,-rpath,$(LIBPATH)"; \
196         fi; $(LINK_APP)
197
198 # For Darwin AKA Mac OS/X (dyld)
199 # Originally link_o.darwin produced .so, because it was hard-coded
200 # in dso_dlfcn module. At later point dso_dlfcn switched to .dylib
201 # extension in order to allow for run-time linking with vendor-
202 # supplied shared libraries such as libz, so that link_o.darwin had
203 # to be harmonized with it. This caused minor controversy, because
204 # it was believed that dlopen can't be used to dynamically load
205 # .dylib-s, only so called bundle modules (ones linked with -bundle
206 # flag). The belief seems to be originating from pre-10.4 release,
207 # where dlfcn functionality was emulated by dlcompat add-on. In
208 # 10.4 dlopen was rewritten as native part of dyld and is documented
209 # to be capable of loading both dynamic libraries and bundles. In
210 # order to provide compatibility with pre-10.4 dlopen, modules are
211 # linked with -bundle flag, which makes .dylib extension misleading.
212 # It works, because dlopen is [and always was] extension-agnostic.
213 # Alternative to this heuristic approach is to develop specific
214 # MacOS X dso module relying on whichever "native" dyld interface.
215 link_o.darwin:
216         @ $(CALC_VERSIONS); \
217         SHLIB=lib$(LIBNAME); \
218         SHLIB_SUFFIX=.dylib; \
219         ALLSYMSFLAGS='-all_load'; \
220         NOALLSYMSFLAGS=''; \
221         SHAREDFLAGS="$(CFLAGS) `echo $(SHARED_LDFLAGS) | sed s/dynamiclib/bundle/`"; \
222         if [ -n "$(LIBVERSION)" ]; then \
223                 SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
224         fi; \
225         if [ -n "$$SHLIB_SOVER_NODOT" ]; then \
226                 SHAREDFLAGS="$$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \
227         fi; \
228         $(LINK_SO_O)
229 link_a.darwin:
230         @ $(CALC_VERSIONS); \
231         SHLIB=lib$(LIBNAME); \
232         SHLIB_SUFFIX=.dylib; \
233         ALLSYMSFLAGS='-all_load'; \
234         NOALLSYMSFLAGS=''; \
235         SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS)"; \
236         if [ -n "$(LIBVERSION)" ]; then \
237                 SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
238         fi; \
239         if [ -n "$$SHLIB_SOVER_NODOT" ]; then \
240                 SHAREDFLAGS="$$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \
241         fi; \
242         SHAREDFLAGS="$$SHAREDFLAGS -install_name $(INSTALLTOP)/$(LIBDIR)/$$SHLIB$(SHLIB_EXT)"; \
243         $(LINK_SO_A)
244 link_app.darwin:        # is there run-path on darwin?
245         $(LINK_APP)
246
247 link_o.cygwin:
248         @ $(CALC_VERSIONS); \
249         INHIBIT_SYMLINKS=yes; \
250         SHLIB=cyg$(LIBNAME); \
251         base=-Wl,--enable-auto-image-base; \
252         deffile=; \
253         if expr $(PLATFORM) : 'mingw' > /dev/null; then \
254                 SHLIB=$(LIBNAME)eay32; base=; \
255                 if test -f $(LIBNAME)eay32.def; then \
256                         deffile=$(LIBNAME)eay32.def; \
257                 fi; \
258         fi; \
259         SHLIB_SUFFIX=.dll; \
260         LIBVERSION="$(LIBVERSION)"; \
261         SHLIB_SOVER=${LIBVERSION:+"-$(LIBVERSION)"}; \
262         ALLSYMSFLAGS='-Wl,--whole-archive'; \
263         NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
264         SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base $$deffile -Wl,-s,-Bsymbolic"; \
265         $(LINK_SO_O)
266 #for mingw target if def-file is in use dll-name should match library-name
267 link_a.cygwin:
268         @ $(CALC_VERSIONS); \
269         INHIBIT_SYMLINKS=yes; \
270         SHLIB=cyg$(LIBNAME); SHLIB_SOVER=-$(LIBVERSION); SHLIB_SUFFIX=.dll; \
271         dll_name=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; extras=; \
272         base=-Wl,--enable-auto-image-base; \
273         if expr $(PLATFORM) : 'mingw' > /dev/null; then \
274                 case $(LIBNAME) in \
275                         crypto) SHLIB=libeay;; \
276                         ssl) SHLIB=ssleay;; \
277                 esac; \
278                 SHLIB_SOVER=32; \
279                 extras="$(LIBNAME).def"; \
280                 $(PERL) util/mkdef.pl 32 $$SHLIB > $$extras; \
281                 base=; [ $(LIBNAME) = "crypto" ] && base=-Wl,--image-base,0x63000000; \
282         fi; \
283         dll_name=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \
284         $(PERL) util/mkrc.pl $$dll_name | \
285                 $(CROSS_COMPILE)windres -o rc.o; \
286         extras="$$extras rc.o"; \
287         ALLSYMSFLAGS='-Wl,--whole-archive'; \
288         NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
289         SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base -Wl,-s,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a $$extras"; \
290         [ -f apps/$$dll_name ] && rm apps/$$dll_name; \
291         [ -f test/$$dll_name ] && rm test/$$dll_name; \
292         $(LINK_SO_A) || exit 1; \
293         rm $$extras; \
294         cp -p $$dll_name apps/; \
295         cp -p $$dll_name test/
296 link_app.cygwin:
297         @if expr "$(CFLAGS)" : '.*OPENSSL_USE_APPLINK' > /dev/null; then \
298                 LIBDEPS="$(TOP)/crypto/applink.o $${LIBDEPS:-$(LIBDEPS)}"; \
299                 export LIBDEPS; \
300         fi; \
301         $(LINK_APP)
302
303 link_o.alpha-osf1:
304         @ if $(DETECT_GNU_LD); then \
305                 $(DO_GNU_SO); \
306         else \
307                 SHLIB=lib$(LIBNAME).so; \
308                 SHLIB_SUFFIX=; \
309                 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
310                 if [ -n "$$SHLIB_HIST" ]; then \
311                         SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
312                 else \
313                         SHLIB_HIST="$(LIBVERSION)"; \
314                 fi; \
315                 SHLIB_SOVER=; \
316                 ALLSYMSFLAGS='-all'; \
317                 NOALLSYMSFLAGS='-none'; \
318                 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-B,symbolic"; \
319                 if [ -n "$$SHLIB_HIST" ]; then \
320                         SHAREDFLAGS="$$SHAREDFLAGS -set_version $$SHLIB_HIST"; \
321                 fi; \
322         fi; \
323         $(LINK_SO_O)
324 link_a.alpha-osf1:
325         @ if $(DETECT_GNU_LD); then \
326                 $(DO_GNU_SO); \
327         else \
328                 SHLIB=lib$(LIBNAME).so; \
329                 SHLIB_SUFFIX=; \
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="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-B,symbolic"; \
340                 if [ -n "$$SHLIB_HIST" ]; then \
341                         SHAREDFLAGS="$$SHAREDFLAGS -set_version $$SHLIB_HIST"; \
342                 fi; \
343         fi; \
344         $(LINK_SO_A)
345 link_app.alpha-osf1:
346         @if $(DETECT_GNU_LD); then \
347                 $(DO_GNU_APP); \
348         else \
349                 LDFLAGS="$(CFLAGS) -rpath $(LIBRPATH)"; \
350         fi; \
351         $(LINK_APP)
352
353 link_o.solaris:
354         @ if $(DETECT_GNU_LD); then \
355                 $(DO_GNU_SO); \
356         else \
357                 $(CALC_VERSIONS); \
358                 MINUSZ='-z '; \
359                 ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSZ='-Wl,-z,'; \
360                 SHLIB=lib$(LIBNAME).so; \
361                 SHLIB_SUFFIX=; \
362                 ALLSYMSFLAGS="$${MINUSZ}allextract"; \
363                 NOALLSYMSFLAGS="$${MINUSZ}defaultextract"; \
364                 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-Bsymbolic"; \
365         fi; \
366         $(LINK_SO_O)
367 link_a.solaris:
368         @ if $(DETECT_GNU_LD); then \
369                 $(DO_GNU_SO); \
370         else \
371                 $(CALC_VERSIONS); \
372                 MINUSZ='-z '; \
373                 ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSZ='-Wl,-z,'; \
374                 SHLIB=lib$(LIBNAME).so; \
375                 SHLIB_SUFFIX=;\
376                 ALLSYMSFLAGS="$${MINUSZ}allextract"; \
377                 NOALLSYMSFLAGS="$${MINUSZ}defaultextract"; \
378                 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-Bsymbolic"; \
379         fi; \
380         $(LINK_SO_A)
381 link_app.solaris:
382         @ if $(DETECT_GNU_LD); then \
383                 $(DO_GNU_APP); \
384         else \
385                 LDFLAGS="$(CFLAGS) -R $(LIBRPATH)"; \
386         fi; \
387         $(LINK_APP)
388
389 # OpenServer 5 native compilers used
390 link_o.svr3:
391         @ if $(DETECT_GNU_LD); then \
392                 $(DO_GNU_SO); \
393         else \
394                 $(CALC_VERSIONS); \
395                 SHLIB=lib$(LIBNAME).so; \
396                 SHLIB_SUFFIX=; \
397                 ALLSYMSFLAGS=''; \
398                 NOALLSYMSFLAGS=''; \
399                 SHAREDFLAGS="$(CFLAGS) -G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
400         fi; \
401         $(LINK_SO_O)
402 link_a.svr3:
403         @ if $(DETECT_GNU_LD); then \
404                 $(DO_GNU_SO); \
405         else \
406                 $(CALC_VERSIONS); \
407                 SHLIB=lib$(LIBNAME).so; \
408                 SHLIB_SUFFIX=; \
409                 ALLSYMSFLAGS=''; \
410                 NOALLSYMSFLAGS=''; \
411                 SHAREDFLAGS="$(CFLAGS) -G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
412         fi; \
413         $(LINK_SO_A_UNPACKED)
414 link_app.svr3:
415         @$(DETECT_GNU_LD) && $(DO_GNU_APP); \
416         $(LINK_APP)
417
418 # UnixWare 7 and OpenUNIX 8 native compilers used
419 link_o.svr5:
420         @ if $(DETECT_GNU_LD); then \
421                 $(DO_GNU_SO); \
422         else \
423                 $(CALC_VERSIONS); \
424                 SHARE_FLAG='-G'; \
425                 ($(CC) -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
426                 SHLIB=lib$(LIBNAME).so; \
427                 SHLIB_SUFFIX=; \
428                 ALLSYMSFLAGS=''; \
429                 NOALLSYMSFLAGS=''; \
430                 SHAREDFLAGS="$(CFLAGS) $${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
431         fi; \
432         $(LINK_SO_O)
433 link_a.svr5:
434         @ if $(DETECT_GNU_LD); then \
435                 $(DO_GNU_SO); \
436         else \
437                 $(CALC_VERSIONS); \
438                 SHARE_FLAG='-G'; \
439                 ($(CC) -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
440                 SHLIB=lib$(LIBNAME).so; \
441                 SHLIB_SUFFIX=; \
442                 ALLSYMSFLAGS=''; \
443                 NOALLSYMSFLAGS=''; \
444                 SHAREDFLAGS="$(CFLAGS) $${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
445         fi; \
446         $(LINK_SO_A_UNPACKED)
447 link_app.svr5:
448         @$(DETECT_GNU_LD) && $(DO_GNU_APP); \
449         $(LINK_APP)
450
451 link_o.irix:
452         @ if $(DETECT_GNU_LD); then \
453                 $(DO_GNU_SO); \
454         else \
455                 $(CALC_VERSIONS); \
456                 SHLIB=lib$(LIBNAME).so; \
457                 SHLIB_SUFFIX=; \
458                 MINUSWL=""; \
459                 ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSWL="-Wl,"; \
460                 ALLSYMSFLAGS="$${MINUSWL}-all"; \
461                 NOALLSYMSFLAGS="$${MINUSWL}-none"; \
462                 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,-B,symbolic"; \
463         fi; \
464         $(LINK_SO_O)
465 link_a.irix:
466         @ if $(DETECT_GNU_LD); then \
467                 $(DO_GNU_SO); \
468         else \
469                 $(CALC_VERSIONS); \
470                 SHLIB=lib$(LIBNAME).so; \
471                 SHLIB_SUFFIX=; \
472                 MINUSWL=""; \
473                 ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSWL="-Wl,"; \
474                 ALLSYMSFLAGS="$${MINUSWL}-all"; \
475                 NOALLSYMSFLAGS="$${MINUSWL}-none"; \
476                 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,-B,symbolic"; \
477         fi; \
478         $(LINK_SO_A)
479 link_app.irix:
480         @LDFLAGS="$(CFLAGS) -Wl,-rpath,$(LIBRPATH)"; \
481         $(LINK_APP)
482
483 # 32-bit PA-RISC HP-UX embeds the -L pathname of libs we link with, so
484 # we compensate for it with +cdp ../: and +cdp ./:. Yes, these rewrite
485 # rules imply that we can only link one level down in catalog structure,
486 # but that's what takes place for the moment of this writing. +cdp option
487 # was introduced in HP-UX 11.x and applies in 32-bit PA-RISC link
488 # editor context only [it's simply ignored in other cases, which are all
489 # ELFs by the way].
490 #
491 link_o.hpux:
492         @if $(DETECT_GNU_LD); then $(DO_GNU_SO); else \
493         $(CALC_VERSIONS); \
494         SHLIB=lib$(LIBNAME).sl; \
495         expr "$(CFLAGS)" : '.*DSO_DLFCN' > /dev/null && SHLIB=lib$(LIBNAME).so; \
496         SHLIB_SUFFIX=; \
497         ALLSYMSFLAGS='-Wl,-Fl'; \
498         NOALLSYMSFLAGS=''; \
499         expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \
500         SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,+cdp,../:,+cdp,./:"; \
501         fi; \
502         rm -f $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX || :; \
503         $(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
504 link_a.hpux:
505         @if $(DETECT_GNU_LD); then $(DO_GNU_SO); else \
506         $(CALC_VERSIONS); \
507         SHLIB=lib$(LIBNAME).sl; \
508         expr $(PLATFORM) : '.*ia64' > /dev/null && SHLIB=lib$(LIBNAME).so; \
509         SHLIB_SUFFIX=; \
510         ALLSYMSFLAGS='-Wl,-Fl'; \
511         NOALLSYMSFLAGS=''; \
512         expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \
513         SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,+cdp,../:,+cdp,./:"; \
514         fi; \
515         rm -f $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX || :; \
516         $(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
517 link_app.hpux:
518         @if $(DETECT_GNU_LD); then $(DO_GNU_APP); else \
519         LDFLAGS="$(CFLAGS) -Wl,+s,+cdp,../:,+cdp,./:,+b,$(LIBRPATH)"; \
520         fi; \
521         $(LINK_APP)
522
523 link_o.aix:
524         @ $(CALC_VERSIONS); \
525         OBJECT_MODE=`expr "x$(SHARED_LDFLAGS)" : 'x\-[a-z]*\(64\)'` || :; \
526         OBJECT_MODE=$${OBJECT_MODE:-32}; export OBJECT_MODE; \
527         SHLIB=lib$(LIBNAME).so; \
528         SHLIB_SUFFIX=; \
529         ALLSYMSFLAGS=''; \
530         NOALLSYMSFLAGS=''; \
531         SHAREDFLAGS='$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-bexpall,-bnolibpath,-bM:SRE'; \
532         $(LINK_SO_O);
533 link_a.aix:
534         @ $(CALC_VERSIONS); \
535         OBJECT_MODE=`expr "x$(SHARED_LDFLAGS)" : 'x\-[a-z]*\(64\)'` || : ; \
536         OBJECT_MODE=$${OBJECT_MODE:-32}; export OBJECT_MODE; \
537         SHLIB=lib$(LIBNAME).so; \
538         SHLIB_SUFFIX=; \
539         ALLSYMSFLAGS='-bnogc'; \
540         NOALLSYMSFLAGS=''; \
541         SHAREDFLAGS='$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-bexpall,-bnolibpath,-bM:SRE'; \
542         $(LINK_SO_A_VIA_O)
543 link_app.aix:
544         LDFLAGS="$(CFLAGS) -Wl,-brtl,-blibpath:$(LIBRPATH):$${LIBPATH:-/usr/lib:/lib}"; \
545         $(LINK_APP)
546
547
548 # Targets to build symbolic links when needed
549 symlink.gnu symlink.solaris symlink.svr3 symlink.svr5 symlink.irix \
550 symlink.aix:
551         @ $(CALC_VERSIONS); \
552         SHLIB=lib$(LIBNAME).so; \
553         $(SYMLINK_SO)
554 symlink.darwin:
555         @ $(CALC_VERSIONS); \
556         SHLIB=lib$(LIBNAME); \
557         SHLIB_SUFFIX=.dylib; \
558         $(SYMLINK_SO)
559 symlink.hpux:
560         @ $(CALC_VERSIONS); \
561         SHLIB=lib$(LIBNAME).sl; \
562         expr $(PLATFORM) : '.*ia64' > /dev/null && SHLIB=lib$(LIBNAME).so; \
563         $(SYMLINK_SO)
564 # The following lines means those specific architectures do no symlinks
565 symlink.cygwin symlink.alpha-osf1 symlink.tru64 symlink.tru64-rpath:
566
567 # Compatibility targets
568 link_o.bsd-gcc-shared link_o.linux-shared link_o.gnu-shared: link_o.gnu
569 link_a.bsd-gcc-shared link_a.linux-shared link_a.gnu-shared: link_a.gnu
570 link_app.bsd-gcc-shared link_app.linux-shared link_app.gnu-shared: link_app.gnu
571 symlink.bsd-gcc-shared symlink.bsd-shared symlink.linux-shared symlink.gnu-shared: symlink.gnu
572 link_o.bsd-shared: link_o.bsd
573 link_a.bsd-shared: link_a.bsd
574 link_app.bsd-shared: link_app.bsd
575 link_o.darwin-shared: link_o.darwin
576 link_a.darwin-shared: link_a.darwin
577 link_app.darwin-shared: link_app.darwin
578 symlink.darwin-shared: symlink.darwin
579 link_o.cygwin-shared: link_o.cygwin
580 link_a.cygwin-shared: link_a.cygwin
581 link_app.cygwin-shared: link_app.cygwin
582 symlink.cygwin-shared: symlink.cygwin
583 link_o.alpha-osf1-shared: link_o.alpha-osf1
584 link_a.alpha-osf1-shared: link_a.alpha-osf1
585 link_app.alpha-osf1-shared: link_app.alpha-osf1
586 symlink.alpha-osf1-shared: symlink.alpha-osf1
587 link_o.tru64-shared: link_o.tru64
588 link_a.tru64-shared: link_a.tru64
589 link_app.tru64-shared: link_app.tru64
590 symlink.tru64-shared: symlink.tru64
591 link_o.tru64-shared-rpath: link_o.tru64-rpath
592 link_a.tru64-shared-rpath: link_a.tru64-rpath
593 link_app.tru64-shared-rpath: link_app.tru64-rpath
594 symlink.tru64-shared-rpath: symlink.tru64-rpath
595 link_o.solaris-shared: link_o.solaris
596 link_a.solaris-shared: link_a.solaris
597 link_app.solaris-shared: link_app.solaris
598 symlink.solaris-shared: symlink.solaris
599 link_o.svr3-shared: link_o.svr3
600 link_a.svr3-shared: link_a.svr3
601 link_app.svr3-shared: link_app.svr3
602 symlink.svr3-shared: symlink.svr3
603 link_o.svr5-shared: link_o.svr5
604 link_a.svr5-shared: link_a.svr5
605 link_app.svr5-shared: link_app.svr5
606 symlink.svr5-shared: symlink.svr5
607 link_o.irix-shared: link_o.irix
608 link_a.irix-shared: link_a.irix
609 link_app.irix-shared: link_app.irix
610 symlink.irix-shared: symlink.irix
611 link_o.hpux-shared: link_o.hpux
612 link_a.hpux-shared: link_a.hpux
613 link_app.hpux-shared: link_app.hpux
614 symlink.hpux-shared: symlink.hpux
615 link_o.aix-shared: link_o.aix
616 link_a.aix-shared: link_a.aix
617 link_app.aix-shared: link_app.aix
618 symlink.aix-shared: symlink.aix