Makefile.shared 17.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
#
# Helper makefile to link shared libraries in a portable way.
# This is much simpler than libtool, and hopefully not too error-prone.
#
# The following variables need to be set on the command line to build
# properly

# CC contains the current compiler.  This one MUST be defined
CC=cc
# LDFLAGS contains flags to be used when the temporary object file is
# created.  SHARED_LDFLAGS contains flags to be used when the shared
# library is created.
LDFLAGS=
SHARED_LDFLAGS=

# LIBNAME contains just the name of thhe library, without prefix ("lib"
# on Unix, "cyg" for certain forms under Cygwin...) or suffix (.a, .so,
# .dll, ...).  This one MUST have a value when using this makefile.
# For example, to build libfoo.so, you need to do the following:
#LIBNAME=foo
LIBNAME=

# LIBEXTRAS contains extra modules to link together with the library.
24
# For example, if a second library, say libbar.a needs to be linked into
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
# libfoo.so, you need to do the following:
#LIBEXTRAS=libbar.a
# Note that this MUST be used when using the link_o targets, to hold the
# names of all object files that go into the target library.
LIBEXTRAS=

# LIBVERSION contains the current version of the library.
# For example, to build libfoo.so.1.2, you need to do the following:
#LIBVERSION=1.2
LIBVERSION=

# LIBCOMPATVERSIONS contains the compatibility versions (a list) of
# the library.  They MUST be in decreasing order.
# For example, if libfoo.so.1.2.1 is backward compatible with libfoo.so.1.2
# and libfoo.so.1, you need to do the following:
#LIBCOMPATVERSIONS=1.2 1
# Note that on systems that use sonames, the last number will appear as
# part of it.
# It's also possible, for systems that support it (Tru64, for example),
# to add extra compatibility info with more precision, by adding a second
# list of versions, separated from the first with a semicolon, like this:
#LIBCOMPATVERSIONS=1.2 1;1.2.0 1.1.2 1.1.1 1.1.0 1.0.0
LIBCOMPATVERSIONS=

# LIBDEPS contains all the flags necessary to cover all necessary
# dependencies to other libraries.
LIBDEPS=

#------------------------------------------------------------------------------
# The rest is private to this makefile.

#DEBUG=:
DEBUG=set -x

top:
	echo "Trying to use this makefile interactively?  Don't."

CALC_VERSIONS=	\
	SHLIB_COMPAT=; SHLIB_SOVER=; \
64
	if [ -n "$(LIBVERSION)$(LIBCOMPATVERSIONS)" ]; then \
65 66
		prev=""; \
		for v in `echo "$(LIBVERSION) $(LIBCOMPATVERSIONS)" | cut -d';' -f1`; do \
67
			SHLIB_SOVER_NODOT=$$v; \
68 69
			SHLIB_SOVER=.$$v; \
			if [ -n "$$prev" ]; then \
R
Richard Levitte 已提交
70
				SHLIB_COMPAT="$$SHLIB_COMPAT .$$prev"; \
71 72 73 74 75 76 77 78
			fi; \
			prev=$$v; \
		done; \
	fi

LINK_SO=	\
  ( $(DEBUG); \
    nm -Pg $$SHOBJECTS | grep ' [BDT] ' | cut -f1 -d' ' > lib$(LIBNAME).exp; \
79
    $$SHAREDCMD $(SHARED_LDFLAGS) $$SHAREDFLAGS -o $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \
80 81 82
	$$ALLSYMSFLAGS $$SHOBJECTS $$NOALLSYMSFLAGS $$LIBDEPS ) && \
  $(SYMLINK_SO); ( $(DEBUG); rm -f lib$(LIBNAME).exp )
SYMLINK_SO=	\
83 84 85 86 87 88 89 90 91 92 93 94 95
	if [ -n "$$INHIBIT_SYMLINKS" ]; then :; else \
		prev=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \
		if [ -n "$$SHLIB_COMPAT" ]; then \
			for x in $$SHLIB_COMPAT; do \
				( $(DEBUG); rm -f $$SHLIB$$x$$SHLIB_SUFFIX; \
				  ln -s $$prev $$SHLIB$$x$$SHLIB_SUFFIX ); \
				prev=$$SHLIB$$x$$SHLIB_SUFFIX; \
			done; \
		fi; \
		if [ -n "$$SHLIB_SOVER" ]; then \
			( $(DEBUG); rm -f $$SHLIB$$SHLIB_SUFFIX; \
			  ln -s $$prev $$SHLIB$$SHLIB_SUFFIX ); \
		fi; \
96
	fi
97

98 99 100
LINK_SO_A=	SHOBJECTS="lib$(LIBNAME).a $(LIBEXTRAS)"; $(LINK_SO)
LINK_SO_O=	SHOBJECTS="$(LIBEXTRAS)"; $(LINK_SO)
LINK_SO_A_VIA_O=	\
101 102
  SHOBJECTS=lib$(LIBNAME).o; \
  ALL=$$ALLSYMSFLAGS; ALLSYMSFLAGS=; NOALLSYMSFLAGS=; \
103 104 105 106 107 108 109 110 111
  ( $(DEBUG); \
    ld $(LDFLAGS) -r -o lib$(LIBNAME).o $$ALL lib$(LIBNAME).a $(LIBEXTRAS) ); \
  $(LINK_SO) && rm -f $(LIBNAME).o
LINK_SO_A_UNPACKED=	\
  UNPACKDIR=link_tmp.$$$$; rm -rf $$UNPACKDIR; mkdir $$UNPACKDIR; \
  (cd $$UNPACKDIR; ar x ../lib$(LIBNAME).a) && cp $(LIBEXTRAS) $$UNPACKDIR && \
  SHOBJECTS=$$UNPACKDIR/*.o; \
  $(LINK_SO) && rm -rf $$UNPACKDIR

A
Andy Polyakov 已提交
112 113
DETECT_GNU_LD=(${CC} -Wl,-V /dev/null 2>&1 | grep '^GNU ld' )>/dev/null

114
DO_GNU=$(CALC_VERSIONS); \
115 116 117 118 119 120
	SHLIB=lib$(LIBNAME).so; \
	SHLIB_SUFFIX=; \
	LIBDEPS="$(LIBDEPS) -lc"; \
	ALLSYMSFLAGS='-Wl,--whole-archive'; \
	NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
	SHAREDFLAGS="-shared -Wl,-Bsymbolic -Wl,-soname=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
121 122 123 124
	SHAREDCMD='$(CC)'

link_o.gnu:
	@ $(DO_GNU); $(LINK_SO_O)
125
link_a.gnu:
126
	@ $(DO_GNU); $(LINK_SO_A)
127 128 129 130

# For Darwin AKA Mac OS/X (dyld)
link_o.darwin:
	@ $(CALC_VERSIONS); \
131 132 133 134 135 136
	SHLIB=lib$(LIBNAME); \
	SHLIB_SUFFIX=.dylib; \
	LIBDEPS="$(LIBDEPS) -lc"; \
	ALLSYMSFLAGS='-all_load'; \
	NOALLSYMSFLAGS=''; \
	SHAREDFLAGS="-dynamiclib"; \
137
	SHAREDCMD='$(CC)'; \
138
	if [ -n "$(LIBVERSION)" ]; then \
139
		SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
140 141
	fi; \
	if [ -n "$$SHLIB_SOVER_NODOT" ]; then \
142
		SHAREDFLAGS="$$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \
143
	fi; \
144 145 146
	$(LINK_SO_O)
link_a.darwin:
	@ $(CALC_VERSIONS); \
147 148 149 150 151 152
	SHLIB=lib$(LIBNAME); \
	SHLIB_SUFFIX=.dylib; \
	LIBDEPS="$(LIBDEPS) -lc"; \
	ALLSYMSFLAGS='-all_load'; \
	NOALLSYMSFLAGS=''; \
	SHAREDFLAGS="-dynamiclib"; \
153
	SHAREDCMD='$(CC)'; \
154
	if [ -n "$(LIBVERSION)" ]; then \
155
		SHAREDFLAGS="$$SHAREDFLAGS -current_version $(LIBVERSION)"; \
156 157
	fi; \
	if [ -n "$$SHLIB_SOVER_NODOT" ]; then \
158
		SHAREDFLAGS="$$SHAREDFLAGS -compatibility_version $$SHLIB_SOVER_NODOT"; \
159
	fi; \
160 161 162
	$(LINK_SO_A)

link_o.cygwin:
163 164
	@ $(CALC_VERSIONS); \
	INHIBIT_SYMLINKS=yes; \
165 166 167 168 169 170 171
	SHLIB=cyg$(LIBNAME); \
	SHLIB_SUFFIX=.dll; \
	LIBDEPS="$(LIBDEPS) -lc"; \
	SHLIB_SOVER=-$(LIBVERSION); \
	ALLSYMSFLAGS='-Wl,--whole-archive'; \
	NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
	SHAREDFLAGS="-shared -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a"; \
172 173 174
	SHAREDCMD='${CC}'; \
	$(LINK_SO_O)
link_a.cygwin:
175 176
	@ $(CALC_VERSIONS); \
	INHIBIT_SYMLINKS=yes; \
177 178 179 180 181 182 183
	SHLIB=cyg$(LIBNAME); \
	SHLIB_SUFFIX=.dll; \
	LIBDEPS="$(LIBDEPS) -lc"; \
	SHLIB_SOVER=; \
	ALLSYMSFLAGS='-Wl,--whole-archive'; \
	NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
	SHAREDFLAGS="-shared -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a"; \
184 185 186 187 188
	SHAREDCMD='${CC}'; \
	$(LINK_SO_A)

link_o.alpha-osf1:
	@ if ${DETECT_GNU_LD}; then \
189
		$(DO_GNU); \
190
	else \
191 192 193
		SHLIB=lib$(LIBNAME).so; \
		SHLIB_SUFFIX=; \
		LIBDEPS="$(LIBDEPS) -lc"; \
194 195 196 197 198
		SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
		if [ -n "$$SHLIB_HIST" ]; then \
			SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
		else \
			SHLIB_HIST="$(LIBVERSION)"; \
199
		fi; \
200 201 202 203
		SHLIB_SOVER=; \
		ALLSYMSFLAGS='-all'; \
		NOALLSYMSFLAGS='-none'; \
		SHAREDFLAGS="-shared"; \
204
		SHAREDCMD='$(CC)'; \
205
		if [ -n "$$SHLIB_HIST" ]; then \
206
			SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
207
		fi; \
208 209
	fi; \
	$(LINK_SO_O)
210 211
link_a.alpha-osf1:
	@ if ${DETECT_GNU_LD}; then \
212
		$(DO_GNU); \
213
	else \
214 215 216
		SHLIB=lib$(LIBNAME).so; \
		SHLIB_SUFFIX=; \
		LIBDEPS="$(LIBDEPS) -lc"; \
217 218 219 220 221
		SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
		if [ -n "$$SHLIB_HIST" ]; then \
			SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
		else \
			SHLIB_HIST="$(LIBVERSION)"; \
222
		fi; \
223 224 225 226
		SHLIB_SOVER=; \
		ALLSYMSFLAGS='-all'; \
		NOALLSYMSFLAGS='-none'; \
		SHAREDFLAGS="-shared"; \
227
		SHAREDCMD='$(CC)'; \
228
		if [ -n "$$SHLIB_HIST" ]; then \
229
			SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
230
		fi; \
231 232
	fi; \
	$(LINK_SO_A)
233 234 235 236 237

# The difference between alpha-osf1-shared and tru64-shared is the `-msym'
# option passed to the linker.
link_o.tru64:
	@ if ${DETECT_GNU_LD}; then \
238
		$(DO_GNU); \
239
	else \
240 241 242
		SHLIB=lib$(LIBNAME).so; \
		SHLIB_SUFFIX=; \
		LIBDEPS="$(LIBDEPS) -lc"; \
243 244 245 246 247
		SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
		if [ -n "$$SHLIB_HIST" ]; then \
			SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
		else \
			SHLIB_HIST="$(LIBVERSION)"; \
248
		fi; \
249 250 251 252
		SHLIB_SOVER=; \
		ALLSYMSFLAGS='-all'; \
		NOALLSYMSFLAGS='-none'; \
		SHAREDFLAGS="-shared -msym"; \
253
		SHAREDCMD='$(CC)'; \
254
		if [ -n "$$SHLIB_HIST" ]; then \
255
			SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
256
		fi; \
257 258
	fi; \
	$(LINK_SO_O)
259 260
link_a.tru64:
	@ if ${DETECT_GNU_LD}; then \
261
		$(DO_GNU); \
262
	else \
263 264 265
		SHLIB=lib$(LIBNAME).so; \
		SHLIB_SUFFIX=; \
		LIBDEPS="$(LIBDEPS) -lc"; \
266 267 268 269 270
		SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
		if [ -n "$$SHLIB_HIST" ]; then \
			SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
		else \
			SHLIB_HIST="$(LIBVERSION)"; \
271
		fi; \
272 273 274 275
		SHLIB_SOVER=; \
		ALLSYMSFLAGS='-all'; \
		NOALLSYMSFLAGS='-none'; \
		SHAREDFLAGS="-shared -msym"; \
276
		SHAREDCMD='$(CC)'; \
277
		if [ -n "$$SHLIB_HIST" ]; then \
278
			SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
279
		fi; \
280 281
	fi; \
	$(LINK_SO_A)
282 283 284 285 286

# The difference between tru64-shared and tru64-shared-rpath is the
# -rpath ${LIBRPATH} passed to the linker.
link_o.tru64-rpath:
	@ if ${DETECT_GNU_LD}; then \
287
		$(DO_GNU); \
288
	else \
289 290 291
		SHLIB=lib$(LIBNAME).so; \
		SHLIB_SUFFIX=; \
		LIBDEPS="$(LIBDEPS) -lc"; \
292 293 294 295 296
		SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
		if [ -n "$$SHLIB_HIST" ]; then \
			SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
		else \
			SHLIB_HIST="$(LIBVERSION)"; \
297
		fi; \
298 299 300 301
		SHLIB_SOVER=; \
		ALLSYMSFLAGS='-all'; \
		NOALLSYMSFLAGS='-none'; \
		SHAREDFLAGS="-shared -msym -rpath $(LIBRPATH)"; \
302
		SHAREDCMD='$(CC)'; \
303
		if [ -n "$$SHLIB_HIST" ]; then \
304
			SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
305
		fi; \
306 307
	fi; \
	$(LINK_SO_O)
308 309
link_a.tru64-rpath:
	@ if ${DETECT_GNU_LD}; then \
310
		$(DO_GNU); \
311
	else \
312 313 314
		SHLIB=lib$(LIBNAME).so; \
		SHLIB_SUFFIX=; \
		LIBDEPS="$(LIBDEPS) -lc"; \
315 316 317 318 319
		SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
		if [ -n "$$SHLIB_HIST" ]; then \
			SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
		else \
			SHLIB_HIST="$(LIBVERSION)"; \
320
		fi; \
321 322 323 324
		SHLIB_SOVER=; \
		ALLSYMSFLAGS='-all'; \
		NOALLSYMSFLAGS='-none'; \
		SHAREDFLAGS="-shared -msym -rpath $(LIBRPATH)"; \
325
		SHAREDCMD='$(CC)'; \
326
		if [ -n "$$SHLIB_HIST" ]; then \
327
			SHAREDFLAGS="$$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
328
		fi; \
329 330
	fi; \
	$(LINK_SO_A)
331 332

link_o.solaris:
R
Richard Levitte 已提交
333
	@ if ${DETECT_GNU_LD}; then \
334
		$(DO_GNU); \
335 336
	else \
		$(CALC_VERSIONS); \
337 338
		MINUSZ='-z '; \
		(${CC} -v 2>&1 | grep gcc) > /dev/null && MINUSZ='-Wl,-z,'; \
339 340 341 342 343 344
		SHLIB=lib$(LIBNAME).so; \
		SHLIB_SUFFIX=; \
		LIBDEPS="$(LIBDEPS) -lc"; \
		ALLSYMSFLAGS="$${MINUSZ}allextract"; \
		NOALLSYMSFLAGS="$${MINUSZ}defaultextract"; \
		SHAREDFLAGS="-G -dy -z text -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
345
		SHAREDCMD='$(CC)'; \
346 347
	fi; \
	$(LINK_SO_O)
348
link_a.solaris:
R
Richard Levitte 已提交
349
	@ if ${DETECT_GNU_LD}; then \
350
		$(DO_GNU); \
351 352
	else \
		$(CALC_VERSIONS); \
353 354
		MINUSZ='-z '; \
		(${CC} -v 2>&1 | grep gcc) > /dev/null && MINUSZ='-Wl,-z,'; \
355 356 357 358 359 360
		SHLIB=lib$(LIBNAME).so; \
		SHLIB_SUFFIX=;\
		LIBDEPS="$(LIBDEPS) -lc"; \
		ALLSYMSFLAGS="$${MINUSZ}allextract"; \
		NOALLSYMSFLAGS="$${MINUSZ}defaultextract"; \
		SHAREDFLAGS="-G -dy -z text -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
361
		SHAREDCMD='$(CC)'; \
362 363
	fi; \
	$(LINK_SO_A)
364 365 366 367 368

# OpenServer 5 native compilers used
# UnixWare 7 and OpenUNIX 8 native compilers used
link_o.svr3:
	@ if ${DETECT_GNU_LD}; then \
369
		$(DO_GNU); \
370 371
	else \
		$(CALC_VERSIONS); \
372 373 374 375 376 377
		SHLIB=lib$(LIBNAME).so; \
		SHLIB_SUFFIX=; \
		LIBDEPS="$(LIBDEPS) -lc"; \
		ALLSYMSFLAGS='-z allextract'; \
		NOALLSYMSFLAGS=''; \
		SHAREDFLAGS="-G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
378
		SHAREDCMD='$(CC)'; \
379 380
	fi; \
	$(LINK_SO_O)
381 382
link_a.svr3:
	@ if ${DETECT_GNU_LD}; then \
383
		$(DO_GNU); \
384 385
	else \
		$(CALC_VERSIONS); \
386 387 388 389 390 391
		SHLIB=lib$(LIBNAME).so; \
		SHLIB_SUFFIX=; \
		LIBDEPS="$(LIBDEPS) -lc"; \
		ALLSYMSFLAGS='-z allextract'; \
		NOALLSYMSFLAGS=''; \
		SHAREDFLAGS="-G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
392
		SHAREDCMD='$(CC)'; \
393 394
	fi; \
	$(LINK_SO_A_UNPACKED)
395 396 397

link_o.irix:
	@ if ${DETECT_GNU_LD}; then \
398
		$(DO_GNU); \
399 400
	else \
		$(CALC_VERSIONS); \
401 402 403 404 405 406
		SHLIB=lib$(LIBNAME).so; \
		SHLIB_SUFFIX=; \
		LIBDEPS="$(LIBDEPS) -lc"; \
		ALLSYMSFLAGS='-all'; \
		NOALLSYMSFLAGS=''; \
		SHAREDFLAGS="-shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
407
		SHAREDCMD='$(CC)'; \
408 409
	fi; \
	$(LINK_SO_O)
410 411
link_a.irix:
	@ if ${DETECT_GNU_LD}; then \
412
		$(DO_GNU); \
413 414
	else \
		$(CALC_VERSIONS); \
415 416 417 418 419 420
		SHLIB=lib$(LIBNAME).so; \
		SHLIB_SUFFIX=; \
		LIBDEPS="$(LIBDEPS) -lc"; \
		ALLSYMSFLAGS='-all'; \
		NOALLSYMSFLAGS=''; \
		SHAREDFLAGS="-shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
421
		SHAREDCMD='$(CC)'; \
422 423
	fi; \
	$(LINK_SO_A)
424 425 426 427 428 429 430 431 432 433 434 435 436

# HP-UX includes the full pathname of libs we depend on, so we would get
# ./libcrypto (with ./ as path information) compiled into libssl, hence
# we omit the SHLIBDEPS. Applications must be linked with -lssl -lcrypto
# anyway.
# The object modules are loaded from lib$i.a using the undocumented -Fl
# option.
#
# WARNING: Until DSO is fixed to support a search path, we support SHLIB_PATH
#          by temporarily specifying "+s"!
#
link_o.hpux32:
	@ $(CALC_VERSIONS); \
437 438 439 440 441 442
	SHLIB=lib$(LIBNAME).sl; \
	SHLIB_SUFFIX=; \
	LIBDEPS="$(LIBDEPS) -lc"; \
	ALLSYMSFLAGS='-Fl'; \
	NOALLSYMSFLAGS=''; \
	SHAREDFLAGS="+vnocompatwarnings -b -z +s +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
443
	SHAREDCMD='/usr/ccs/bin/ld'; \
444
	$(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
445 446
link_a.hpux32:
	@ $(CALC_VERSIONS); \
447 448 449 450 451 452
	SHLIB=lib$(LIBNAME).sl; \
	SHLIB_SUFFIX=; \
	LIBDEPS="$(LIBDEPS) -lc"; \
	ALLSYMSFLAGS='-Fl'; \
	NOALLSYMSFLAGS=''; \
	SHAREDFLAGS="+vnocompatwarnings -b -z +s +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
453
	SHAREDCMD='/usr/ccs/bin/ld'; \
454
	$(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
455 456 457 458 459 460 461 462 463 464 465

# HP-UX includes the full pathname of libs we depend on, so we would get
# ./libcrypto (with ./ as path information) compiled into libssl, hence
# we omit the SHLIBDEPS. Applications must be linked with -lssl -lcrypto
# anyway.
#
# HP-UX in 64bit mode has "+s" enabled by default; it will search for
# shared libraries along LD_LIBRARY_PATH _and_ SHLIB_PATH.
#
link_o.hpux64:
	@ $(CALC_VERSIONS); \
466 467 468 469 470 471
	SHLIB=lib$(LIBNAME).sl; \
	SHLIB_SUFFIX=; \
	LIBDEPS="$(LIBDEPS) -lc"; \
	ALLSYMSFLAGS='+forceload'; \
	NOALLSYMSFLAGS=''; \
	SHAREDFLAGS="-b -z +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
472
	SHAREDCMD='/usr/ccs/bin/ld'; \
473
	$(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
474 475
link_a.hpux64:
	@ $(CALC_VERSIONS); \
476 477 478 479 480 481
	SHLIB=lib$(LIBNAME).sl; \
	SHLIB_SUFFIX=; \
	LIBDEPS="$(LIBDEPS) -lc"; \
	ALLSYMSFLAGS='+forceload'; \
	NOALLSYMSFLAGS=''; \
	SHAREDFLAGS="-b -z +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX"; \
482
	SHAREDCMD='/usr/ccs/bin/ld'; \
483
	$(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
484 485 486

link_o.aix:
	@ $(CALC_VERSIONS); \
487 488 489 490 491 492
	SHLIB=lib$(LIBNAME).so; \
	SHLIB_SUFFIX=; \
	LIBDEPS="$(LIBDEPS) -lc"; \
	ALLSYMSFLAGS='-bnogc'; \
	NOALLSYMSFLAGS=''; \
	SHAREDFLAGS='-G -bE:lib$(LIBNAME).exp -bM:SRE'; \
493 494 495 496
	SHAREDCMD='$(CC)'; \
	$(LINK_SO_O)
link_a.aix:
	@ $(CALC_VERSIONS); \
497 498 499 500 501 502
	SHLIB=lib$(LIBNAME).so; \
	SHLIB_SUFFIX=; \
	LIBDEPS="$(LIBDEPS) -lc"; \
	ALLSYMSFLAGS='-bnogc'; \
	NOALLSYMSFLAGS=''; \
	SHAREDFLAGS='-G -bE:lib$(LIBNAME).exp -bM:SRE'; \
503 504 505 506 507
	SHAREDCMD='$(CC)'; \
	$(LINK_SO_A_VIA_O)

link_o.reliantunix:
	@ $(CALC_VERSIONS); \
508 509 510 511 512 513
	SHLIB=lib$(LIBNAME).so; \
	SHLIB_SUFFIX=; \
	LIBDEPS="$(LIBDEPS) -lc"; \
	ALLSYMSFLAGS=; \
	NOALLSYMSFLAGS=''; \
	SHAREDFLAGS='-G'; \
514 515 516 517
	SHAREDCMD='$(CC)'; \
	$(LINK_SO_O)
link_a.reliantunix:
	@ $(CALC_VERSIONS); \
518 519 520 521 522 523
	SHLIB=lib$(LIBNAME).so; \
	SHLIB_SUFFIX=; \
	LIBDEPS="$(LIBDEPS) -lc"; \
	ALLSYMSFLAGS=; \
	NOALLSYMSFLAGS=''; \
	SHAREDFLAGS='-G'; \
524 525 526 527
	SHAREDCMD='$(CC)'; \
	$(LINK_SO_A_UNPACKED)

# Targets to build symbolic links when needed
528
symlink.gnu symlink.solaris symlink.svr3 symlink.irix \
529 530
symlink.aix symlink.reliantunix:
	@ $(CALC_VERSIONS); \
531
	SHLIB=lib$(LIBNAME).so; \
532
	$(SYMLINK_SO)
533 534
symlink.darwin:
	@ $(CALC_VERSIONS); \
535
	SHLIB=lib$(LIBNAME); \
536
	SHLIB_SUFFIX=.dylib; \
537
	$(SYMLINK_SO)
538 539
symlink.hpux32 symlink.hpux64:
	@ $(CALC_VERSIONS); \
540
	SHLIB=lib$(LIBNAME).sl; \
541
	$(SYMLINK_SO)
542 543
# The following lines means those specific architectures do no symlinks
symlink.cygwin symlib.alpha-osf1 symlink.tru64 symlink.tru64-rpath:
544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587

# Compatibility targets
link_o.bsd-gcc-shared link_o.linux-shared link_o.gnu-shared: link_o.gnu
link_a.bsd-gcc-shared link_a.linux-shared link_a.gnu-shared: link_a.gnu
symlink.bsd-gcc-shared symlink.linux-shared symlink.gnu-shared: symlink.gnu
link_o.darwin-shared: link_o.darwin
link_a.darwin-shared: link_a.darwin
symlink.darwin-shared: symlink.darwin
link_o.cygwin-shared: link_o.cygwin
link_a.cygwin-shared: link_a.cygwin
symlink.cygwin-shared: symlink.cygwin
link_o.alpha-osf1-shared: link_o.alpha-osf1
link_a.alpha-osf1-shared: link_a.alpha-osf1
symlink.alpha-osf1-shared: symlink.alpha-osf1
link_o.tru64-shared: link_o.tru64
link_a.tru64-shared: link_a.tru64
symlink.tru64-shared: symlink.tru64
link_o.tru64-shared-rpath: link_o.tru64-rpath
link_a.tru64-shared-rpath: link_a.tru64-rpath
symlink.tru64-shared-rpath: symlink.tru64-rpath
link_o.solaris-shared: link_o.solaris
link_a.solaris-shared: link_a.solaris
symlink.solaris-shared: symlink.solaris
link_o.svr3-shared: link_o.svr3
link_a.svr3-shared: link_a.svr3
symlink.svr3-shared: symlink.svr3
link_o.svr5-shared: link_o.svr3
link_a.svr5-shared: link_a.svr3
symlink.svr5-shared: symlink.svr3
link_o.irix-shared: link_o.irix
link_a.irix-shared: link_a.irix
symlink.irix-shared: symlink.irix
link_o.hpux-shared: link_o.hpux32
link_a.hpux-shared: link_a.hpux32
symlink.hpux-shared: symlink.hpux32
link_o.hpux64-shared: link_o.hpux64
link_a.hpux64-shared: link_a.hpux64
symlink.hpux64-shared: symlink.hpux64
link_o.aix-shared: link_o.aix
link_a.aix-shared: link_a.aix
symlink.aix-shared: symlink.aix
link_o.reliantunix-shared: link_o.reliantunix
link_a.reliantunix-shared: link_a.reliantunix
symlink.reliantunix-shared: symlink.reliantunix