]> git.ipfire.org Git - thirdparty/openssl.git/blame - Makefile.shared
manual pages as HTML
[thirdparty/openssl.git] / Makefile.shared
CommitLineData
30afcc07
RL
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
f210eb7b 10CFLAGS=$(CFLAG)
2d3de726
RL
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.
30afcc07
RL
14LDFLAGS=
15SHARED_LDFLAGS=
16
2d3de726 17# LIBNAME contains just the name of the library, without prefix ("lib"
30afcc07 18# on Unix, "cyg" for certain forms under Cygwin...) or suffix (.a, .so,
2d3de726
RL
19# .dll, ...). This one MUST have a value when using this makefile to
20# build shared libraries.
30afcc07
RL
21# For example, to build libfoo.so, you need to do the following:
22#LIBNAME=foo
23LIBNAME=
24
2d3de726
RL
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
30APPNAME=
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
35OBJECTS=
36
30afcc07 37# LIBEXTRAS contains extra modules to link together with the library.
8d6fc30b 38# For example, if a second library, say libbar.a needs to be linked into
30afcc07
RL
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.
43LIBEXTRAS=
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
48LIBVERSION=
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
61LIBCOMPATVERSIONS=
62
63# LIBDEPS contains all the flags necessary to cover all necessary
64# dependencies to other libraries.
65LIBDEPS=
66
67#------------------------------------------------------------------------------
68# The rest is private to this makefile.
69
c4cd925c
AP
70SET_X=:
71#SET_X=set -x
30afcc07
RL
72
73top:
74 echo "Trying to use this makefile interactively? Don't."
75
76CALC_VERSIONS= \
77 SHLIB_COMPAT=; SHLIB_SOVER=; \
cf3b8b52 78 if [ -n "$(LIBVERSION)$(LIBCOMPATVERSIONS)" ]; then \
30afcc07
RL
79 prev=""; \
80 for v in `echo "$(LIBVERSION) $(LIBCOMPATVERSIONS)" | cut -d';' -f1`; do \
f968059c 81 SHLIB_SOVER_NODOT=$$v; \
30afcc07
RL
82 SHLIB_SOVER=.$$v; \
83 if [ -n "$$prev" ]; then \
a0bf8f20 84 SHLIB_COMPAT="$$SHLIB_COMPAT .$$prev"; \
30afcc07
RL
85 fi; \
86 prev=$$v; \
87 done; \
88 fi
89
2d3de726 90LINK_APP= \
fe28866d 91 ( $(SET_X); \
7858cc03
AP
92 LIBDEPS="$${LIBDEPS:-$(LIBDEPS)}"; \
93 LDCMD="$${LDCMD:-$(CC)}"; LDFLAGS="$${LDFLAGS:-$(CFLAGS)}"; \
a1092201 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`; \
d6fd88ff 95 LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \
e96133e4 96 LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
7858cc03 97 $${LDCMD} $${LDFLAGS} -o $${APPNAME:=$(APPNAME)} $(OBJECTS) $${LIBDEPS} )
2d3de726 98
30afcc07 99LINK_SO= \
fe28866d 100 ( $(SET_X); \
7858cc03
AP
101 LIBDEPS="$${LIBDEPS:-$(LIBDEPS)}"; \
102 SHAREDCMD="$${SHAREDCMD:-$(CC)}"; \
103 SHAREDFLAGS="$${SHAREDFLAGS:-$(CFLAGS) $(SHARED_LDFLAGS)}"; \
30afcc07 104 nm -Pg $$SHOBJECTS | grep ' [BDT] ' | cut -f1 -d' ' > lib$(LIBNAME).exp; \
a1092201 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`; \
d6fd88ff 106 LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \
e96133e4 107 LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
7858cc03 108 $${SHAREDCMD} $${SHAREDFLAGS} \
f210eb7b
AP
109 -o $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \
110 $$ALLSYMSFLAGS $$SHOBJECTS $$NOALLSYMSFLAGS $$LIBDEPS \
111 ) && $(SYMLINK_SO); \
112 ( $(SET_X); rm -f lib$(LIBNAME).exp )
113
30afcc07 114SYMLINK_SO= \
bfa96bc2
RL
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 \
fe28866d 119 ( $(SET_X); rm -f $$SHLIB$$x$$SHLIB_SUFFIX; \
bfa96bc2
RL
120 ln -s $$prev $$SHLIB$$x$$SHLIB_SUFFIX ); \
121 prev=$$SHLIB$$x$$SHLIB_SUFFIX; \
122 done; \
123 fi; \
124 if [ -n "$$SHLIB_SOVER" ]; then \
fe28866d 125 ( $(SET_X); rm -f $$SHLIB$$SHLIB_SUFFIX; \
bfa96bc2
RL
126 ln -s $$prev $$SHLIB$$SHLIB_SUFFIX ); \
127 fi; \
30afcc07 128 fi
cf3b8b52 129
30afcc07
RL
130LINK_SO_A= SHOBJECTS="lib$(LIBNAME).a $(LIBEXTRAS)"; $(LINK_SO)
131LINK_SO_O= SHOBJECTS="$(LIBEXTRAS)"; $(LINK_SO)
f210eb7b 132
30afcc07 133LINK_SO_A_VIA_O= \
f968059c
RL
134 SHOBJECTS=lib$(LIBNAME).o; \
135 ALL=$$ALLSYMSFLAGS; ALLSYMSFLAGS=; NOALLSYMSFLAGS=; \
fe28866d 136 ( $(SET_X); \
30afcc07
RL
137 ld $(LDFLAGS) -r -o lib$(LIBNAME).o $$ALL lib$(LIBNAME).a $(LIBEXTRAS) ); \
138 $(LINK_SO) && rm -f $(LIBNAME).o
f210eb7b 139
30afcc07
RL
140LINK_SO_A_UNPACKED= \
141 UNPACKDIR=link_tmp.$$$$; rm -rf $$UNPACKDIR; mkdir $$UNPACKDIR; \
e96133e4
RL
142 (cd $$UNPACKDIR; ar x ../lib$(LIBNAME).a) && \
143 ([ -z "$(LIBEXTRAS)" ] || cp $(LIBEXTRAS) $$UNPACKDIR) && \
30afcc07
RL
144 SHOBJECTS=$$UNPACKDIR/*.o; \
145 $(LINK_SO) && rm -rf $$UNPACKDIR
146
4d77d5b3
AP
147DETECT_GNU_LD=(${CC} -Wl,-V /dev/null 2>&1 | grep '^GNU ld' )>/dev/null
148
2d3de726 149DO_GNU_SO=$(CALC_VERSIONS); \
f968059c
RL
150 SHLIB=lib$(LIBNAME).so; \
151 SHLIB_SUFFIX=; \
f968059c
RL
152 ALLSYMSFLAGS='-Wl,--whole-archive'; \
153 NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
f210eb7b
AP
154 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-Bsymbolic -Wl,-soname=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"
155
156DO_GNU_APP=LDFLAGS="$(CFLAGS) -Wl,-rpath,$(LIBRPATH)"
12fd8be2 157
132eaa59
RL
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...
163link_app.:
132eaa59
RL
164 $(LINK_APP)
165
12fd8be2 166link_o.gnu:
2d3de726 167 @ $(DO_GNU_SO); $(LINK_SO_O)
30afcc07 168link_a.gnu:
2d3de726
RL
169 @ $(DO_GNU_SO); $(LINK_SO_A)
170link_app.gnu:
171 @ $(DO_GNU_APP); $(LINK_APP)
30afcc07 172
16760a30
AP
173link_o.bsd:
174 @if ${DETECT_GNU_LD}; then $(DO_GNU_SO); else \
175 $(CALC_VERSIONS); \
176 SHLIB=lib$(LIBNAME).so; \
177 SHLIB_SUFFIX=; \
f210eb7b 178 LIBDEPS=" "; \
16760a30
AP
179 ALLSYMSFLAGS="-Wl,-Bforcearchive"; \
180 NOALLSYMSFLAGS=; \
f210eb7b 181 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -nostdlib"; \
16760a30
AP
182 fi; $(LINK_SO_O)
183link_a.bsd:
184 @if ${DETECT_GNU_LD}; then $(DO_GNU_SO); else \
185 $(CALC_VERSIONS); \
186 SHLIB=lib$(LIBNAME).so; \
187 SHLIB_SUFFIX=; \
f210eb7b 188 LIBDEPS=" "; \
16760a30
AP
189 ALLSYMSFLAGS="-Wl,-Bforcearchive"; \
190 NOALLSYMSFLAGS=; \
f210eb7b 191 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -nostdlib"; \
16760a30
AP
192 fi; $(LINK_SO_A)
193link_app.bsd:
194 @if ${DETECT_GNU_LD}; then $(DO_GNU_APP); else \
4aca9297 195 LDFLAGS="$(CFLAGS) -Wl,-rpath,$(LIBPATH)"; \
16760a30
AP
196 fi; $(LINK_APP)
197
30afcc07 198# For Darwin AKA Mac OS/X (dyld)
755c5b33
AP
199# link_o.darwin produces .so, because we let it use dso_dlfcn module,
200# which has .so extension hard-coded. One can argue that one should
201# develop special dso module for MacOS X. At least manual encourages
202# to use native NSModule(3) API and refers to dlfcn as termporary hack.
30afcc07
RL
203link_o.darwin:
204 @ $(CALC_VERSIONS); \
f968059c 205 SHLIB=lib$(LIBNAME); \
755c5b33 206 SHLIB_SUFFIX=.so; \
f968059c
RL
207 ALLSYMSFLAGS='-all_load'; \
208 NOALLSYMSFLAGS=''; \
ab6cf1b8 209 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS)"; \
36757b44 210 if [ -n "$(LIBVERSION)" ]; then \
62966f38 211 SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
36757b44
RL
212 fi; \
213 if [ -n "$$SHLIB_SOVER_NODOT" ]; then \
62966f38 214 SHAREDFLAGS="$$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \
36757b44 215 fi; \
30afcc07
RL
216 $(LINK_SO_O)
217link_a.darwin:
218 @ $(CALC_VERSIONS); \
f968059c
RL
219 SHLIB=lib$(LIBNAME); \
220 SHLIB_SUFFIX=.dylib; \
f968059c
RL
221 ALLSYMSFLAGS='-all_load'; \
222 NOALLSYMSFLAGS=''; \
ab6cf1b8 223 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS)"; \
36757b44 224 if [ -n "$(LIBVERSION)" ]; then \
62966f38 225 SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
36757b44
RL
226 fi; \
227 if [ -n "$$SHLIB_SOVER_NODOT" ]; then \
62966f38 228 SHAREDFLAGS="$$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \
36757b44 229 fi; \
99c675b2 230 SHAREDFLAGS="$$SHAREDFLAGS -install_name ${INSTALLTOP}/lib/$$SHLIB${SHLIB_EXT}"; \
30afcc07 231 $(LINK_SO_A)
f210eb7b 232link_app.darwin: # is there run-path on darwin?
2d3de726 233 $(LINK_APP)
30afcc07
RL
234
235link_o.cygwin:
bfa96bc2
RL
236 @ $(CALC_VERSIONS); \
237 INHIBIT_SYMLINKS=yes; \
f968059c 238 SHLIB=cyg$(LIBNAME); \
ec38ddc7 239 expr $(PLATFORM) : 'mingw' > /dev/null && SHLIB=$(LIBNAME)eay32; \
f968059c 240 SHLIB_SUFFIX=.dll; \
447aa490
RL
241 LIBVERSION="$(LIBVERSION)"; \
242 SHLIB_SOVER=${LIBVERSION:+"-$(LIBVERSION)"}; \
f968059c
RL
243 ALLSYMSFLAGS='-Wl,--whole-archive'; \
244 NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
f210eb7b 245 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a"; \
30afcc07
RL
246 $(LINK_SO_O)
247link_a.cygwin:
bfa96bc2
RL
248 @ $(CALC_VERSIONS); \
249 INHIBIT_SYMLINKS=yes; \
f968059c 250 SHLIB=cyg$(LIBNAME); \
ec38ddc7 251 expr $(PLATFORM) : 'mingw' > /dev/null && SHLIB=$(LIBNAME)eay32; \
f968059c 252 SHLIB_SUFFIX=.dll; \
447aa490 253 SHLIB_SOVER=-$(LIBVERSION); \
f968059c
RL
254 ALLSYMSFLAGS='-Wl,--whole-archive'; \
255 NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
447aa490 256 base=; [ $(LIBNAME) = "crypto" ] && base=-Wl,--image-base,0x63000000; \
f210eb7b 257 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared $$base -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a"; \
94c1672e
AP
258 [ -f apps/$$SHLIB$$SHLIB_SUFFIX ] && rm apps/$$SHLIB$$SHLIB_SUFFIX; \
259 [ -f test/$$SHLIB$$SHLIB_SUFFIX ] && rm test/$$SHLIB$$SHLIB_SUFFIX; \
260 $(LINK_SO_A) || exit 1; \
447aa490
RL
261 cp -p $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX apps/; \
262 cp -p $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX test/
2d3de726 263link_app.cygwin:
2d3de726 264 $(LINK_APP)
30afcc07
RL
265
266link_o.alpha-osf1:
267 @ if ${DETECT_GNU_LD}; then \
2d3de726 268 $(DO_GNU_SO); \
30afcc07 269 else \
f968059c
RL
270 SHLIB=lib$(LIBNAME).so; \
271 SHLIB_SUFFIX=; \
30afcc07
RL
272 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
273 if [ -n "$$SHLIB_HIST" ]; then \
274 SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
275 else \
276 SHLIB_HIST="$(LIBVERSION)"; \
62966f38 277 fi; \
f968059c
RL
278 SHLIB_SOVER=; \
279 ALLSYMSFLAGS='-all'; \
280 NOALLSYMSFLAGS='-none'; \
f210eb7b 281 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared"; \
36757b44 282 if [ -n "$$SHLIB_HIST" ]; then \
9ab51701 283 SHAREDFLAGS="$$SHAREDFLAGS -set_version $$SHLIB_HIST"; \
36757b44 284 fi; \
12fd8be2
RL
285 fi; \
286 $(LINK_SO_O)
30afcc07
RL
287link_a.alpha-osf1:
288 @ if ${DETECT_GNU_LD}; then \
2d3de726 289 $(DO_GNU_SO); \
30afcc07 290 else \
f968059c
RL
291 SHLIB=lib$(LIBNAME).so; \
292 SHLIB_SUFFIX=; \
30afcc07
RL
293 SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
294 if [ -n "$$SHLIB_HIST" ]; then \
295 SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
296 else \
297 SHLIB_HIST="$(LIBVERSION)"; \
62966f38 298 fi; \
f968059c
RL
299 SHLIB_SOVER=; \
300 ALLSYMSFLAGS='-all'; \
301 NOALLSYMSFLAGS='-none'; \
f210eb7b 302 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared"; \
36757b44 303 if [ -n "$$SHLIB_HIST" ]; then \
9ab51701 304 SHAREDFLAGS="$$SHAREDFLAGS -set_version $$SHLIB_HIST"; \
36757b44 305 fi; \
12fd8be2
RL
306 fi; \
307 $(LINK_SO_A)
2d3de726 308link_app.alpha-osf1:
f210eb7b 309 @if ${DETECT_GNU_LD}; then \
2d3de726
RL
310 $(DO_GNU_APP); \
311 else \
4aca9297 312 LDFLAGS="$(CFLAGS) -rpath $(LIBRPATH)"; \
2d3de726
RL
313 fi; \
314 $(LINK_APP)
30afcc07
RL
315
316link_o.solaris:
a0bf8f20 317 @ if ${DETECT_GNU_LD}; then \
2d3de726 318 $(DO_GNU_SO); \
30afcc07
RL
319 else \
320 $(CALC_VERSIONS); \
c4451425 321 MINUSZ='-z '; \
f210eb7b 322 ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSZ='-Wl,-z,'; \
f968059c
RL
323 SHLIB=lib$(LIBNAME).so; \
324 SHLIB_SUFFIX=; \
f968059c
RL
325 ALLSYMSFLAGS="$${MINUSZ}allextract"; \
326 NOALLSYMSFLAGS="$${MINUSZ}defaultextract"; \
f210eb7b 327 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-Bsymbolic"; \
12fd8be2
RL
328 fi; \
329 $(LINK_SO_O)
30afcc07 330link_a.solaris:
a0bf8f20 331 @ if ${DETECT_GNU_LD}; then \
2d3de726 332 $(DO_GNU_SO); \
30afcc07
RL
333 else \
334 $(CALC_VERSIONS); \
c4451425
RL
335 MINUSZ='-z '; \
336 (${CC} -v 2>&1 | grep gcc) > /dev/null && MINUSZ='-Wl,-z,'; \
f968059c
RL
337 SHLIB=lib$(LIBNAME).so; \
338 SHLIB_SUFFIX=;\
f968059c
RL
339 ALLSYMSFLAGS="$${MINUSZ}allextract"; \
340 NOALLSYMSFLAGS="$${MINUSZ}defaultextract"; \
f210eb7b 341 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX -Wl,-Bsymbolic"; \
12fd8be2
RL
342 fi; \
343 $(LINK_SO_A)
2d3de726
RL
344link_app.solaris:
345 @ if ${DETECT_GNU_LD}; then \
346 $(DO_GNU_APP); \
347 else \
4aca9297 348 LDFLAGS="$(CFLAGS) -R $(LIBRPATH)"; \
2d3de726
RL
349 fi; \
350 $(LINK_APP)
30afcc07
RL
351
352# OpenServer 5 native compilers used
30afcc07 353link_o.svr3:
a1092201
RL
354 @ if ${DETECT_GNU_LD}; then \
355 $(DO_GNU_SO); \
356 else \
357 $(CALC_VERSIONS); \
358 SHLIB=lib$(LIBNAME).so; \
359 SHLIB_SUFFIX=; \
a1092201
RL
360 ALLSYMSFLAGS=''; \
361 NOALLSYMSFLAGS=''; \
4aca9297 362 SHAREDFLAGS="$(CFLAGS) -G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
a1092201
RL
363 fi; \
364 $(LINK_SO_O)
365link_a.svr3:
366 @ if ${DETECT_GNU_LD}; then \
367 $(DO_GNU_SO); \
368 else \
369 $(CALC_VERSIONS); \
370 SHLIB=lib$(LIBNAME).so; \
371 SHLIB_SUFFIX=; \
a1092201
RL
372 ALLSYMSFLAGS=''; \
373 NOALLSYMSFLAGS=''; \
4aca9297 374 SHAREDFLAGS="$(CFLAGS) -G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
a1092201
RL
375 fi; \
376 $(LINK_SO_A_UNPACKED)
377link_app.svr3:
f210eb7b 378 @${DETECT_GNU_LD} && $(DO_GNU_APP); \
a1092201
RL
379 $(LINK_APP)
380
381# UnixWare 7 and OpenUNIX 8 native compilers used
382link_o.svr5:
30afcc07 383 @ if ${DETECT_GNU_LD}; then \
2d3de726 384 $(DO_GNU_SO); \
30afcc07
RL
385 else \
386 $(CALC_VERSIONS); \
24692fc5 387 SHARE_FLAG='-G'; \
f210eb7b 388 ($(CC) -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
f968059c
RL
389 SHLIB=lib$(LIBNAME).so; \
390 SHLIB_SUFFIX=; \
e96133e4 391 ALLSYMSFLAGS=''; \
f968059c 392 NOALLSYMSFLAGS=''; \
4aca9297 393 SHAREDFLAGS="$(CFLAGS) $${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
12fd8be2
RL
394 fi; \
395 $(LINK_SO_O)
a1092201 396link_a.svr5:
30afcc07 397 @ if ${DETECT_GNU_LD}; then \
2d3de726 398 $(DO_GNU_SO); \
30afcc07
RL
399 else \
400 $(CALC_VERSIONS); \
24692fc5 401 SHARE_FLAG='-G'; \
e96133e4 402 (${CC} -v 2>&1 | grep gcc) > /dev/null && SHARE_FLAG='-shared'; \
f968059c
RL
403 SHLIB=lib$(LIBNAME).so; \
404 SHLIB_SUFFIX=; \
e96133e4 405 ALLSYMSFLAGS=''; \
f968059c 406 NOALLSYMSFLAGS=''; \
4aca9297 407 SHAREDFLAGS="$(CFLAGS) $${SHARE_FLAG} -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
12fd8be2
RL
408 fi; \
409 $(LINK_SO_A_UNPACKED)
a1092201 410link_app.svr5:
f210eb7b 411 @${DETECT_GNU_LD} && $(DO_GNU_APP); \
2d3de726 412 $(LINK_APP)
30afcc07
RL
413
414link_o.irix:
415 @ if ${DETECT_GNU_LD}; then \
2d3de726 416 $(DO_GNU_SO); \
30afcc07
RL
417 else \
418 $(CALC_VERSIONS); \
f968059c
RL
419 SHLIB=lib$(LIBNAME).so; \
420 SHLIB_SUFFIX=; \
30fbcaa2
AP
421 MINUSWL=""; \
422 ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSWL="-Wl,"; \
423 ALLSYMSFLAGS="$${MINUSWL}-all"; \
bd16cd6b 424 NOALLSYMSFLAGS="$${MINUSWL}-none"; \
f210eb7b 425 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
12fd8be2
RL
426 fi; \
427 $(LINK_SO_O)
30afcc07
RL
428link_a.irix:
429 @ if ${DETECT_GNU_LD}; then \
2d3de726 430 $(DO_GNU_SO); \
30afcc07
RL
431 else \
432 $(CALC_VERSIONS); \
f968059c
RL
433 SHLIB=lib$(LIBNAME).so; \
434 SHLIB_SUFFIX=; \
30fbcaa2
AP
435 MINUSWL=""; \
436 ($(CC) -v 2>&1 | grep gcc) > /dev/null && MINUSWL="-Wl,"; \
437 ALLSYMSFLAGS="$${MINUSWL}-all"; \
bd16cd6b 438 NOALLSYMSFLAGS="$${MINUSWL}-none"; \
f210eb7b 439 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
12fd8be2
RL
440 fi; \
441 $(LINK_SO_A)
2d3de726 442link_app.irix:
f210eb7b 443 @LDFLAGS="$(CFLAGS) -Wl,-rpath,$(LIBRPATH)"; \
2d3de726 444 $(LINK_APP)
30afcc07 445
393b704d
AP
446# 32-bit PA-RISC HP-UX embeds the -L pathname of libs we link with, so
447# we compensate for it with +cdp ../: and +cdp ./:. Yes, these rewrite
448# rules imply that we can only link one level down in catalog structure,
449# but that's what takes place for the moment of this writing. +cdp option
450# was introduced in HP-UX 11.x and applies in 32-bit PA-RISC link
451# editor context only [it's simply ignored in other cases, which are all
452# ELFs by the way].
30afcc07 453#
1a83c372 454link_o.hpux:
15fd2de3
AP
455 @if ${DETECT_GNU_LD}; then $(DO_GNU_SO); else \
456 $(CALC_VERSIONS); \
f968059c 457 SHLIB=lib$(LIBNAME).sl; \
755c5b33 458 expr "$(CFLAGS)" : 'DSO_DLFCN' > /dev/null && SHLIB=lib$(LIBNAME).so; \
f968059c 459 SHLIB_SUFFIX=; \
2bbc970e 460 ALLSYMSFLAGS='-Wl,-Fl'; \
f968059c 461 NOALLSYMSFLAGS=''; \
1a83c372 462 expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \
f210eb7b 463 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
15fd2de3 464 fi; \
a41b0aad 465 rm -f $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX || :; \
83699c47 466 $(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
1a83c372 467link_a.hpux:
15fd2de3
AP
468 @if ${DETECT_GNU_LD}; then $(DO_GNU_SO); else \
469 $(CALC_VERSIONS); \
f968059c 470 SHLIB=lib$(LIBNAME).sl; \
86119343 471 expr $(PLATFORM) : '.*ia64' > /dev/null && SHLIB=lib$(LIBNAME).so; \
f968059c 472 SHLIB_SUFFIX=; \
2bbc970e 473 ALLSYMSFLAGS='-Wl,-Fl'; \
f968059c 474 NOALLSYMSFLAGS=''; \
1a83c372 475 expr $(PLATFORM) : 'hpux64' > /dev/null && ALLSYMSFLAGS='-Wl,+forceload'; \
f210eb7b 476 SHAREDFLAGS="$(CFLAGS) $(SHARED_LDFLAGS) -Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+h,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
15fd2de3 477 fi; \
a41b0aad 478 rm -f $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX || :; \
83699c47 479 $(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
1a83c372 480link_app.hpux:
15fd2de3 481 @if ${DETECT_GNU_LD}; then $(DO_GNU_APP); else \
4aca9297 482 LDFLAGS="$(CFLAGS) -Wl,+s,+cdp,../:,+cdp,./:,+b,$(LIBRPATH)"; \
15fd2de3 483 fi; \
2d3de726 484 $(LINK_APP)
30afcc07 485
30afcc07
RL
486link_o.aix:
487 @ $(CALC_VERSIONS); \
fe28866d
AP
488 OBJECT_MODE=`expr x$(SHARED_LDFLAGS) : 'x\-[a-z]\([0-9]*\)'`; \
489 OBJECT_MODE=$${OBJECT_MODE:-32}; export OBJECT_MODE; \
f968059c
RL
490 SHLIB=lib$(LIBNAME).so; \
491 SHLIB_SUFFIX=; \
f968059c
RL
492 ALLSYMSFLAGS='-bnogc'; \
493 NOALLSYMSFLAGS=''; \
f210eb7b 494 SHAREDFLAGS='$(CFLAGS) $(SHARED_LDFLAGS) -G -bE:lib$(LIBNAME).exp -bM:SRE'; \
fe28866d 495 $(LINK_SO_O); rm -rf lib$(LIBNAME).exp
30afcc07
RL
496link_a.aix:
497 @ $(CALC_VERSIONS); \
fe28866d
AP
498 OBJECT_MODE=`expr x$(SHARED_LDFLAGS) : 'x\-[a-z]\([0-9]*\)'`; \
499 OBJECT_MODE=$${OBJECT_MODE:-32}; export OBJECT_MODE; \
f968059c
RL
500 SHLIB=lib$(LIBNAME).so; \
501 SHLIB_SUFFIX=; \
f968059c
RL
502 ALLSYMSFLAGS='-bnogc'; \
503 NOALLSYMSFLAGS=''; \
f210eb7b 504 SHAREDFLAGS='$(CFLAGS) $(SHARED_LDFLAGS) -G -bE:lib$(LIBNAME).exp -bM:SRE'; \
30afcc07 505 $(LINK_SO_A_VIA_O)
2d3de726 506link_app.aix:
4f92a764 507 LDFLAGS="$(CFLAGS) -blibpath:$(LIBRPATH):$${LIBPATH:-/usr/lib:/lib}"; \
2d3de726 508 $(LINK_APP)
30afcc07
RL
509
510link_o.reliantunix:
511 @ $(CALC_VERSIONS); \
f968059c
RL
512 SHLIB=lib$(LIBNAME).so; \
513 SHLIB_SUFFIX=; \
f968059c
RL
514 ALLSYMSFLAGS=; \
515 NOALLSYMSFLAGS=''; \
4aca9297 516 SHAREDFLAGS='$(CFLAGS) -G'; \
30afcc07
RL
517 $(LINK_SO_O)
518link_a.reliantunix:
519 @ $(CALC_VERSIONS); \
f968059c
RL
520 SHLIB=lib$(LIBNAME).so; \
521 SHLIB_SUFFIX=; \
f968059c
RL
522 ALLSYMSFLAGS=; \
523 NOALLSYMSFLAGS=''; \
4aca9297 524 SHAREDFLAGS='$(CFLAGS) -G'; \
30afcc07 525 $(LINK_SO_A_UNPACKED)
2d3de726 526link_app.reliantunix:
2d3de726 527 $(LINK_APP)
30afcc07
RL
528
529# Targets to build symbolic links when needed
a1092201 530symlink.gnu symlink.solaris symlink.svr3 symlink.svr5 symlink.irix \
30afcc07
RL
531symlink.aix symlink.reliantunix:
532 @ $(CALC_VERSIONS); \
bfa96bc2 533 SHLIB=lib$(LIBNAME).so; \
30afcc07 534 $(SYMLINK_SO)
83699c47
RL
535symlink.darwin:
536 @ $(CALC_VERSIONS); \
f968059c 537 SHLIB=lib$(LIBNAME); \
bfa96bc2 538 SHLIB_SUFFIX=.dylib; \
83699c47 539 $(SYMLINK_SO)
1a83c372 540symlink.hpux:
30afcc07 541 @ $(CALC_VERSIONS); \
bfa96bc2 542 SHLIB=lib$(LIBNAME).sl; \
86119343 543 expr $(PLATFORM) : '.*ia64' > /dev/null && SHLIB=lib$(LIBNAME).so; \
30afcc07 544 $(SYMLINK_SO)
bfa96bc2 545# The following lines means those specific architectures do no symlinks
9ab51701 546symlink.cygwin symlink.alpha-osf1 symlink.tru64 symlink.tru64-rpath:
30afcc07
RL
547
548# Compatibility targets
549link_o.bsd-gcc-shared link_o.linux-shared link_o.gnu-shared: link_o.gnu
550link_a.bsd-gcc-shared link_a.linux-shared link_a.gnu-shared: link_a.gnu
2d3de726 551link_app.bsd-gcc-shared link_app.linux-shared link_app.gnu-shared: link_app.gnu
16760a30
AP
552symlink.bsd-gcc-shared symlink.bsd-shared symlink.linux-shared symlink.gnu-shared: symlink.gnu
553link_o.bsd-shared: link_o.bsd
554link_a.bsd-shared: link_a.bsd
555link_app.bsd-shared: link_app.bsd
30afcc07
RL
556link_o.darwin-shared: link_o.darwin
557link_a.darwin-shared: link_a.darwin
2d3de726 558link_app.darwin-shared: link_app.darwin
30afcc07
RL
559symlink.darwin-shared: symlink.darwin
560link_o.cygwin-shared: link_o.cygwin
561link_a.cygwin-shared: link_a.cygwin
2d3de726 562link_app.cygwin-shared: link_app.cygwin
30afcc07
RL
563symlink.cygwin-shared: symlink.cygwin
564link_o.alpha-osf1-shared: link_o.alpha-osf1
565link_a.alpha-osf1-shared: link_a.alpha-osf1
2d3de726 566link_app.alpha-osf1-shared: link_app.alpha-osf1
30afcc07
RL
567symlink.alpha-osf1-shared: symlink.alpha-osf1
568link_o.tru64-shared: link_o.tru64
569link_a.tru64-shared: link_a.tru64
2d3de726 570link_app.tru64-shared: link_app.tru64
30afcc07
RL
571symlink.tru64-shared: symlink.tru64
572link_o.tru64-shared-rpath: link_o.tru64-rpath
573link_a.tru64-shared-rpath: link_a.tru64-rpath
2d3de726 574link_app.tru64-shared-rpath: link_app.tru64-rpath
30afcc07
RL
575symlink.tru64-shared-rpath: symlink.tru64-rpath
576link_o.solaris-shared: link_o.solaris
577link_a.solaris-shared: link_a.solaris
2d3de726 578link_app.solaris-shared: link_app.solaris
30afcc07
RL
579symlink.solaris-shared: symlink.solaris
580link_o.svr3-shared: link_o.svr3
581link_a.svr3-shared: link_a.svr3
2d3de726 582link_app.svr3-shared: link_app.svr3
30afcc07 583symlink.svr3-shared: symlink.svr3
a1092201
RL
584link_o.svr5-shared: link_o.svr5
585link_a.svr5-shared: link_a.svr5
586link_app.svr5-shared: link_app.svr5
587symlink.svr5-shared: symlink.svr5
30afcc07
RL
588link_o.irix-shared: link_o.irix
589link_a.irix-shared: link_a.irix
2d3de726 590link_app.irix-shared: link_app.irix
30afcc07 591symlink.irix-shared: symlink.irix
1a83c372
AP
592link_o.hpux-shared: link_o.hpux
593link_a.hpux-shared: link_a.hpux
594link_app.hpux-shared: link_app.hpux
595symlink.hpux-shared: symlink.hpux
30afcc07
RL
596link_o.aix-shared: link_o.aix
597link_a.aix-shared: link_a.aix
2d3de726 598link_app.aix-shared: link_app.aix
30afcc07
RL
599symlink.aix-shared: symlink.aix
600link_o.reliantunix-shared: link_o.reliantunix
601link_a.reliantunix-shared: link_a.reliantunix
2d3de726 602link_app.reliantunix-shared: link_app.reliantunix
30afcc07 603symlink.reliantunix-shared: symlink.reliantunix