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