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