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