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