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