Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 8 Sep 2013 09:40:23 +0000 (UTC)
From:      Dag-Erling Smørgrav <des@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r255384 - in head: . etc/mtree share/mk
Message-ID:  <201309080940.r889eNsR046328@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: des
Date: Sun Sep  8 09:40:23 2013
New Revision: 255384
URL: http://svnweb.freebsd.org/changeset/base/255384

Log:
  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)

Modified:
  head/Makefile.inc1
  head/etc/mtree/BSD.usr.dist
  head/share/mk/bsd.lib.mk
  head/share/mk/bsd.own.mk
  head/share/mk/bsd.prog.mk

Modified: head/Makefile.inc1
==============================================================================
--- head/Makefile.inc1	Sun Sep  8 09:06:52 2013	(r255383)
+++ head/Makefile.inc1	Sun Sep  8 09:40:23 2013	(r255384)
@@ -382,6 +382,7 @@ LIB32WMAKEENV+=	MAKEOBJDIRPREFIX=${OBJTR
 		PATH=${TMPPATH} \
 		LIBDIR=/usr/lib32 \
 		SHLIBDIR=/usr/lib32 \
+		LIBPRIVATEDIR=/usr/lib32/private \
 		COMPILER_TYPE=${WMAKE_COMPILER_TYPE}
 LIB32WMAKEFLAGS+=	\
 		CC="${XCC} ${LIB32FLAGS}" \

Modified: head/etc/mtree/BSD.usr.dist
==============================================================================
--- head/etc/mtree/BSD.usr.dist	Sun Sep  8 09:06:52 2013	(r255383)
+++ head/etc/mtree/BSD.usr.dist	Sun Sep  8 09:40:23 2013	(r255384)
@@ -24,12 +24,16 @@
         ..
         i18n
         ..
+        private
+        ..
     ..
     lib32
         dtrace
         ..
         i18n
         ..
+        private
+        ..
     ..
     libdata
         gcc

Modified: head/share/mk/bsd.lib.mk
==============================================================================
--- head/share/mk/bsd.lib.mk	Sun Sep  8 09:06:52 2013	(r255383)
+++ head/share/mk/bsd.lib.mk	Sun Sep  8 09:40:23 2013	(r255384)
@@ -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} \

Modified: head/share/mk/bsd.own.mk
==============================================================================
--- head/share/mk/bsd.own.mk	Sun Sep  8 09:06:52 2013	(r255383)
+++ head/share/mk/bsd.own.mk	Sun Sep  8 09:40:23 2013	(r255384)
@@ -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

Modified: head/share/mk/bsd.prog.mk
==============================================================================
--- head/share/mk/bsd.prog.mk	Sun Sep  8 09:06:52 2013	(r255383)
+++ head/share/mk/bsd.prog.mk	Sun Sep  8 09:40:23 2013	(r255384)
@@ -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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201309080940.r889eNsR046328>