]> git.ipfire.org Git - thirdparty/openssl.git/blob - Makefile.shared
Display the linking commands that are performed
[thirdparty/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=$(LDFLAG)
15 SHARED_LDFLAGS=$(SHARED_LDFLAG)
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) $(LDFLAGS)}"; \
96 LIBPATH=`for x in $$LIBDEPS; do echo $$x; done | sed -e 's/^ *-L//;t' -e d | uniq`; \
97 LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \
98 echo LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
99 $${LDCMD} $${LDFLAGS} -o $${APPNAME:=$(APPNAME)} $(OBJECTS) $${LIBDEPS}; \
100 LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
101 $${LDCMD} $${LDFLAGS} -o $${APPNAME:=$(APPNAME)} $(OBJECTS) $${LIBDEPS} )
102
103 LINK_SO= \
104 ( $(SET_X); \
105 LIBDEPS="$${LIBDEPS:-$(LIBDEPS)}"; \
106 SHAREDCMD="$${SHAREDCMD:-$(CC)}"; \
107 SHAREDFLAGS="$${SHAREDFLAGS:-$(CFLAGS) $(SHARED_LDFLAGS)}"; \
108 LIBPATH=`for x in $$LIBDEPS; do echo $$x; done | sed -e 's/^ *-L//;t' -e d | uniq`; \
109 LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \
110 echo LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
111 $${SHAREDCMD} $${SHAREDFLAGS} \
112 -o $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \
113 $$ALLSYMSFLAGS $$SHOBJECTS $$NOALLSYMSFLAGS $$LIBDEPS; \
114 LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
115 $${SHAREDCMD} $${SHAREDFLAGS} \
116 -o $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \
117 $$ALLSYMSFLAGS $$SHOBJECTS $$NOALLSYMSFLAGS $$LIBDEPS \
118 ) && $(SYMLINK_SO)
119
120 SYMLINK_SO= \
121 if [ -n "$$INHIBIT_SYMLINKS" ]; then :; else \
122 prev=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \
123 if [ -n "$$SHLIB_COMPAT" ]; then \
124 for x in $$SHLIB_COMPAT; do \
125 ( $(SET_X); rm -f $$SHLIB$$x$$SHLIB_SUFFIX; \
126 ln -s $$prev $$SHLIB$$x$$SHLIB_SUFFIX ); \
127 prev=$$SHLIB$$x$$SHLIB_SUFFIX; \
128 done; \
129 fi; \
130 if [ -n "$$SHLIB_SOVER" ]; then \
131 ( $(SET_X); rm -f $$SHLIB$$SHLIB_SUFFIX; \
132 ln -s $$prev $$SHLIB$$SHLIB_SUFFIX ); \
133 fi; \
134 fi
135
136 LINK_SO_A= SHOBJECTS="lib$(LIBNAME).a $(LIBEXTRAS)"; $(LINK_SO)
137 LINK_SO_O= SHOBJECTS="$(LIBEXTRAS)"; $(LINK_SO)
138
139 LINK_SO_A_VIA_O= \
140 SHOBJECTS=lib$(LIBNAME).o; \
141 ALL=$$ALLSYMSFLAGS; ALLSYMSFLAGS=; NOALLSYMSFLAGS=; \
142 ( echo ld $(LDFLAGS) -r -o lib$(LIBNAME).o $$ALL lib$(LIBNAME).a $(LIBEXTRAS); \
143 ld $(LDFLAGS) -r -o lib$(LIBNAME).o $$ALL lib$(LIBNAME).a $(LIBEXTRAS) ); \
144 $(LINK_SO) && ( echo rm -f lib$(LIBNAME).o; rm -f lib$(LIBNAME).o )
145
146 LINK_SO_A_UNPACKED= \
147 UNPACKDIR=link_tmp.$$$$; rm -rf $$UNPACKDIR; mkdir $$UNPACKDIR; \
148 (cd $$UNPACKDIR; ar x ../lib$(LIBNAME).a) && \
149 ([ -z "$(LIBEXTRAS)" ] || cp $(LIBEXTRAS) $$UNPACKDIR) && \
150 SHOBJECTS=$$UNPACKDIR/*.o; \
151 $(LINK_SO) && rm -rf $$UNPACKDIR
152
153 DETECT_GNU_LD=($(CC) -Wl,-V /dev/null 2>&1 | grep '^GNU ld' )>/dev/null
154
155 DO_GNU_SO=$(CALC_VERSIONS); \
156 SHLIB=lib$(LIBNAME).so; \
157 SHLIB_SUFFIX=; \
158 ALLSYMSFLAGS='-Wl,--whole-archive'; \
159 NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
160 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-Bsymbolic -Wl,-soname=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"
161
162 DO_GNU_APP=LDFLAGS="$(CFLAGS) $(LDFLAGS) -Wl,-rpath,$(LIBRPATH)"
163
164 #This is rather special. It's a special target with which one can link
165 #applications without bothering with any features that have anything to
166 #do with shared libraries, for example when linking against static
167 #libraries. It's mostly here to avoid a lot of conditionals everywhere
168 #else...
169 link_app.:
170 $(LINK_APP)
171
172 link_o.gnu:
173 @ $(DO_GNU_SO); $(LINK_SO_O)
174 link_a.gnu:
175 @ $(DO_GNU_SO); $(LINK_SO_A)
176 link_app.gnu:
177 @ $(DO_GNU_APP); $(LINK_APP)
178
179 link_a.linux-shared:
180 @if [ $(LIBNAME) != "crypto" -a $(LIBNAME) != "ssl" ]; then $(DO_GNU_SO); else \
181 $(PERL) util/mkdef.pl $(LIBNAME) linux >$(LIBNAME).map; \
182 $(CALC_VERSIONS); \
183 SHLIB=lib$(LIBNAME).so; \
184 SHLIB_SUFFIX=; \
185 ALLSYMSFLAGS='-Wl,--whole-archive,--version-script=$(LIBNAME).map'; \
186 NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
187 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-Bsymbolic -Wl,-soname=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
188 fi; $(LINK_SO_A)
189
190 link_o.bsd:
191 @if $(DETECT_GNU_LD); then $(DO_GNU_SO); else \
192 $(CALC_VERSIONS); \
193 SHLIB=lib$(LIBNAME).so; \
194 SHLIB_SUFFIX=; \
195 LIBDEPS=" "; \
196 ALLSYMSFLAGS="-Wl,-Bforcearchive"; \
197 NOALLSYMSFLAGS=; \
198 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -nostdlib"; \
199 fi; $(LINK_SO_O)
200 link_a.bsd:
201 @if $(DETECT_GNU_LD); then $(DO_GNU_SO); else \
202 $(CALC_VERSIONS); \
203 SHLIB=lib$(LIBNAME).so; \
204 SHLIB_SUFFIX=; \
205 LIBDEPS=" "; \
206 ALLSYMSFLAGS="-Wl,-Bforcearchive"; \
207 NOALLSYMSFLAGS=; \
208 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -nostdlib"; \
209 fi; $(LINK_SO_A)
210 link_app.bsd:
211 @if $(DETECT_GNU_LD); then $(DO_GNU_APP); else \
212 LDFLAGS="$(CFLAGS) $(LDFLAGS) -Wl,-rpath,$(LIBPATH)"; \
213 fi; $(LINK_APP)
214
215 # For Darwin AKA Mac OS/X (dyld)
216 # Originally link_o.darwin produced .so, because it was hard-coded
217 # in dso_dlfcn module. At later point dso_dlfcn switched to .dylib
218 # extension in order to allow for run-time linking with vendor-
219 # supplied shared libraries such as libz, so that link_o.darwin had
220 # to be harmonized with it. This caused minor controversy, because
221 # it was believed that dlopen can't be used to dynamically load
222 # .dylib-s, only so called bundle modules (ones linked with -bundle
223 # flag). The belief seems to be originating from pre-10.4 release,
224 # where dlfcn functionality was emulated by dlcompat add-on. In
225 # 10.4 dlopen was rewritten as native part of dyld and is documented
226 # to be capable of loading both dynamic libraries and bundles. In
227 # order to provide compatibility with pre-10.4 dlopen, modules are
228 # linked with -bundle flag, which makes .dylib extension misleading.
229 # It works, because dlopen is [and always was] extension-agnostic.
230 # Alternative to this heuristic approach is to develop specific
231 # MacOS X dso module relying on whichever "native" dyld interface.
232 link_o.darwin:
233 @ $(CALC_VERSIONS); \
234 SHLIB=lib$(LIBNAME); \
235 SHLIB_SUFFIX=.dylib; \
236 ALLSYMSFLAGS='-all_load'; \
237 NOALLSYMSFLAGS=''; \
238 SHAREDFLAGS="$(CFLAGS) `echo $(SHARED_LDFLAGS) | sed s/dynamiclib/bundle/`"; \
239 if [ -n "$(LIBVERSION)" ]; then \
240 SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
241 fi; \
242 if [ -n "$$SHLIB_SOVER_NODOT" ]; then \
243 SHAREDFLAGS="$$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \
244 fi; \
245 $(LINK_SO_O)
246 link_a.darwin:
247 @ $(CALC_VERSIONS); \
248 SHLIB=lib$(LIBNAME); \
249 SHLIB_SUFFIX=.dylib; \
250 ALLSYMSFLAGS='-all_load'; \
251 NOALLSYMSFLAGS=''; \
252 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS)"; \
253 if [ -n "$(LIBVERSION)" ]; then \
254 SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
255 fi; \
256 if [ -n "$$SHLIB_SOVER_NODOT" ]; then \
257 SHAREDFLAGS="$$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \
258 fi; \
259 SHAREDFLAGS="$$SHAREDFLAGS -install_name $(INSTALLTOP)/$(LIBDIR)/$$SHLIB$(SHLIB_EXT)"; \
260 $(LINK_SO_A)
261 link_app.darwin: # is there run-path on darwin?
262 $(LINK_APP)
263
264 link_o.cygwin:
265 @ $(CALC_VERSIONS); \
266 INHIBIT_SYMLINKS=yes; \
267 SHLIB=cyg$(LIBNAME); \
268 base=-Wl,--enable-auto-image-base; \
269 deffile=; \
270 if expr $(PLATFORM) : 'mingw' > /dev/null; then \
271 SHLIB=$(LIBNAME)eay32; base=; \
272 if test -f $(LIBNAME)eay32.def; then \
273 deffile=$(LIBNAME)eay32.def; \
274 fi; \
275 fi; \
276 SHLIB_SUFFIX=.dll; \
277 LIBVERSION="$(LIBVERSION)"; \
278 SHLIB_SOVER=${LIBVERSION:+"-$(LIBVERSION)"}; \
279 ALLSYMSFLAGS='-Wl,--whole-archive'; \
280 NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
281 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base $$deffile -Wl,-Bsymbolic"; \
282 $(LINK_SO_O)
283 #for mingw target if def-file is in use dll-name should match library-name
284 link_a.cygwin:
285 @ $(CALC_VERSIONS); \
286 INHIBIT_SYMLINKS=yes; \
287 SHLIB=cyg$(LIBNAME); SHLIB_SOVER=-$(LIBVERSION); SHLIB_SUFFIX=.dll; \
288 dll_name=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; extras=; \
289 base=-Wl,--enable-auto-image-base; \
290 if expr $(PLATFORM) : 'mingw' > /dev/null; then \
291 case $(LIBNAME) in \
292 crypto) SHLIB=libeay;; \
293 ssl) SHLIB=ssleay;; \
294 esac; \
295 SHLIB_SOVER=32; \
296 extras="$(LIBNAME).def"; \
297 $(PERL) util/mkdef.pl 32 $$SHLIB > $$extras; \
298 base=; [ $(LIBNAME) = "crypto" ] && base=-Wl,--image-base,0x63000000; \
299 fi; \
300 dll_name=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \
301 $(PERL) util/mkrc.pl $$dll_name | \
302 $(CROSS_COMPILE)windres -o rc.o; \
303 extras="$$extras rc.o"; \
304 ALLSYMSFLAGS='-Wl,--whole-archive'; \
305 NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
306 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a $$extras"; \
307 [ -f apps/$$dll_name ] && rm apps/$$dll_name; \
308 [ -f test/$$dll_name ] && rm test/$$dll_name; \
309 $(LINK_SO_A) || exit 1; \
310 rm $$extras; \
311 cp -p $$dll_name apps/; \
312 cp -p $$dll_name test/
313 link_app.cygwin:
314 @if expr "$(CFLAGS)" : '.*OPENSSL_USE_APPLINK' > /dev/null; then \
315 LIBDEPS="$(TOP)/crypto/applink.o $${LIBDEPS:-$(LIBDEPS)}"; \
316 export LIBDEPS; \
317 fi; \
318 $(LINK_APP)
319
320 link_o.alpha-osf1:
321 @ if $(DETECT_GNU_LD); then \
322 $(DO_GNU_SO); \
323 else \
324 SHLIB=lib$(LIBNAME).so; \
325 SHLIB_SUFFIX=; \
326 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
327 if [ -n "$$SHLIB_HIST" ]; then \
328 SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
329 else \
330 SHLIB_HIST="$(LIBVERSION)"; \
331 fi; \
332 SHLIB_SOVER=; \
333 ALLSYMSFLAGS='-all'; \
334 NOALLSYMSFLAGS='-none'; \
335 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-B,symbolic"; \
336 if [ -n "$$SHLIB_HIST" ]; then \
337 SHAREDFLAGS="$$SHAREDFLAGS -set_version $$SHLIB_HIST"; \
338 fi; \
339 fi; \
340 $(LINK_SO_O)
341 link_a.alpha-osf1:
342 @ if $(DETECT_GNU_LD); then \
343 $(DO_GNU_SO); \
344 else \
345 SHLIB=lib$(LIBNAME).so; \
346 SHLIB_SUFFIX=; \
347 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
348 if [ -n "$$SHLIB_HIST" ]; then \
349 SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
350 else \
351 SHLIB_HIST="$(LIBVERSION)"; \
352 fi; \
353 SHLIB_SOVER=; \
354 ALLSYMSFLAGS='-all'; \
355 NOALLSYMSFLAGS='-none'; \
356 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-B,symbolic"; \
357 if [ -n "$$SHLIB_HIST" ]; then \
358 SHAREDFLAGS="$$SHAREDFLAGS -set_version $$SHLIB_HIST"; \
359 fi; \
360 fi; \
361 $(LINK_SO_A)
362 link_app.alpha-osf1:
363 @if $(DETECT_GNU_LD); then \
364 $(DO_GNU_APP); \
365 else \
366 LDFLAGS="$(CFLAGS) $(LDFLAGS) -rpath $(LIBRPATH)"; \
367 fi; \
368 $(LINK_APP)
369
370 link_o.solaris:
371 @ if $(DETECT_GNU_LD); then \
372 $(DO_GNU_SO); \
373 else \
374 $(CALC_VERSIONS); \
375 MINUSZ='-z '; \
376 ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSZ='-Wl,-z,'; \
377 SHLIB=lib$(LIBNAME).so; \
378 SHLIB_SUFFIX=; \
379 ALLSYMSFLAGS="$${MINUSZ}allextract"; \
380 NOALLSYMSFLAGS="$${MINUSZ}defaultextract"; \
381 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-Bsymbolic"; \
382 fi; \
383 $(LINK_SO_O)
384 link_a.solaris:
385 @ if $(DETECT_GNU_LD); then \
386 $(DO_GNU_SO); \
387 else \
388 $(CALC_VERSIONS); \
389 MINUSZ='-z '; \
390 ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSZ='-Wl,-z,'; \
391 SHLIB=lib$(LIBNAME).so; \
392 SHLIB_SUFFIX=;\
393 if [ $(LIBNAME) != "crypto" -a $(LIBNAME) != "ssl" ]; then \
394 ALLSYMSFLAGS="$${MINUSZ}allextract"; \
395 else \
396 $(PERL) util/mkdef.pl $(LIBNAME) linux >$(LIBNAME).map; \
397 ALLSYMSFLAGS="$${MINUSZ}allextract,-M,$(LIBNAME).map"; \
398 fi; \
399 NOALLSYMSFLAGS="$${MINUSZ}defaultextract"; \
400 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-Bsymbolic"; \
401 fi; \
402 $(LINK_SO_A)
403 link_app.solaris:
404 @ if $(DETECT_GNU_LD); then \
405 $(DO_GNU_APP); \
406 else \
407 LDFLAGS="$(CFLAGS) $(LDFLAGS) -R $(LIBRPATH)"; \
408 fi; \
409 $(LINK_APP)
410
411 # OpenServer 5 native compilers used
412 link_o.svr3:
413 @ if $(DETECT_GNU_LD); then \
414 $(DO_GNU_SO); \
415 else \
416 $(CALC_VERSIONS); \
417 SHLIB=lib$(LIBNAME).so; \
418 SHLIB_SUFFIX=; \
419 ALLSYMSFLAGS=''; \
420 NOALLSYMSFLAGS=''; \
421 SHAREDFLAGS="$(CFLAGS) -G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
422 fi; \
423 $(LINK_SO_O)
424 link_a.svr3:
425 @ if $(DETECT_GNU_LD); then \
426 $(DO_GNU_SO); \
427 else \
428 $(CALC_VERSIONS); \
429 SHLIB=lib$(LIBNAME).so; \
430 SHLIB_SUFFIX=; \
431 ALLSYMSFLAGS=''; \
432 NOALLSYMSFLAGS=''; \
433 SHAREDFLAGS="$(CFLAGS) -G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
434 fi; \
435 $(LINK_SO_A_UNPACKED)
436 link_app.svr3:
437 @$(DETECT_GNU_LD) && $(DO_GNU_APP); \
438 $(LINK_APP)
439
440 # UnixWare 7 and OpenUNIX 8 native compilers used
441 link_o.svr5:
442 @ if $(DETECT_GNU_LD); then \
443 $(DO_GNU_SO); \
444 else \
445 $(CALC_VERSIONS); \
446 SHARE_FLAG='-G'; \
447 ($(CC) -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
448 SHLIB=lib$(LIBNAME).so; \
449 SHLIB_SUFFIX=; \
450 ALLSYMSFLAGS=''; \
451 NOALLSYMSFLAGS=''; \
452 SHAREDFLAGS="$(CFLAGS) $${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
453 fi; \
454 $(LINK_SO_O)
455 link_a.svr5:
456 @ if $(DETECT_GNU_LD); then \
457 $(DO_GNU_SO); \
458 else \
459 $(CALC_VERSIONS); \
460 SHARE_FLAG='-G'; \
461 ($(CC) -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
462 SHLIB=lib$(LIBNAME).so; \
463 SHLIB_SUFFIX=; \
464 ALLSYMSFLAGS=''; \
465 NOALLSYMSFLAGS=''; \
466 SHAREDFLAGS="$(CFLAGS) $${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
467 fi; \
468 $(LINK_SO_A_UNPACKED)
469 link_app.svr5:
470 @$(DETECT_GNU_LD) && $(DO_GNU_APP); \
471 $(LINK_APP)
472
473 link_o.irix:
474 @ if $(DETECT_GNU_LD); then \
475 $(DO_GNU_SO); \
476 else \
477 $(CALC_VERSIONS); \
478 SHLIB=lib$(LIBNAME).so; \
479 SHLIB_SUFFIX=; \
480 MINUSWL=""; \
481 ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSWL="-Wl,"; \
482 ALLSYMSFLAGS="$${MINUSWL}-all"; \
483 NOALLSYMSFLAGS="$${MINUSWL}-none"; \
484 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,-B,symbolic"; \
485 fi; \
486 $(LINK_SO_O)
487 link_a.irix:
488 @ if $(DETECT_GNU_LD); then \
489 $(DO_GNU_SO); \
490 else \
491 $(CALC_VERSIONS); \
492 SHLIB=lib$(LIBNAME).so; \
493 SHLIB_SUFFIX=; \
494 MINUSWL=""; \
495 ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSWL="-Wl,"; \
496 ALLSYMSFLAGS="$${MINUSWL}-all"; \
497 NOALLSYMSFLAGS="$${MINUSWL}-none"; \
498 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,-B,symbolic"; \
499 fi; \
500 $(LINK_SO_A)
501 link_app.irix:
502 @LDFLAGS="$(CFLAGS) $(LDFLAGS) -Wl,-rpath,$(LIBRPATH)"; \
503 $(LINK_APP)
504
505 # 32-bit PA-RISC HP-UX embeds the -L pathname of libs we link with, so
506 # we compensate for it with +cdp ../: and +cdp ./:. Yes, these rewrite
507 # rules imply that we can only link one level down in catalog structure,
508 # but that's what takes place for the moment of this writing. +cdp option
509 # was introduced in HP-UX 11.x and applies in 32-bit PA-RISC link
510 # editor context only [it's simply ignored in other cases, which are all
511 # ELFs by the way].
512 #
513 link_o.hpux:
514 @if $(DETECT_GNU_LD); then $(DO_GNU_SO); else \
515 $(CALC_VERSIONS); \
516 SHLIB=lib$(LIBNAME).sl; \
517 expr "$(CFLAGS)" : '.*DSO_DLFCN' > /dev/null && SHLIB=lib$(LIBNAME).so; \
518 SHLIB_SUFFIX=; \
519 ALLSYMSFLAGS='-Wl,-Fl'; \
520 NOALLSYMSFLAGS=''; \
521 expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \
522 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,+cdp,../:,+cdp,./:"; \
523 fi; \
524 rm -f $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX || :; \
525 $(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
526 link_a.hpux:
527 @if $(DETECT_GNU_LD); then $(DO_GNU_SO); else \
528 $(CALC_VERSIONS); \
529 SHLIB=lib$(LIBNAME).sl; \
530 expr $(PLATFORM) : '.*ia64' > /dev/null && SHLIB=lib$(LIBNAME).so; \
531 SHLIB_SUFFIX=; \
532 ALLSYMSFLAGS='-Wl,-Fl'; \
533 NOALLSYMSFLAGS=''; \
534 expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \
535 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX,+cdp,../:,+cdp,./:"; \
536 fi; \
537 rm -f $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX || :; \
538 $(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
539 link_app.hpux:
540 @if $(DETECT_GNU_LD); then $(DO_GNU_APP); else \
541 LDFLAGS="$(CFLAGS) $(LDFLAGS) -Wl,+s,+cdp,../:,+cdp,./:,+b,$(LIBRPATH)"; \
542 fi; \
543 $(LINK_APP)
544
545 link_o.aix:
546 @ $(CALC_VERSIONS); \
547 OBJECT_MODE=`expr "x$(SHARED_LDFLAGS)" : 'x\-[a-z]*\(64\)'` || :; \
548 OBJECT_MODE=$${OBJECT_MODE:-32}; export OBJECT_MODE; \
549 SHLIB=lib$(LIBNAME).so; \
550 SHLIB_SUFFIX=; \
551 ALLSYMSFLAGS=''; \
552 NOALLSYMSFLAGS=''; \
553 SHAREDFLAGS='$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-bexpall,-bnolibpath,-bM:SRE'; \
554 $(LINK_SO_O);
555 link_a.aix:
556 @ $(CALC_VERSIONS); \
557 OBJECT_MODE=`expr "x$(SHARED_LDFLAGS)" : 'x\-[a-z]*\(64\)'` || : ; \
558 OBJECT_MODE=$${OBJECT_MODE:-32}; export OBJECT_MODE; \
559 SHLIB=lib$(LIBNAME).so; \
560 SHLIB_SUFFIX=; \
561 ALLSYMSFLAGS='-bnogc'; \
562 NOALLSYMSFLAGS=''; \
563 SHAREDFLAGS='$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-bexpall,-bnolibpath,-bM:SRE'; \
564 $(LINK_SO_A_VIA_O)
565 link_app.aix:
566 LDFLAGS="$(CFLAGS) $(LDFLAGS) -Wl,-brtl,-blibpath:$(LIBRPATH):$${LIBPATH:-/usr/lib:/lib}"; \
567 $(LINK_APP)
568
569
570 # Targets to build symbolic links when needed
571 symlink.gnu symlink.solaris symlink.svr3 symlink.svr5 symlink.irix \
572 symlink.aix:
573 @ $(CALC_VERSIONS); \
574 SHLIB=lib$(LIBNAME).so; \
575 $(SYMLINK_SO)
576 symlink.darwin:
577 @ $(CALC_VERSIONS); \
578 SHLIB=lib$(LIBNAME); \
579 SHLIB_SUFFIX=.dylib; \
580 $(SYMLINK_SO)
581 symlink.hpux:
582 @ $(CALC_VERSIONS); \
583 SHLIB=lib$(LIBNAME).sl; \
584 expr $(PLATFORM) : '.*ia64' > /dev/null && SHLIB=lib$(LIBNAME).so; \
585 $(SYMLINK_SO)
586 # The following lines means those specific architectures do no symlinks
587 symlink.cygwin symlink.alpha-osf1 symlink.tru64 symlink.tru64-rpath:
588
589 # Compatibility targets
590 link_o.bsd-gcc-shared link_o.linux-shared link_o.gnu-shared: link_o.gnu
591 link_a.bsd-gcc-shared link_a.gnu-shared: link_a.gnu
592 link_app.bsd-gcc-shared link_app.linux-shared link_app.gnu-shared: link_app.gnu
593 symlink.bsd-gcc-shared symlink.bsd-shared symlink.linux-shared symlink.gnu-shared: symlink.gnu
594 link_o.bsd-shared: link_o.bsd
595 link_a.bsd-shared: link_a.bsd
596 link_app.bsd-shared: link_app.bsd
597 link_o.darwin-shared: link_o.darwin
598 link_a.darwin-shared: link_a.darwin
599 link_app.darwin-shared: link_app.darwin
600 symlink.darwin-shared: symlink.darwin
601 link_o.cygwin-shared: link_o.cygwin
602 link_a.cygwin-shared: link_a.cygwin
603 link_app.cygwin-shared: link_app.cygwin
604 symlink.cygwin-shared: symlink.cygwin
605 link_o.alpha-osf1-shared: link_o.alpha-osf1
606 link_a.alpha-osf1-shared: link_a.alpha-osf1
607 link_app.alpha-osf1-shared: link_app.alpha-osf1
608 symlink.alpha-osf1-shared: symlink.alpha-osf1
609 link_o.tru64-shared: link_o.tru64
610 link_a.tru64-shared: link_a.tru64
611 link_app.tru64-shared: link_app.tru64
612 symlink.tru64-shared: symlink.tru64
613 link_o.tru64-shared-rpath: link_o.tru64-rpath
614 link_a.tru64-shared-rpath: link_a.tru64-rpath
615 link_app.tru64-shared-rpath: link_app.tru64-rpath
616 symlink.tru64-shared-rpath: symlink.tru64-rpath
617 link_o.solaris-shared: link_o.solaris
618 link_a.solaris-shared: link_a.solaris
619 link_app.solaris-shared: link_app.solaris
620 symlink.solaris-shared: symlink.solaris
621 link_o.svr3-shared: link_o.svr3
622 link_a.svr3-shared: link_a.svr3
623 link_app.svr3-shared: link_app.svr3
624 symlink.svr3-shared: symlink.svr3
625 link_o.svr5-shared: link_o.svr5
626 link_a.svr5-shared: link_a.svr5
627 link_app.svr5-shared: link_app.svr5
628 symlink.svr5-shared: symlink.svr5
629 link_o.irix-shared: link_o.irix
630 link_a.irix-shared: link_a.irix
631 link_app.irix-shared: link_app.irix
632 symlink.irix-shared: symlink.irix
633 link_o.hpux-shared: link_o.hpux
634 link_a.hpux-shared: link_a.hpux
635 link_app.hpux-shared: link_app.hpux
636 symlink.hpux-shared: symlink.hpux
637 link_o.aix-shared: link_o.aix
638 link_a.aix-shared: link_a.aix
639 link_app.aix-shared: link_app.aix
640 symlink.aix-shared: symlink.aix