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