diff options
author | des <des@FreeBSD.org> | 2013-09-08 09:40:23 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2013-09-08 09:40:23 +0000 |
commit | fcb1c0aa6d23f22394a713ca07e5b4fe2d77270f (patch) | |
tree | afa1159b74d646c787c36ea8cc6e9d83b93babe4 | |
parent | b136eed63006963c7bf74ec337f78e9e320493c2 (diff) | |
download | FreeBSD-src-fcb1c0aa6d23f22394a713ca07e5b4fe2d77270f.zip FreeBSD-src-fcb1c0aa6d23f22394a713ca07e5b4fe2d77270f.tar.gz |
Create a private library directory (LIBPRIVATEDIR) for libraries which
we don't want to expose but which can't or shouldn't be static.
To mark a library as private, define PRIVATELIB in its Makefile. It
will be installed in LIBPRIVATEDIR, which is normally /usr/lib/private
(or /usr/lib32/private for 32-bit libraries on 64-bit platforms).
To indicate that a program or library depends on a private library,
define USEPRIVATELIB in its Makefile. The correct version of
LIBPRIVATEDIR will be added to its run-time library search path.
Approved by: re (blanket)
-rw-r--r-- | Makefile.inc1 | 1 | ||||
-rw-r--r-- | etc/mtree/BSD.usr.dist | 4 | ||||
-rw-r--r-- | share/mk/bsd.lib.mk | 52 | ||||
-rw-r--r-- | share/mk/bsd.own.mk | 3 | ||||
-rw-r--r-- | share/mk/bsd.prog.mk | 4 |
5 files changed, 44 insertions, 20 deletions
diff --git a/Makefile.inc1 b/Makefile.inc1 index 5185706..bbb9d89 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -382,6 +382,7 @@ LIB32WMAKEENV+= MAKEOBJDIRPREFIX=${OBJTREE}/lib32 \ PATH=${TMPPATH} \ LIBDIR=/usr/lib32 \ SHLIBDIR=/usr/lib32 \ + LIBPRIVATEDIR=/usr/lib32/private \ COMPILER_TYPE=${WMAKE_COMPILER_TYPE} LIB32WMAKEFLAGS+= \ CC="${XCC} ${LIB32FLAGS}" \ diff --git a/etc/mtree/BSD.usr.dist b/etc/mtree/BSD.usr.dist index 636a5d2..c06d3e1 100644 --- a/etc/mtree/BSD.usr.dist +++ b/etc/mtree/BSD.usr.dist @@ -24,12 +24,16 @@ .. i18n .. + private + .. .. lib32 dtrace .. i18n .. + private + .. .. libdata gcc diff --git a/share/mk/bsd.lib.mk b/share/mk/bsd.lib.mk index 66d0a29..bb3db64 100644 --- a/share/mk/bsd.lib.mk +++ b/share/mk/bsd.lib.mk @@ -119,16 +119,24 @@ PO_FLAG=-pg all: objwarn +.if defined(PRIVATELIB) +_LIBDIR:=${LIBPRIVATEDIR} +_SHLIBDIR:=${LIBPRIVATEDIR} +.else +_LIBDIR:=${LIBDIR} +_SHLIBDIR:=${SHLIBDIR} +.endif + .if defined(SHLIB_NAME) .if ${MK_DEBUG_FILES} != "no" SHLIB_NAME_FULL=${SHLIB_NAME}.full # Use ${DEBUGDIR} for base system debug files, else .debug subdirectory -.if ${SHLIBDIR} == "/boot" ||\ +.if ${_SHLIBDIR} == "/boot" ||\ ${SHLIBDIR:C%/lib(/.*)?$%/lib%} == "/lib" ||\ ${SHLIBDIR:C%/usr/lib(32)?(/.*)?%/usr/lib%} == "/usr/lib" -DEBUGFILEDIR=${DEBUGDIR}${SHLIBDIR} +DEBUGFILEDIR=${DEBUGDIR}${_SHLIBDIR} .else -DEBUGFILEDIR=${SHLIBDIR}/.debug +DEBUGFILEDIR=${_SHLIBDIR}/.debug DEBUGMKDIR= .endif .else @@ -145,6 +153,10 @@ ${SHLIB_NAME_FULL}: ${VERSION_MAP} LDFLAGS+= -Wl,--version-script=${VERSION_MAP} .endif +.if defined(USEPRIVATELIB) +LDFLAGS+= -L${_SHLIBDIRPREFIX}${LIBPRIVATEDIR} -rpath ${LIBPRIVATEDIR} +.endif + .if defined(LIB) && !empty(LIB) || defined(SHLIB_NAME) OBJS+= ${SRCS:N*.h:R:S/$/.o/} .endif @@ -291,16 +303,16 @@ realinstall: _libinstall _libinstall: .if defined(LIB) && !empty(LIB) && ${MK_INSTALLLIB} != "no" ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ - ${_INSTALLFLAGS} lib${LIB}.a ${DESTDIR}${LIBDIR} + ${_INSTALLFLAGS} lib${LIB}.a ${DESTDIR}${_LIBDIR} .endif .if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB) ${INSTALL} -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ - ${_INSTALLFLAGS} lib${LIB}_p.a ${DESTDIR}${LIBDIR} + ${_INSTALLFLAGS} lib${LIB}_p.a ${DESTDIR}${_LIBDIR} .endif .if defined(SHLIB_NAME) ${INSTALL} ${STRIP} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ ${_INSTALLFLAGS} ${_SHLINSTALLFLAGS} \ - ${SHLIB_NAME} ${DESTDIR}${SHLIBDIR} + ${SHLIB_NAME} ${DESTDIR}${_SHLIBDIR} .if ${MK_DEBUG_FILES} != "no" .if defined(DEBUGMKDIR) ${INSTALL} -T debug -d ${DESTDIR}${DEBUGFILEDIR} @@ -328,23 +340,23 @@ _libinstall: # installworld; in the later case ${_LDSCRIPTROOT} must be obviously empty # because on the target system, libraries are meant to be looked up from /. .if defined(SHLIB_LDSCRIPT) && !empty(SHLIB_LDSCRIPT) && exists(${.CURDIR}/${SHLIB_LDSCRIPT}) - sed -e 's,@@SHLIB@@,${_LDSCRIPTROOT}${SHLIBDIR}/${SHLIB_NAME},g' \ - -e 's,@@LIBDIR@@,${_LDSCRIPTROOT}${LIBDIR},g' \ - ${.CURDIR}/${SHLIB_LDSCRIPT} > ${DESTDIR}${LIBDIR}/${SHLIB_LINK:R}.ld + sed -e 's,@@SHLIB@@,${_LDSCRIPTROOT}${_SHLIBDIR}/${SHLIB_NAME},g' \ + -e 's,@@LIBDIR@@,${_LDSCRIPTROOT}${_LIBDIR},g' \ + ${.CURDIR}/${SHLIB_LDSCRIPT} > ${DESTDIR}${_LIBDIR}/${SHLIB_LINK:R}.ld ${INSTALL} -S -C -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ - ${_INSTALLFLAGS} ${DESTDIR}${LIBDIR}/${SHLIB_LINK:R}.ld \ - ${DESTDIR}${LIBDIR}/${SHLIB_LINK} - rm -f ${DESTDIR}${LIBDIR}/${SHLIB_LINK:R}.ld + ${_INSTALLFLAGS} ${DESTDIR}${_LIBDIR}/${SHLIB_LINK:R}.ld \ + ${DESTDIR}${_LIBDIR}/${SHLIB_LINK} + rm -f ${DESTDIR}${_LIBDIR}/${SHLIB_LINK:R}.ld .else -.if ${SHLIBDIR} == ${LIBDIR} - ${INSTALL_SYMLINK} ${SHLIB_NAME} ${DESTDIR}${LIBDIR}/${SHLIB_LINK} +.if ${_SHLIBDIR} == ${_LIBDIR} + ${INSTALL_SYMLINK} ${SHLIB_NAME} ${DESTDIR}${_LIBDIR}/${SHLIB_LINK} .else - ${INSTALL_SYMLINK} ${_SHLIBDIRPREFIX}${SHLIBDIR}/${SHLIB_NAME} \ - ${DESTDIR}${LIBDIR}/${SHLIB_LINK} -.if exists(${DESTDIR}${LIBDIR}/${SHLIB_NAME}) - -chflags noschg ${DESTDIR}${LIBDIR}/${SHLIB_NAME} - rm -f ${DESTDIR}${LIBDIR}/${SHLIB_NAME} + ${INSTALL_SYMLINK} ${_SHLIBDIRPREFIX}${_SHLIBDIR}/${SHLIB_NAME} \ + ${DESTDIR}${_LIBDIR}/${SHLIB_LINK} +.if exists(${DESTDIR}${_LIBDIR}/${SHLIB_NAME}) + -chflags noschg ${DESTDIR}${_LIBDIR}/${SHLIB_NAME} + rm -f ${DESTDIR}${_LIBDIR}/${SHLIB_NAME} .endif .endif .endif # SHLIB_LDSCRIPT @@ -352,7 +364,7 @@ _libinstall: .endif # SHIB_NAME .if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no" ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ - ${_INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${LIBDIR} + ${_INSTALLFLAGS} lib${LIB}_pic.a ${DESTDIR}${_LIBDIR} .endif .if defined(WANT_LINT) && !defined(NO_LINT) && defined(LIB) && !empty(LIB) ${INSTALL} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \ diff --git a/share/mk/bsd.own.mk b/share/mk/bsd.own.mk index 39cf72e..8f7f0b9 100644 --- a/share/mk/bsd.own.mk +++ b/share/mk/bsd.own.mk @@ -28,6 +28,8 @@ # # LIBCOMPATDIR Base path for compat libraries. [/usr/lib/compat] # +# LIBPRIVATEDIR Base path for private libraries. [/usr/lib/private] +# # LIBDATADIR Base path for misc. utility data files. [/usr/libdata] # # LIBEXECDIR Base path for system daemons and utilities. [/usr/libexec] @@ -144,6 +146,7 @@ KMODMODE?= ${BINMODE} LIBDIR?= /usr/lib LIBCOMPATDIR?= /usr/lib/compat +LIBPRIVATEDIR?= /usr/lib/private LIBDATADIR?= /usr/libdata LIBEXECDIR?= /usr/libexec LINTLIBDIR?= /usr/libdata/lint diff --git a/share/mk/bsd.prog.mk b/share/mk/bsd.prog.mk index f4546dc..12f14cb 100644 --- a/share/mk/bsd.prog.mk +++ b/share/mk/bsd.prog.mk @@ -52,6 +52,10 @@ STRIP?= -s LDFLAGS+= -static .endif +.if defined(USEPRIVATELIB) +LDFLAGS+= -L${_SHLIBDIRPREFIX}${LIBPRIVATEDIR} -rpath ${LIBPRIVATEDIR} +.endif + .if ${MK_DEBUG_FILES} != "no" PROG_FULL=${PROG}.full # Use ${DEBUGDIR} for base system debug files, else .debug subdirectory |