1# $Id: lib.mk,v 1.62 2017/06/11 03:24:04 sjg Exp $ 2 3.if !target(__${.PARSEFILE}__) 4__${.PARSEFILE}__: 5 6.include <init.mk> 7 8.if ${OBJECT_FMT} == "ELF" 9NEED_SOLINKS?= yes 10.endif 11 12SHLIB_VERSION_FILE?= ${.CURDIR}/shlib_version 13.if !defined(SHLIB_MAJOR) && exists(${SHLIB_VERSION_FILE}) 14SHLIB_MAJOR != . ${SHLIB_VERSION_FILE} ; echo $$major 15SHLIB_MINOR != . ${SHLIB_VERSION_FILE} ; echo $$minor 16SHLIB_TEENY != . ${SHLIB_VERSION_FILE} ; echo $$teeny 17.endif 18 19.for x in major minor teeny 20print-shlib-$x: 21.if defined(SHLIB_${x:tu}) && ${MK_PIC} != "no" 22 @echo ${SHLIB_${x:tu}} 23.else 24 @false 25.endif 26.endfor 27 28SHLIB_FULLVERSION ?= ${${SHLIB_MAJOR} ${SHLIB_MINOR} ${SHLIB_TEENY}:L:ts.} 29SHLIB_FULLVERSION := ${SHLIB_FULLVERSION} 30 31# add additional suffixes not exported. 32# .po is used for profiling object files. 33# ${PICO} is used for PIC object files. 34PICO?= .pico 35.SUFFIXES: .out .a .ln ${PICO} .po .o .s .S .c .cc .C .m .F .f .r .y .l .cl .p .h 36.SUFFIXES: .sh .m4 .m 37 38CFLAGS+= ${COPTS} 39 40# Originally derrived from NetBSD-1.6 41 42# Set PICFLAGS to cc flags for producing position-independent code, 43# if not already set. Includes -DPIC, if required. 44 45# Data-driven table using make variables to control how shared libraries 46# are built for different platforms and object formats. 47# OBJECT_FMT: currently either "ELF" or "a.out", from <bsd.own.mk> 48# SHLIB_SOVERSION: version number to be compiled into a shared library 49# via -soname. Usually ${SHLIB_MAJOR} on ELF. 50# NetBSD/pmax used to use ${SHLIB_MAJOR}[.${SHLIB_MINOR} 51# [.${SHLIB_TEENY}]] 52# SHLIB_SHFLAGS: Flags to tell ${LD} to emit shared library. 53# with ELF, also set shared-lib version for ld.so. 54# SHLIB_LDSTARTFILE: support .o file, call C++ file-level constructors 55# SHLIB_LDENDFILE: support .o file, call C++ file-level destructors 56# FPICFLAGS: flags for ${FC} to compile .[fF] files to ${PICO} objects. 57# CPPICFLAGS: flags for ${CPP} to preprocess .[sS] files for ${AS} 58# CPICFLAGS: flags for ${CC} to compile .[cC] files to ${PICO} objects. 59# CAPICFLAGS flags for {$CC} to compiling .[Ss] files 60# (usually just ${CPPPICFLAGS} ${CPICFLAGS}) 61# APICFLAGS: flags for ${AS} to assemble .[sS] to ${PICO} objects. 62 63.if ${TARGET_OSNAME} == "NetBSD" 64.if ${MACHINE_ARCH} == "alpha" 65 # Alpha-specific shared library flags 66FPICFLAGS ?= -fPIC 67CPICFLAGS ?= -fPIC -DPIC 68CPPPICFLAGS?= -DPIC 69CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS} 70APICFLAGS ?= 71.elif ${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb" 72 # mips-specific shared library flags 73 74# On mips, all libs are compiled with ABIcalls, not just sharedlibs. 75MKPICLIB= no 76 77# so turn shlib PIC flags on for ${AS}. 78AINC+=-DABICALLS 79AFLAGS+= -fPIC 80AS+= -KPIC 81 82.elif ${MACHINE_ARCH} == "vax" && ${OBJECT_FMT} == "ELF" 83# On the VAX, all object are PIC by default, not just sharedlibs. 84MKPICLIB= no 85 86.elif (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64") && \ 87 ${OBJECT_FMT} == "ELF" 88# If you use -fPIC you need to define BIGPIC to turn on 32-bit 89# relocations in asm code 90FPICFLAGS ?= -fPIC 91CPICFLAGS ?= -fPIC -DPIC 92CPPPICFLAGS?= -DPIC -DBIGPIC 93CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS} 94APICFLAGS ?= -KPIC 95 96.else 97 98# Platform-independent flags for NetBSD a.out shared libraries 99SHLIB_SOVERSION=${SHLIB_FULLVERSION} 100SHLIB_SHFLAGS= 101FPICFLAGS ?= -fPIC 102CPICFLAGS?= -fPIC -DPIC 103CPPPICFLAGS?= -DPIC 104CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS} 105APICFLAGS?= -k 106 107.endif 108 109# Platform-independent linker flags for ELF shared libraries 110.if ${OBJECT_FMT} == "ELF" 111SHLIB_SOVERSION= ${SHLIB_MAJOR} 112SHLIB_SHFLAGS= -soname lib${LIB}.so.${SHLIB_SOVERSION} 113SHLIB_LDSTARTFILE?= /usr/lib/crtbeginS.o 114SHLIB_LDENDFILE?= /usr/lib/crtendS.o 115.endif 116 117# for compatibility with the following 118CC_PIC?= ${CPICFLAGS} 119LD_shared=${SHLIB_SHFLAGS} 120 121.endif # NetBSD 122 123.if ${TARGET_OSNAME} == "FreeBSD" 124.if ${OBJECT_FMT} == "ELF" 125SHLIB_SOVERSION= ${SHLIB_MAJOR} 126SHLIB_SHFLAGS= -soname lib${LIB}.so.${SHLIB_SOVERSION} 127.else 128SHLIB_SHFLAGS= -assert pure-text 129.endif 130SHLIB_LDSTARTFILE= 131SHLIB_LDENDFILE= 132CC_PIC?= -fpic 133LD_shared=${SHLIB_SHFLAGS} 134 135.endif # FreeBSD 136 137MKPICLIB?= yes 138 139# sys.mk can override these 140LD_X?=-X 141LD_x?=-x 142LD_r?=-r 143 144# Non BSD machines will be using bmake. 145.if ${TARGET_OSNAME} == "SunOS" 146LD_shared=-assert pure-text 147.if ${OBJECT_FMT} == "ELF" || ${MACHINE} == "solaris" 148# Solaris 149LD_shared=-h lib${LIB}.so.${SHLIB_MAJOR} -G 150.endif 151.elif ${TARGET_OSNAME} == "HP-UX" 152LD_shared=-b 153LD_so=sl 154DLLIB= 155# HPsUX lorder does not grok anything but .o 156LD_sobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,${PICO},'` 157LD_pobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,.po,'` 158.elif ${TARGET_OSNAME} == "OSF1" 159LD_shared= -msym -shared -expect_unresolved '*' 160LD_solib= -all lib${LIB}_pic.a 161DLLIB= 162# lorder does not grok anything but .o 163LD_sobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,${PICO},'` 164LD_pobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,.po,'` 165AR_cq= -cqs 166.elif ${TARGET_OSNAME} == "FreeBSD" 167LD_solib= lib${LIB}_pic.a 168.elif ${TARGET_OSNAME} == "Linux" 169SHLIB_LD = ${CC} 170# this is ambiguous of course 171LD_shared=-shared -Wl,"-h lib${LIB}.so.${SHLIB_MAJOR}" 172LD_solib= -Wl,--whole-archive lib${LIB}_pic.a -Wl,--no-whole-archive 173# Linux uses GNU ld, which is a multi-pass linker 174# so we don't need to use lorder or tsort 175LD_objs = ${OBJS} 176LD_pobjs = ${POBJS} 177LD_sobjs = ${SOBJS} 178.elif ${TARGET_OSNAME} == "Darwin" 179SHLIB_LD = ${CC} 180SHLIB_INSTALL_VERSION ?= ${SHLIB_MAJOR} 181SHLIB_COMPATABILITY_VERSION ?= ${SHLIB_MAJOR}.${SHLIB_MINOR:U0} 182SHLIB_COMPATABILITY ?= \ 183 -compatibility_version ${SHLIB_COMPATABILITY_VERSION} \ 184 -current_version ${SHLIB_FULLVERSION} 185LD_shared = -dynamiclib \ 186 -flat_namespace -undefined suppress \ 187 -install_name ${LIBDIR}/lib${LIB}.${SHLIB_INSTALL_VERSION}.${LD_solink} \ 188 ${SHLIB_COMPATABILITY} 189SHLIB_LINKS = 190.for v in ${SHLIB_COMPATABILITY_VERSION} ${SHLIB_INSTALL_VERSION} 191.if "$v" != "${SHLIB_FULLVERSION}" 192SHLIB_LINKS += lib${LIB}.$v.${LD_solink} 193.endif 194.endfor 195.if ${MK_LINKLIB} != "no" 196SHLIB_LINKS += lib${LIB}.${LD_solink} 197.endif 198 199LD_so = ${SHLIB_FULLVERSION}.dylib 200LD_sobjs = ${SOBJS:O:u} 201LD_solib = ${LD_sobjs} 202SOLIB = ${LD_sobjs} 203LD_solink = dylib 204.if ${MACHINE_ARCH} == "i386" 205PICFLAG ?= -fPIC 206.else 207PICFLAG ?= -fPIC -fno-common 208.endif 209RANLIB = : 210.endif 211 212SHLIB_LD ?= ${LD} 213 214.if !empty(SHLIB_MAJOR) 215.if ${NEED_SOLINKS} && empty(SHLIB_LINKS) 216.if ${MK_LINKLIB} != "no" 217SHLIB_LINKS = lib${LIB}.${LD_solink} 218.endif 219.if "${SHLIB_FULLVERSION}" != "${SHLIB_MAJOR}" 220SHLIB_LINKS += lib${LIB}.${LD_solink}.${SHLIB_MAJOR} 221.endif 222.endif 223.endif 224 225LIBTOOL?=libtool 226LD_shared ?= -Bshareable -Bforcearchive 227LD_so ?= so.${SHLIB_FULLVERSION} 228LD_solink ?= so 229.if empty(LORDER) 230LD_objs ?= ${OBJS} 231LD_pobjs ?= ${POBJS} 232LD_sobjs ?= ${SOBJS} 233.else 234LD_objs ?= `${LORDER} ${OBJS} | ${TSORT}` 235LD_sobjs ?= `${LORDER} ${SOBJS} | ${TSORT}` 236LD_pobjs ?= `${LORDER} ${POBJS} | ${TSORT}` 237.endif 238LD_solib ?= ${LD_sobjs} 239AR_cq ?= cq 240.if exists(/netbsd) && exists(${DESTDIR}/usr/lib/libdl.so) 241DLLIB ?= -ldl 242.endif 243 244# some libs have lots of objects, and scanning all .o, .po and ${PICO} meta files 245# is a waste of time, this tells meta.autodep.mk to just pick one 246# (typically ${PICO}) 247# yes, 42 is a random number. 248.if ${MK_DIRDEPS_BUILD} == "yes" && ${SRCS:Uno:[\#]} > 42 249OPTIMIZE_OBJECT_META_FILES ?= yes 250.endif 251 252 253.if ${MK_LIBTOOL} == "yes" 254# because libtool is so fascist about naming the object files, 255# we cannot (yet) build profiled libs 256MK_PROFILE=no 257_LIBS=lib${LIB}.a 258.if exists(${.CURDIR}/shlib_version) 259SHLIB_AGE != . ${.CURDIR}/shlib_version ; echo $$age 260.endif 261.else 262# for the normal .a we do not want to strip symbols 263.c.o: 264 ${COMPILE.c} ${.IMPSRC} 265 266# for the normal .a we do not want to strip symbols 267${CXX_SUFFIXES:%=%.o}: 268 ${COMPILE.cc} ${.IMPSRC} 269 270.S.o .s.o: 271 ${COMPILE.S} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} 272 273.if (${LD_X} == "") 274.c.po: 275 ${COMPILE.c} ${CC_PG} ${PROFFLAGS} ${.IMPSRC} -o ${.TARGET} 276 277${CXX_SUFFIXES:%=%.po}: 278 ${COMPILE.cc} -pg ${.IMPSRC} -o ${.TARGET} 279 280.S${PICO} .s${PICO}: 281 ${COMPILE.S} ${PICFLAG} ${CC_PIC} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET} 282.else 283.c.po: 284 ${COMPILE.c} ${CC_PG} ${PROFFLAGS} ${.IMPSRC} -o ${.TARGET}.o 285 @${LD} ${LD_X} ${LD_r} ${.TARGET}.o -o ${.TARGET} 286 @rm -f ${.TARGET}.o 287 288${CXX_SUFFIXES:%=%.po}: 289 ${COMPILE.cc} ${CXX_PG} ${.IMPSRC} -o ${.TARGET}.o 290 ${LD} ${LD_X} ${LD_r} ${.TARGET}.o -o ${.TARGET} 291 @rm -f ${.TARGET}.o 292 293.S${PICO} .s${PICO}: 294 ${COMPILE.S} ${PICFLAG} ${CC_PIC} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o 295 ${LD} ${LD_x} ${LD_r} ${.TARGET}.o -o ${.TARGET} 296 @rm -f ${.TARGET}.o 297.endif 298 299.if (${LD_x} == "") 300.c${PICO}: 301 ${COMPILE.c} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET} 302 303${CXX_SUFFIXES:%=%${PICO}}: 304 ${COMPILE.cc} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET} 305 306.S.po .s.po: 307 ${COMPILE.S} ${PROFFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET} 308.else 309 310.c${PICO}: 311 ${COMPILE.c} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}.o 312 ${LD} ${LD_x} ${LD_r} ${.TARGET}.o -o ${.TARGET} 313 @rm -f ${.TARGET}.o 314 315${CXX_SUFFIXES:%=%${PICO}}: 316 ${COMPILE.cc} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}.o 317 ${LD} ${LD_x} ${LD_r} ${.TARGET}.o -o ${.TARGET} 318 @rm -f ${.TARGET}.o 319 320.S.po .s.po: 321 ${COMPILE.S} ${PROFFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o 322 ${LD} ${LD_X} ${LD_r} ${.TARGET}.o -o ${.TARGET} 323 @rm -f ${.TARGET}.o 324 325.endif 326.endif 327 328.c.ln: 329 ${LINT} ${LINTFLAGS} ${CFLAGS:M-[IDU]*} -i ${.IMPSRC} 330 331.if ${MK_LIBTOOL} != "yes" 332 333.if !defined(PICFLAG) 334PICFLAG=-fpic 335.endif 336 337_LIBS= 338 339.if ${MK_ARCHIVE} != "no" 340_LIBS += lib${LIB}.a 341.endif 342 343.if ${MK_PROFILE} != "no" 344_LIBS+=lib${LIB}_p.a 345POBJS+=${OBJS:.o=.po} 346.endif 347 348.if ${MK_PIC} != "no" 349.if ${MK_PICLIB} == "no" 350SOLIB ?= lib${LIB}.a 351.else 352SOLIB=lib${LIB}_pic.a 353_LIBS+=${SOLIB} 354.endif 355.if !empty(SHLIB_FULLVERSION) 356_LIBS+=lib${LIB}.${LD_so} 357.endif 358.endif 359 360.if ${MK_LINT} != "no" 361_LIBS+=llib-l${LIB}.ln 362.endif 363 364# here is where you can define what LIB* are 365.-include <libnames.mk> 366.if ${MK_DPADD_MK} == "yes" 367# lots of cool magic, but might not suit everyone. 368.include <dpadd.mk> 369.endif 370 371.if empty(LIB) 372_LIBS= 373.endif 374 375.if !defined(_SKIP_BUILD) 376realbuild: ${_LIBS} 377.endif 378 379all: _SUBDIRUSE 380 381.for s in ${SRCS:N*.h:M*/*} 382${.o ${PICO} .po .lo:L:@o@${s:T:R}$o@}: $s 383.endfor 384 385OBJS+= ${SRCS:T:N*.h:R:S/$/.o/g} 386.NOPATH: ${OBJS} 387 388.if ${MK_LIBTOOL} == "yes" 389.if ${MK_PIC} == "no" 390LT_STATIC=-static 391.else 392LT_STATIC= 393.endif 394SHLIB_AGE?=0 395 396# .lo's are created as a side effect 397.s.o .S.o .c.o: 398 ${LIBTOOL} --mode=compile ${CC} ${LT_STATIC} ${CFLAGS} ${CPPFLAGS} ${IMPFLAGS} -c ${.IMPSRC} 399 400# can't really do profiled libs with libtool - its too fascist about 401# naming the output... 402lib${LIB}.a:: ${OBJS} 403 @rm -f ${.TARGET} 404 ${LIBTOOL} --mode=link ${CC} ${LT_STATIC} -o ${.TARGET:.a=.la} ${OBJS:.o=.lo} -rpath ${SHLIBDIR}:/usr/lib -version-info ${SHLIB_MAJOR}:${SHLIB_MINOR}:${SHLIB_AGE} 405 @ln .libs/${.TARGET} . 406 407lib${LIB}.${LD_so}:: lib${LIB}.a 408 @[ -s ${.TARGET}.${SHLIB_AGE} ] || { ln -s .libs/lib${LIB}.${LD_so}* . 2>/dev/null; : } 409 @[ -s ${.TARGET} ] || ln -s ${.TARGET}.${SHLIB_AGE} ${.TARGET} 410 411.else # MK_LIBTOOL=yes 412 413lib${LIB}.a:: ${OBJS} 414 @${META_NOECHO} building standard ${LIB} library 415 @rm -f ${.TARGET} 416 @${AR} ${AR_cq} ${.TARGET} ${LD_objs} 417 ${RANLIB} ${.TARGET} 418 419POBJS+= ${OBJS:.o=.po} 420.NOPATH: ${POBJS} 421lib${LIB}_p.a:: ${POBJS} 422 @${META_NOECHO} building profiled ${LIB} library 423 @rm -f ${.TARGET} 424 @${AR} ${AR_cq} ${.TARGET} ${LD_pobjs} 425 ${RANLIB} ${.TARGET} 426 427SOBJS+= ${OBJS:.o=${PICO}} 428.NOPATH: ${SOBJS} 429lib${LIB}_pic.a:: ${SOBJS} 430 @${META_NOECHO} building shared object ${LIB} library 431 @rm -f ${.TARGET} 432 @${AR} ${AR_cq} ${.TARGET} ${LD_sobjs} 433 ${RANLIB} ${.TARGET} 434 435#SHLIB_LDADD?= ${LDADD} 436 437# bound to be non-portable... 438# this is known to work for NetBSD 1.6 and FreeBSD 4.2 439lib${LIB}.${LD_so}: ${SOLIB} ${DPADD} 440 @${META_NOECHO} building shared ${LIB} library \(version ${SHLIB_FULLVERSION}\) 441 @rm -f ${.TARGET} 442.if ${TARGET_OSNAME} == "NetBSD" || ${TARGET_OSNAME} == "FreeBSD" 443.if ${OBJECT_FMT} == "ELF" 444 ${SHLIB_LD} -x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \ 445 ${SHLIB_LDSTARTFILE} \ 446 --whole-archive ${SOLIB} --no-whole-archive ${SHLIB_LDADD} \ 447 ${SHLIB_LDENDFILE} 448.else 449 ${SHLIB_LD} ${LD_x} ${LD_shared} \ 450 -o ${.TARGET} ${SOLIB} ${SHLIB_LDADD} 451.endif 452.else 453 ${SHLIB_LD} -o ${.TARGET} ${LD_shared} ${LD_solib} ${DLLIB} ${SHLIB_LDADD} 454.endif 455.endif 456.if !empty(SHLIB_LINKS) 457 rm -f ${SHLIB_LINKS}; ${SHLIB_LINKS:O:u:@x@ln -s ${.TARGET} $x;@} 458.endif 459 460LOBJS+= ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln} 461.NOPATH: ${LOBJS} 462LLIBS?= -lc 463llib-l${LIB}.ln: ${LOBJS} 464 @${META_NOECHO} building llib-l${LIB}.ln 465 @rm -f llib-l${LIB}.ln 466 @${LINT} -C${LIB} ${LOBJS} ${LLIBS} 467 468.if !target(clean) 469cleanlib: .PHONY 470 rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES} 471 rm -f lib${LIB}.a ${OBJS} 472 rm -f lib${LIB}_p.a ${POBJS} 473 rm -f lib${LIB}_pic.a lib${LIB}.so.*.* ${SOBJS} 474 rm -f llib-l${LIB}.ln ${LOBJS} 475.if !empty(SHLIB_LINKS) 476 rm -f ${SHLIB_LINKS} 477.endif 478 479clean: _SUBDIRUSE cleanlib 480cleandir: _SUBDIRUSE cleanlib 481.else 482cleandir: _SUBDIRUSE clean 483.endif 484 485.if defined(SRCS) && (!defined(MKDEP) || ${MKDEP} != autodep) 486afterdepend: .depend 487 @(TMP=/tmp/_depend$$$$; \ 488 sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1${PICO} \1.ln:/' \ 489 < .depend > $$TMP; \ 490 mv $$TMP .depend) 491.endif 492 493.if !target(install) 494.if !target(beforeinstall) 495beforeinstall: 496.endif 497 498.if !empty(LIBOWN) 499LIB_INSTALL_OWN ?= -o ${LIBOWN} -g ${LIBGRP} 500.endif 501 502.include <links.mk> 503 504.if !target(libinstall) && !empty(LIB) 505realinstall: libinstall 506libinstall: 507 [ -d ${DESTDIR}/${LIBDIR} ] || \ 508 ${INSTALL} -d ${LIB_INSTALL_OWN} -m 775 ${DESTDIR}${LIBDIR} 509.if ${MK_ARCHIVE} != "no" 510 ${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m 600 lib${LIB}.a \ 511 ${DESTDIR}${LIBDIR} 512 ${RANLIB} ${DESTDIR}${LIBDIR}/lib${LIB}.a 513 chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}.a 514.endif 515.if ${MK_PROFILE} != "no" 516 ${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m 600 \ 517 lib${LIB}_p.a ${DESTDIR}${LIBDIR} 518 ${RANLIB} ${DESTDIR}${LIBDIR}/lib${LIB}_p.a 519 chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_p.a 520.endif 521.if ${MK_PIC} != "no" 522.if ${MK_PICLIB} != "no" 523 ${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m 600 \ 524 lib${LIB}_pic.a ${DESTDIR}${LIBDIR} 525 ${RANLIB} ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a 526 chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a 527.endif 528.if !empty(SHLIB_MAJOR) 529 ${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m ${LIBMODE} \ 530 lib${LIB}.${LD_so} ${DESTDIR}${LIBDIR} 531.if !empty(SHLIB_LINKS) 532 (cd ${DESTDIR}${LIBDIR} && { rm -f ${SHLIB_LINKS}; ${SHLIB_LINKS:O:u:@x@ln -s lib${LIB}.${LD_so} $x;@} }) 533.endif 534.endif 535.endif 536.if ${MK_LINT} != "no" && ${MK_LINKLIB} != "no" && !empty(LOBJS) 537 ${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m ${LIBMODE} \ 538 llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR} 539.endif 540.if defined(LINKS) && !empty(LINKS) 541 @set ${LINKS}; ${_LINKS_SCRIPT} 542.endif 543.endif 544 545.if ${MK_MAN} != "no" 546install: maninstall _SUBDIRUSE 547maninstall: afterinstall 548.endif 549afterinstall: realinstall 550libinstall: beforeinstall 551realinstall: beforeinstall 552.endif 553 554.if defined(FILES) || defined(FILESGROUPS) 555.include <files.mk> 556.endif 557 558.if ${MK_MAN} != "no" 559.include <man.mk> 560.endif 561 562.if ${MK_NLS} != "no" 563.include <nls.mk> 564.endif 565 566.include <obj.mk> 567.include <inc.mk> 568.include <dep.mk> 569.include <subdir.mk> 570.endif 571 572# during building we usually need/want to install libs somewhere central 573# note that we do NOT ch{own,grp} as that would likely fail at this point. 574# otherwise it is the same as realinstall 575# Note that we don't need this when using dpadd.mk 576.libinstall: ${_LIBS} 577 test -d ${DESTDIR}${LIBDIR} || ${INSTALL} -d -m775 ${DESTDIR}${LIBDIR} 578.for _lib in ${_LIBS:M*.a} 579 ${INSTALL} ${COPY} -m 644 ${_lib} ${DESTDIR}${LIBDIR} 580 ${RANLIB} ${DESTDIR}${LIBDIR}/${_lib} 581.endfor 582.for _lib in ${_LIBS:M*.${LD_solink}*:O:u} 583 ${INSTALL} ${COPY} -m ${LIBMODE} ${_lib} ${DESTDIR}${LIBDIR} 584.if !empty(SHLIB_LINKS) 585 (cd ${DESTDIR}${LIBDIR} && { ${SHLIB_LINKS:O:u:@x@ln -sf ${_lib} $x;@}; }) 586.endif 587.endfor 588 @touch ${.TARGET} 589 590.if !empty(LIB) 591STAGE_LIBDIR?= ${STAGE_OBJTOP}${LIBDIR} 592stage_libs: ${_LIBS} 593.endif 594 595.include <final.mk> 596.endif 597