xref: /freebsd/share/mk/bsd.lib.mk (revision f976241773df2260e6170317080761d1c5814fe5)
1#	from: @(#)bsd.lib.mk	5.26 (Berkeley) 5/2/91
2# $FreeBSD$
3#
4
5.include <bsd.init.mk>
6.include <bsd.compiler.mk>
7.include <bsd.linker.mk>
8
9.if defined(LIB_CXX) || defined(SHLIB_CXX)
10_LD=	${CXX}
11.else
12_LD=	${CC}
13.endif
14.if defined(LIB_CXX)
15LIB=	${LIB_CXX}
16.endif
17.if defined(SHLIB_CXX)
18SHLIB=	${SHLIB_CXX}
19.endif
20
21LIB_PRIVATE=	${PRIVATELIB:Dprivate}
22# Set up the variables controlling shared libraries.  After this section,
23# SHLIB_NAME will be defined only if we are to create a shared library.
24# SHLIB_LINK will be defined only if we are to create a link to it.
25# INSTALL_PIC_ARCHIVE will be defined only if we are to create a PIC archive.
26# BUILD_NOSSP_PIC_ARCHIVE will be defined only if we are to create a PIC archive.
27.if defined(NO_PIC)
28.undef SHLIB_NAME
29.undef INSTALL_PIC_ARCHIVE
30.undef BUILD_NOSSP_PIC_ARCHIVE
31.else
32.if !defined(SHLIB) && defined(LIB)
33SHLIB=		${LIB}
34.endif
35.if !defined(SHLIB_NAME) && defined(SHLIB) && defined(SHLIB_MAJOR)
36SHLIB_NAME=	lib${LIB_PRIVATE}${SHLIB}.so.${SHLIB_MAJOR}
37.endif
38.if defined(SHLIB_NAME) && !empty(SHLIB_NAME:M*.so.*)
39SHLIB_LINK?=	${SHLIB_NAME:R}
40.endif
41SONAME?=	${SHLIB_NAME}
42.endif
43
44.if defined(CRUNCH_CFLAGS)
45CFLAGS+=	${CRUNCH_CFLAGS}
46.endif
47
48.if ${MK_ASSERT_DEBUG} == "no"
49CFLAGS+= -DNDEBUG
50NO_WERROR=
51.endif
52
53.if defined(DEBUG_FLAGS)
54CFLAGS+= ${DEBUG_FLAGS}
55
56.if ${MK_CTF} != "no" && ${DEBUG_FLAGS:M-g} != ""
57CTFFLAGS+= -g
58.endif
59.else
60STRIP?=	-s
61.endif
62
63.if ${SHLIBDIR:M*lib32*}
64TAGS+=	lib32
65.endif
66
67.if defined(NO_ROOT)
68.if !defined(TAGS) || ! ${TAGS:Mpackage=*}
69TAGS+=		package=${PACKAGE:Uutilities}
70.endif
71TAG_ARGS=	-T ${TAGS:[*]:S/ /,/g}
72.endif
73
74# ELF hardening knobs
75.if ${MK_BIND_NOW} != "no"
76LDFLAGS+= -Wl,-znow
77.endif
78.if ${MK_RETPOLINE} != "no"
79.if ${COMPILER_FEATURES:Mretpoline} && ${LINKER_FEATURES:Mretpoline}
80CFLAGS+= -mretpoline
81CXXFLAGS+= -mretpoline
82LDFLAGS+= -Wl,-zretpolineplt
83.else
84.warning Retpoline requested but not supported by compiler or linker
85.endif
86.endif
87
88.if ${MK_DEBUG_FILES} != "no" && empty(DEBUG_FLAGS:M-g) && \
89    empty(DEBUG_FLAGS:M-gdwarf*)
90CFLAGS+= ${DEBUG_FILES_CFLAGS}
91CXXFLAGS+= ${DEBUG_FILES_CFLAGS}
92CTFFLAGS+= -g
93.endif
94
95# clang currently defaults to dynamic TLS for mips64 object files without -fPIC
96.if ${MACHINE_ARCH:Mmips64*} && ${COMPILER_TYPE} == "clang"
97STATIC_CFLAGS+= -ftls-model=initial-exec
98STATIC_CXXFLAGS+= -ftls-model=initial-exec
99.endif
100
101.if ${MACHINE_CPUARCH} == "riscv" && ${LINKER_FEATURES:Mriscv-relaxations} == ""
102CFLAGS += -mno-relax
103.endif
104
105.include <bsd.libnames.mk>
106
107# prefer .s to a .c, add .po, remove stuff not used in the BSD libraries
108# .pico used for PIC object files
109# .nossppico used for NOSSP PIC object files
110# .pieo used for PIE object files
111.SUFFIXES: .out .o .bc .ll .po .pico .nossppico .pieo .S .asm .s .c .cc .cpp .cxx .C .f .y .l .ln
112
113.if !defined(PICFLAG)
114.if ${MACHINE_CPUARCH} == "sparc64"
115PICFLAG=-fPIC
116PIEFLAG=-fPIE
117.else
118PICFLAG=-fpic
119PIEFLAG=-fpie
120.endif
121.endif
122
123PO_FLAG=-pg
124
125.c.po:
126	${CC} ${PO_FLAG} ${STATIC_CFLAGS} ${PO_CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
127	${CTFCONVERT_CMD}
128
129.c.pico:
130	${CC} ${PICFLAG} -DPIC ${SHARED_CFLAGS} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
131	${CTFCONVERT_CMD}
132
133.c.nossppico:
134	${CC} ${PICFLAG} -DPIC ${SHARED_CFLAGS:C/^-fstack-protector.*$//} ${CFLAGS:C/^-fstack-protector.*$//} -c ${.IMPSRC} -o ${.TARGET}
135	${CTFCONVERT_CMD}
136
137.c.pieo:
138	${CC} ${PIEFLAG} -DPIC ${SHARED_CFLAGS} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
139	${CTFCONVERT_CMD}
140
141.cc.po .C.po .cpp.po .cxx.po:
142	${CXX} ${PO_FLAG} ${STATIC_CXXFLAGS} ${PO_CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET}
143
144.cc.pico .C.pico .cpp.pico .cxx.pico:
145	${CXX} ${PICFLAG} -DPIC ${SHARED_CXXFLAGS} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET}
146
147.cc.nossppico .C.nossppico .cpp.nossppico .cxx.nossppico:
148	${CXX} ${PICFLAG} -DPIC ${SHARED_CXXFLAGS:C/^-fstack-protector.*$//} ${CXXFLAGS:C/^-fstack-protector.*$//} -c ${.IMPSRC} -o ${.TARGET}
149
150.cc.pieo .C.pieo .cpp.pieo .cxx.pieo:
151	${CXX} ${PIEFLAG} ${SHARED_CXXFLAGS} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET}
152
153.f.po:
154	${FC} -pg ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC}
155	${CTFCONVERT_CMD}
156
157.f.pico:
158	${FC} ${PICFLAG} -DPIC ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC}
159	${CTFCONVERT_CMD}
160
161.f.nossppico:
162	${FC} ${PICFLAG} -DPIC ${FFLAGS:C/^-fstack-protector.*$//} -o ${.TARGET} -c ${.IMPSRC}
163	${CTFCONVERT_CMD}
164
165.s.po .s.pico .s.nossppico .s.pieo:
166	${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC}
167	${CTFCONVERT_CMD}
168
169.asm.po:
170	${CC:N${CCACHE_BIN}} -x assembler-with-cpp -DPROF ${PO_CFLAGS} \
171	    ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET}
172	${CTFCONVERT_CMD}
173
174.asm.pico:
175	${CC:N${CCACHE_BIN}} -x assembler-with-cpp ${PICFLAG} -DPIC \
176	    ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET}
177	${CTFCONVERT_CMD}
178
179.asm.nossppico:
180	${CC:N${CCACHE_BIN}} -x assembler-with-cpp ${PICFLAG} -DPIC \
181	    ${CFLAGS:C/^-fstack-protector.*$//} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET}
182	${CTFCONVERT_CMD}
183
184.asm.pieo:
185	${CC:N${CCACHE_BIN}} -x assembler-with-cpp ${PIEFLAG} -DPIC \
186	    ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET}
187	${CTFCONVERT_CMD}
188
189.S.po:
190	${CC:N${CCACHE_BIN}} -DPROF ${PO_CFLAGS} ${ACFLAGS} -c ${.IMPSRC} \
191	    -o ${.TARGET}
192	${CTFCONVERT_CMD}
193
194.S.pico:
195	${CC:N${CCACHE_BIN}} ${PICFLAG} -DPIC ${CFLAGS} ${ACFLAGS} \
196	    -c ${.IMPSRC} -o ${.TARGET}
197	${CTFCONVERT_CMD}
198
199.S.nossppico:
200	${CC:N${CCACHE_BIN}} ${PICFLAG} -DPIC ${CFLAGS:C/^-fstack-protector.*$//} ${ACFLAGS} \
201	    -c ${.IMPSRC} -o ${.TARGET}
202	${CTFCONVERT_CMD}
203
204.S.pieo:
205	${CC:N${CCACHE_BIN}} ${PIEFLAG} -DPIC ${CFLAGS} ${ACFLAGS} \
206	    -c ${.IMPSRC} -o ${.TARGET}
207	${CTFCONVERT_CMD}
208
209_LIBDIR:=${LIBDIR}
210_SHLIBDIR:=${SHLIBDIR}
211
212.if defined(SHLIB_NAME)
213.if ${MK_DEBUG_FILES} != "no"
214SHLIB_NAME_FULL=${SHLIB_NAME}.full
215# Use ${DEBUGDIR} for base system debug files, else .debug subdirectory
216.if ${_SHLIBDIR} == "/boot" ||\
217    ${SHLIBDIR:C%/lib(/.*)?$%/lib%} == "/lib" ||\
218    ${SHLIBDIR:C%/usr/(tests/)?lib(32|exec)?(/.*)?%/usr/lib%} == "/usr/lib"
219DEBUGFILEDIR=${DEBUGDIR}${_SHLIBDIR}
220.else
221DEBUGFILEDIR=${_SHLIBDIR}/.debug
222.endif
223.if !exists(${DESTDIR}${DEBUGFILEDIR})
224DEBUGMKDIR=
225.endif
226.else
227SHLIB_NAME_FULL=${SHLIB_NAME}
228.endif
229.endif
230
231.include <bsd.symver.mk>
232
233# Allow libraries to specify their own version map or have it
234# automatically generated (see bsd.symver.mk above).
235.if ${MK_SYMVER} == "yes" && !empty(VERSION_MAP)
236${SHLIB_NAME_FULL}:	${VERSION_MAP}
237LDFLAGS+=	-Wl,--version-script=${VERSION_MAP}
238.endif
239
240.if defined(LIB) && !empty(LIB) || defined(SHLIB_NAME)
241OBJS+=		${SRCS:N*.h:${OBJS_SRCS_FILTER:ts:}:S/$/.o/}
242BCOBJS+=	${SRCS:N*.[hsS]:N*.asm:${OBJS_SRCS_FILTER:ts:}:S/$/.bco/g}
243LLOBJS+=	${SRCS:N*.[hsS]:N*.asm:${OBJS_SRCS_FILTER:ts:}:S/$/.llo/g}
244CLEANFILES+=	${OBJS} ${BCOBJS} ${LLOBJS} ${STATICOBJS}
245.endif
246
247.if defined(LIB) && !empty(LIB)
248_LIBS=		lib${LIB_PRIVATE}${LIB}.a
249
250lib${LIB_PRIVATE}${LIB}.a: ${OBJS} ${STATICOBJS}
251	@${ECHO} building static ${LIB} library
252	@rm -f ${.TARGET}
253	${AR} ${ARFLAGS} ${.TARGET} `NM='${NM}' NMFLAGS='${NMFLAGS}' \
254	    ${LORDER} ${OBJS} ${STATICOBJS} | ${TSORT} ${TSORTFLAGS}` ${ARADD}
255	${RANLIB} ${RANLIBFLAGS} ${.TARGET}
256.endif
257
258.if !defined(INTERNALLIB)
259
260.if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB)
261_LIBS+=		lib${LIB_PRIVATE}${LIB}_p.a
262POBJS+=		${OBJS:.o=.po} ${STATICOBJS:.o=.po}
263DEPENDOBJS+=	${POBJS}
264CLEANFILES+=	${POBJS}
265
266lib${LIB_PRIVATE}${LIB}_p.a: ${POBJS}
267	@${ECHO} building profiled ${LIB} library
268	@rm -f ${.TARGET}
269	${AR} ${ARFLAGS} ${.TARGET} `NM='${NM}' NMFLAGS='${NMFLAGS}' \
270	    ${LORDER} ${POBJS} | ${TSORT} ${TSORTFLAGS}` ${ARADD}
271	${RANLIB} ${RANLIBFLAGS} ${.TARGET}
272.endif
273
274.if defined(LLVM_LINK)
275lib${LIB_PRIVATE}${LIB}.bc: ${BCOBJS}
276	${LLVM_LINK} -o ${.TARGET} ${BCOBJS}
277
278lib${LIB_PRIVATE}${LIB}.ll: ${LLOBJS}
279	${LLVM_LINK} -S -o ${.TARGET} ${LLOBJS}
280
281CLEANFILES+=	lib${LIB_PRIVATE}${LIB}.bc lib${LIB_PRIVATE}${LIB}.ll
282.endif
283
284.if defined(SHLIB_NAME) || \
285    defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB)
286SOBJS+=		${OBJS:.o=.pico}
287DEPENDOBJS+=	${SOBJS}
288CLEANFILES+=	${SOBJS}
289.endif
290
291.if defined(SHLIB_NAME)
292_LIBS+=		${SHLIB_NAME}
293
294SOLINKOPTS+=	-shared -Wl,-x
295.if defined(LD_FATAL_WARNINGS) && ${LD_FATAL_WARNINGS} == "no"
296SOLINKOPTS+=	-Wl,--no-fatal-warnings
297.else
298SOLINKOPTS+=	-Wl,--fatal-warnings
299.endif
300SOLINKOPTS+=	-Wl,--warn-shared-textrel
301
302.if target(beforelinking)
303beforelinking: ${SOBJS}
304${SHLIB_NAME_FULL}: beforelinking
305.endif
306
307.if defined(SHLIB_LINK)
308.if defined(SHLIB_LDSCRIPT) && !empty(SHLIB_LDSCRIPT) && exists(${.CURDIR}/${SHLIB_LDSCRIPT})
309${SHLIB_LINK:R}.ld: ${.CURDIR}/${SHLIB_LDSCRIPT}
310	sed -e 's,@@SHLIB@@,${_SHLIBDIR}/${SHLIB_NAME},g' \
311	    -e 's,@@LIBDIR@@,${_LIBDIR},g' \
312	    ${.ALLSRC} > ${.TARGET}
313
314${SHLIB_NAME_FULL}: ${SHLIB_LINK:R}.ld
315CLEANFILES+=	${SHLIB_LINK:R}.ld
316.endif
317CLEANFILES+=	${SHLIB_LINK}
318.endif
319
320${SHLIB_NAME_FULL}: ${SOBJS}
321	@${ECHO} building shared library ${SHLIB_NAME}
322	@rm -f ${SHLIB_NAME} ${SHLIB_LINK}
323.if defined(SHLIB_LINK) && !commands(${SHLIB_LINK:R}.ld) && ${MK_DEBUG_FILES} == "no"
324	@${INSTALL_LIBSYMLINK} ${TAG_ARGS:D${TAG_ARGS},development} ${SHLIB_NAME} ${SHLIB_LINK}
325.endif
326	${_LD:N${CCACHE_BIN}} ${LDFLAGS} ${SSP_CFLAGS} ${SOLINKOPTS} \
327	    -o ${.TARGET} -Wl,-soname,${SONAME} \
328	    `NM='${NM}' NMFLAGS='${NMFLAGS}' ${LORDER} ${SOBJS} | \
329	    ${TSORT} ${TSORTFLAGS}` ${LDADD}
330.if ${MK_CTF} != "no"
331	${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SOBJS}
332.endif
333
334.if ${MK_DEBUG_FILES} != "no"
335CLEANFILES+=	${SHLIB_NAME_FULL} ${SHLIB_NAME}.debug
336${SHLIB_NAME}: ${SHLIB_NAME_FULL} ${SHLIB_NAME}.debug
337	${OBJCOPY} --strip-debug --add-gnu-debuglink=${SHLIB_NAME}.debug \
338	    ${SHLIB_NAME_FULL} ${.TARGET}
339.if defined(SHLIB_LINK) && !commands(${SHLIB_LINK:R}.ld)
340	@${INSTALL_LIBSYMLINK} ${TAG_ARGS:D${TAG_ARGS},development} ${SHLIB_NAME} ${SHLIB_LINK}
341.endif
342
343${SHLIB_NAME}.debug: ${SHLIB_NAME_FULL}
344	${OBJCOPY} --only-keep-debug ${SHLIB_NAME_FULL} ${.TARGET}
345.endif
346.endif #defined(SHLIB_NAME)
347
348.if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no"
349_LIBS+=		lib${LIB_PRIVATE}${LIB}_pic.a
350
351lib${LIB_PRIVATE}${LIB}_pic.a: ${SOBJS}
352	@${ECHO} building special pic ${LIB} library
353	@rm -f ${.TARGET}
354	${AR} ${ARFLAGS} ${.TARGET} ${SOBJS} ${ARADD}
355	${RANLIB} ${RANLIBFLAGS} ${.TARGET}
356.endif
357
358.if defined(BUILD_NOSSP_PIC_ARCHIVE) && defined(LIB) && !empty(LIB)
359NOSSPSOBJS+=	${OBJS:.o=.nossppico}
360DEPENDOBJS+=	${NOSSPSOBJS}
361CLEANFILES+=	${NOSSPSOBJS}
362_LIBS+=		lib${LIB_PRIVATE}${LIB}_nossp_pic.a
363
364lib${LIB_PRIVATE}${LIB}_nossp_pic.a: ${NOSSPSOBJS}
365	@${ECHO} building special nossp pic ${LIB} library
366	@rm -f ${.TARGET}
367	${AR} ${ARFLAGS} ${.TARGET} ${NOSSPSOBJS} ${ARADD}
368	${RANLIB} ${RANLIBFLAGS} ${.TARGET}
369.endif
370
371.endif # !defined(INTERNALLIB)
372
373.if defined(INTERNALLIB) && ${MK_PIE} != "no"
374PIEOBJS+=	${OBJS:.o=.pieo}
375DEPENDOBJS+=	${PIEOBJS}
376CLEANFILES+=	${PIEOBJS}
377
378_LIBS+=		lib${LIB_PRIVATE}${LIB}_pie.a
379
380lib${LIB_PRIVATE}${LIB}_pie.a: ${PIEOBJS}
381	@${ECHO} building pie ${LIB} library
382	@rm -f ${.TARGET}
383	${AR} ${ARFLAGS} ${.TARGET} ${PIEOBJS} ${ARADD}
384	${RANLIB} ${RANLIBFLAGS} ${.TARGET}
385.endif
386
387.if defined(_SKIP_BUILD)
388all:
389.else
390.if defined(_LIBS) && !empty(_LIBS)
391all: ${_LIBS}
392.endif
393
394.if ${MK_MAN} != "no" && !defined(LIBRARIES_ONLY)
395all: all-man
396.endif
397.endif
398
399CLEANFILES+=	${_LIBS}
400
401_EXTRADEPEND:
402.if !defined(NO_EXTRADEPEND) && defined(SHLIB_NAME)
403.if defined(DPADD) && !empty(DPADD)
404	echo ${SHLIB_NAME_FULL}: ${DPADD} >> ${DEPENDFILE}
405.endif
406.endif
407
408.if !target(install)
409
410.if defined(PRECIOUSLIB)
411.if !defined(NO_FSCHG)
412SHLINSTALLFLAGS+= -fschg
413.endif
414.endif
415# Install libraries with -S to avoid risk of modifying in-use libraries when
416# installing to a running system.  It is safe to avoid this for NO_ROOT builds
417# that are only creating an image.
418.if !defined(NO_SAFE_LIBINSTALL) && !defined(NO_ROOT)
419SHLINSTALLFLAGS+= -S
420.endif
421
422_INSTALLFLAGS:=	${INSTALLFLAGS}
423.for ie in ${INSTALLFLAGS_EDIT}
424_INSTALLFLAGS:=	${_INSTALLFLAGS${ie}}
425.endfor
426_SHLINSTALLFLAGS:=	${SHLINSTALLFLAGS}
427.for ie in ${INSTALLFLAGS_EDIT}
428_SHLINSTALLFLAGS:=	${_SHLINSTALLFLAGS${ie}}
429.endfor
430
431.if !defined(INTERNALLIB)
432realinstall: _libinstall
433.ORDER: beforeinstall _libinstall
434_libinstall:
435.if defined(LIB) && !empty(LIB) && ${MK_INSTALLLIB} != "no"
436	${INSTALL} ${TAG_ARGS:D${TAG_ARGS},development} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
437	    ${_INSTALLFLAGS} lib${LIB_PRIVATE}${LIB}.a ${DESTDIR}${_LIBDIR}/
438.endif
439.if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB)
440	${INSTALL} ${TAG_ARGS:D${TAG_ARGS},development} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
441	    ${_INSTALLFLAGS} lib${LIB_PRIVATE}${LIB}_p.a ${DESTDIR}${_LIBDIR}/
442.endif
443.if defined(SHLIB_NAME)
444	${INSTALL} ${TAG_ARGS} ${STRIP} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
445	    ${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \
446	    ${SHLIB_NAME} ${DESTDIR}${_SHLIBDIR}/
447.if ${MK_DEBUG_FILES} != "no"
448.if defined(DEBUGMKDIR)
449	${INSTALL} ${TAG_ARGS:D${TAG_ARGS},debug} -d ${DESTDIR}${DEBUGFILEDIR}/
450.endif
451	${INSTALL} ${TAG_ARGS:D${TAG_ARGS},debug} -o ${LIBOWN} -g ${LIBGRP} -m ${DEBUGMODE} \
452	    ${_INSTALLFLAGS} \
453	    ${SHLIB_NAME}.debug ${DESTDIR}${DEBUGFILEDIR}/
454.endif
455.if defined(SHLIB_LINK)
456.if commands(${SHLIB_LINK:R}.ld)
457	${INSTALL} ${TAG_ARGS:D${TAG_ARGS},development} -S -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
458	    ${_INSTALLFLAGS} ${SHLIB_LINK:R}.ld \
459	    ${DESTDIR}${_LIBDIR}/${SHLIB_LINK}
460.for _SHLIB_LINK_LINK in ${SHLIB_LDSCRIPT_LINKS}
461	${INSTALL_LIBSYMLINK} ${TAG_ARGS} ${SHLIB_LINK} ${DESTDIR}${_LIBDIR}/${_SHLIB_LINK_LINK}
462.endfor
463.else
464.if ${_SHLIBDIR} == ${_LIBDIR}
465.if ${SHLIB_LINK:Mlib*}
466	${INSTALL_RSYMLINK} ${TAG_ARGS:D${TAG_ARGS},development} ${SHLIB_NAME} ${DESTDIR}${_LIBDIR}/${SHLIB_LINK}
467.else
468	${INSTALL_RSYMLINK} ${TAG_ARGS} ${DESTDIR}${_SHLIBDIR}/${SHLIB_NAME} \
469	    ${DESTDIR}${_LIBDIR}/${SHLIB_LINK}
470.endif
471.else
472.if ${SHLIB_LINK:Mlib*}
473	${INSTALL_RSYMLINK} ${TAG_ARGS:D${TAG_ARGS},development} ${DESTDIR}${_SHLIBDIR}/${SHLIB_NAME} \
474	    ${DESTDIR}${_LIBDIR}/${SHLIB_LINK}
475.else
476	${INSTALL_RSYMLINK} ${TAG_ARGS} ${DESTDIR}${_SHLIBDIR}/${SHLIB_NAME} \
477	    ${DESTDIR}${_LIBDIR}/${SHLIB_LINK}
478.endif
479.if exists(${DESTDIR}${_LIBDIR}/${SHLIB_NAME})
480	-chflags noschg ${DESTDIR}${_LIBDIR}/${SHLIB_NAME}
481	rm -f ${DESTDIR}${_LIBDIR}/${SHLIB_NAME}
482.endif
483.endif
484.endif # SHLIB_LDSCRIPT
485.endif # SHLIB_LINK
486.endif # SHIB_NAME
487.if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no"
488	${INSTALL} ${TAG_ARGS:D${TAG_ARGS},development} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
489	    ${_INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${_LIBDIR}/
490.endif
491.endif # !defined(INTERNALLIB)
492
493.if !defined(LIBRARIES_ONLY)
494.include <bsd.nls.mk>
495.include <bsd.confs.mk>
496.include <bsd.files.mk>
497.include <bsd.incs.mk>
498.endif
499
500LINKOWN?=	${LIBOWN}
501LINKGRP?=	${LIBGRP}
502LINKMODE?=	${LIBMODE}
503SYMLINKOWN?=	${LIBOWN}
504SYMLINKGRP?=	${LIBGRP}
505.include <bsd.links.mk>
506
507.if ${MK_MAN} != "no" && !defined(LIBRARIES_ONLY)
508realinstall: maninstall
509.ORDER: beforeinstall maninstall
510.endif
511
512.endif
513
514.if ${MK_MAN} != "no" && !defined(LIBRARIES_ONLY)
515.include <bsd.man.mk>
516.endif
517
518.if defined(LIB) && !empty(LIB)
519OBJS_DEPEND_GUESS+= ${SRCS:M*.h}
520.for _S in ${SRCS:N*.[hly]}
521OBJS_DEPEND_GUESS.${_S:${OBJS_SRCS_FILTER:ts:}}.po+=	${_S}
522.endfor
523.endif
524.if defined(SHLIB_NAME) || \
525    defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB)
526.for _S in ${SRCS:N*.[hly]}
527OBJS_DEPEND_GUESS.${_S:${OBJS_SRCS_FILTER:ts:}}.pico+=	${_S}
528.endfor
529.endif
530.if defined(BUILD_NOSSP_PIC_ARCHIVE) && defined(LIB) && !empty(LIB)
531.for _S in ${SRCS:N*.[hly]}
532OBJS_DEPEND_GUESS.${_S:${OBJS_SRCS_FILTER:ts:}}.nossppico+=	${_S}
533.endfor
534.endif
535
536.if defined(HAS_TESTS)
537MAKE+=			MK_MAKE_CHECK_USE_SANDBOX=yes
538SUBDIR_TARGETS+=	check
539TESTS_LD_LIBRARY_PATH+=	${.OBJDIR}
540.endif
541
542.include <bsd.dep.mk>
543.include <bsd.clang-analyze.mk>
544.include <bsd.obj.mk>
545.include <bsd.sys.mk>
546