Makefile.shared 19.9 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 24 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
#
# 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.
# For example, if a seond library, say libbar.a needs to be linked into
# 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
	prev=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \
R
Richard Levitte 已提交
84
	if [ -n "$$SHLIB_COMPAT" ]; then \
85
		for x in $$SHLIB_COMPAT; do \
86 87 88
			( $(DEBUG); rm -f $$SHLIB$$x$$SHLIB_SUFFIX; \
			  ln -s $$prev $$SHLIB$$x$$SHLIB_SUFFIX ); \
			prev=$$SHLIB$$x$$SHLIB_SUFFIX; \
89
		done; \
90 91 92 93
	fi; \
	if [ -n "$$SHLIB_SOVER" ]; then \
		( $(DEBUG); rm -f $$SHLIB$$SHLIB_SUFFIX; \
		  ln -s $$prev $$SHLIB$$SHLIB_SUFFIX ); \
94
	fi
95

96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
LINK_SO_A=	SHOBJECTS="lib$(LIBNAME).a $(LIBEXTRAS)"; $(LINK_SO)
LINK_SO_O=	SHOBJECTS="$(LIBEXTRAS)"; $(LINK_SO)
LINK_SO_A_VIA_O=	\
  SHOBJECTS=lib$(LIBNAME).o ALL=$$ALLSYMSFLAGS ALLSYMSFLAGS= NOALLSYMSFLAGS=; \
  ( $(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

DETECT_GNU_LD=${CC} -v 2>&1 | grep '^gcc' >/dev/null 2>&1 && \
	my_ld=`gcc -print-prog-name=ld 2>&1` && \
	[ -n "$$my_ld" ] && \
	$$my_ld -v 2>&1 | grep 'GNU ld' >/dev/null 2>&1

link_o.gnu:
	@ $(CALC_VERSIONS); \
	SHLIB=lib$(LIBNAME).so \
117
	SHLIB_SUFFIX= \
R
Richard Levitte 已提交
118
	LIBDEPS="$(LIBDEPS) -lc" \
119
	NOALLSYMSFLAGS='-Wl,--no-whole-archive' \
120
	SHAREDFLAGS="-shared -Wl,-Bsymbolic -Wl,-soname=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX" \
121 122 123 124 125
	SHAREDCMD='$(CC)'; \
	$(LINK_SO_O)
link_a.gnu:
	@ $(CALC_VERSIONS); \
	SHLIB=lib$(LIBNAME).so \
126
	SHLIB_SUFFIX= \
R
Richard Levitte 已提交
127
	LIBDEPS="$(LIBDEPS) -lc" \
128 129
	ALLSYMSFLAGS='-Wl,--whole-archive' \
	NOALLSYMSFLAGS='-Wl,--no-whole-archive' \
130
	SHAREDFLAGS="-shared -Wl,-Bsymbolic -Wl,-soname=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX" \
131 132 133 134 135 136
	SHAREDCMD='$(CC)'; \
	$(LINK_SO_A)

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

link_o.cygwin:
	@ SHLIB=cyg$(LIBNAME).dll \
170
	SHLIB_SUFFIX= \
R
Richard Levitte 已提交
171
	LIBDEPS="$(LIBDEPS) -lc" \
172 173 174 175 176 177 178 179
	SHLIB_SOVER= \
	ALLSYMSFLAGS='-Wl,--whole-archive' \
	NOALLSYMSFLAGS='-Wl,--no-whole-archive' \
	SHAREDFLAGS="-shared -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a" \
	SHAREDCMD='${CC}'; \
	$(LINK_SO_O)
link_a.cygwin:
	@ SHLIB=cyg$(LIBNAME).dll \
180
	SHLIB_SUFFIX= \
R
Richard Levitte 已提交
181
	LIBDEPS="$(LIBDEPS) -lc" \
182 183 184 185 186 187 188 189 190
	SHLIB_SOVER= \
	ALLSYMSFLAGS='-Wl,--whole-archive' \
	NOALLSYMSFLAGS='-Wl,--no-whole-archive' \
	SHAREDFLAGS="-shared -Wl,-Bsymbolic -Wl,--out-implib,lib$(LIBNAME).dll.a" \
	SHAREDCMD='${CC}'; \
	$(LINK_SO_A)

link_o.alpha-osf1:
	@ if ${DETECT_GNU_LD}; then \
R
Richard Levitte 已提交
191
		$(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS)" \
192 193
			SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
			LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
194
			LIBVERSION=$(LIBVERSION) \
195 196 197 198
			LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
			LIBDEPS="$(LIBDEPS)" link_o.gnu; \
	else \
		SHLIB=lib$(LIBNAME).so \
199
		SHLIB_SUFFIX= \
R
Richard Levitte 已提交
200
		LIBDEPS="$(LIBDEPS) -lc" \
201 202 203 204 205 206 207 208 209
		SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
		if [ -n "$$SHLIB_HIST" ]; then \
			SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
		else \
			SHLIB_HIST="$(LIBVERSION)"; \
		fi
		SHLIB_SOVER= \
		ALLSYMSFLAGS='-all' \
		NOALLSYMSFLAGS='-none' \
210
		SHAREDFLAGS="-shared" \
211
		SHAREDCMD='$(CC)'; \
212 213 214
		if [ -n "$$SHLIB_HIST" ]; then \
			SHAREDFLAGS="$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
		fi; \
215 216 217 218
		$(LINK_SO_O); \
	fi
link_a.alpha-osf1:
	@ if ${DETECT_GNU_LD}; then \
R
Richard Levitte 已提交
219
		$(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS)" \
220 221
			SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
			LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
222
			LIBVERSION=$(LIBVERSION) \
223 224 225 226
			LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
			LIBDEPS="$(LIBDEPS)" link_o.gnu; \
	else \
		SHLIB=lib$(LIBNAME).so \
227
		SHLIB_SUFFIX= \
R
Richard Levitte 已提交
228
		LIBDEPS="$(LIBDEPS) -lc" \
229 230 231 232 233 234 235 236 237
		SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
		if [ -n "$$SHLIB_HIST" ]; then \
			SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
		else \
			SHLIB_HIST="$(LIBVERSION)"; \
		fi
		SHLIB_SOVER= \
		ALLSYMSFLAGS='-all' \
		NOALLSYMSFLAGS='-none' \
238
		SHAREDFLAGS="-shared" \
239
		SHAREDCMD='$(CC)'; \
240 241 242
		if [ -n "$$SHLIB_HIST" ]; then \
			SHAREDFLAGS="$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
		fi; \
243 244 245 246 247 248 249
		$(LINK_SO_A); \
	fi

# 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 \
R
Richard Levitte 已提交
250
		$(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS)" \
251 252
			SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
			LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
253
			LIBVERSION=$(LIBVERSION) \
254 255 256 257
			LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
			LIBDEPS="$(LIBDEPS)" link_o.gnu; \
	else \
		SHLIB=lib$(LIBNAME).so \
258
		SHLIB_SUFFIX= \
R
Richard Levitte 已提交
259
		LIBDEPS="$(LIBDEPS) -lc" \
260 261 262 263 264 265 266 267 268
		SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
		if [ -n "$$SHLIB_HIST" ]; then \
			SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
		else \
			SHLIB_HIST="$(LIBVERSION)"; \
		fi
		SHLIB_SOVER= \
		ALLSYMSFLAGS='-all' \
		NOALLSYMSFLAGS='-none' \
269
		SHAREDFLAGS="-shared -msym" \
270
		SHAREDCMD='$(CC)'; \
271 272 273
		if [ -n "$$SHLIB_HIST" ]; then \
			SHAREDFLAGS="$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
		fi; \
274 275 276 277
		$(LINK_SO_O); \
	fi
link_a.tru64:
	@ if ${DETECT_GNU_LD}; then \
R
Richard Levitte 已提交
278
		$(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS)" \
279 280
			SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
			LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
281
			LIBVERSION=$(LIBVERSION) \
282 283 284 285
			LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
			LIBDEPS="$(LIBDEPS)" link_o.gnu; \
	else \
		SHLIB=lib$(LIBNAME).so \
286
		SHLIB_SUFFIX= \
R
Richard Levitte 已提交
287
		LIBDEPS="$(LIBDEPS) -lc" \
288 289 290 291 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)"; \
		fi
		SHLIB_SOVER= \
		ALLSYMSFLAGS='-all' \
		NOALLSYMSFLAGS='-none' \
297
		SHAREDFLAGS="-shared -msym" \
298
		SHAREDCMD='$(CC)'; \
299 300 301
		if [ -n "$$SHLIB_HIST" ]; then \
			SHAREDFLAGS="$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
		fi; \
302 303 304 305 306 307 308
		$(LINK_SO_A); \
	fi

# 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 \
R
Richard Levitte 已提交
309
		$(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS)" \
310 311
			SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
			LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
312
			LIBVERSION=$(LIBVERSION) \
313 314 315 316
			LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
			LIBDEPS="$(LIBDEPS)" link_o.gnu; \
	else \
		SHLIB=lib$(LIBNAME).so \
317
		SHLIB_SUFFIX= \
R
Richard Levitte 已提交
318
		LIBDEPS="$(LIBDEPS) -lc" \
319 320 321 322 323 324 325 326 327
		SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
		if [ -n "$$SHLIB_HIST" ]; then \
			SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
		else \
			SHLIB_HIST="$(LIBVERSION)"; \
		fi
		SHLIB_SOVER= \
		ALLSYMSFLAGS='-all' \
		NOALLSYMSFLAGS='-none' \
328
		SHAREDFLAGS="-shared -msym -rpath $(LIBRPATH)" \
329
		SHAREDCMD='$(CC)'; \
330 331 332
		if [ -n "$$SHLIB_HIST" ]; then \
			SHAREDFLAGS="$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
		fi; \
333 334 335 336
		$(LINK_SO_O); \
	fi
link_a.tru64-rpath:
	@ if ${DETECT_GNU_LD}; then \
R
Richard Levitte 已提交
337
		$(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS)" \
338 339
			SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
			LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
340
			LIBVERSION=$(LIBVERSION) \
341 342 343 344
			LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
			LIBDEPS="$(LIBDEPS)" link_o.gnu; \
	else \
		SHLIB=lib$(LIBNAME).so \
345
		SHLIB_SUFFIX= \
R
Richard Levitte 已提交
346
		LIBDEPS="$(LIBDEPS) -lc" \
347 348 349 350 351 352 353 354 355
		SHLIB_HIST=`echo "$(LIBCOMPATVERSIONS)" | cut -d';' -f2 | sed -e 's/ */:/'`; \
		if [ -n "$$SHLIB_HIST" ]; then \
			SHLIB_HIST="$${SHLIB_HIST}:$(LIBVERSION)"; \
		else \
			SHLIB_HIST="$(LIBVERSION)"; \
		fi
		SHLIB_SOVER= \
		ALLSYMSFLAGS='-all' \
		NOALLSYMSFLAGS='-none' \
356
		SHAREDFLAGS="-shared -msym -rpath $(LIBRPATH)" \
357
		SHAREDCMD='$(CC)'; \
358 359 360
		if [ -n "$$SHLIB_HIST" ]; then \
			SHAREDFLAGS="$SHAREDFLAGS -set_version \"$$SHLIB_HIST\""; \
		fi; \
361 362 363 364
		$(LINK_SO_A); \
	fi

link_o.solaris:
R
Richard Levitte 已提交
365 366
	@ if ${DETECT_GNU_LD}; then \
		$(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS)" \
367 368
			SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
			LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
369
			LIBVERSION="$(LIBVERSION)" \
370 371 372 373 374
			LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
			LIBDEPS="$(LIBDEPS)" link_o.gnu; \
	else \
		$(CALC_VERSIONS); \
		SHLIB=lib$(LIBNAME).so \
375
		SHLIB_SUFFIX= \
R
Richard Levitte 已提交
376
		LIBDEPS="$(LIBDEPS) -lc" \
377 378
		ALLSYMSFLAGS='-z allextract' \
		NOALLSYMSFLAGS='' \
379
		SHAREDFLAGS='-G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
380 381 382 383
		SHAREDCMD='$(CC)'; \
		$(LINK_SO_O); \
	fi
link_a.solaris:
R
Richard Levitte 已提交
384 385
	@ if ${DETECT_GNU_LD}; then \
		$(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS)" \
386 387
			SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
			LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
388
			LIBVERSION="$(LIBVERSION)" \
389 390 391 392 393
			LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
			LIBDEPS="$(LIBDEPS)" link_o.gnu; \
	else \
		$(CALC_VERSIONS); \
		SHLIB=lib$(LIBNAME).so \
394
		SHLIB_SUFFIX= \
R
Richard Levitte 已提交
395
		LIBDEPS="$(LIBDEPS) -lc" \
396 397
		ALLSYMSFLAGS='-z allextract' \
		NOALLSYMSFLAGS='' \
398
		SHAREDFLAGS='-G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
399 400 401 402 403 404 405 406
		SHAREDCMD='$(CC)'; \
		$(LINK_SO_A); \
	fi

# OpenServer 5 native compilers used
# UnixWare 7 and OpenUNIX 8 native compilers used
link_o.svr3:
	@ if ${DETECT_GNU_LD}; then \
R
Richard Levitte 已提交
407
		$(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS)" \
408 409
			SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
			LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
410
			LIBVERSION=$(LIBVERSION) \
411 412 413 414 415
			LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
			LIBDEPS="$(LIBDEPS)" link_o.gnu; \
	else \
		$(CALC_VERSIONS); \
		SHLIB=lib$(LIBNAME).so \
416
		SHLIB_SUFFIX= \
R
Richard Levitte 已提交
417
		LIBDEPS="$(LIBDEPS) -lc" \
418 419
		ALLSYMSFLAGS='-z allextract' \
		NOALLSYMSFLAGS='' \
420
		SHAREDFLAGS='-G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
421 422 423 424 425
		SHAREDCMD='$(CC)'; \
		$(LINK_SO_O); \
	fi
link_a.svr3:
	@ if ${DETECT_GNU_LD}; then \
R
Richard Levitte 已提交
426
		$(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS)" \
427 428
			SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
			LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
429
			LIBVERSION=$(LIBVERSION) \
430 431 432 433 434
			LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
			LIBDEPS="$(LIBDEPS)" link_o.gnu; \
	else \
		$(CALC_VERSIONS); \
		SHLIB=lib$(LIBNAME).so \
435
		SHLIB_SUFFIX= \
R
Richard Levitte 已提交
436
		LIBDEPS="$(LIBDEPS) -lc" \
437 438
		ALLSYMSFLAGS='-z allextract' \
		NOALLSYMSFLAGS='' \
439
		SHAREDFLAGS='-G -h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
440 441 442 443 444 445
		SHAREDCMD='$(CC)'; \
		$(LINK_SO_A_UNPACKED); \
	fi

link_o.irix:
	@ if ${DETECT_GNU_LD}; then \
R
Richard Levitte 已提交
446
		$(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS)" \
447 448
			SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
			LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
449
			LIBVERSION=$(LIBVERSION) \
450 451 452 453 454
			LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
			LIBDEPS="$(LIBDEPS)" link_o.gnu; \
	else \
		$(CALC_VERSIONS); \
		SHLIB=lib$(LIBNAME).so \
455
		SHLIB_SUFFIX= \
R
Richard Levitte 已提交
456
		LIBDEPS="$(LIBDEPS) -lc" \
457 458
		ALLSYMSFLAGS='-all' \
		NOALLSYMSFLAGS='' \
459
		SHAREDFLAGS='-shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
460 461 462 463 464
		SHAREDCMD='$(CC)'; \
		$(LINK_SO_O); \
	fi
link_a.irix:
	@ if ${DETECT_GNU_LD}; then \
R
Richard Levitte 已提交
465
		$(MAKE) -f $(SHARED_MAKEFILE) CC="$(CC)" LDFLAGS="$(LDFLAGS)" \
466 467
			SHARED_LDFLAGS="$(SHARED_LDFLAGS)" \
			LIBNAME="$(LIBNAME)" LIBEXTRAS="$(LIBEXTRAS)" \
468
			LIBVERSION=$(LIBVERSION) \
469 470 471 472 473
			LIBCOMPATVERSIONS="$(LIBCOMPATVERSIONS)" \
			LIBDEPS="$(LIBDEPS)" link_o.gnu; \
	else \
		$(CALC_VERSIONS); \
		SHLIB=lib$(LIBNAME).so \
474
		SHLIB_SUFFIX= \
R
Richard Levitte 已提交
475
		LIBDEPS="$(LIBDEPS) -lc" \
476 477
		ALLSYMSFLAGS='-all' \
		NOALLSYMSFLAGS='' \
478
		SHAREDFLAGS='-shared -Wl,-soname,$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495
		SHAREDCMD='$(CC)'; \
		$(LINK_SO_A); \
	fi

# 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); \
	SHLIB=lib$(LIBNAME).sl \
496
	SHLIB_SUFFIX= \
497 498 499
	LIBDEPS="$(LIBDEPS) -lc" \
	ALLSYMSFLAGS='-Fl' \
	NOALLSYMSFLAGS='' \
500
	SHAREDFLAGS='+vnocompatwarnings -b -z +s +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
501
	SHAREDCMD='/usr/ccs/bin/ld'; \
502
	$(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
503 504 505
link_a.hpux32:
	@ $(CALC_VERSIONS); \
	SHLIB=lib$(LIBNAME).sl \
506
	SHLIB_SUFFIX= \
507 508 509
	LIBDEPS="$(LIBDEPS) -lc" \
	ALLSYMSFLAGS='-Fl' \
	NOALLSYMSFLAGS='' \
510
	SHAREDFLAGS='+vnocompatwarnings -b -z +s +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
511
	SHAREDCMD='/usr/ccs/bin/ld'; \
512
	$(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
513 514 515 516 517 518 519 520 521 522 523 524

# 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); \
	SHLIB=lib$(LIBNAME).sl \
525
	SHLIB_SUFFIX= \
526 527 528
	LIBDEPS="$(LIBDEPS) -lc" \
	ALLSYMSFLAGS='+forceload' \
	NOALLSYMSFLAGS='' \
529
	SHAREDFLAGS='-b -z +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
530
	SHAREDCMD='/usr/ccs/bin/ld'; \
531
	$(LINK_SO_O) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
532 533 534
link_a.hpux64:
	@ $(CALC_VERSIONS); \
	SHLIB=lib$(LIBNAME).sl \
535
	SHLIB_SUFFIX= \
536 537 538
	LIBDEPS="$(LIBDEPS) -lc" \
	ALLSYMSFLAGS='+forceload' \
	NOALLSYMSFLAGS='' \
539
	SHAREDFLAGS='-b -z +h $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX' \
540
	SHAREDCMD='/usr/ccs/bin/ld'; \
541
	$(LINK_SO_A) && chmod a=rx $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX
542 543 544 545

link_o.aix:
	@ $(CALC_VERSIONS); \
	SHLIB=lib$(LIBNAME).so \
546
	SHLIB_SUFFIX= \
R
Richard Levitte 已提交
547
	LIBDEPS="$(LIBDEPS) -lc" \
548 549 550 551 552 553 554 555
	ALLSYMSFLAGS='-bnogc' \
	NOALLSYMSFLAGS='' \
	SHAREDFLAGS='-G -bE:lib$(LIBNAME).exp -bM:SRE' \
	SHAREDCMD='$(CC)'; \
	$(LINK_SO_O)
link_a.aix:
	@ $(CALC_VERSIONS); \
	SHLIB=lib$(LIBNAME).so \
556
	SHLIB_SUFFIX= \
R
Richard Levitte 已提交
557
	LIBDEPS="$(LIBDEPS) -lc" \
558 559 560 561 562 563 564 565 566
	ALLSYMSFLAGS='-bnogc' \
	NOALLSYMSFLAGS='' \
	SHAREDFLAGS='-G -bE:lib$(LIBNAME).exp -bM:SRE' \
	SHAREDCMD='$(CC)'; \
	$(LINK_SO_A_VIA_O)

link_o.reliantunix:
	@ $(CALC_VERSIONS); \
	SHLIB=lib$(LIBNAME).so \
567
	SHLIB_SUFFIX= \
R
Richard Levitte 已提交
568
	LIBDEPS="$(LIBDEPS) -lc" \
569 570 571 572 573 574 575 576
	ALLSYMSFLAGS= \
	NOALLSYMSFLAGS='' \
	SHAREDFLAGS='-G' \
	SHAREDCMD='$(CC)'; \
	$(LINK_SO_O)
link_a.reliantunix:
	@ $(CALC_VERSIONS); \
	SHLIB=lib$(LIBNAME).so \
577
	SHLIB_SUFFIX= \
R
Richard Levitte 已提交
578
	LIBDEPS="$(LIBDEPS) -lc" \
579 580 581 582 583 584 585
	ALLSYMSFLAGS= \
	NOALLSYMSFLAGS='' \
	SHAREDFLAGS='-G' \
	SHAREDCMD='$(CC)'; \
	$(LINK_SO_A_UNPACKED)

# Targets to build symbolic links when needed
586
symlink.gnu symlink.solaris symlink.svr3 symlink.irix \
587 588 589 590
symlink.aix symlink.reliantunix:
	@ $(CALC_VERSIONS); \
	SHLIB=lib$(LIBNAME).so \
	$(SYMLINK_SO)
591 592 593 594 595
symlink.darwin:
	@ $(CALC_VERSIONS); \
	SHLIB=lib$(LIBNAME) \
	SHLIB_SUFFIX=.dylib \
	$(SYMLINK_SO)
596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644
symlink.cygwin symlib.alpha-osf1 symlink.tru64 symlink.tru64-rpath:
symlink.hpux32 symlink.hpux64:
	@ $(CALC_VERSIONS); \
	SHLIB=lib$(LIBNAME).sl \
	$(SYMLINK_SO)

# 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