Make AES_T[ed] private to aes-586 module.
[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 if echo $$x | grep '^ *-L' > /dev/null 2>&1; then echo $$x | sed -e 's/^ *-L//'; fi; done | 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 if echo $$x | grep '^ *-L' > /dev/null 2>&1; then echo $$x | sed -e 's/^ *-L//'; fi; done | 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 $(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 DO_BEOS_SO=     SHLIB=lib$(LIBNAME).so; \
174         SHLIB_SUFFIX=; \
175         ALLSYMSFLAGS='-Wl,--whole-archive'; \
176         NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
177         SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-Bsymbolic -Wl,-soname=$$SHLIB$$SHLIB_SUFFIX"
178
179 link_o.beos:
180         @ $(DO_BEOS_SO); $(LINK_SO_O)
181 link_a.beos:
182         @ $(DO_BEOS_SO); $(LINK_SO_A)
183
184 link_o.bsd:
185         @if ${DETECT_GNU_LD}; then $(DO_GNU_SO); else \
186         $(CALC_VERSIONS); \
187         SHLIB=lib$(LIBNAME).so; \
188         SHLIB_SUFFIX=; \
189         LIBDEPS=" "; \
190         ALLSYMSFLAGS="-Wl,-Bforcearchive"; \
191         NOALLSYMSFLAGS=; \
192         SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -nostdlib"; \
193         fi; $(LINK_SO_O)
194 link_a.bsd:
195         @if ${DETECT_GNU_LD}; then $(DO_GNU_SO); else \
196         $(CALC_VERSIONS); \
197         SHLIB=lib$(LIBNAME).so; \
198         SHLIB_SUFFIX=; \
199         LIBDEPS=" "; \
200         ALLSYMSFLAGS="-Wl,-Bforcearchive"; \
201         NOALLSYMSFLAGS=; \
202         SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -nostdlib"; \
203         fi; $(LINK_SO_A)
204 link_app.bsd:
205         @if ${DETECT_GNU_LD}; then $(DO_GNU_APP); else \
206         LDFLAGS="$(CFLAGS) -Wl,-rpath,$(LIBPATH)"; \
207         fi; $(LINK_APP)
208
209 # For Darwin AKA Mac OS/X (dyld)
210 # link_o.darwin produces .so, because we let it use dso_dlfcn module,
211 # which has .so extension hard-coded. One can argue that one should
212 # develop special dso module for MacOS X. At least manual encourages
213 # to use native NSModule(3) API and refers to dlfcn as termporary hack.
214 link_o.darwin:
215         @ $(CALC_VERSIONS); \
216         SHLIB=lib$(LIBNAME); \
217         SHLIB_SUFFIX=.so; \
218         ALLSYMSFLAGS='-all_load'; \
219         NOALLSYMSFLAGS=''; \
220         SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS)"; \
221         if [ -n "$(LIBVERSION)" ]; then \
222                 SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
223         fi; \
224         if [ -n "$$SHLIB_SOVER_NODOT" ]; then \
225                 SHAREDFLAGS="$$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \
226         fi; \
227         $(LINK_SO_O)
228 link_a.darwin:
229         @ $(CALC_VERSIONS); \
230         SHLIB=lib$(LIBNAME); \
231         SHLIB_SUFFIX=.dylib; \
232         ALLSYMSFLAGS='-all_load'; \
233         NOALLSYMSFLAGS=''; \
234         SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS)"; \
235         if [ -n "$(LIBVERSION)" ]; then \
236                 SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
237         fi; \
238         if [ -n "$$SHLIB_SOVER_NODOT" ]; then \
239                 SHAREDFLAGS="$$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \
240         fi; \
241         SHAREDFLAGS="$$SHAREDFLAGS -install_name ${INSTALLTOP}/lib/$$SHLIB${SHLIB_EXT}"; \
242         $(LINK_SO_A)
243 link_app.darwin:        # is there run-path on darwin?
244         $(LINK_APP)
245
246 link_o.cygwin:
247         @ $(CALC_VERSIONS); \
248         INHIBIT_SYMLINKS=yes; \
249         SHLIB=cyg$(LIBNAME); \
250         base=-Wl,--enable-auto-image-base; \
251         if expr $(PLATFORM) : 'mingw' > /dev/null; then \
252                  SHLIB=$(LIBNAME); base=; \
253         fi; \
254         SHLIB_SUFFIX=.dll; \
255         LIBVERSION="$(LIBVERSION)"; \
256         SHLIB_SOVER=${LIBVERSION:+"-$(LIBVERSION)"}; \
257         ALLSYMSFLAGS='-Wl,--whole-archive'; \
258         NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
259         SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base -Wl,-s,-Bsymbolic"; \
260         $(LINK_SO_O)
261 link_a.cygwin:
262         @ $(CALC_VERSIONS); \
263         INHIBIT_SYMLINKS=yes; \
264         SHLIB=cyg$(LIBNAME); SHLIB_SOVER=-$(LIBVERSION); SHLIB_SUFFIX=.dll; \
265         dll_name=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; extras=; \
266         base=-Wl,--enable-auto-image-base; \
267         if expr $(PLATFORM) : 'mingw' > /dev/null; then \
268                 SHLIB=$(LIBNAME); SHLIB_SOVER=32; \
269                 extras="$(LIBNAME).def"; \
270                 $(PERL) util/mkdef.pl 32 $(LIBNAME) > $$extras; \
271                 base=; [ $(LIBNAME) = "crypto" ] && base=-Wl,--image-base,0x63000000; \
272         fi; \
273         dll_name=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \
274         $(PERL) util/mkrc.pl $$dll_name | \
275                 $(CROSS_COMPILE_PREFIX)windres -o rc.o; \
276         extras="$$extras rc.o"; \
277         ALLSYMSFLAGS='-Wl,--whole-archive'; \
278         NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
279         SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base -Wl,-s,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a $$extras"; \
280         [ -f apps/$$dll_name ] && rm apps/$$dll_name; \
281         [ -f test/$$dll_name ] && rm test/$$dll_name; \
282         $(LINK_SO_A) || exit 1; \
283         rm $$extras; \
284         cp -p $$dll_name apps/; \
285         cp -p $$dll_name test/
286 link_app.cygwin:
287         @if expr "$(CFLAGS)" : '.*OPENSSL_USE_APPLINK' > /dev/null; then \
288                 LIBDEPS="$(TOP)/crypto/applink.o $${LIBDEPS:-$(LIBDEPS)}"; \
289                 export LIBDEPS; \
290         fi; \
291         $(LINK_APP)
292
293 link_o.alpha-osf1:
294         @ if ${DETECT_GNU_LD}; then \
295                 $(DO_GNU_SO); \
296         else \
297                 SHLIB=lib$(LIBNAME).so; \
298                 SHLIB_SUFFIX=; \
299                 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
300                 if [ -n "$$SHLIB_HIST" ]; then \
301                         SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
302                 else \
303                         SHLIB_HIST="$(LIBVERSION)"; \
304                 fi; \
305                 SHLIB_SOVER=; \
306                 ALLSYMSFLAGS='-all'; \
307                 NOALLSYMSFLAGS='-none'; \
308                 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-B,symbolic"; \
309                 if [ -n "$$SHLIB_HIST" ]; then \
310                         SHAREDFLAGS="$$SHAREDFLAGS -set_version $$SHLIB_HIST"; \
311                 fi; \
312         fi; \
313         $(LINK_SO_O)
314 link_a.alpha-osf1:
315         @ if ${DETECT_GNU_LD}; then \
316                 $(DO_GNU_SO); \
317         else \
318                 SHLIB=lib$(LIBNAME).so; \
319                 SHLIB_SUFFIX=; \
320                 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
321                 if [ -n "$$SHLIB_HIST" ]; then \
322                         SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
323                 else \
324                         SHLIB_HIST="$(LIBVERSION)"; \
325                 fi; \
326                 SHLIB_SOVER=; \
327                 ALLSYMSFLAGS='-all'; \
328                 NOALLSYMSFLAGS='-none'; \
329                 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-B,symbolic"; \
330                 if [ -n "$$SHLIB_HIST" ]; then \
331                         SHAREDFLAGS="$$SHAREDFLAGS -set_version $$SHLIB_HIST"; \
332                 fi; \
333         fi; \
334         $(LINK_SO_A)
335 link_app.alpha-osf1:
336         @if ${DETECT_GNU_LD}; then \
337                 $(DO_GNU_APP); \
338         else \
339                 LDFLAGS="$(CFLAGS) -rpath $(LIBRPATH)"; \
340         fi; \
341         $(LINK_APP)
342
343 link_o.solaris:
344         @ if ${DETECT_GNU_LD}; then \
345                 $(DO_GNU_SO); \
346         else \
347                 $(CALC_VERSIONS); \
348                 MINUSZ='-z '; \
349                 ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSZ='-Wl,-z,'; \
350                 SHLIB=lib$(LIBNAME).so; \
351                 SHLIB_SUFFIX=; \
352                 ALLSYMSFLAGS="$${MINUSZ}allextract"; \
353                 NOALLSYMSFLAGS="$${MINUSZ}defaultextract"; \
354                 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-Bsymbolic"; \
355         fi; \
356         $(LINK_SO_O)
357 link_a.solaris:
358         @ if ${DETECT_GNU_LD}; then \
359                 $(DO_GNU_SO); \
360         else \
361                 $(CALC_VERSIONS); \
362                 MINUSZ='-z '; \
363                 (${CC} -v 2>&1 | grep gcc) > /dev/null && MINUSZ='-Wl,-z,'; \
364                 SHLIB=lib$(LIBNAME).so; \
365                 SHLIB_SUFFIX=;\
366                 ALLSYMSFLAGS="$${MINUSZ}allextract"; \
367                 NOALLSYMSFLAGS="$${MINUSZ}defaultextract"; \
368                 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-Bsymbolic"; \
369         fi; \
370         $(LINK_SO_A)
371 link_app.solaris:
372         @ if ${DETECT_GNU_LD}; then \
373                 $(DO_GNU_APP); \
374         else \
375                 LDFLAGS="$(CFLAGS) -R $(LIBRPATH)"; \
376         fi; \
377         $(LINK_APP)
378
379 # OpenServer 5 native compilers used
380 link_o.svr3:
381         @ if ${DETECT_GNU_LD}; then \
382                 $(DO_GNU_SO); \
383         else \
384                 $(CALC_VERSIONS); \
385                 SHLIB=lib$(LIBNAME).so; \
386                 SHLIB_SUFFIX=; \
387                 ALLSYMSFLAGS=''; \
388                 NOALLSYMSFLAGS=''; \
389                 SHAREDFLAGS="$(CFLAGS) -G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
390         fi; \
391         $(LINK_SO_O)
392 link_a.svr3:
393         @ if ${DETECT_GNU_LD}; then \
394                 $(DO_GNU_SO); \
395         else \
396                 $(CALC_VERSIONS); \
397                 SHLIB=lib$(LIBNAME).so; \
398                 SHLIB_SUFFIX=; \
399                 ALLSYMSFLAGS=''; \
400                 NOALLSYMSFLAGS=''; \
401                 SHAREDFLAGS="$(CFLAGS) -G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
402         fi; \
403         $(LINK_SO_A_UNPACKED)
404 link_app.svr3:
405         @${DETECT_GNU_LD} && $(DO_GNU_APP); \
406         $(LINK_APP)
407
408 # UnixWare 7 and OpenUNIX 8 native compilers used
409 link_o.svr5:
410         @ if ${DETECT_GNU_LD}; then \
411                 $(DO_GNU_SO); \
412         else \
413                 $(CALC_VERSIONS); \
414                 SHARE_FLAG='-G'; \
415                 ($(CC) -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
416                 SHLIB=lib$(LIBNAME).so; \
417                 SHLIB_SUFFIX=; \
418                 ALLSYMSFLAGS=''; \
419                 NOALLSYMSFLAGS=''; \
420                 SHAREDFLAGS="$(CFLAGS) $${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
421         fi; \
422         $(LINK_SO_O)
423 link_a.svr5:
424         @ if ${DETECT_GNU_LD}; then \
425                 $(DO_GNU_SO); \
426         else \
427                 $(CALC_VERSIONS); \
428                 SHARE_FLAG='-G'; \
429                 (${CC} -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
430                 SHLIB=lib$(LIBNAME).so; \
431                 SHLIB_SUFFIX=; \
432                 ALLSYMSFLAGS=''; \
433                 NOALLSYMSFLAGS=''; \
434                 SHAREDFLAGS="$(CFLAGS) $${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
435         fi; \
436         $(LINK_SO_A_UNPACKED)
437 link_app.svr5:
438         @${DETECT_GNU_LD} && $(DO_GNU_APP); \
439         $(LINK_APP)
440
441 link_o.irix:
442         @ if ${DETECT_GNU_LD}; then \
443                 $(DO_GNU_SO); \
444         else \
445                 $(CALC_VERSIONS); \
446                 SHLIB=lib$(LIBNAME).so; \
447                 SHLIB_SUFFIX=; \
448                 MINUSWL=""; \
449                 ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSWL="-Wl,"; \
450                 ALLSYMSFLAGS="$${MINUSWL}-all"; \
451                 NOALLSYMSFLAGS="$${MINUSWL}-none"; \
452                 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,-B,symbolic"; \
453         fi; \
454         $(LINK_SO_O)
455 link_a.irix:
456         @ if ${DETECT_GNU_LD}; then \
457                 $(DO_GNU_SO); \
458         else \
459                 $(CALC_VERSIONS); \
460                 SHLIB=lib$(LIBNAME).so; \
461                 SHLIB_SUFFIX=; \
462                 MINUSWL=""; \
463                 ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSWL="-Wl,"; \
464                 ALLSYMSFLAGS="$${MINUSWL}-all"; \
465                 NOALLSYMSFLAGS="$${MINUSWL}-none"; \
466                 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,-B,symbolic"; \
467         fi; \
468         $(LINK_SO_A)
469 link_app.irix:
470         @LDFLAGS="$(CFLAGS) -Wl,-rpath,$(LIBRPATH)"; \
471         $(LINK_APP)
472
473 # 32-bit PA-RISC HP-UX embeds the -L pathname of libs we link with, so
474 # we compensate for it with +cdp ../: and +cdp ./:. Yes, these rewrite
475 # rules imply that we can only link one level down in catalog structure,
476 # but that's what takes place for the moment of this writing. +cdp option
477 # was introduced in HP-UX 11.x and applies in 32-bit PA-RISC link
478 # editor context only [it's simply ignored in other cases, which are all
479 # ELFs by the way].
480 #
481 link_o.hpux:
482         @if ${DETECT_GNU_LD}; then $(DO_GNU_SO); else \
483         $(CALC_VERSIONS); \
484         SHLIB=lib$(LIBNAME).sl; \
485         expr "$(CFLAGS)" : '.*DSO_DLFCN' > /dev/null && SHLIB=lib$(LIBNAME).so; \
486         SHLIB_SUFFIX=; \
487         ALLSYMSFLAGS='-Wl,-Fl'; \
488         NOALLSYMSFLAGS=''; \
489         expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \
490         SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,+cdp,../:,+cdp,./:"; \
491         fi; \
492         rm -f $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX || :; \
493         $(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
494 link_a.hpux:
495         @if ${DETECT_GNU_LD}; then $(DO_GNU_SO); else \
496         $(CALC_VERSIONS); \
497         SHLIB=lib$(LIBNAME).sl; \
498         expr $(PLATFORM) : '.*ia64' > /dev/null && SHLIB=lib$(LIBNAME).so; \
499         SHLIB_SUFFIX=; \
500         ALLSYMSFLAGS='-Wl,-Fl'; \
501         NOALLSYMSFLAGS=''; \
502         expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \
503         SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,+cdp,../:,+cdp,./:"; \
504         fi; \
505         rm -f $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX || :; \
506         $(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
507 link_app.hpux:
508         @if ${DETECT_GNU_LD}; then $(DO_GNU_APP); else \
509         LDFLAGS="$(CFLAGS) -Wl,+s,+cdp,../:,+cdp,./:,+b,$(LIBRPATH)"; \
510         fi; \
511         $(LINK_APP)
512
513 link_o.aix:
514         @ $(CALC_VERSIONS); \
515         OBJECT_MODE=`expr x$(SHARED_LDFLAGS) : 'x\-[a-z]*\(64\)'` || :; \
516         OBJECT_MODE=$${OBJECT_MODE:-32}; export OBJECT_MODE; \
517         SHLIB=lib$(LIBNAME).so; \
518         SHLIB_SUFFIX=; \
519         ALLSYMSFLAGS=''; \
520         NOALLSYMSFLAGS=''; \
521         SHAREDFLAGS='$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-G,-bexpall,-bnolibpath,-bM:SRE'; \
522         $(LINK_SO_O);
523 link_a.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='-bnogc'; \
530         NOALLSYMSFLAGS=''; \
531         SHAREDFLAGS='$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-G,-bexpall,-bnolibpath,-bM:SRE'; \
532         $(LINK_SO_A_VIA_O)
533 link_app.aix:
534         LDFLAGS="$(CFLAGS) -Wl,-brtl,-blibpath:$(LIBRPATH):$${LIBPATH:-/usr/lib:/lib}"; \
535         $(LINK_APP)
536
537 link_o.reliantunix:
538         @ $(CALC_VERSIONS); \
539         SHLIB=lib$(LIBNAME).so; \
540         SHLIB_SUFFIX=; \
541         ALLSYMSFLAGS=; \
542         NOALLSYMSFLAGS=''; \
543         SHAREDFLAGS='$(CFLAGS) -G'; \
544         $(LINK_SO_O)
545 link_a.reliantunix:
546         @ $(CALC_VERSIONS); \
547         SHLIB=lib$(LIBNAME).so; \
548         SHLIB_SUFFIX=; \
549         ALLSYMSFLAGS=; \
550         NOALLSYMSFLAGS=''; \
551         SHAREDFLAGS='$(CFLAGS) -G'; \
552         $(LINK_SO_A_UNPACKED)
553 link_app.reliantunix:
554         $(LINK_APP)
555
556 # Targets to build symbolic links when needed
557 symlink.gnu symlink.solaris symlink.svr3 symlink.svr5 symlink.irix \
558 symlink.aix symlink.reliantunix:
559         @ $(CALC_VERSIONS); \
560         SHLIB=lib$(LIBNAME).so; \
561         $(SYMLINK_SO)
562 symlink.darwin:
563         @ $(CALC_VERSIONS); \
564         SHLIB=lib$(LIBNAME); \
565         SHLIB_SUFFIX=.dylib; \
566         $(SYMLINK_SO)
567 symlink.hpux:
568         @ $(CALC_VERSIONS); \
569         SHLIB=lib$(LIBNAME).sl; \
570         expr $(PLATFORM) : '.*ia64' > /dev/null && SHLIB=lib$(LIBNAME).so; \
571         $(SYMLINK_SO)
572 # The following lines means those specific architectures do no symlinks
573 symlink.cygwin symlink.alpha-osf1 symlink.tru64 symlink.tru64-rpath symlink.beos:
574
575 # Compatibility targets
576 link_o.bsd-gcc-shared link_o.linux-shared link_o.gnu-shared: link_o.gnu
577 link_a.bsd-gcc-shared link_a.linux-shared link_a.gnu-shared: link_a.gnu
578 link_app.bsd-gcc-shared link_app.linux-shared link_app.gnu-shared: link_app.gnu
579 symlink.bsd-gcc-shared symlink.bsd-shared symlink.linux-shared symlink.gnu-shared: symlink.gnu
580 link_o.bsd-shared: link_o.bsd
581 link_a.bsd-shared: link_a.bsd
582 link_app.bsd-shared: link_app.bsd
583 link_o.darwin-shared: link_o.darwin
584 link_a.darwin-shared: link_a.darwin
585 link_app.darwin-shared: link_app.darwin
586 symlink.darwin-shared: symlink.darwin
587 link_o.cygwin-shared: link_o.cygwin
588 link_a.cygwin-shared: link_a.cygwin
589 link_app.cygwin-shared: link_app.cygwin
590 symlink.cygwin-shared: symlink.cygwin
591 link_o.alpha-osf1-shared: link_o.alpha-osf1
592 link_a.alpha-osf1-shared: link_a.alpha-osf1
593 link_app.alpha-osf1-shared: link_app.alpha-osf1
594 symlink.alpha-osf1-shared: symlink.alpha-osf1
595 link_o.tru64-shared: link_o.tru64
596 link_a.tru64-shared: link_a.tru64
597 link_app.tru64-shared: link_app.tru64
598 symlink.tru64-shared: symlink.tru64
599 link_o.tru64-shared-rpath: link_o.tru64-rpath
600 link_a.tru64-shared-rpath: link_a.tru64-rpath
601 link_app.tru64-shared-rpath: link_app.tru64-rpath
602 symlink.tru64-shared-rpath: symlink.tru64-rpath
603 link_o.solaris-shared: link_o.solaris
604 link_a.solaris-shared: link_a.solaris
605 link_app.solaris-shared: link_app.solaris
606 symlink.solaris-shared: symlink.solaris
607 link_o.svr3-shared: link_o.svr3
608 link_a.svr3-shared: link_a.svr3
609 link_app.svr3-shared: link_app.svr3
610 symlink.svr3-shared: symlink.svr3
611 link_o.svr5-shared: link_o.svr5
612 link_a.svr5-shared: link_a.svr5
613 link_app.svr5-shared: link_app.svr5
614 symlink.svr5-shared: symlink.svr5
615 link_o.irix-shared: link_o.irix
616 link_a.irix-shared: link_a.irix
617 link_app.irix-shared: link_app.irix
618 symlink.irix-shared: symlink.irix
619 link_o.hpux-shared: link_o.hpux
620 link_a.hpux-shared: link_a.hpux
621 link_app.hpux-shared: link_app.hpux
622 symlink.hpux-shared: symlink.hpux
623 link_o.aix-shared: link_o.aix
624 link_a.aix-shared: link_a.aix
625 link_app.aix-shared: link_app.aix
626 symlink.aix-shared: symlink.aix
627 link_o.reliantunix-shared: link_o.reliantunix
628 link_a.reliantunix-shared: link_a.reliantunix
629 link_app.reliantunix-shared: link_app.reliantunix
630 symlink.reliantunix-shared: symlink.reliantunix
631 link_o.beos-shared: link_o.beos
632 link_a.beos-shared: link_a.beos
633 link_app.beos-shared: link_app.gnu
634 symlink.beos-shared: symlink.beos