xref: /freebsd/share/mk/bsd.lib.mk (revision f9fd7337f63698f33239c58c07bf430198235a22)
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)
114PICFLAG=-fpic
115PIEFLAG=-fpie
116.endif
117
118PO_FLAG=-pg
119
120.c.po:
121	${CC} ${PO_FLAG} ${STATIC_CFLAGS} ${PO_CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
122	${CTFCONVERT_CMD}
123
124.c.pico:
125	${CC} ${PICFLAG} -DPIC ${SHARED_CFLAGS} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
126	${CTFCONVERT_CMD}
127
128.c.nossppico:
129	${CC} ${PICFLAG} -DPIC ${SHARED_CFLAGS:C/^-fstack-protector.*$//} ${CFLAGS:C/^-fstack-protector.*$//} -c ${.IMPSRC} -o ${.TARGET}
130	${CTFCONVERT_CMD}
131
132.c.pieo:
133	${CC} ${PIEFLAG} -DPIC ${SHARED_CFLAGS} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET}
134	${CTFCONVERT_CMD}
135
136.cc.po .C.po .cpp.po .cxx.po:
137	${CXX} ${PO_FLAG} ${STATIC_CXXFLAGS} ${PO_CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET}
138
139.cc.pico .C.pico .cpp.pico .cxx.pico:
140	${CXX} ${PICFLAG} -DPIC ${SHARED_CXXFLAGS} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET}
141
142.cc.nossppico .C.nossppico .cpp.nossppico .cxx.nossppico:
143	${CXX} ${PICFLAG} -DPIC ${SHARED_CXXFLAGS:C/^-fstack-protector.*$//} ${CXXFLAGS:C/^-fstack-protector.*$//} -c ${.IMPSRC} -o ${.TARGET}
144
145.cc.pieo .C.pieo .cpp.pieo .cxx.pieo:
146	${CXX} ${PIEFLAG} ${SHARED_CXXFLAGS} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET}
147
148.f.po:
149	${FC} -pg ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC}
150	${CTFCONVERT_CMD}
151
152.f.pico:
153	${FC} ${PICFLAG} -DPIC ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC}
154	${CTFCONVERT_CMD}
155
156.f.nossppico:
157	${FC} ${PICFLAG} -DPIC ${FFLAGS:C/^-fstack-protector.*$//} -o ${.TARGET} -c ${.IMPSRC}
158	${CTFCONVERT_CMD}
159
160.s.po .s.pico .s.nossppico .s.pieo:
161	${AS} ${AFLAGS} -o ${.TARGET} ${.IMPSRC}
162	${CTFCONVERT_CMD}
163
164.asm.po:
165	${CC:N${CCACHE_BIN}} -x assembler-with-cpp -DPROF ${PO_CFLAGS} \
166	    ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET}
167	${CTFCONVERT_CMD}
168
169.asm.pico:
170	${CC:N${CCACHE_BIN}} -x assembler-with-cpp ${PICFLAG} -DPIC \
171	    ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET}
172	${CTFCONVERT_CMD}
173
174.asm.nossppico:
175	${CC:N${CCACHE_BIN}} -x assembler-with-cpp ${PICFLAG} -DPIC \
176	    ${CFLAGS:C/^-fstack-protector.*$//} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET}
177	${CTFCONVERT_CMD}
178
179.asm.pieo:
180	${CC:N${CCACHE_BIN}} -x assembler-with-cpp ${PIEFLAG} -DPIC \
181	    ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET}
182	${CTFCONVERT_CMD}
183
184.S.po:
185	${CC:N${CCACHE_BIN}} -DPROF ${PO_CFLAGS} ${ACFLAGS} -c ${.IMPSRC} \
186	    -o ${.TARGET}
187	${CTFCONVERT_CMD}
188
189.S.pico:
190	${CC:N${CCACHE_BIN}} ${PICFLAG} -DPIC ${CFLAGS} ${ACFLAGS} \
191	    -c ${.IMPSRC} -o ${.TARGET}
192	${CTFCONVERT_CMD}
193
194.S.nossppico:
195	${CC:N${CCACHE_BIN}} ${PICFLAG} -DPIC ${CFLAGS:C/^-fstack-protector.*$//} ${ACFLAGS} \
196	    -c ${.IMPSRC} -o ${.TARGET}
197	${CTFCONVERT_CMD}
198
199.S.pieo:
200	${CC:N${CCACHE_BIN}} ${PIEFLAG} -DPIC ${CFLAGS} ${ACFLAGS} \
201	    -c ${.IMPSRC} -o ${.TARGET}
202	${CTFCONVERT_CMD}
203
204_LIBDIR:=${LIBDIR}
205_SHLIBDIR:=${SHLIBDIR}
206
207.if defined(SHLIB_NAME)
208.if ${MK_DEBUG_FILES} != "no"
209SHLIB_NAME_FULL=${SHLIB_NAME}.full
210# Use ${DEBUGDIR} for base system debug files, else .debug subdirectory
211.if ${_SHLIBDIR} == "/boot" ||\
212    ${SHLIBDIR:C%/lib(/.*)?$%/lib%} == "/lib" ||\
213    ${SHLIBDIR:C%/usr/(tests/)?lib(32|exec)?(/.*)?%/usr/lib%} == "/usr/lib"
214DEBUGFILEDIR=${DEBUGDIR}${_SHLIBDIR}
215.else
216DEBUGFILEDIR=${_SHLIBDIR}/.debug
217.endif
218.if !exists(${DESTDIR}${DEBUGFILEDIR})
219DEBUGMKDIR=
220.endif
221.else
222SHLIB_NAME_FULL=${SHLIB_NAME}
223.endif
224.endif
225
226.include <bsd.symver.mk>
227
228# Allow libraries to specify their own version map or have it
229# automatically generated (see bsd.symver.mk above).
230.if !empty(VERSION_MAP)
231${SHLIB_NAME_FULL}:	${VERSION_MAP}
232LDFLAGS+=	-Wl,--version-script=${VERSION_MAP}
233.endif
234
235.if defined(LIB) && !empty(LIB) || defined(SHLIB_NAME)
236OBJS+=		${SRCS:N*.h:${OBJS_SRCS_FILTER:ts:}:S/$/.o/}
237BCOBJS+=	${SRCS:N*.[hsS]:N*.asm:${OBJS_SRCS_FILTER:ts:}:S/$/.bco/g}
238LLOBJS+=	${SRCS:N*.[hsS]:N*.asm:${OBJS_SRCS_FILTER:ts:}:S/$/.llo/g}
239CLEANFILES+=	${OBJS} ${BCOBJS} ${LLOBJS} ${STATICOBJS}
240.endif
241
242.if defined(LIB) && !empty(LIB)
243_LIBS=		lib${LIB_PRIVATE}${LIB}.a
244
245lib${LIB_PRIVATE}${LIB}.a: ${OBJS} ${STATICOBJS}
246	@${ECHO} building static ${LIB} library
247	@rm -f ${.TARGET}
248	${AR} ${ARFLAGS} ${.TARGET} ${OBJS} ${STATICOBJS} ${ARADD}
249.endif
250
251.if !defined(INTERNALLIB)
252
253.if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB)
254_LIBS+=		lib${LIB_PRIVATE}${LIB}_p.a
255POBJS+=		${OBJS:.o=.po} ${STATICOBJS:.o=.po}
256DEPENDOBJS+=	${POBJS}
257CLEANFILES+=	${POBJS}
258
259lib${LIB_PRIVATE}${LIB}_p.a: ${POBJS}
260	@${ECHO} building profiled ${LIB} library
261	@rm -f ${.TARGET}
262	${AR} ${ARFLAGS} ${.TARGET} ${POBJS} ${ARADD}
263.endif
264
265.if defined(LLVM_LINK)
266lib${LIB_PRIVATE}${LIB}.bc: ${BCOBJS}
267	${LLVM_LINK} -o ${.TARGET} ${BCOBJS}
268
269lib${LIB_PRIVATE}${LIB}.ll: ${LLOBJS}
270	${LLVM_LINK} -S -o ${.TARGET} ${LLOBJS}
271
272CLEANFILES+=	lib${LIB_PRIVATE}${LIB}.bc lib${LIB_PRIVATE}${LIB}.ll
273.endif
274
275.if defined(SHLIB_NAME) || \
276    defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB)
277SOBJS+=		${OBJS:.o=.pico}
278DEPENDOBJS+=	${SOBJS}
279CLEANFILES+=	${SOBJS}
280.endif
281
282.if defined(SHLIB_NAME)
283_LIBS+=		${SHLIB_NAME}
284
285SOLINKOPTS+=	-shared -Wl,-x
286.if defined(LD_FATAL_WARNINGS) && ${LD_FATAL_WARNINGS} == "no"
287SOLINKOPTS+=	-Wl,--no-fatal-warnings
288.else
289SOLINKOPTS+=	-Wl,--fatal-warnings
290.endif
291SOLINKOPTS+=	-Wl,--warn-shared-textrel
292
293.if target(beforelinking)
294beforelinking: ${SOBJS}
295${SHLIB_NAME_FULL}: beforelinking
296.endif
297
298.if defined(SHLIB_LINK)
299.if defined(SHLIB_LDSCRIPT) && !empty(SHLIB_LDSCRIPT) && exists(${.CURDIR}/${SHLIB_LDSCRIPT})
300${SHLIB_LINK:R}.ld: ${.CURDIR}/${SHLIB_LDSCRIPT}
301	sed -e 's,@@SHLIB@@,${_SHLIBDIR}/${SHLIB_NAME},g' \
302	    -e 's,@@LIBDIR@@,${_LIBDIR},g' \
303	    ${.ALLSRC} > ${.TARGET}
304
305${SHLIB_NAME_FULL}: ${SHLIB_LINK:R}.ld
306CLEANFILES+=	${SHLIB_LINK:R}.ld
307.endif
308CLEANFILES+=	${SHLIB_LINK}
309.endif
310
311${SHLIB_NAME_FULL}: ${SOBJS}
312	@${ECHO} building shared library ${SHLIB_NAME}
313	@rm -f ${SHLIB_NAME} ${SHLIB_LINK}
314.if defined(SHLIB_LINK) && !commands(${SHLIB_LINK:R}.ld) && ${MK_DEBUG_FILES} == "no"
315	# Note: This uses ln instead of ${INSTALL_LIBSYMLINK} since we are in OBJDIR
316	@${LN:Uln} -fs ${SHLIB_NAME} ${SHLIB_LINK}
317.endif
318	${_LD:N${CCACHE_BIN}} ${LDFLAGS} ${SSP_CFLAGS} ${SOLINKOPTS} \
319	    -o ${.TARGET} -Wl,-soname,${SONAME} ${SOBJS} ${LDADD}
320.if ${MK_CTF} != "no"
321	${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SOBJS}
322.endif
323
324.if ${MK_DEBUG_FILES} != "no"
325CLEANFILES+=	${SHLIB_NAME_FULL} ${SHLIB_NAME}.debug
326${SHLIB_NAME}: ${SHLIB_NAME_FULL} ${SHLIB_NAME}.debug
327	${OBJCOPY} --strip-debug --add-gnu-debuglink=${SHLIB_NAME}.debug \
328	    ${SHLIB_NAME_FULL} ${.TARGET}
329.if defined(SHLIB_LINK) && !commands(${SHLIB_LINK:R}.ld)
330	# Note: This uses ln instead of ${INSTALL_LIBSYMLINK} since we are in OBJDIR
331	@${LN:Uln} -fs ${SHLIB_NAME} ${SHLIB_LINK}
332.endif
333
334${SHLIB_NAME}.debug: ${SHLIB_NAME_FULL}
335	${OBJCOPY} --only-keep-debug ${SHLIB_NAME_FULL} ${.TARGET}
336.endif
337.endif #defined(SHLIB_NAME)
338
339.if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no"
340_LIBS+=		lib${LIB_PRIVATE}${LIB}_pic.a
341
342lib${LIB_PRIVATE}${LIB}_pic.a: ${SOBJS}
343	@${ECHO} building special pic ${LIB} library
344	@rm -f ${.TARGET}
345	${AR} ${ARFLAGS} ${.TARGET} ${SOBJS} ${ARADD}
346.endif
347
348.if defined(BUILD_NOSSP_PIC_ARCHIVE) && defined(LIB) && !empty(LIB)
349NOSSPSOBJS+=	${OBJS:.o=.nossppico}
350DEPENDOBJS+=	${NOSSPSOBJS}
351CLEANFILES+=	${NOSSPSOBJS}
352_LIBS+=		lib${LIB_PRIVATE}${LIB}_nossp_pic.a
353
354lib${LIB_PRIVATE}${LIB}_nossp_pic.a: ${NOSSPSOBJS}
355	@${ECHO} building special nossp pic ${LIB} library
356	@rm -f ${.TARGET}
357	${AR} ${ARFLAGS} ${.TARGET} ${NOSSPSOBJS} ${ARADD}
358.endif
359
360.endif # !defined(INTERNALLIB)
361
362.if defined(INTERNALLIB) && ${MK_PIE} != "no"
363PIEOBJS+=	${OBJS:.o=.pieo}
364DEPENDOBJS+=	${PIEOBJS}
365CLEANFILES+=	${PIEOBJS}
366
367_LIBS+=		lib${LIB_PRIVATE}${LIB}_pie.a
368
369lib${LIB_PRIVATE}${LIB}_pie.a: ${PIEOBJS}
370	@${ECHO} building pie ${LIB} library
371	@rm -f ${.TARGET}
372	${AR} ${ARFLAGS} ${.TARGET} ${PIEOBJS} ${ARADD}
373.endif
374
375.if defined(_SKIP_BUILD)
376all:
377.else
378.if defined(_LIBS) && !empty(_LIBS)
379all: ${_LIBS}
380.endif
381
382.if ${MK_MAN} != "no" && !defined(LIBRARIES_ONLY)
383all: all-man
384.endif
385.endif
386
387CLEANFILES+=	${_LIBS}
388
389_EXTRADEPEND:
390.if !defined(NO_EXTRADEPEND) && defined(SHLIB_NAME)
391.if defined(DPADD) && !empty(DPADD)
392	echo ${SHLIB_NAME_FULL}: ${DPADD} >> ${DEPENDFILE}
393.endif
394.endif
395
396.if !target(install)
397
398.if defined(PRECIOUSLIB)
399.if !defined(NO_FSCHG)
400SHLINSTALLFLAGS+= -fschg
401.endif
402.endif
403# Install libraries with -S to avoid risk of modifying in-use libraries when
404# installing to a running system.  It is safe to avoid this for NO_ROOT builds
405# that are only creating an image.
406.if !defined(NO_SAFE_LIBINSTALL) && !defined(NO_ROOT)
407SHLINSTALLFLAGS+= -S
408SHLINSTALLSYMLINKFLAGS+= -S
409.endif
410
411_INSTALLFLAGS:=	${INSTALLFLAGS}
412.for ie in ${INSTALLFLAGS_EDIT}
413_INSTALLFLAGS:=	${_INSTALLFLAGS${ie}}
414.endfor
415_SHLINSTALLFLAGS:=	${SHLINSTALLFLAGS}
416_SHLINSTALLSYMLINKFLAGS:= ${SHLINSTALLSYMLINKFLAGS}
417.for ie in ${INSTALLFLAGS_EDIT}
418_SHLINSTALLFLAGS:=	${_SHLINSTALLFLAGS${ie}}
419.endfor
420
421.if !defined(INTERNALLIB)
422realinstall: _libinstall
423.ORDER: beforeinstall _libinstall
424_libinstall:
425.if defined(LIB) && !empty(LIB) && ${MK_INSTALLLIB} != "no"
426	${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dev} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
427	    ${_INSTALLFLAGS} lib${LIB_PRIVATE}${LIB}.a ${DESTDIR}${_LIBDIR}/
428.endif
429.if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB)
430	${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dev} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
431	    ${_INSTALLFLAGS} lib${LIB_PRIVATE}${LIB}_p.a ${DESTDIR}${_LIBDIR}/
432.endif
433.if defined(SHLIB_NAME)
434	${INSTALL} ${TAG_ARGS} ${STRIP} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
435	    ${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \
436	    ${SHLIB_NAME} ${DESTDIR}${_SHLIBDIR}/
437.if ${MK_DEBUG_FILES} != "no"
438.if defined(DEBUGMKDIR)
439	${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dbg} -d ${DESTDIR}${DEBUGFILEDIR}/
440.endif
441	${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dbg} -o ${LIBOWN} -g ${LIBGRP} -m ${DEBUGMODE} \
442	    ${_INSTALLFLAGS} \
443	    ${SHLIB_NAME}.debug ${DESTDIR}${DEBUGFILEDIR}/
444.endif
445.if defined(SHLIB_LINK)
446.if commands(${SHLIB_LINK:R}.ld)
447	${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dev} -S -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
448	    ${_INSTALLFLAGS} ${SHLIB_LINK:R}.ld \
449	    ${DESTDIR}${_LIBDIR}/${SHLIB_LINK}
450.for _SHLIB_LINK_LINK in ${SHLIB_LDSCRIPT_LINKS}
451	${INSTALL_LIBSYMLINK} ${_SHLINSTALLSYMLINKFLAGS} ${TAG_ARGS} ${SHLIB_LINK} \
452	    ${DESTDIR}${_LIBDIR}/${_SHLIB_LINK_LINK}
453.endfor
454.else
455.if ${_SHLIBDIR} == ${_LIBDIR}
456.if ${SHLIB_LINK:Mlib*}
457	${INSTALL_RSYMLINK} ${_SHLINSTALLSYMLINKFLAGS} ${TAG_ARGS:D${TAG_ARGS},dev} \
458	    ${SHLIB_NAME} ${DESTDIR}${_LIBDIR}/${SHLIB_LINK}
459.else
460	${INSTALL_RSYMLINK} ${_SHLINSTALLSYMLINKFLAGS} ${TAG_ARGS} ${DESTDIR}${_SHLIBDIR}/${SHLIB_NAME} \
461	    ${DESTDIR}${_LIBDIR}/${SHLIB_LINK}
462.endif
463.else
464.if ${SHLIB_LINK:Mlib*}
465	${INSTALL_RSYMLINK} ${_SHLINSTALLSYMLINKFLAGS} ${TAG_ARGS:D${TAG_ARGS},dev} \
466	    ${DESTDIR}${_SHLIBDIR}/${SHLIB_NAME} ${DESTDIR}${_LIBDIR}/${SHLIB_LINK}
467.else
468	${INSTALL_RSYMLINK} ${_SHLINSTALLSYMLINKFLAGS} ${TAG_ARGS} \
469	    ${DESTDIR}${_SHLIBDIR}/${SHLIB_NAME} ${DESTDIR}${_LIBDIR}/${SHLIB_LINK}
470.endif
471.if exists(${DESTDIR}${_LIBDIR}/${SHLIB_NAME})
472	-chflags noschg ${DESTDIR}${_LIBDIR}/${SHLIB_NAME}
473	rm -f ${DESTDIR}${_LIBDIR}/${SHLIB_NAME}
474.endif
475.endif # _SHLIBDIR == _LIBDIR
476.endif # SHLIB_LDSCRIPT
477.endif # SHLIB_LINK
478.endif # SHIB_NAME
479.if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no"
480	${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dev} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
481	    ${_INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${_LIBDIR}/
482.endif
483.endif # !defined(INTERNALLIB)
484
485.if !defined(LIBRARIES_ONLY)
486.include <bsd.nls.mk>
487.include <bsd.confs.mk>
488.include <bsd.files.mk>
489#No need to install header for INTERNALLIB
490.if !defined(INTERNALLIB)
491.include <bsd.incs.mk>
492.endif
493.endif
494
495LINKOWN?=	${LIBOWN}
496LINKGRP?=	${LIBGRP}
497LINKMODE?=	${LIBMODE}
498SYMLINKOWN?=	${LIBOWN}
499SYMLINKGRP?=	${LIBGRP}
500.include <bsd.links.mk>
501
502.if ${MK_MAN} != "no" && !defined(LIBRARIES_ONLY)
503realinstall: maninstall
504.ORDER: beforeinstall maninstall
505.endif
506
507.endif
508
509.if ${MK_MAN} != "no" && !defined(LIBRARIES_ONLY)
510.include <bsd.man.mk>
511.endif
512
513.if defined(LIB) && !empty(LIB)
514OBJS_DEPEND_GUESS+= ${SRCS:M*.h}
515.for _S in ${SRCS:N*.[hly]}
516OBJS_DEPEND_GUESS.${_S:${OBJS_SRCS_FILTER:ts:}}.po+=	${_S}
517.endfor
518.endif
519.if defined(SHLIB_NAME) || \
520    defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB)
521.for _S in ${SRCS:N*.[hly]}
522OBJS_DEPEND_GUESS.${_S:${OBJS_SRCS_FILTER:ts:}}.pico+=	${_S}
523.endfor
524.endif
525.if defined(BUILD_NOSSP_PIC_ARCHIVE) && defined(LIB) && !empty(LIB)
526.for _S in ${SRCS:N*.[hly]}
527OBJS_DEPEND_GUESS.${_S:${OBJS_SRCS_FILTER:ts:}}.nossppico+=	${_S}
528.endfor
529.endif
530
531.if defined(HAS_TESTS)
532MAKE+=			MK_MAKE_CHECK_USE_SANDBOX=yes
533SUBDIR_TARGETS+=	check
534TESTS_LD_LIBRARY_PATH+=	${.OBJDIR}
535.endif
536
537.include <bsd.dep.mk>
538.include <bsd.clang-analyze.mk>
539.include <bsd.obj.mk>
540.include <bsd.sys.mk>
541