Properly version libjsoncpp.so.

Fix the problem described in bug 200969: currently, libjsoncpp.so is not
properly versioned by SCons; in other words, there's no SONAME in the
library's ELF header, which confuses the linker when creating binaries that
link against it.

Solve it by using InstallVersionedLib(), available since SCons 2.3.0: this
call is able to properly version the shared library the way we need it.
Since there is no support for actually installing the files outside the
build directory, we have to recreate the required symlinks ourselves in the
Makefile. Another related change is that we now create the libraries with
the proper names instead of doing that in the Makefile.

I'm (ab)using the maintainer's approval given to bug 200939, as swills's
latest patch includes this change as well.

PR:		200969
PR:		201057
Approved by:	johan@stromnet.se (maintainer)
This commit is contained in:
Raphael Kubo da Costa 2015-06-30 21:43:04 +00:00
parent 0b6e3c0697
commit 7dfc4025ea
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=391009
4 changed files with 57 additions and 10 deletions

View file

@ -3,7 +3,7 @@
PORTNAME= jsoncpp
DISTVERSION= 0.6.0-rc2
PORTREVISION= 1
PORTREVISION= 2
CATEGORIES= devel
MASTER_SITES= SF/${PORTNAME}/jsoncpp/${DISTVERSION}
DISTNAME= jsoncpp-src-${DISTVERSION}
@ -21,12 +21,11 @@ MAKE_ARGS= platform=linux-gcc
do-install:
@${MKDIR} ${STAGEDIR}${PREFIX}/include/jsoncpp
(cd ${WRKSRC}/include/ && ${COPYTREE_SHARE} json/ ${STAGEDIR}${PREFIX}/include/jsoncpp/)
(cd ${WRKSRC}/libs/linux-gcc-FreeBSD/ && \
${INSTALL_DATA} libjson_linux-gcc-FreeBSD_libmt.a \
${STAGEDIR}${PREFIX}/lib/libjsoncpp.a)
(cd ${WRKSRC}/libs/linux-gcc-FreeBSD/ && \
${INSTALL_LIB} libjson_linux-gcc-FreeBSD_libmt.so \
${STAGEDIR}${PREFIX}/lib/libjsoncpp.so.0)
(cd ${STAGEDIR}${PREFIX}/lib/ && ${LN} -sf libjsoncpp.so.0 libjsoncpp.so )
${INSTALL_DATA} ${WRKSRC}/libs/linux-gcc-FreeBSD/libjsoncpp.a \
${STAGEDIR}${PREFIX}/lib
${INSTALL_LIB} ${WRKSRC}/libs/linux-gcc-FreeBSD/libjsoncpp.so.0.6.0 \
${STAGEDIR}${PREFIX}/lib
${LN} -s libjsoncpp.so.0.6.0 ${STAGEDIR}${PREFIX}/lib/libjsoncpp.so.0
${LN} -s libjsoncpp.so.0.6.0 ${STAGEDIR}${PREFIX}/lib/libjsoncpp.so
.include <bsd.port.mk>

View file

@ -1,5 +1,5 @@
--- SConstruct.orig 2014-12-02 06:28:17.000000000 +0300
+++ SConstruct 2014-12-02 06:28:31.000000000 +0300
--- SConstruct
+++ SConstruct
@@ -26,7 +26,7 @@
if platform == 'linux-gcc':
CXX = 'g++' # not quite right, but env is not yet available.
@ -26,3 +26,42 @@
else:
print "UNSUPPORTED PLATFORM."
env.Exit(1)
@@ -147,6 +148,11 @@
env['BUILD_DIR'] = env.Dir(build_dir)
env['ROOTBUILD_DIR'] = env.Dir(rootbuild_dir)
env['DIST_DIR'] = DIST_DIR
+
+# Set SHLIBVERSION for env.InstallVersionedLib(). We use the version number
+# without the "-rcXX" part.
+env['SHLIBVERSION'] = JSONCPP_VERSION.partition('-')[0]
+
if 'TarGz' in env['BUILDERS']:
class SrcDistAdder:
def __init__( self, env ):
@@ -164,7 +170,7 @@
env['SRCDIST_TARGET'] = os.path.join( DIST_DIR, 'jsoncpp-src-%s.tar.gz' % env['JSONCPP_VERSION'] )
env_testing = env.Clone( )
-env_testing.Append( LIBS = ['json_${LIB_NAME_SUFFIX}'] )
+env_testing.Append( LIBS = ['jsoncpp'] )
def buildJSONExample( env, target_sources, target_name ):
env = env.Clone()
@@ -187,14 +193,14 @@
env.AlwaysBuild( check_alias_target )
def buildLibrary( env, target_sources, target_name ):
- static_lib = env.StaticLibrary( target=target_name + '_${LIB_NAME_SUFFIX}',
+ static_lib = env.StaticLibrary( target=target_name,
source=target_sources )
global lib_dir
env.Install( lib_dir, static_lib )
if env['SHARED_LIB_ENABLED']:
- shared_lib = env.SharedLibrary( target=target_name + '_${LIB_NAME_SUFFIX}',
+ shared_lib = env.SharedLibrary( target=target_name,
source=target_sources )
- env.Install( lib_dir, shared_lib )
+ env.InstallVersionedLib( lib_dir, shared_lib )
env['SRCDIST_ADD']( source=[target_sources] )
Export( 'env env_testing buildJSONExample buildLibrary buildJSONTests buildUnitTests' )

View file

@ -0,0 +1,8 @@
--- src/lib_json/sconscript.orig 2015-06-22 20:34:03 UTC
+++ src/lib_json/sconscript
@@ -5,4 +5,4 @@ buildLibrary( env, Split( """
json_value.cpp
json_writer.cpp
""" ),
- 'json' )
+ 'jsoncpp' )

View file

@ -1,3 +1,4 @@
lib/libjsoncpp.so.0.6.0
lib/libjsoncpp.so.0
lib/libjsoncpp.so
lib/libjsoncpp.a