Rework PRIVATELIB

Now when a lib is marked as PRIVATELIB it is renamed into libprivate$foo instead
of being installed in /usr/lib/private and playing with rpath.

Also allow to install headers for PRIVATELIBS in that case the headers will be
installed in /usr/include/private/$foo

Keep the headers under a private namespace to prevent third party build system
to easily find them to ensure they are only used on purpose.

This allows for non base applications to statically link against a library in
base which is linked to a privatelib

Treating PRIVATELIBS as regular libraries allows to push them into our current
compatX packages if needed.

While here finish promotion of libevent as PRIVATELIB
Install header for bsdstat and libucl

Differential Revision:	https://reviews.freebsd.org/D2365
Reviewed by:	brooks, des
Discussed with:	imp
This commit is contained in:
bapt 2015-05-04 16:28:54 +00:00
parent fdda0c9272
commit 79de2555b1
9 changed files with 65 additions and 86 deletions

View File

@ -38,6 +38,29 @@
# xargs -n1 | sort | uniq -d;
# done
# 20150504
OLD_LIBS+=usr/lib32/private/libatf-c++.so.2
OLD_LIBS+=usr/lib32/private/libbsdstat.so.1
OLD_LIBS+=usr/lib32/private/libheimipcs.so.11
OLD_LIBS+=usr/lib32/private/libsqlite3.so.0
OLD_LIBS+=usr/lib32/private/libunbound.so.5
OLD_LIBS+=usr/lib32/private/libatf-c.so.1
OLD_LIBS+=usr/lib32/private/libheimipcc.so.11
OLD_LIBS+=usr/lib32/private/libldns.so.5
OLD_LIBS+=usr/lib32/private/libssh.so.5
OLD_LIBS+=usr/lib32/private/libucl.so.1
OLD_DIRS+=usr/lib32/private
OLD_LIBS+=usr/lib/private/libatf-c++.so.2
OLD_LIBS+=usr/lib/private/libbsdstat.so.1
OLD_LIBS+=usr/lib/private/libheimipcs.so.11
OLD_LIBS+=usr/lib/private/libsqlite3.so.0
OLD_LIBS+=usr/lib/private/libunbound.so.5
OLD_LIBS+=usr/lib/private/libatf-c.so.1
OLD_LIBS+=usr/lib/private/libheimipcc.so.11
OLD_LIBS+=usr/lib/private/libldns.so.5
OLD_LIBS+=usr/lib/private/libssh.so.5
OLD_LIBS+=usr/lib/private/libucl.so.1
OLD_DIRS+=usr/lib/private
# 20150501
OLD_FILES+=usr/bin/soeliminate
OLD_FILES+=usr/share/man/man1/soeliminate.1.gz

View File

@ -8,6 +8,12 @@
bin
..
include
private
bsdstat
..
ucl
..
..
..
lib
aout
@ -32,16 +38,12 @@
..
i18n
..
private
..
..
lib32
dtrace
..
i18n
..
private
..
..
libdata
gcc

View File

@ -7,7 +7,6 @@
LIB= event
SHLIB_MAJOR= 1
PRIVATELIB=
INTERNALLIB=
SRCS= buffer.c evbuffer.c event.c kqueue.c log.c poll.c select.c signal.c
HDRS= event.h

View File

@ -14,8 +14,10 @@ SRCS= ucl_emitter_streamline.c \
ucl_util.c \
xxhash.c
.PATH: ${LIBUCL}/src
.PATH: ${LIBUCL}/src \
${LIBUCL}/include
INCS= ucl.h
LIBADD= m
WARNS= 1

View File

@ -72,11 +72,10 @@ MAN.${_T}?= # empty
SRCS.${_T}?= ${_T}.c
DPADD.${_T}+= ${LIBATF_C}
.if empty(LDFLAGS:M-static) && empty(LDFLAGS.${_T}:M-static)
LDADD.${_T}+= ${LDATF_C}
LDADD.${_T}+= ${LDADD_atf_c}
.else
LDADD.${_T}+= ${LIBATF_C}
.endif
USEPRIVATELIB+= atf-c
TEST_INTERFACE.${_T}= atf
.endfor
.endif
@ -90,11 +89,10 @@ MAN.${_T}?= # empty
SRCS.${_T}?= ${_T}${CXX_SUFFIX:U.cc}
DPADD.${_T}+= ${LIBATF_CXX} ${LIBATF_C}
.if empty(LDFLAGS:M-static) && empty(LDFLAGS.${_T}:M-static)
LDADD.${_T}+= ${LDATF_CXX} ${LDATF_C}
LDADD.${_T}+= ${LDADD_atf_cxx} ${LDADD_atf_c}
.else
LDADD.${_T}+= ${LIBATF_CXX} ${LIBATF_C}
.endif
USEPRIVATELIB+= atf-c++
TEST_INTERFACE.${_T}= atf
.endfor
.endif

View File

@ -23,7 +23,7 @@ all: buildincludes
${group}OWN?= ${BINOWN}
${group}GRP?= ${BINGRP}
${group}MODE?= ${NOBINMODE}
${group}DIR?= ${INCLUDEDIR}
${group}DIR?= ${INCLUDEDIR}${PRIVATELIB:D/private/${LIB}}
_${group}INCS=
.for header in ${${group}}

View File

@ -11,6 +11,7 @@ _LD= ${CXX}
_LD= ${CC}
.endif
LIB_PRIVATE= ${PRIVATELIB:Dprivate}
# Set up the variables controlling shared libraries. After this section,
# SHLIB_NAME will be defined only if we are to create a shared library.
# SHLIB_LINK will be defined only if we are to create a link to it.
@ -23,7 +24,7 @@ _LD= ${CC}
SHLIB= ${LIB}
.endif
.if !defined(SHLIB_NAME) && defined(SHLIB) && defined(SHLIB_MAJOR)
SHLIB_NAME= lib${SHLIB}.so.${SHLIB_MAJOR}
SHLIB_NAME= lib${LIB_PRIVATE}${SHLIB}.so.${SHLIB_MAJOR}
.endif
.if defined(SHLIB_NAME) && !empty(SHLIB_NAME:M*.so.*)
SHLIB_LINK?= ${SHLIB_NAME:R}
@ -128,13 +129,8 @@ PO_FLAG=-pg
all: beforebuild .WAIT
beforebuild: objwarn
.if defined(PRIVATELIB)
_LIBDIR:=${LIBPRIVATEDIR}
_SHLIBDIR:=${LIBPRIVATEDIR}
.else
_LIBDIR:=${LIBDIR}
_SHLIBDIR:=${SHLIBDIR}
.endif
.if defined(SHLIB_NAME)
.if ${MK_DEBUG_FILES} != "no"
@ -162,19 +158,15 @@ ${SHLIB_NAME_FULL}: ${VERSION_MAP}
LDFLAGS+= -Wl,--version-script=${VERSION_MAP}
.endif
.if defined(USEPRIVATELIB)
LDFLAGS+= -rpath ${LIBPRIVATEDIR}
.endif
.if defined(LIB) && !empty(LIB) || defined(SHLIB_NAME)
OBJS+= ${SRCS:N*.h:R:S/$/.o/}
NOPATH_FILES+= ${OBJS}
.endif
.if defined(LIB) && !empty(LIB)
_LIBS= lib${LIB}.a
_LIBS= lib${LIB_PRIVATE}${LIB}.a
lib${LIB}.a: ${OBJS} ${STATICOBJS}
lib${LIB_PRIVATE}${LIB}.a: ${OBJS} ${STATICOBJS}
@${ECHO} building static ${LIB} library
@rm -f ${.TARGET}
@${AR} ${ARFLAGS} ${.TARGET} `NM='${NM}' lorder ${OBJS} ${STATICOBJS} | tsort -q` ${ARADD}
@ -184,11 +176,11 @@ lib${LIB}.a: ${OBJS} ${STATICOBJS}
.if !defined(INTERNALLIB)
.if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB)
_LIBS+= lib${LIB}_p.a
_LIBS+= lib${LIB_PRIVATE}${LIB}_p.a
POBJS+= ${OBJS:.o=.po} ${STATICOBJS:.o=.po}
NOPATH_FILES+= ${POBJS}
lib${LIB}_p.a: ${POBJS}
lib${LIB_PRIVATE}${LIB}_p.a: ${POBJS}
@${ECHO} building profiled ${LIB} library
@rm -f ${.TARGET}
@${AR} ${ARFLAGS} ${.TARGET} `NM='${NM}' lorder ${POBJS} | tsort -q` ${ARADD}
@ -243,9 +235,9 @@ ${SHLIB_NAME}.debug: ${SHLIB_NAME_FULL}
.endif #defined(SHLIB_NAME)
.if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no"
_LIBS+= lib${LIB}_pic.a
_LIBS+= lib${LIB_PRIVATE}${LIB}_pic.a
lib${LIB}_pic.a: ${SOBJS}
lib${LIB_PRIVATE}${LIB}_pic.a: ${SOBJS}
@${ECHO} building special pic ${LIB} library
@rm -f ${.TARGET}
@${AR} ${ARFLAGS} ${.TARGET} ${SOBJS} ${ARADD}
@ -305,13 +297,13 @@ _SHLINSTALLFLAGS:= ${_SHLINSTALLFLAGS${ie}}
realinstall: _libinstall
.ORDER: beforeinstall _libinstall
_libinstall:
.if defined(LIB) && !empty(LIB) && ${MK_INSTALLLIB} != "no" && !defined(PRIVATELIB)
.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_PRIVATE}${LIB}.a ${DESTDIR}${_LIBDIR}
.endif
.if ${MK_PROFILE} != "no" && defined(LIB) && !empty(LIB) && !defined(PRIVATELIB)
.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_PRIVATE}${LIB}_p.a ${DESTDIR}${_LIBDIR}
.endif
.if defined(SHLIB_NAME)
${INSTALL} ${STRIP} -o ${LIBOWN} -g ${LIBGRP} -m ${LIBMODE} \
@ -325,7 +317,7 @@ _libinstall:
${_INSTALLFLAGS} \
${SHLIB_NAME}.debug ${DESTDIR}${DEBUGFILEDIR}
.endif
.if defined(SHLIB_LINK) && !defined(PRIVATELIB)
.if defined(SHLIB_LINK)
# ${_SHLIBDIRPREFIX} and ${_LDSCRIPTROOT} are both needed when cross-building
# and when building 32 bits library shims. ${_SHLIBDIRPREFIX} is the directory
# prefix where shared objects will be installed by the install target.
@ -366,7 +358,7 @@ _libinstall:
.endif # SHLIB_LDSCRIPT
.endif # SHLIB_LINK
.endif # SHIB_NAME
.if defined(INSTALL_PIC_ARCHIVE) && defined(LIB) && !empty(LIB) && ${MK_TOOLCHAIN} != "no" && !defined(PRIVATELIB)
.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}
.endif

View File

@ -51,10 +51,6 @@ 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

View File

@ -15,6 +15,7 @@ _PRIVATELIBS= \
atf_c \
atf_cxx \
bsdstat \
event \
heimipcc \
heimipcs \
ldns \
@ -28,7 +29,6 @@ _INTERNALIBS= \
bsnmptools \
cron \
elftc \
event \
fifolog \
ipf \
lpr \
@ -233,18 +233,25 @@ _DP_vmmapi= util
# Define spacial cases
LDADD_supcplusplus= -lsupc++
LDADD_atf_c= -L${LIBATF_CDIR} -latf-c
LDADD_atf_cxx= -L${LIBATF_CXXDIR} -latf-c++
LIBATF_C= $(DESTDIR)$(LIBDIR)/libprivateatf-c.a
LIBATF_CXX= $(DESTDIR)$(LIBDIR)/libprivateatf-c++.a
LDADD_atf_c= -lprivateatf-c
LDADD_atf_cxx= -lprivateatf-c++
.for _l in ${_PRIVATELIBS}
LIB${_l:tu}?= ${DESTDIR}${LIBDIR}/libprivate${_l}.a
.endfor
.for _l in ${_LIBRARIES}
.if ${_PRIVATELIBS:M${_l}}
LDADD_${_l}_L+= -L${LIB${_l:tu}DIR}
.endif
.if ${_INTERNALIBS:M${_l}}
LDADD_${_l}_L+= -L${LIB${_l:tu}DIR}
.endif
DPADD_${_l}?= ${LIB${_l:tu}}
.if ${_PRIVATELIBS:M${_l}}
LDADD_${_l}?= -lprivate${_l}
.else
LDADD_${_l}?= ${LDADD_${_l}_L} -l${_l}
.endif
.if defined(_DP_${_l}) && defined(NO_SHARED)
.for _d in ${_DP_${_l}}
DPADD_${_l}+= ${DPADD_${_d}}
@ -253,12 +260,12 @@ LDADD_${_l}+= ${LDADD_${_d}}
.endif
.endfor
DPADD_sqlite3+= ${DPADD_pthread}
LDADD_sqlite3+= ${LDADD_pthread}
DPADD_atf_cxx+= ${DPADD_atf_c}
LDADD_atf_cxx+= ${LDADD_atf_c}
DPADD_sqlite3+= ${DPADD_pthread}
LDADD_sqlite3+= ${LDADD_pthread}
DPADD_fifolog+= ${DPADD_z}
LDADD_fifolog+= ${LDADD_z}
@ -290,55 +297,15 @@ LDADD+= ${LDADD_${_l}}
.error Missing ${DPADD:Mmissing-dpadd_*:S/missing-dpadd_//:S/^/DPADD_/} variable add "${DPADD:Mmissing-dpadd_*:S/missing-dpadd_//}" to _LIBRARIES, _INTERNALLIBS, or _PRIVATELIBS and define "${DPADD:Mmissing-dpadd_*:S/missing-dpadd_//:S/^/LIB/:tu}".
.endif
.if defined(USEPRIVATELIB)
LDFLAGS+= -rpath ${LIBPRIVATEDIR}
.endif
LIBATF_CDIR= ${ROOTOBJDIR}/lib/atf/libatf-c
LDATF_C?= ${LIBATF_CDIR}/libatf-c.so
LIBATF_C?= ${LIBATF_CDIR}/libatf-c.a
LIBATF_CXXDIR= ${ROOTOBJDIR}/lib/atf/libatf-c++
LDATF_CXX?= ${LIBATF_CXXDIR}/libatf-c++.so
LIBATF_CXX?= ${LIBATF_CXXDIR}/libatf-c++.a
LIBBSDSTATDIR= ${ROOTOBJDIR}/lib/libbsdstat
LIBBSDSTAT?= ${LIBBSDSTATDIR}/libbsdstat.a
LIBELFTCDIR= ${ROOTOBJDIR}/lib/libelftc
LDELFTC?= ${LIBELFTCDIR}/libelftc.a
LIBELFTC?= ${LIBELFTCDIR}/libelftc.a
LIBEVENTDIR= ${ROOTOBJDIR}/lib/libevent
LIBEVENT?= ${LIBEVENTDIR}/libevent.a
LIBHEIMIPCCDIR= ${ROOTOBJDIR}/kerberos5/lib/libheimipcc
LIBHEIMIPCC?= ${LIBHEIMIPCCDIR}/libheimipcc.a
LIBHEIMIPCSDIR= ${ROOTOBJDIR}/kerberos5/lib/libheimipcs
LIBHEIMIPCS?= ${LIBHEIMIPCSDIR}/libheimipcs.a
LIBLDNSDIR= ${ROOTOBJDIR}/lib/libldns
LIBLDNS?= ${LIBLDNSDIR}/libldns.a
LIBSSHDIR= ${ROOTOBJDIR}/secure/lib/libssh
LIBSSH?= ${LIBSSHDIR}/libssh.a
LIBUNBOUNDDIR= ${ROOTOBJDIR}/lib/libunbound
LIBUNBOUND?= ${LIBUNBOUNDDIR}/libunbound.a
LIBUCLDIR= ${ROOTOBJDIR}/lib/libucl
LIBUCL?= ${LIBUCLDIR}/libucl.a
LIBREADLINEDIR= ${ROOTOBJDIR}/gnu/lib/libreadline/readline
LIBREADLINE?= ${LIBREADLINEDIR}/libreadline.a
LIBOHASHDIR= ${ROOTOBJDIR}/lib/libohash
LIBOHASH?= ${LIBOHASHDIR}/libohash.a
LIBSQLITE3DIR= ${ROOTOBJDIR}/lib/libsqlite3
LIBSQLITE3?= ${LIBSQLITE3DIR}/libsqlite3.a
LIBMANDOCDIR= ${ROOTOBJDIR}/lib/libmandoc
LIBMANDOC?= ${LIBMANDOCDIR}/libmandoc.a