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