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