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