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