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