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