1# $Id: lib.mk,v 1.61 2017/05/06 17:30:09 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 @echo ${COMPILE.S} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} 272 @${COMPILE.S} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} 273 274.if (${LD_X} == "") 275.c.po: 276 ${COMPILE.c} ${CC_PG} ${PROFFLAGS} ${.IMPSRC} -o ${.TARGET} 277 278${CXX_SUFFIXES:%=%.po}: 279 ${COMPILE.cc} -pg ${.IMPSRC} -o ${.TARGET} 280 281.S${PICO} .s${PICO}: 282 ${COMPILE.S} ${PICFLAG} ${CC_PIC} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET} 283.else 284.c.po: 285 @echo ${COMPILE.c} ${CC_PG} ${PROFFLAGS} ${.IMPSRC} -o ${.TARGET} 286 @${COMPILE.c} ${CC_PG} ${PROFFLAGS} ${.IMPSRC} -o ${.TARGET}.o 287 @${LD} ${LD_X} ${LD_r} ${.TARGET}.o -o ${.TARGET} 288 @rm -f ${.TARGET}.o 289 290${CXX_SUFFIXES:%=%.po}: 291 @echo ${COMPILE.cc} ${CXX_PG} ${PROFFLAGS} ${.IMPSRC} -o ${.TARGET} 292 @${COMPILE.cc} ${CXX_PG} ${.IMPSRC} -o ${.TARGET}.o 293 @${LD} ${LD_X} ${LD_r} ${.TARGET}.o -o ${.TARGET} 294 @rm -f ${.TARGET}.o 295 296.S${PICO} .s${PICO}: 297 @echo ${COMPILE.S} ${PICFLAG} ${CC_PIC} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET} 298 @${COMPILE.S} ${PICFLAG} ${CC_PIC} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o 299 @${LD} ${LD_x} ${LD_r} ${.TARGET}.o -o ${.TARGET} 300 @rm -f ${.TARGET}.o 301.endif 302 303.if (${LD_x} == "") 304.c${PICO}: 305 ${COMPILE.c} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET} 306 307${CXX_SUFFIXES:%=%${PICO}}: 308 ${COMPILE.cc} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET} 309 310.S.po .s.po: 311 ${COMPILE.S} ${PROFFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET} 312.else 313 314.c${PICO}: 315 @echo ${COMPILE.c} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET} 316 @${COMPILE.c} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}.o 317 @${LD} ${LD_x} ${LD_r} ${.TARGET}.o -o ${.TARGET} 318 @rm -f ${.TARGET}.o 319 320${CXX_SUFFIXES:%=%${PICO}}: 321 @echo ${COMPILE.cc} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET} 322 @${COMPILE.cc} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}.o 323 @${LD} ${LD_x} ${LD_r} ${.TARGET}.o -o ${.TARGET} 324 @rm -f ${.TARGET}.o 325 326.S.po .s.po: 327 @echo ${COMPILE.S} ${PROFFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET} 328 @${COMPILE.S} ${PROFFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o 329 @${LD} ${LD_X} ${LD_r} ${.TARGET}.o -o ${.TARGET} 330 @rm -f ${.TARGET}.o 331 332.endif 333.endif 334 335.c.ln: 336 ${LINT} ${LINTFLAGS} ${CFLAGS:M-[IDU]*} -i ${.IMPSRC} 337 338.if ${MK_LIBTOOL} != "yes" 339 340.if !defined(PICFLAG) 341PICFLAG=-fpic 342.endif 343 344_LIBS= 345 346.if ${MK_ARCHIVE} != "no" 347_LIBS += lib${LIB}.a 348.endif 349 350.if ${MK_PROFILE} != "no" 351_LIBS+=lib${LIB}_p.a 352POBJS+=${OBJS:.o=.po} 353.endif 354 355.if ${MK_PIC} != "no" 356.if ${MK_PICLIB} == "no" 357SOLIB ?= lib${LIB}.a 358.else 359SOLIB=lib${LIB}_pic.a 360_LIBS+=${SOLIB} 361.endif 362.if !empty(SHLIB_FULLVERSION) 363_LIBS+=lib${LIB}.${LD_so} 364.endif 365.endif 366 367.if ${MK_LINT} != "no" 368_LIBS+=llib-l${LIB}.ln 369.endif 370 371# here is where you can define what LIB* are 372.-include <libnames.mk> 373.if ${MK_DPADD_MK} == "yes" 374# lots of cool magic, but might not suit everyone. 375.include <dpadd.mk> 376.endif 377 378.if empty(LIB) 379_LIBS= 380.endif 381 382.if !defined(_SKIP_BUILD) 383realbuild: ${_LIBS} 384.endif 385 386all: _SUBDIRUSE 387 388.for s in ${SRCS:N*.h:M*/*} 389${.o ${PICO} .po .lo:L:@o@${s:T:R}$o@}: $s 390.endfor 391 392OBJS+= ${SRCS:T:N*.h:R:S/$/.o/g} 393.NOPATH: ${OBJS} 394 395.if ${MK_LIBTOOL} == "yes" 396.if ${MK_PIC} == "no" 397LT_STATIC=-static 398.else 399LT_STATIC= 400.endif 401SHLIB_AGE?=0 402 403# .lo's are created as a side effect 404.s.o .S.o .c.o: 405 ${LIBTOOL} --mode=compile ${CC} ${LT_STATIC} ${CFLAGS} ${CPPFLAGS} ${IMPFLAGS} -c ${.IMPSRC} 406 407# can't really do profiled libs with libtool - its too fascist about 408# naming the output... 409lib${LIB}.a:: ${OBJS} 410 @rm -f ${.TARGET} 411 ${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} 412 @ln .libs/${.TARGET} . 413 414lib${LIB}.${LD_so}:: lib${LIB}.a 415 @[ -s ${.TARGET}.${SHLIB_AGE} ] || { ln -s .libs/lib${LIB}.${LD_so}* . 2>/dev/null; : } 416 @[ -s ${.TARGET} ] || ln -s ${.TARGET}.${SHLIB_AGE} ${.TARGET} 417 418.else # MK_LIBTOOL=yes 419 420lib${LIB}.a:: ${OBJS} 421 @echo building standard ${LIB} library 422 @rm -f ${.TARGET} 423 @${AR} ${AR_cq} ${.TARGET} ${LD_objs} 424 ${RANLIB} ${.TARGET} 425 426POBJS+= ${OBJS:.o=.po} 427.NOPATH: ${POBJS} 428lib${LIB}_p.a:: ${POBJS} 429 @echo building profiled ${LIB} library 430 @rm -f ${.TARGET} 431 @${AR} ${AR_cq} ${.TARGET} ${LD_pobjs} 432 ${RANLIB} ${.TARGET} 433 434SOBJS+= ${OBJS:.o=${PICO}} 435.NOPATH: ${SOBJS} 436lib${LIB}_pic.a:: ${SOBJS} 437 @echo building shared object ${LIB} library 438 @rm -f ${.TARGET} 439 @${AR} ${AR_cq} ${.TARGET} ${LD_sobjs} 440 ${RANLIB} ${.TARGET} 441 442#SHLIB_LDADD?= ${LDADD} 443 444# bound to be non-portable... 445# this is known to work for NetBSD 1.6 and FreeBSD 4.2 446lib${LIB}.${LD_so}: ${SOLIB} ${DPADD} 447 @echo building shared ${LIB} library \(version ${SHLIB_FULLVERSION}\) 448 @rm -f ${.TARGET} 449.if ${TARGET_OSNAME} == "NetBSD" || ${TARGET_OSNAME} == "FreeBSD" 450.if ${OBJECT_FMT} == "ELF" 451 ${SHLIB_LD} -x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \ 452 ${SHLIB_LDSTARTFILE} \ 453 --whole-archive ${SOLIB} --no-whole-archive ${SHLIB_LDADD} \ 454 ${SHLIB_LDENDFILE} 455.else 456 ${SHLIB_LD} ${LD_x} ${LD_shared} \ 457 -o ${.TARGET} ${SOLIB} ${SHLIB_LDADD} 458.endif 459.else 460 ${SHLIB_LD} -o ${.TARGET} ${LD_shared} ${LD_solib} ${DLLIB} ${SHLIB_LDADD} 461.endif 462.endif 463.if !empty(SHLIB_LINKS) 464 rm -f ${SHLIB_LINKS}; ${SHLIB_LINKS:O:u:@x@ln -s ${.TARGET} $x;@} 465.endif 466 467LOBJS+= ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln} 468.NOPATH: ${LOBJS} 469LLIBS?= -lc 470llib-l${LIB}.ln: ${LOBJS} 471 @echo building llib-l${LIB}.ln 472 @rm -f llib-l${LIB}.ln 473 @${LINT} -C${LIB} ${LOBJS} ${LLIBS} 474 475.if !target(clean) 476cleanlib: .PHONY 477 rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES} 478 rm -f lib${LIB}.a ${OBJS} 479 rm -f lib${LIB}_p.a ${POBJS} 480 rm -f lib${LIB}_pic.a lib${LIB}.so.*.* ${SOBJS} 481 rm -f llib-l${LIB}.ln ${LOBJS} 482.if !empty(SHLIB_LINKS) 483 rm -f ${SHLIB_LINKS} 484.endif 485 486clean: _SUBDIRUSE cleanlib 487cleandir: _SUBDIRUSE cleanlib 488.else 489cleandir: _SUBDIRUSE clean 490.endif 491 492.if defined(SRCS) && (!defined(MKDEP) || ${MKDEP} != autodep) 493afterdepend: .depend 494 @(TMP=/tmp/_depend$$$$; \ 495 sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1${PICO} \1.ln:/' \ 496 < .depend > $$TMP; \ 497 mv $$TMP .depend) 498.endif 499 500.if !target(install) 501.if !target(beforeinstall) 502beforeinstall: 503.endif 504 505.if !empty(LIBOWN) 506LIB_INSTALL_OWN ?= -o ${LIBOWN} -g ${LIBGRP} 507.endif 508 509.include <links.mk> 510 511.if !target(realinstall) && !empty(LIB) 512realinstall: libinstall 513.endif 514.if !target(libinstall) 515libinstall: 516 [ -d ${DESTDIR}/${LIBDIR} ] || \ 517 ${INSTALL} -d ${LIB_INSTALL_OWN} -m 775 ${DESTDIR}${LIBDIR} 518.if ${MK_ARCHIVE} != "no" 519 ${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m 600 lib${LIB}.a \ 520 ${DESTDIR}${LIBDIR} 521 ${RANLIB} ${DESTDIR}${LIBDIR}/lib${LIB}.a 522 chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}.a 523.endif 524.if ${MK_PROFILE} != "no" 525 ${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m 600 \ 526 lib${LIB}_p.a ${DESTDIR}${LIBDIR} 527 ${RANLIB} ${DESTDIR}${LIBDIR}/lib${LIB}_p.a 528 chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_p.a 529.endif 530.if ${MK_PIC} != "no" 531.if ${MK_PICLIB} != "no" 532 ${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m 600 \ 533 lib${LIB}_pic.a ${DESTDIR}${LIBDIR} 534 ${RANLIB} ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a 535 chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a 536.endif 537.if !empty(SHLIB_MAJOR) 538 ${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m ${LIBMODE} \ 539 lib${LIB}.${LD_so} ${DESTDIR}${LIBDIR} 540.if !empty(SHLIB_LINKS) 541 (cd ${DESTDIR}${LIBDIR} && { rm -f ${SHLIB_LINKS}; ${SHLIB_LINKS:O:u:@x@ln -s lib${LIB}.${LD_so} $x;@} }) 542.endif 543.endif 544.endif 545.if ${MK_LINT} != "no" && ${MK_LINKLIB} != "no" && !empty(LOBJS) 546 ${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m ${LIBMODE} \ 547 llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR} 548.endif 549.if defined(LINKS) && !empty(LINKS) 550 @set ${LINKS}; ${_LINKS_SCRIPT} 551.endif 552.endif 553 554.if ${MK_MAN} != "no" 555install: maninstall _SUBDIRUSE 556maninstall: afterinstall 557.endif 558afterinstall: realinstall 559libinstall: beforeinstall 560realinstall: beforeinstall 561.endif 562 563.if defined(FILES) || defined(FILESGROUPS) 564.include <files.mk> 565.endif 566 567.if ${MK_MAN} != "no" 568.include <man.mk> 569.endif 570 571.if ${MK_NLS} != "no" 572.include <nls.mk> 573.endif 574 575.include <obj.mk> 576.include <inc.mk> 577.include <dep.mk> 578.include <subdir.mk> 579.endif 580 581# during building we usually need/want to install libs somewhere central 582# note that we do NOT ch{own,grp} as that would likely fail at this point. 583# otherwise it is the same as realinstall 584# Note that we don't need this when using dpadd.mk 585.libinstall: ${_LIBS} 586 test -d ${DESTDIR}${LIBDIR} || ${INSTALL} -d -m775 ${DESTDIR}${LIBDIR} 587.for _lib in ${_LIBS:M*.a} 588 ${INSTALL} ${COPY} -m 644 ${_lib} ${DESTDIR}${LIBDIR} 589 ${RANLIB} ${DESTDIR}${LIBDIR}/${_lib} 590.endfor 591.for _lib in ${_LIBS:M*.${LD_solink}*:O:u} 592 ${INSTALL} ${COPY} -m ${LIBMODE} ${_lib} ${DESTDIR}${LIBDIR} 593.if !empty(SHLIB_LINKS) 594 (cd ${DESTDIR}${LIBDIR} && { ${SHLIB_LINKS:O:u:@x@ln -sf ${_lib} $x;@}; }) 595.endif 596.endfor 597 @touch ${.TARGET} 598 599.if !empty(LIB) 600STAGE_LIBDIR?= ${STAGE_OBJTOP}${LIBDIR} 601stage_libs: ${_LIBS} 602.endif 603 604.include <final.mk> 605.endif 606