xref: /freebsd/share/mk/bsd.lib.mk (revision e60861eb41ca9d141a0d967db3ecbe2b2909c300)
1# If INTERNALLIB is defined, we build lib<name>.a and lib<name>_pie.a,
2# i.e. only static archives without dso, in both non-PIE and PIE variants,
3# suitable for static linking into binaries.
4# INTERNALLIB library headers are not installed.  A component that uses
5# the library should add explicit -I$(LIB<name>DIR) to CFLAGS.
6#
7# If PRIVATELIB is defined, we build and install both libprivate<name>.a
8# and libprivate<name>.so, so the library can be linked dynamically, but
9# cannot be picked up by third-party configure scripts.
10# PRIVATELIB library headers are installed into include/private/<name>.
11#
12# If neither of control variables are defined, we install headers into
13# include/, and both non-pic static and shared libraries under the defined
14# name.
15
16.include <bsd.init.mk>
17.include <bsd.compiler.mk>
18.include <bsd.linker.mk>
19.include <bsd.compat.pre.mk>
20
21__<bsd.lib.mk>__:	.NOTMAIN
22
23.if defined(LIB_CXX) || defined(SHLIB_CXX)
24_LD=	${CXX}
25.else
26_LD=	${CC}
27.endif
28.if defined(LIB_CXX)
29LIB=	${LIB_CXX}
30.endif
31.if defined(SHLIB_CXX)
32SHLIB=	${SHLIB_CXX}
33.endif
34
35LIB_PRIVATE=	${PRIVATELIB:Dprivate}
36# Set up the variables controlling shared libraries.  After this section,
37# SHLIB_NAME will be defined only if we are to create a shared library.
38# SHLIB_LINK will be defined only if we are to create a link to it.
39# INSTALL_PIC_ARCHIVE will be defined only if we are to create a PIC archive.
40# BUILD_NOSSP_PIC_ARCHIVE will be defined only if we are to create a PIC archive.
41.if defined(NO_PIC)
42.undef SHLIB_NAME
43.undef INSTALL_PIC_ARCHIVE
44.undef BUILD_NOSSP_PIC_ARCHIVE
45.else
46.if !defined(SHLIB) && defined(LIB)
47SHLIB=		${LIB}
48.endif
49.if !defined(SHLIB_NAME) && defined(SHLIB) && defined(SHLIB_MAJOR)
50SHLIB_NAME=	lib${LIB_PRIVATE}${SHLIB}.so.${SHLIB_MAJOR}
51.endif
52.if defined(SHLIB_NAME) && !empty(SHLIB_NAME:M*.so.*)
53SHLIB_LINK?=	${SHLIB_NAME:R}
54.endif
55SONAME?=	${SHLIB_NAME}
56.endif
57
58.if defined(CRUNCH_CFLAGS)
59CFLAGS+=	${CRUNCH_CFLAGS}
60.endif
61
62.for _libcompat in ${_ALL_libcompats}
63.if ${SHLIBDIR:M*/lib${_libcompat}} || ${SHLIBDIR:M*/lib${_libcompat}/*}
64TAGS+=	lib${_libcompat}
65.endif
66.endfor
67
68.if defined(NO_ROOT)
69.if !defined(TAGS) || ! ${TAGS:Mpackage=*}
70TAGS+=	package=${PACKAGE:Uutilities}
71.endif
72
73# By default, if PACKAGE=foo, then the native runtime libraries will go into
74# the FreeBSD-foo package, and subpackages will be created for -dev, -lib32,
75# and so on.  If LIB_PACKAGE is set, then we also create a subpackage for
76# runtime libraries with a -lib suffix.  This is used when a package has
77# libraries and some other content (e.g., executables) to allow consumers to
78# depend on the libraries.
79.if defined(LIB_PACKAGE) && ! ${TAGS:Mlib*}
80.if !defined(PACKAGE)
81.error LIB_PACKAGE cannot be used without PACKAGE
82.endif
83
84LIB_TAG_ARGS=	${TAG_ARGS},lib
85.else
86LIB_TAG_ARGS=	${TAG_ARGS}
87.endif
88
89TAG_ARGS=	-T ${TAGS:ts,:[*]}
90
91DBG_TAG_ARGS=	${TAG_ARGS},dbg
92# Usually we want to put development files (e.g., static libraries) into a
93# separate -dev packages but for a few cases, like tests, that's not wanted,
94# so allow the caller to disable it by setting NO_DEV_PACKAGE.
95.if !defined(NO_DEV_PACKAGE)
96DEV_TAG_ARGS=	${TAG_ARGS},dev
97.else
98DEV_TAG_ARGS=	${TAG_ARGS}
99.endif
100
101.endif	# defined(NO_ROOT)
102
103# By default, put library manpages in the -dev subpackage, since they're not
104# usually interesting if the development files aren't installed.   For pages
105# that should be installed in the base package, define a new MANNODEV group.
106# Note that bsd.man.mk ignores this setting if MANSPLITPKG is enabled: then
107# manpages are always installed in the -man subpackage.
108MANSUBPACKAGE?=	-dev
109MANGROUPS?=	MAN
110MANGROUPS+=	MANNODEV
111MANNODEVSUBPACKAGE=
112
113# ELF hardening knobs
114.if ${MK_BIND_NOW} != "no"
115LDFLAGS+= -Wl,-znow
116.endif
117.if ${LINKER_TYPE} != "mac"
118.if ${MK_RELRO} == "no"
119LDFLAGS+= -Wl,-znorelro
120.else
121LDFLAGS+= -Wl,-zrelro
122.endif
123.endif
124.if ${MK_RETPOLINE} != "no"
125.if ${COMPILER_FEATURES:Mretpoline} && ${LINKER_FEATURES:Mretpoline}
126CFLAGS+= -mretpoline
127CXXFLAGS+= -mretpoline
128LDFLAGS+= -Wl,-zretpolineplt
129.else
130.warning Retpoline requested but not supported by compiler or linker
131.endif
132.endif
133# LLD sensibly defaults to -znoexecstack, so do the same for BFD
134LDFLAGS.bfd+= -Wl,-znoexecstack
135.if ${MK_BRANCH_PROTECTION} != "no"
136CFLAGS+=  -mbranch-protection=standard
137.if ${LINKER_FEATURES:Mbti-report} && defined(BTI_REPORT_ERROR)
138LDFLAGS+= -Wl,-zbti-report=error
139.endif
140.endif
141
142# Initialize stack variables on function entry
143.if ${OPT_INIT_ALL} != "none"
144.if ${COMPILER_FEATURES:Minit-all}
145CFLAGS+= -ftrivial-auto-var-init=${OPT_INIT_ALL}
146CXXFLAGS+= -ftrivial-auto-var-init=${OPT_INIT_ALL}
147.if ${OPT_INIT_ALL} == "zero" && ${COMPILER_TYPE} == "clang" && ${COMPILER_VERSION} < 160000
148CFLAGS+= -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
149CXXFLAGS+= -enable-trivial-auto-var-init-zero-knowing-it-will-be-removed-from-clang
150.endif
151.else
152.warning INIT_ALL (${OPT_INIT_ALL}) requested but not supported by compiler
153.endif
154.endif
155
156# Zero used registers on return (mitigate some ROP)
157.if ${MK_ZEROREGS} != "no"
158.if ${COMPILER_FEATURES:Mzeroregs}
159ZEROREG_TYPE?= used
160CFLAGS+= -fzero-call-used-regs=${ZEROREG_TYPE}
161CXXFLAGS+= -fzero-call-used-regs=${ZEROREG_TYPE}
162.endif
163.endif
164
165# bsd.sanitizer.mk is not installed, so don't require it (e.g. for ports).
166.sinclude "bsd.sanitizer.mk"
167
168.if ${MACHINE_CPUARCH} == "riscv" && ${LINKER_FEATURES:Mriscv-relaxations} == ""
169CFLAGS += -mno-relax
170.endif
171
172.include <bsd.libnames.mk>
173
174.include <bsd.suffixes-extra.mk>
175
176_LIBDIR:=${LIBDIR}
177_SHLIBDIR:=${SHLIBDIR}
178
179.if defined(SHLIB_NAME)
180.if ${MK_DEBUG_FILES} != "no"
181SHLIB_NAME_FULL=${SHLIB_NAME}.full
182DEBUGFILE= ${SHLIB_NAME}.debug
183# Use ${DEBUGDIR} for base system debug files, else .debug subdirectory
184.if ${_SHLIBDIR} == "/boot" ||\
185    ${SHLIBDIR:C%/lib(/.*)?$%/lib%} == "/lib" ||\
186    ${SHLIBDIR:C%/usr/lib(32|exec)?(/.*)?%/usr/lib%} == "/usr/lib" ||\
187    ${SHLIBDIR:C%/usr/tests(/.*)?%/usr/tests%} == "/usr/tests"
188DEBUGFILEDIR=${DEBUGDIR}${_SHLIBDIR}
189.else
190DEBUGFILEDIR=${_SHLIBDIR}/.debug
191.endif
192.if !exists(${DESTDIR}${DEBUGFILEDIR})
193DEBUGMKDIR=
194.endif
195.else
196SHLIB_NAME_FULL=${SHLIB_NAME}
197.endif
198.endif
199
200.include <bsd.symver.mk>
201
202# Allow libraries to specify their own version map or have it
203# automatically generated (see bsd.symver.mk above).
204.if !empty(VERSION_MAP)
205${SHLIB_NAME_FULL}:	${VERSION_MAP}
206LDFLAGS+=	-Wl,--version-script=${VERSION_MAP}
207
208# Ideally we'd always enable --no-undefined-version (default for lld >= 16),
209# but we have several symbols in our version maps that may or may not exist,
210# depending on compile-time defines and that needs to be handled first.
211.if ${MK_UNDEFINED_VERSION} == "no"
212LDFLAGS+=	-Wl,--no-undefined-version
213.else
214LDFLAGS+=	-Wl,--undefined-version
215.endif
216.endif
217
218.if defined(LIB) && !empty(LIB) || defined(SHLIB_NAME)
219OBJS+=		${SRCS:N*.h:${OBJS_SRCS_FILTER:ts:}:S/$/.o/}
220BCOBJS+=	${SRCS:N*.[hsS]:N*.asm:${OBJS_SRCS_FILTER:ts:}:S/$/.bco/g}
221LLOBJS+=	${SRCS:N*.[hsS]:N*.asm:${OBJS_SRCS_FILTER:ts:}:S/$/.llo/g}
222CLEANFILES+=	${OBJS} ${BCOBJS} ${LLOBJS} ${STATICOBJS}
223.endif
224
225.if defined(LIB) && !empty(LIB)
226.if defined(STATIC_LDSCRIPT)
227_STATICLIB_SUFFIX=	_real
228.endif
229_LIBS=		lib${LIB_PRIVATE}${LIB}${_STATICLIB_SUFFIX}.a
230
231lib${LIB_PRIVATE}${LIB}${_STATICLIB_SUFFIX}.a: ${OBJS} ${STATICOBJS}
232	@${ECHO} Building static ${LIB} library
233	@rm -f ${.TARGET}
234	${AR} ${ARFLAGS} ${.TARGET} ${OBJS} ${STATICOBJS} ${ARADD}
235.endif
236
237.if !defined(INTERNALLIB)
238
239.if defined(LLVM_LINK)
240lib${LIB_PRIVATE}${LIB}.bc: ${BCOBJS}
241	${LLVM_LINK} -o ${.TARGET} ${BCOBJS}
242
243lib${LIB_PRIVATE}${LIB}.ll: ${LLOBJS}
244	${LLVM_LINK} -S -o ${.TARGET} ${LLOBJS}
245
246CLEANFILES+=	lib${LIB_PRIVATE}${LIB}.bc lib${LIB_PRIVATE}${LIB}.ll
247.endif
248
249.if defined(SHLIB_NAME) || \
250    defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB)
251SOBJS+=		${OBJS:.o=.pico}
252DEPENDOBJS+=	${SOBJS}
253CLEANFILES+=	${SOBJS}
254.endif
255
256.if defined(SHLIB_NAME)
257_LIBS+=		${SHLIB_NAME}
258
259SOLINKOPTS+=	-shared -Wl,-x
260.if defined(LD_FATAL_WARNINGS) && ${LD_FATAL_WARNINGS} == "no"
261SOLINKOPTS+=	-Wl,--no-fatal-warnings
262.else
263SOLINKOPTS+=	-Wl,--fatal-warnings
264.endif
265SOLINKOPTS+=	-Wl,--warn-shared-textrel
266
267.if target(beforelinking)
268beforelinking: ${SOBJS}
269${SHLIB_NAME_FULL}: beforelinking
270.endif
271
272.if defined(SHLIB_LINK)
273.if defined(SHLIB_LDSCRIPT) && !empty(SHLIB_LDSCRIPT) && exists(${.CURDIR}/${SHLIB_LDSCRIPT})
274${SHLIB_LINK:R}.ld: ${.CURDIR}/${SHLIB_LDSCRIPT}
275	sed -e 's,@@SHLIB@@,${_SHLIBDIR}/${SHLIB_NAME},g' \
276	    -e 's,@@LIBDIR@@,${_LIBDIR},g' \
277	    ${.ALLSRC} > ${.TARGET}
278
279${SHLIB_NAME_FULL}: ${SHLIB_LINK:R}.ld
280CLEANFILES+=	${SHLIB_LINK:R}.ld
281.endif
282CLEANFILES+=	${SHLIB_LINK}
283.endif
284
285${SHLIB_NAME_FULL}: ${SOBJS}
286	@${ECHO} Building shared library ${SHLIB_NAME}
287	@rm -f ${SHLIB_NAME} ${SHLIB_LINK}
288.if defined(SHLIB_LINK) && !commands(${SHLIB_LINK:R}.ld) && ${MK_DEBUG_FILES} == "no"
289	# Note: This uses ln instead of ${INSTALL_LIBSYMLINK} since we are in OBJDIR
290	@${LN:Uln} -fs ${SHLIB_NAME} ${SHLIB_LINK}
291.endif
292	${_LD:N${CCACHE_BIN}} ${LDFLAGS} ${SSP_CFLAGS} ${SOLINKOPTS} \
293	    -o ${.TARGET} -Wl,-soname,${SONAME} ${SOBJS} ${LDADD}
294.if ${MK_CTF} != "no"
295	${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SOBJS}
296.endif
297
298.if ${MK_DEBUG_FILES} != "no"
299CLEANFILES+=	${SHLIB_NAME_FULL} ${DEBUGFILE}
300${SHLIB_NAME}: ${SHLIB_NAME_FULL} ${DEBUGFILE}
301	${OBJCOPY} --strip-debug --add-gnu-debuglink=${DEBUGFILE} \
302	    ${SHLIB_NAME_FULL} ${.TARGET}
303.if defined(SHLIB_LINK) && !commands(${SHLIB_LINK:R}.ld)
304	# Note: This uses ln instead of ${INSTALL_LIBSYMLINK} since we are in OBJDIR
305	@${LN:Uln} -fs ${SHLIB_NAME} ${SHLIB_LINK}
306.endif
307
308${DEBUGFILE}: ${SHLIB_NAME_FULL}
309	${OBJCOPY} --only-keep-debug ${SHLIB_NAME_FULL} ${.TARGET}
310.endif
311.endif #defined(SHLIB_NAME)
312
313.if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB)
314_LIBS+=		lib${LIB_PRIVATE}${LIB}_pic.a
315
316lib${LIB_PRIVATE}${LIB}_pic.a: ${SOBJS}
317	@${ECHO} Building special pic ${LIB} library
318	@rm -f ${.TARGET}
319	${AR} ${ARFLAGS} ${.TARGET} ${SOBJS} ${ARADD}
320.endif
321
322.if defined(BUILD_NOSSP_PIC_ARCHIVE) && defined(LIB) && !empty(LIB)
323NOSSPSOBJS+=	${OBJS:.o=.nossppico}
324DEPENDOBJS+=	${NOSSPSOBJS}
325CLEANFILES+=	${NOSSPSOBJS}
326_LIBS+=		lib${LIB_PRIVATE}${LIB}_nossp_pic.a
327
328lib${LIB_PRIVATE}${LIB}_nossp_pic.a: ${NOSSPSOBJS}
329	@${ECHO} Building special nossp pic ${LIB} library
330	@rm -f ${.TARGET}
331	${AR} ${ARFLAGS} ${.TARGET} ${NOSSPSOBJS} ${ARADD}
332.endif
333
334.endif # !defined(INTERNALLIB)
335
336.if defined(INTERNALLIB) && ${MK_PIE} != "no" && defined(LIB) && !empty(LIB)
337PIEOBJS+=	${OBJS:.o=.pieo}
338DEPENDOBJS+=	${PIEOBJS}
339CLEANFILES+=	${PIEOBJS}
340
341_LIBS+=		lib${LIB_PRIVATE}${LIB}_pie.a
342
343lib${LIB_PRIVATE}${LIB}_pie.a: ${PIEOBJS}
344	@${ECHO} Building pie ${LIB} library
345	@rm -f ${.TARGET}
346	${AR} ${ARFLAGS} ${.TARGET} ${PIEOBJS} ${ARADD}
347.endif
348
349.if defined(_SKIP_BUILD)
350all:
351.else
352.if defined(_LIBS) && !empty(_LIBS)
353all: ${_LIBS}
354.endif
355
356.if ${MK_MAN} != "no" && !defined(LIBRARIES_ONLY)
357all: all-man
358.endif
359.endif
360
361CLEANFILES+=	${_LIBS}
362
363_EXTRADEPEND:
364.if !defined(NO_EXTRADEPEND) && defined(SHLIB_NAME)
365.if defined(DPADD) && !empty(DPADD)
366	echo ${SHLIB_NAME_FULL}: ${DPADD} >> ${DEPENDFILE}
367.endif
368.endif
369
370.if !target(install)
371
372INSTALLFLAGS+= -C
373.if defined(PRECIOUSLIB)
374.if !defined(NO_FSCHG)
375SHLINSTALLFLAGS+= -fschg
376.endif
377.endif
378# Install libraries with -S to avoid risk of modifying in-use libraries when
379# installing to a running system.  It is safe to avoid this for NO_ROOT builds
380# that are only creating an image.
381#
382# XXX: Since Makefile.inc1 ends up building lib/libc both as part of
383# _startup_libs and as part of _generic_libs it ends up getting installed a
384# second time during the parallel build, and although the .WAIT in lib/Makefile
385# stops that mattering for lib, other directories like secure/lib are built in
386# parallel at the top level and are unaffected by that, so can sometimes race
387# with the libc.so.7 reinstall and see a missing or corrupt file. Ideally the
388# build system would be fixed to not build/install libc to WORLDTMP the second
389# time round, but for now using -S ensures the install is atomic and thus we
390# never see a broken intermediate state, so use it even for NO_ROOT builds.
391.if !defined(NO_SAFE_LIBINSTALL) #&& !defined(NO_ROOT)
392SHLINSTALLFLAGS+= -S
393SHLINSTALLSYMLINKFLAGS+= -S
394.endif
395
396_INSTALLFLAGS:=	${INSTALLFLAGS}
397.for ie in ${INSTALLFLAGS_EDIT}
398_INSTALLFLAGS:=	${_INSTALLFLAGS${ie}}
399.endfor
400_SHLINSTALLFLAGS:=	${SHLINSTALLFLAGS}
401_SHLINSTALLSYMLINKFLAGS:= ${SHLINSTALLSYMLINKFLAGS}
402.for ie in ${INSTALLFLAGS_EDIT}
403_SHLINSTALLFLAGS:=	${_SHLINSTALLFLAGS${ie}}
404.endfor
405
406.if defined(PCFILES)
407.for pcfile in ${PCFILES}
408installpcfiles: installpcfiles-${pcfile}
409
410installpcfiles-${pcfile}: ${pcfile}
411	${INSTALL} ${DEV_TAG_ARGS} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
412	    ${_INSTALLFLAGS} \
413	    ${.ALLSRC} ${DESTDIR}${LIBDATADIR}/pkgconfig/
414.endfor
415.endif
416installpcfiles: .PHONY
417
418.if !defined(INTERNALLIB)
419realinstall: _libinstall installpcfiles _debuginstall
420.ORDER: beforeinstall _libinstall _debuginstall
421_libinstall:
422.if defined(LIB) && !empty(LIB) && ${MK_INSTALLLIB} != "no"
423	${INSTALL} ${DEV_TAG_ARGS} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
424	    ${_INSTALLFLAGS} lib${LIB_PRIVATE}${LIB}${_STATICLIB_SUFFIX}.a ${DESTDIR}${_LIBDIR}/
425.endif
426.if defined(SHLIB_NAME)
427	${INSTALL} ${LIB_TAG_ARGS} ${STRIP} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
428	    ${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \
429	    ${SHLIB_NAME} ${DESTDIR}${_SHLIBDIR}/
430.if defined(SHLIB_LINK)
431.if commands(${SHLIB_LINK:R}.ld)
432	${INSTALL} ${DEV_TAG_ARGS} -S -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
433	    ${_INSTALLFLAGS} ${SHLIB_LINK:R}.ld \
434	    ${DESTDIR}${_LIBDIR}/${SHLIB_LINK}
435.for _SHLIB_LINK_LINK in ${SHLIB_LDSCRIPT_LINKS}
436	${INSTALL_LIBSYMLINK} ${_SHLINSTALLSYMLINKFLAGS} ${LIB_TAG_ARGS} \
437	    ${SHLIB_LINK} ${DESTDIR}${_LIBDIR}/${_SHLIB_LINK_LINK}
438.endfor
439.else
440.if ${_SHLIBDIR} == ${_LIBDIR}
441.if ${SHLIB_LINK:Mlib*}
442	${INSTALL_RSYMLINK} ${_SHLINSTALLSYMLINKFLAGS} ${DEV_TAG_ARGS} \
443	    ${SHLIB_NAME} ${DESTDIR}${_LIBDIR}/${SHLIB_LINK}
444.else
445	${INSTALL_RSYMLINK} ${_SHLINSTALLSYMLINKFLAGS} ${LIB_TAG_ARGS} \
446	    ${DESTDIR}${_SHLIBDIR}/${SHLIB_NAME} \
447	    ${DESTDIR}${_LIBDIR}/${SHLIB_LINK}
448.endif
449.else
450.if ${SHLIB_LINK:Mlib*}
451	${INSTALL_RSYMLINK} ${_SHLINSTALLSYMLINKFLAGS} ${DEV_TAG_ARGS} \
452	    ${DESTDIR}${_SHLIBDIR}/${SHLIB_NAME} ${DESTDIR}${_LIBDIR}/${SHLIB_LINK}
453.else
454	${INSTALL_RSYMLINK} ${_SHLINSTALLSYMLINKFLAGS} ${LIB_TAG_ARGS} \
455	    ${DESTDIR}${_SHLIBDIR}/${SHLIB_NAME} ${DESTDIR}${_LIBDIR}/${SHLIB_LINK}
456.endif
457.if exists(${DESTDIR}${_LIBDIR}/${SHLIB_NAME})
458	-chflags noschg ${DESTDIR}${_LIBDIR}/${SHLIB_NAME}
459	rm -f ${DESTDIR}${_LIBDIR}/${SHLIB_NAME}
460.endif
461.endif # _SHLIBDIR == _LIBDIR
462.endif # SHLIB_LDSCRIPT
463.endif # SHLIB_LINK
464.endif # SHIB_NAME
465.if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB)
466	${INSTALL} ${DEV_TAG_ARGS} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
467	    ${_INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${_LIBDIR}/
468.endif
469.endif # !defined(INTERNALLIB)
470
471.if !defined(LIBRARIES_ONLY)
472.include <bsd.nls.mk>
473.include <bsd.confs.mk>
474.include <bsd.files.mk>
475#No need to install header for INTERNALLIB
476.if !defined(INTERNALLIB)
477.include <bsd.incs.mk>
478.endif
479.endif
480
481LINKOWN?=	${LIBOWN}
482LINKGRP?=	${LIBGRP}
483LINKMODE?=	${LIBMODE}
484SYMLINKOWN?=	${LIBOWN}
485SYMLINKGRP?=	${LIBGRP}
486.if !defined(NO_DEV_PACKAGE)
487LINKTAGS=	dev${_COMPAT_TAG}
488.else
489LINKTAGS=	${_COMPAT_TAG}
490.endif
491.include <bsd.links.mk>
492
493.if ${MK_MAN} != "no" && !defined(LIBRARIES_ONLY)
494realinstall: maninstall
495.ORDER: beforeinstall maninstall
496.endif
497
498.endif
499
500.if ${MK_MAN} != "no" && !defined(LIBRARIES_ONLY)
501.include <bsd.man.mk>
502.endif
503
504.if defined(LIB) && !empty(LIB)
505OBJS_DEPEND_GUESS+= ${SRCS:M*.h}
506.endif
507.if defined(SHLIB_NAME) || \
508    defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB)
509.for _S in ${SRCS:N*.[hly]}
510OBJS_DEPEND_GUESS.${_S:${OBJS_SRCS_FILTER:ts:}}.pico+=	${_S}
511.endfor
512.endif
513.if defined(BUILD_NOSSP_PIC_ARCHIVE) && defined(LIB) && !empty(LIB)
514.for _S in ${SRCS:N*.[hly]}
515OBJS_DEPEND_GUESS.${_S:${OBJS_SRCS_FILTER:ts:}}.nossppico+=	${_S}
516.endfor
517.endif
518
519.if defined(HAS_TESTS)
520MAKE+=			MK_MAKE_CHECK_USE_SANDBOX=yes
521SUBDIR_TARGETS+=	check
522TESTS_LD_LIBRARY_PATH+=	${.OBJDIR}
523.endif
524
525.include <bsd.debug.mk>
526.include <bsd.dep.mk>
527.include <bsd.clang-analyze.mk>
528.include <bsd.obj.mk>
529.include <bsd.sys.mk>
530