Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. =================================================================== RCS file: /ftp/cvs/cvsroot/src/share/mk/bsd.lib.mk,v rcsdiff: /ftp/cvs/cvsroot/src/share/mk/bsd.lib.mk,v: warning: Unknown phrases like `commitid ...;' are present. retrieving revision 1.306 retrieving revision 1.316 diff -u -p -r1.306 -r1.316 --- src/share/mk/bsd.lib.mk 2010/04/26 03:46:00 1.306 +++ src/share/mk/bsd.lib.mk 2011/09/10 16:57:35 1.316 @@ -1,4 +1,4 @@ -# $NetBSD: bsd.lib.mk,v 1.306 2010/04/26 03:46:00 lukem Exp $ +# $NetBSD: bsd.lib.mk,v 1.316 2011/09/10 16:57:35 apb Exp $ # @(#)bsd.lib.mk 8.3 (Berkeley) 4/22/94 .include @@ -37,7 +37,6 @@ MKPROFILE:= no ##### Basic targets .PHONY: checkver libinstall realinstall: checkver libinstall -clean: cleanlib ##### LIB specific flags. # XXX: This is needed for programs that link with .a libraries @@ -63,16 +62,6 @@ DPADD+= ${LIBDO.${_lib}}/lib${_lib}.so ##### Build and install rules MKDEP_SUFFIXES?= .o .po .pico .go .ln -# Use purely kernel private headers in rump builds -.if !defined(RUMPKERNEL) -.if empty(CPPFLAGS:M-nostdinc) -CPPFLAGS+= ${DESTDIR:D-nostdinc ${CPPFLAG_ISYSTEM} ${DESTDIR}/usr/include} -.endif -.if empty(CXXFLAGS:M-nostdinc++) -CXXFLAGS+= ${DESTDIR:D-nostdinc++ ${CPPFLAG_ISYSTEMXX} ${DESTDIR}/usr/include/g++} -.endif -.endif - .if !defined(SHLIB_MAJOR) && exists(${SHLIB_VERSION_FILE}) # { SHLIB_MAJOR != . ${SHLIB_VERSION_FILE} ; echo $$major SHLIB_MINOR != . ${SHLIB_VERSION_FILE} ; echo $$minor @@ -140,7 +129,6 @@ SHLIB_FULLVERSION=${SHLIB_MAJOR} # Data-driven table using make variables to control how shared libraries # are built for different platforms and object formats. -# OBJECT_FMT: currently either "ELF" or "a.out", from # SHLIB_MAJOR, SHLIB_MINOR, SHLIB_TEENY: Major, minor, and teeny version # numbers of shared library # SHLIB_SOVERSION: version number to be compiled into a shared library @@ -168,8 +156,7 @@ CPPPICFLAGS?= -DPIC CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS} APICFLAGS ?= -.elif (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64") && \ - ${OBJECT_FMT} == "ELF" # } { +.elif (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64") # } { # If you use -fPIC you need to define BIGPIC to turn on 32-bit # relocations in asm code @@ -203,13 +190,11 @@ MKSHLIBOBJS= no .endif # Platform-independent linker flags for ELF shared libraries -.if ${OBJECT_FMT} == "ELF" SHLIB_SOVERSION= ${SHLIB_MAJOR} SHLIB_SHFLAGS= -Wl,-soname,${_LIB_PREFIX}${LIB}.so.${SHLIB_SOVERSION} SHLIB_SHFLAGS+= -Wl,--warn-shared-textrel SHLIB_LDSTARTFILE?= ${_GCC_CRTDIR}/crti.o ${_GCC_CRTBEGINS} SHLIB_LDENDFILE?= ${_GCC_CRTENDS} ${_GCC_CRTDIR}/crtn.o -.endif CFLAGS+= ${COPTS} OBJCFLAGS+= ${OBJCOPTS} @@ -445,6 +430,10 @@ _LIBS+=${SOLIB} SOBJS+=${OBJS:.o=.pico} .endif .if defined(SHLIB_FULLVERSION) +_LIB.so:=lib${LIB}.so.${SHLIB_FULLVERSION} +.if ${MKDEBUG} != "no" +_LIB.debug:=${_LIB.so}.debug +.endif _LIBS+=lib${LIB}.so.${SHLIB_FULLVERSION} .endif .endif # } @@ -471,7 +460,7 @@ _YLSRCS= ${SRCS:M*.[ly]:C/\..$/.c/} ${YH .NOPATH: ${ALLOBJS} ${_LIBS} ${_YLSRCS} -realall: ${SRCS} ${ALLOBJS:O} ${_LIBS} +realall: ${SRCS} ${ALLOBJS:O} ${_LIBS} ${_LIB.debug} MKARZERO?=no @@ -521,12 +510,11 @@ lib${LIB}_g.a:: ${GOBJS} __archivebuild _LIBLDOPTS= .if ${SHLIBDIR} != "/usr/lib" -_LIBLDOPTS+= -Wl,-rpath-link,${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr/lib \ - -R${SHLIBDIR} \ - -L${DESTDIR}${SHLIBDIR} +_LIBLDOPTS+= -Wl,-rpath,${SHLIBDIR} \ + -L=${SHLIBDIR} .elif ${SHLIBINSTALLDIR} != "/usr/lib" -_LIBLDOPTS+= -Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR}:${DESTDIR}/usr/lib \ - -L${DESTDIR}${SHLIBINSTALLDIR} +_LIBLDOPTS+= -Wl,-rpath-link,${DESTDIR}${SHLIBINSTALLDIR} \ + -L=${SHLIBINSTALLDIR} .endif # gcc -shared now adds -lc automatically. For libraries other than libc and @@ -535,10 +523,14 @@ _LIBLDOPTS+= -Wl,-rpath-link,${DESTDIR}$ # -Xl,-nostdlib is not enough because we want to tell the compiler-driver not # to add standard libraries, not the linker. .if !defined(LIB) +.if !empty(LIBC_SO) DPLIBC ?= ${DESTDIR}${LIBC_SO} +.endif .else .if ${LIB} != "c" && ${LIB:Mgcc*} == "" +.if !empty(LIBC_SO) DPLIBC ?= ${DESTDIR}${LIBC_SO} +.endif .else LDLIBC ?= -nodefaultlibs .if ${LIB} == "c" @@ -560,19 +552,9 @@ lib${LIB}.so.${SHLIB_FULLVERSION}: ${SOL ${SHLIB_LDSTARTFILE} ${SHLIB_LDENDFILE} ${_MKTARGET_BUILD} rm -f lib${LIB}.so.${SHLIB_FULLVERSION} -.if defined(DESTDIR) - ${LIBCC} ${LDLIBC} -Wl,-nostdlib -B${_GCC_CRTDIR}/ -B${DESTDIR}${SHLIBDIR}/ \ - -Wl,-x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \ - -Wl,--whole-archive ${SOLIB} \ - -Wl,--no-whole-archive ${_LDADD.lib${LIB}} \ - ${_LIBLDOPTS} ${_LDFLAGS.lib${LIB}} \ - -L${_GCC_LIBGCCDIR} -.else ${LIBCC} ${LDLIBC} -Wl,-x -shared ${SHLIB_SHFLAGS} ${_LDFLAGS.lib${LIB}} \ -o ${.TARGET} ${_LIBLDOPTS} \ -Wl,--whole-archive ${SOLIB} -Wl,--no-whole-archive ${_LDADD.lib${LIB}} -.endif -.if ${OBJECT_FMT} == "ELF" # We don't use INSTALL_SYMLINK here because this is just # happening inside the build directory/objdir. XXX Why does # this spend so much effort on libraries that aren't live??? XXX @@ -583,11 +565,19 @@ lib${LIB}.so.${SHLIB_FULLVERSION}: ${SOL .endif ${HOST_LN} -sf lib${LIB}.so.${SHLIB_FULLVERSION} lib${LIB}.so.tmp mv -f lib${LIB}.so.tmp lib${LIB}.so -.endif .if ${MKSTRIPIDENT} != "no" ${OBJCOPY} -R .ident ${.TARGET} .endif +.if defined(_LIB.debug) +${_LIB.debug}: ${_LIB.so} + ${_MKTARGET_CREATE} + ( ${OBJCOPY} --only-keep-debug ${_LIB.so} ${_LIB.debug} \ + && ${OBJCOPY} --strip-debug -p -R .gnu_debuglink \ + --add-gnu-debuglink=${_LIB.debug} ${_LIB.so} \ + ) || (rm -f ${_LIB.debug}; false) +.endif + .if !empty(LOBJS) # { LLIBS?= -lc llib-l${LIB}.ln: ${LOBJS} @@ -605,14 +595,13 @@ lint: ${LOBJS} ${LINT} ${LINTFLAGS} ${LOBJS} .endif -cleanlib: .PHONY - rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES} - rm -f lib${LIB}.a ${STOBJS} - rm -f lib${LIB}_p.a ${POBJS} - rm -f lib${LIB}_g.a ${GOBJS} - rm -f lib${LIB}_pic.a lib${LIB}.so.* lib${LIB}.so ${SOBJS} - rm -f ${STOBJS:=.tmp} ${POBJS:=.tmp} ${SOBJS:=.tmp} ${GOBJS:=.tmp} - rm -f llib-l${LIB}.ln ${LOBJS} +CLEANFILES+= a.out [Ee]rrs mklog core *.core +CLEANFILES+= lib${LIB}.a ${STOBJS} +CLEANFILES+= lib${LIB}_p.a ${POBJS} +CLEANFILES+= lib${LIB}_g.a ${GOBJS} +CLEANFILES+= lib${LIB}_pic.a lib${LIB}.so.* lib${LIB}.so ${_LIB.debug} ${SOBJS} +CLEANFILES+= ${STOBJS:=.tmp} ${POBJS:=.tmp} ${SOBJS:=.tmp} ${GOBJS:=.tmp} +CLEANFILES+= llib-l${LIB}.ln ${LOBJS} .if !target(libinstall) # { @@ -721,10 +710,6 @@ ${_LIB_SO_TGT}.${SHLIB_FULLVERSION}: lib ${_LIB_SO_TGT}.${SHLIB_FULLVERSION} \ ${_LIB_SO_TGTLIBDIR}.${SHLIB_FULLVERSION} .endif -.if ${OBJECT_FMT} == "a.out" && !defined(DESTDIR) - /sbin/ldconfig -m ${_LIBSODIR} ${LIBDIR} -.endif -.if ${OBJECT_FMT} == "ELF" .if defined(SHLIB_FULLVERSION) && defined(SHLIB_MAJOR) && \ "${SHLIB_FULLVERSION}" != "${SHLIB_MAJOR}" ${INSTALL_SYMLINK} \ @@ -747,6 +732,15 @@ ${_LIB_SO_TGT}.${SHLIB_FULLVERSION}: lib .endif .endif .endif + +.if defined(_LIB.debug) +libinstall:: ${DESTDIR}${DEBUGDIR}${LIBDIR}/${_LIB.debug} +.PRECIOUS: ${DESTDIR}${DEBUGDIR}${LIBDIR}/${_LIB.debug} + +${DESTDIR}${DEBUGDIR}${LIBDIR}/${_LIB.debug}: ${_LIB.debug} + ${_MKTARGET_INSTALL} + ${INSTALL_FILE} -o ${DEBUGOWN} -g ${DEBUGGRP} -m ${DEBUGMODE} \ + ${.ALLSRC} ${.TARGET} .endif .if ${MKLINT} != "no" && !empty(LOBJS) @@ -780,5 +774,7 @@ LINKSMODE?= ${LIBMODE} .include .include .include +.include +.include ${TARGETS}: # ensure existence