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