Ack.

Thanks,
Ramesh.

On 3/15/2017 7:31 PM, Anders Widell wrote:
>   Makefile.am                  |  16 +++++++++-
>   README                       |  12 +------
>   samples/mqsv/Makefile.am     |   4 ++
>   scripts/create_empty_library |  69 
> ++++++++++++++++++++++++++++++++++++++++++++
>   4 files changed, 90 insertions(+), 11 deletions(-)
>
>
> Remove dependencies to internal OpenSAF libraries from the public AIS 
> libraries,
> to avoid future problems similar to the one reported in ticket [#2298]. This
> removes the need for applications programs to use the -Wl,--as-needed linker
> flag.
>
> diff --git a/Makefile.am b/Makefile.am
> --- a/Makefile.am
> +++ b/Makefile.am
> @@ -128,7 +128,7 @@ pkgconfig_DATA += pkgconfig/opensaf.pc
>   
>   BUILT_SOURCES += src/osaf/configmake.h osafdir.conf
>   
> -EXTRA_DIST += samples
> +EXTRA_DIST += samples scripts/create_empty_library
>   
>   dist_doc_DATA += \
>       $(top_srcdir)/00-README.conf \
> @@ -323,6 +323,20 @@ if ENABLE_SYSTEMD
>       fi
>   endif
>   
> +install-exec-hook:
> +     @libs=""; \
> +     for i in $(lib_LTLIBRARIES); do \
> +             l=$$(basename "$$i" .la); \
> +             test $$(echo "$$l" | cut -c1-5) = "libSa" && \
> +                     libs="$$libs $$l"; \
> +     done; \
> +     srcdir=$$(cd $(top_srcdir); pwd; cd - > /dev/null); \
> +     for i in $$libs; do \
> +             sofile=$(DESTDIR)$(libdir)/$$i.so; \
> +             mapfile=$$(bash -c "ls -1 $$srcdir/src/*/saf/$$i.map"); \
> +             bash $$srcdir/scripts/create_empty_library "$$sofile" 
> "$$mapfile"; \
> +     done
> +
>   uninstall-hook:
>       rm -f $(DESTDIR)$(pkgsysconfdir)/node_name
>       -rm -rf $(DESTDIR)$(pkgsysconfdir)
> diff --git a/README b/README
> --- a/README
> +++ b/README
> @@ -825,7 +825,6 @@ installed with the other system `*.pc' f
>   There are two easy ways to use `pkgconfig'. The first one is to call it 
> directly
>   from a `Makefile' and assign its content to make variables e.g.:
>   
> -   AMF_LDFLAGS=-Wl,--as-needed
>      AMF_LIBS=`pkg-config opensaf-amf --libs`
>      AMF_CFLAGS=`pkg-config opensaf-amf --cflags`
>   
> @@ -839,15 +838,8 @@ It will then provides two special variab
>   
>      -- in Makefile.am --
>      mumble_CFLAGS = @AMF_CFLAGS@
> -   mumble_LDFLAGS = -Wl,--as-needed
>      mumble_LDADD = @AMF_LIBS@
>   
> -The --as-needed ld flag is enabled by default on many modern Linux
> -distributions, but just to be on the safe side please make sure to add
> --Wl,--as-needed to your LDFLAGS when linking application programs with the
> -OpenSAF AIS libraries. Otherwise the resulting binary may not be compatible 
> with
> -other versions of OpenSAF.
> -
>   
>   How to Configure `OpenSAF'
>   ==========================
> @@ -927,13 +919,13 @@ The `Makefile' looks for installed `SAF
>   standard system wide locations (e.g. /usr/include/ & /usr/lib/):
>   
>       INCLUDES = -I.
> -    LDFLAGS = -Wl,--as-needed -lSaAmf
> +    LDFLAGS = -lSaAmf
>   
>   If you have `OpenSAF' development packages installed somewhere else, 
> override
>   the default values e.g.:
>   
>       % make INCLUDES="-I. -I/tmp/usr/local/include" \
> -        LDFLAGS="-Wl,--as-needed -L/tmp/usr/local/lib -lSaAmf -lopensaf_core"
> +        LDFLAGS="-L/tmp/usr/local/lib -lSaAmf -lopensaf_core"
>   
>   To run an application you will need a configured `OpenSAF' node running.
>   
> diff --git a/samples/mqsv/Makefile.am b/samples/mqsv/Makefile.am
> --- a/samples/mqsv/Makefile.am
> +++ b/samples/mqsv/Makefile.am
> @@ -1,6 +1,7 @@
>   #      -*- OpenSAF  -*-
>   #
>   # (C) Copyright 2010 The OpenSAF Foundation
> +# Copyright Ericsson AB 2017 - All Rights Reserved.
>   #
>   # This program is distributed in the hope that it will be useful, but
>   # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
> @@ -30,3 +31,6 @@ msg_demo_SOURCES = \
>   
>   msg_demo_LDADD = \
>       @SAF_AIS_MSG_LIBS@
> +
> +msg_demo_LDFLAGS = \
> +     -pthread
> diff --git a/scripts/create_empty_library b/scripts/create_empty_library
> new file mode 100755
> --- /dev/null
> +++ b/scripts/create_empty_library
> @@ -0,0 +1,69 @@
> +#!/bin/bash
> +#
> +# Copyright Ericsson AB 2017 - All Rights Reserved.
> +#
> +# This program is distributed in the hope that it will be useful, but
> +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
> +# or FITNESS FOR A PARTICULAR PURPOSE. This file and program are licensed
> +# under the GNU Lesser General Public License Version 2.1, February 1999.
> +# The complete license can be accessed from the following location:
> +# http://opensource.org/licenses/lgpl-license.php
> +# See the Copying file included with the OpenSAF distribution for full
> +# licensing terms.
> +#
> +
> +if [[ $# -ne 2 ]]; then
> +    echo "Usage: $0 sofile mapfile"
> +    exit 1
> +fi
> +
> +libname=$(basename "$1")
> +if [[ $(echo "$libname" | cut -d. -f2) != "so" ]]; then
> +    echo "$0: $1 is not a shared library"
> +    exit 1
> +fi
> +
> +if [[ $(basename "$2" | cut -d. -f2-) != "map" ]]; then
> +    echo "$0: $2 is not a map file"
> +    exit 1
> +fi
> +
> +if ! [[ -r "$1" ]]; then
> +    echo "$0: $1 does not exist"
> +    exit 1
> +fi
> +
> +if ! [[ -r "$2" ]]; then
> +    echo "$0: $2 does not exist"
> +    exit 1
> +fi
> +
> +realname=$(readlink "$1")
> +if [[ -z "$realname" ]]; then
> +    echo "$0: $1 is not a symbolic link"
> +    exit 1
> +fi
> +
> +libbase=$(echo "$realname" | cut -d. -f1)
> +version1=$(echo "$realname" | cut -d. -f3)
> +version2=$(echo "$realname" | cut -d. -f4)
> +
> +if [[ "$version1" = "" ]] || [[ "$version2" = "" ]] || [[ "$version1" = "" 
> ]]; then
> +    echo "$0: $1 is not in the format libXXX.so.a.b.c"
> +    exit 1
> +fi
> +
> +tmpdir=$(mktemp -d -t create_empty_library.XXXXXXXXXX)
> +destructor() {
> +  rm -rf "$tmpdir"
> +}
> +trap destructor EXIT
> +
> +echo "typedef enum { SA_AIS_ERR_UNAVAILABLE = 31 } SaAisErrorT;" > 
> "$tmpdir/lib.c"
> +
> +symbols=$(nm --dynamic --portability --defined-only "$1" | grep -v " A " | 
> cut -d" " -f 1)
> +for s in $symbols; do
> +    echo "SaAisErrorT $s() { return SA_AIS_ERR_UNAVAILABLE; }" >> 
> "$tmpdir/lib.c"
> +done
> +rm -f "$1"
> +gcc -O2 -shared -fPIC "$tmpdir/lib.c" -Wl,-version-script="$2" 
> -Wl,-soname="$libbase.so.$version1" -o "$1"


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Opensaf-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to