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# bsd.sanitizer.mk is not installed, so don't require it (e.g. for ports). 122.sinclude "bsd.sanitizer.mk" 123 124.if ${MK_DEBUG_FILES} != "no" && empty(DEBUG_FLAGS:M-g) && \ 125 empty(DEBUG_FLAGS:M-gdwarf*) 126.if !${COMPILER_FEATURES:Mcompressed-debug} 127CFLAGS+= ${DEBUG_FILES_CFLAGS:N-gz*} 128CXXFLAGS+= ${DEBUG_FILES_CFLAGS:N-gz*} 129.else 130CFLAGS+= ${DEBUG_FILES_CFLAGS} 131CXXFLAGS+= ${DEBUG_FILES_CFLAGS} 132.endif 133CTFFLAGS+= -g 134.endif 135 136.if ${MACHINE_CPUARCH} == "riscv" && ${LINKER_FEATURES:Mriscv-relaxations} == "" 137CFLAGS += -mno-relax 138.endif 139 140.include <bsd.libnames.mk> 141 142# prefer .s to a .c, add .po, remove stuff not used in the BSD libraries 143# .pico used for PIC object files 144# .nossppico used for NOSSP PIC object files 145# .pieo used for PIE object files 146.SUFFIXES: .out .o .bc .ll .po .pico .nossppico .pieo .S .asm .s .c .cc .cpp .cxx .C .f .y .l .ln 147 148.if !defined(PICFLAG) 149PICFLAG=-fpic 150PIEFLAG=-fpie 151.endif 152 153PO_FLAG=-pg 154 155.c.po: 156 ${CC} ${PO_FLAG} ${STATIC_CFLAGS} ${PO_CFLAGS} -c ${.IMPSRC} -o ${.TARGET} 157 ${CTFCONVERT_CMD} 158 159.c.pico: 160 ${CC} ${PICFLAG} -DPIC ${SHARED_CFLAGS} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} 161 ${CTFCONVERT_CMD} 162 163.c.nossppico: 164 ${CC} ${PICFLAG} -DPIC ${SHARED_CFLAGS:C/^-fstack-protector.*$//:C/^-fsanitize.*$//} ${CFLAGS:C/^-fstack-protector.*$//:C/^-fsanitize.*$//} -c ${.IMPSRC} -o ${.TARGET} 165 ${CTFCONVERT_CMD} 166 167.c.pieo: 168 ${CC} ${PIEFLAG} -DPIC ${SHARED_CFLAGS} ${CFLAGS} -c ${.IMPSRC} -o ${.TARGET} 169 ${CTFCONVERT_CMD} 170 171.cc.po .C.po .cpp.po .cxx.po: 172 ${CXX} ${PO_FLAG} ${STATIC_CXXFLAGS} ${PO_CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} 173 174.cc.pico .C.pico .cpp.pico .cxx.pico: 175 ${CXX} ${PICFLAG} -DPIC ${SHARED_CXXFLAGS} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} 176 177.cc.nossppico .C.nossppico .cpp.nossppico .cxx.nossppico: 178 ${CXX} ${PICFLAG} -DPIC ${SHARED_CXXFLAGS:C/^-fstack-protector.*$//:C/^-fsanitize.*$//} ${CXXFLAGS:C/^-fstack-protector.*$//:C/^-fsanitize.*$//} -c ${.IMPSRC} -o ${.TARGET} 179 180.cc.pieo .C.pieo .cpp.pieo .cxx.pieo: 181 ${CXX} ${PIEFLAG} ${SHARED_CXXFLAGS} ${CXXFLAGS} -c ${.IMPSRC} -o ${.TARGET} 182 183.f.po: 184 ${FC} -pg ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC} 185 ${CTFCONVERT_CMD} 186 187.f.pico: 188 ${FC} ${PICFLAG} -DPIC ${FFLAGS} -o ${.TARGET} -c ${.IMPSRC} 189 ${CTFCONVERT_CMD} 190 191.f.nossppico: 192 ${FC} ${PICFLAG} -DPIC ${FFLAGS:C/^-fstack-protector.*$//} -o ${.TARGET} -c ${.IMPSRC} 193 ${CTFCONVERT_CMD} 194 195.s.po .s.pico .s.nossppico .s.pieo: 196 ${CC:N${CCACHE_BIN}} -x assembler ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET} 197 ${CTFCONVERT_CMD} 198 199.asm.po: 200 ${CC:N${CCACHE_BIN}} -x assembler-with-cpp -DPROF ${PO_CFLAGS} \ 201 ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET} 202 ${CTFCONVERT_CMD} 203 204.asm.pico: 205 ${CC:N${CCACHE_BIN}} -x assembler-with-cpp ${PICFLAG} -DPIC \ 206 ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET} 207 ${CTFCONVERT_CMD} 208 209.asm.nossppico: 210 ${CC:N${CCACHE_BIN}} -x assembler-with-cpp ${PICFLAG} -DPIC \ 211 ${CFLAGS:C/^-fstack-protector.*$//} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET} 212 ${CTFCONVERT_CMD} 213 214.asm.pieo: 215 ${CC:N${CCACHE_BIN}} -x assembler-with-cpp ${PIEFLAG} -DPIC \ 216 ${CFLAGS} ${ACFLAGS} -c ${.IMPSRC} -o ${.TARGET} 217 ${CTFCONVERT_CMD} 218 219.S.po: 220 ${CC:N${CCACHE_BIN}} -DPROF ${PO_CFLAGS} ${ACFLAGS} -c ${.IMPSRC} \ 221 -o ${.TARGET} 222 ${CTFCONVERT_CMD} 223 224.S.pico: 225 ${CC:N${CCACHE_BIN}} ${PICFLAG} -DPIC ${CFLAGS} ${ACFLAGS} \ 226 -c ${.IMPSRC} -o ${.TARGET} 227 ${CTFCONVERT_CMD} 228 229.S.nossppico: 230 ${CC:N${CCACHE_BIN}} ${PICFLAG} -DPIC ${CFLAGS:C/^-fstack-protector.*$//} ${ACFLAGS} \ 231 -c ${.IMPSRC} -o ${.TARGET} 232 ${CTFCONVERT_CMD} 233 234.S.pieo: 235 ${CC:N${CCACHE_BIN}} ${PIEFLAG} -DPIC ${CFLAGS} ${ACFLAGS} \ 236 -c ${.IMPSRC} -o ${.TARGET} 237 ${CTFCONVERT_CMD} 238 239_LIBDIR:=${LIBDIR} 240_SHLIBDIR:=${SHLIBDIR} 241 242.if defined(SHLIB_NAME) 243.if ${MK_DEBUG_FILES} != "no" 244SHLIB_NAME_FULL=${SHLIB_NAME}.full 245# Use ${DEBUGDIR} for base system debug files, else .debug subdirectory 246.if ${_SHLIBDIR} == "/boot" ||\ 247 ${SHLIBDIR:C%/lib(/.*)?$%/lib%} == "/lib" ||\ 248 ${SHLIBDIR:C%/usr/(tests/)?lib(32|exec)?(/.*)?%/usr/lib%} == "/usr/lib" 249DEBUGFILEDIR=${DEBUGDIR}${_SHLIBDIR} 250.else 251DEBUGFILEDIR=${_SHLIBDIR}/.debug 252.endif 253.if !exists(${DESTDIR}${DEBUGFILEDIR}) 254DEBUGMKDIR= 255.endif 256.else 257SHLIB_NAME_FULL=${SHLIB_NAME} 258.endif 259.endif 260 261.include <bsd.symver.mk> 262 263# Allow libraries to specify their own version map or have it 264# automatically generated (see bsd.symver.mk above). 265.if !empty(VERSION_MAP) 266${SHLIB_NAME_FULL}: ${VERSION_MAP} 267LDFLAGS+= -Wl,--version-script=${VERSION_MAP} 268 269# Ideally we'd always enable --no-undefined-version (default for lld >= 16), 270# but we have several symbols in our version maps that may or may not exist, 271# depending on compile-time defines and that needs to be handled first. 272.if ${MK_UNDEFINED_VERSION} == "no" 273LDFLAGS+= -Wl,--no-undefined-version 274.else 275LDFLAGS+= -Wl,--undefined-version 276.endif 277.endif 278 279.if defined(LIB) && !empty(LIB) || defined(SHLIB_NAME) 280OBJS+= ${SRCS:N*.h:${OBJS_SRCS_FILTER:ts:}:S/$/.o/} 281BCOBJS+= ${SRCS:N*.[hsS]:N*.asm:${OBJS_SRCS_FILTER:ts:}:S/$/.bco/g} 282LLOBJS+= ${SRCS:N*.[hsS]:N*.asm:${OBJS_SRCS_FILTER:ts:}:S/$/.llo/g} 283CLEANFILES+= ${OBJS} ${BCOBJS} ${LLOBJS} ${STATICOBJS} 284.endif 285 286.if defined(LIB) && !empty(LIB) 287.if defined(STATIC_LDSCRIPT) 288_STATICLIB_SUFFIX= _real 289.endif 290_LIBS= lib${LIB_PRIVATE}${LIB}${_STATICLIB_SUFFIX}.a 291 292lib${LIB_PRIVATE}${LIB}${_STATICLIB_SUFFIX}.a: ${OBJS} ${STATICOBJS} 293 @${ECHO} building static ${LIB} library 294 @rm -f ${.TARGET} 295 ${AR} ${ARFLAGS} ${.TARGET} ${OBJS} ${STATICOBJS} ${ARADD} 296.endif 297 298.if !defined(INTERNALLIB) 299 300.if defined(LLVM_LINK) 301lib${LIB_PRIVATE}${LIB}.bc: ${BCOBJS} 302 ${LLVM_LINK} -o ${.TARGET} ${BCOBJS} 303 304lib${LIB_PRIVATE}${LIB}.ll: ${LLOBJS} 305 ${LLVM_LINK} -S -o ${.TARGET} ${LLOBJS} 306 307CLEANFILES+= 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) 312SOBJS+= ${OBJS:.o=.pico} 313DEPENDOBJS+= ${SOBJS} 314CLEANFILES+= ${SOBJS} 315.endif 316 317.if defined(SHLIB_NAME) 318_LIBS+= ${SHLIB_NAME} 319 320SOLINKOPTS+= -shared -Wl,-x 321.if defined(LD_FATAL_WARNINGS) && ${LD_FATAL_WARNINGS} == "no" 322SOLINKOPTS+= -Wl,--no-fatal-warnings 323.else 324SOLINKOPTS+= -Wl,--fatal-warnings 325.endif 326SOLINKOPTS+= -Wl,--warn-shared-textrel 327 328.if target(beforelinking) 329beforelinking: ${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 341CLEANFILES+= ${SHLIB_LINK:R}.ld 342.endif 343CLEANFILES+= ${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" 360CLEANFILES+= ${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) 375_LIBS+= lib${LIB_PRIVATE}${LIB}_pic.a 376 377lib${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) 384NOSSPSOBJS+= ${OBJS:.o=.nossppico} 385DEPENDOBJS+= ${NOSSPSOBJS} 386CLEANFILES+= ${NOSSPSOBJS} 387_LIBS+= lib${LIB_PRIVATE}${LIB}_nossp_pic.a 388 389lib${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) 398PIEOBJS+= ${OBJS:.o=.pieo} 399DEPENDOBJS+= ${PIEOBJS} 400CLEANFILES+= ${PIEOBJS} 401 402_LIBS+= lib${LIB_PRIVATE}${LIB}_pie.a 403 404lib${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) 411all: 412.else 413.if defined(_LIBS) && !empty(_LIBS) 414all: ${_LIBS} 415.endif 416 417.if ${MK_MAN} != "no" && !defined(LIBRARIES_ONLY) 418all: all-man 419.endif 420.endif 421 422CLEANFILES+= ${_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 433INSTALLFLAGS+= -C 434.if defined(PRECIOUSLIB) 435.if !defined(NO_FSCHG) 436SHLINSTALLFLAGS+= -fschg 437.endif 438.endif 439# Install libraries with -S to avoid risk of modifying in-use libraries when 440# installing to a running system. It is safe to avoid this for NO_ROOT builds 441# that are only creating an image. 442# 443# XXX: Since Makefile.inc1 ends up building lib/libc both as part of 444# _startup_libs and as part of _generic_libs it ends up getting installed a 445# second time during the parallel build, and although the .WAIT in lib/Makefile 446# stops that mattering for lib, other directories like secure/lib are built in 447# parallel at the top level and are unaffected by that, so can sometimes race 448# with the libc.so.7 reinstall and see a missing or corrupt file. Ideally the 449# build system would be fixed to not build/install libc to WORLDTMP the second 450# time round, but for now using -S ensures the install is atomic and thus we 451# never see a broken intermediate state, so use it even for NO_ROOT builds. 452.if !defined(NO_SAFE_LIBINSTALL) #&& !defined(NO_ROOT) 453SHLINSTALLFLAGS+= -S 454SHLINSTALLSYMLINKFLAGS+= -S 455.endif 456 457_INSTALLFLAGS:= ${INSTALLFLAGS} 458.for ie in ${INSTALLFLAGS_EDIT} 459_INSTALLFLAGS:= ${_INSTALLFLAGS${ie}} 460.endfor 461_SHLINSTALLFLAGS:= ${SHLINSTALLFLAGS} 462_SHLINSTALLSYMLINKFLAGS:= ${SHLINSTALLSYMLINKFLAGS} 463.for ie in ${INSTALLFLAGS_EDIT} 464_SHLINSTALLFLAGS:= ${_SHLINSTALLFLAGS${ie}} 465.endfor 466 467.if defined(PCFILES) 468.for pcfile in ${PCFILES} 469installpcfiles: installpcfiles-${pcfile} 470 471installpcfiles-${pcfile}: ${pcfile} 472 ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dev} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 473 ${_INSTALLFLAGS} \ 474 ${.ALLSRC} ${DESTDIR}${LIBDATADIR}/pkgconfig/ 475.endfor 476.endif 477installpcfiles: .PHONY 478 479.if !defined(INTERNALLIB) 480realinstall: _libinstall installpcfiles 481.ORDER: beforeinstall _libinstall 482_libinstall: 483.if defined(LIB) && !empty(LIB) && ${MK_INSTALLLIB} != "no" 484 ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dev} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 485 ${_INSTALLFLAGS} lib${LIB_PRIVATE}${LIB}${_STATICLIB_SUFFIX}.a ${DESTDIR}${_LIBDIR}/ 486.endif 487.if defined(SHLIB_NAME) 488 ${INSTALL} ${TAG_ARGS} ${STRIP} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 489 ${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \ 490 ${SHLIB_NAME} ${DESTDIR}${_SHLIBDIR}/ 491.if ${MK_DEBUG_FILES} != "no" 492.if defined(DEBUGMKDIR) 493 ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dbg} -d ${DESTDIR}${DEBUGFILEDIR}/ 494.endif 495 ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dbg} -o ${LIBOWN} -g ${LIBGRP} -m ${DEBUGMODE} \ 496 ${_INSTALLFLAGS} \ 497 ${SHLIB_NAME}.debug ${DESTDIR}${DEBUGFILEDIR}/ 498.endif 499.if defined(SHLIB_LINK) 500.if commands(${SHLIB_LINK:R}.ld) 501 ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dev} -S -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 502 ${_INSTALLFLAGS} ${SHLIB_LINK:R}.ld \ 503 ${DESTDIR}${_LIBDIR}/${SHLIB_LINK} 504.for _SHLIB_LINK_LINK in ${SHLIB_LDSCRIPT_LINKS} 505 ${INSTALL_LIBSYMLINK} ${_SHLINSTALLSYMLINKFLAGS} ${TAG_ARGS} ${SHLIB_LINK} \ 506 ${DESTDIR}${_LIBDIR}/${_SHLIB_LINK_LINK} 507.endfor 508.else 509.if ${_SHLIBDIR} == ${_LIBDIR} 510.if ${SHLIB_LINK:Mlib*} 511 ${INSTALL_RSYMLINK} ${_SHLINSTALLSYMLINKFLAGS} ${TAG_ARGS:D${TAG_ARGS},dev} \ 512 ${SHLIB_NAME} ${DESTDIR}${_LIBDIR}/${SHLIB_LINK} 513.else 514 ${INSTALL_RSYMLINK} ${_SHLINSTALLSYMLINKFLAGS} ${TAG_ARGS} ${DESTDIR}${_SHLIBDIR}/${SHLIB_NAME} \ 515 ${DESTDIR}${_LIBDIR}/${SHLIB_LINK} 516.endif 517.else 518.if ${SHLIB_LINK:Mlib*} 519 ${INSTALL_RSYMLINK} ${_SHLINSTALLSYMLINKFLAGS} ${TAG_ARGS:D${TAG_ARGS},dev} \ 520 ${DESTDIR}${_SHLIBDIR}/${SHLIB_NAME} ${DESTDIR}${_LIBDIR}/${SHLIB_LINK} 521.else 522 ${INSTALL_RSYMLINK} ${_SHLINSTALLSYMLINKFLAGS} ${TAG_ARGS} \ 523 ${DESTDIR}${_SHLIBDIR}/${SHLIB_NAME} ${DESTDIR}${_LIBDIR}/${SHLIB_LINK} 524.endif 525.if exists(${DESTDIR}${_LIBDIR}/${SHLIB_NAME}) 526 -chflags noschg ${DESTDIR}${_LIBDIR}/${SHLIB_NAME} 527 rm -f ${DESTDIR}${_LIBDIR}/${SHLIB_NAME} 528.endif 529.endif # _SHLIBDIR == _LIBDIR 530.endif # SHLIB_LDSCRIPT 531.endif # SHLIB_LINK 532.endif # SHIB_NAME 533.if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) 534 ${INSTALL} ${TAG_ARGS:D${TAG_ARGS},dev} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ 535 ${_INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${_LIBDIR}/ 536.endif 537.endif # !defined(INTERNALLIB) 538 539.if !defined(LIBRARIES_ONLY) 540.include <bsd.nls.mk> 541.include <bsd.confs.mk> 542.include <bsd.files.mk> 543#No need to install header for INTERNALLIB 544.if !defined(INTERNALLIB) 545.include <bsd.incs.mk> 546.endif 547.endif 548 549LINKOWN?= ${LIBOWN} 550LINKGRP?= ${LIBGRP} 551LINKMODE?= ${LIBMODE} 552SYMLINKOWN?= ${LIBOWN} 553SYMLINKGRP?= ${LIBGRP} 554LINKTAGS= dev 555.include <bsd.links.mk> 556 557.if ${MK_MAN} != "no" && !defined(LIBRARIES_ONLY) 558realinstall: maninstall 559.ORDER: beforeinstall maninstall 560.endif 561 562.endif 563 564.if ${MK_MAN} != "no" && !defined(LIBRARIES_ONLY) 565.include <bsd.man.mk> 566.endif 567 568.if defined(LIB) && !empty(LIB) 569OBJS_DEPEND_GUESS+= ${SRCS:M*.h} 570.for _S in ${SRCS:N*.[hly]} 571OBJS_DEPEND_GUESS.${_S:${OBJS_SRCS_FILTER:ts:}}.po+= ${_S} 572.endfor 573.endif 574.if defined(SHLIB_NAME) || \ 575 defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) 576.for _S in ${SRCS:N*.[hly]} 577OBJS_DEPEND_GUESS.${_S:${OBJS_SRCS_FILTER:ts:}}.pico+= ${_S} 578.endfor 579.endif 580.if defined(BUILD_NOSSP_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) 581.for _S in ${SRCS:N*.[hly]} 582OBJS_DEPEND_GUESS.${_S:${OBJS_SRCS_FILTER:ts:}}.nossppico+= ${_S} 583.endfor 584.endif 585 586.if defined(HAS_TESTS) 587MAKE+= MK_MAKE_CHECK_USE_SANDBOX=yes 588SUBDIR_TARGETS+= check 589TESTS_LD_LIBRARY_PATH+= ${.OBJDIR} 590.endif 591 592.include <bsd.dep.mk> 593.include <bsd.clang-analyze.mk> 594.include <bsd.obj.mk> 595.include <bsd.sys.mk> 596