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