[Openais] [corosync] - lib versioning

Steven Dake sdake at redhat.com
Wed Mar 31 12:10:08 PDT 2010


Great work!  Good for merge.

Any chance you can make the verso files for the others in the lib
directory?

Also the tabbing is off when printed in configure.

Can you make something like this for the exec directory libraries too?

Regards
-steve


On Wed, 2010-03-31 at 15:47 +0200, Jan Friesse wrote:
> Attached patch solves today very unpleasant situation about libraries
> version (those files from trunk/lib/*).
> 
> Current situation looks like this:
> - Main number configure.ac - Used for all libraries -> problem if some
> library added function (changed API)
> - There is workaround for cpg and confdb. Sadly this workaround is
> really ugly, need too much code duplicity, need changes in configure.ac
> and Makefile.am after any API change.
> 
> So main criteria for new system are following:
> - Allow easy change of library version
> - No change of configure.ac (we are changing library NOT configure system)
> - No change in Makefile.am (again, we are changing library)
> - No code duplicity
> 
> Patch has two main parts:
> - configure.ac part + *.verso. This one is able to:
>   * read version from lib$(LIB).verso file
>   * exports $(LIB)_SONAME with content from the file
>   * displays result in format $(LIB) Library SONAME = $(version)
> - Makefile.am has ability to detect $(LIB)_SONAME and use version from
> that variable or use SONAME if not such variable found.
> 
> In other words, everything what developer must do for changing library
> version is to change lib$(LIB).verso file and make maintainer-clean +
> autogen.sh && configure && make.
> 
> With this patch, only cpg and confdb are there, but adding new library
> means only add LIB_SONAME_IMPORT([lib]) to configure.ac and create of
> lib$(LIB).verso.
> 
> Patch is tested on current trunk on Fedora 11 & FreeBSD 8.0, where it
> produces correct build. Sadly, I'm not able to test Solaris and Darwin
> build.
> 
> Regards,
>   Honza
> plain text document attachment (2010-03-31-verso.patch)
> commit b526f1842c2f5ebc7fb2cf0869522794718c2f9d
> Author: Jan Friesse <jfriesse at redhat.com>
> Date:   Wed Mar 31 14:59:58 2010 +0200
> 
>     Support for specific libraries version
>     
>     Patch adds support for changing version number of library simply by edit
>     lib$(LIB).verso file.
> 
> diff --git a/trunk/configure.ac b/trunk/configure.ac
> index 59f10fb..0e53136 100644
> --- a/trunk/configure.ac
> +++ b/trunk/configure.ac
> @@ -136,6 +136,31 @@ AC_CONFIG_FILES([Makefile
>  ### Local business
>  
>  # ===============================================
> +# Functions / global M4 variables
> +# ===============================================
> +# Global list of LIB names
> +m4_define([local_soname_list], [])
> +
> +# Upcase parameter
> +m4_define([local_upcase], [translit([$*], [a-z], [A-Z])])dnl
> +
> +# M4 macro for include lib/lib$1.soname and subst that
> +m4_define([LIB_SONAME_IMPORT],[dnl
> +m4_define([local_libname], local_upcase($1)[_SONAME])dnl
> +m4_define([local_soname], translit(m4_sinclude(lib/lib$1.verso), [
> +], []))dnl
> +local_libname="local_soname"dnl
> +m4_define([local_soname_list], m4_defn([local_soname_list])[,]local_libname[,]local_upcase($1))dnl
> +AC_SUBST(local_libname)dnl
> +])dnl
> +
> +# Show AC_MSG_RESULT for specific libraries
> +m4_define([LIB_MSG_RESULT], [ifelse([$#], [1],  ,[dnl
> +AC_MSG_RESULT([  $2 Library SONAME		= ${$1}])
> +LIB_MSG_RESULT(m4_shift(m4_shift($@)))dnl
> +])])dnl
> +
> +# ===============================================
>  # Helpers
>  # ===============================================
>  
> @@ -168,17 +193,15 @@ PACKAGE_FEATURES=""
>  LINT_FLAGS="-weak -unrecog +posixlib +ignoresigns -fcnuse \
>  	-badflag -D__gnuc_va_list=va_list -D__attribute\(x\)="
>  
> -# libraries SONAME
> +# default libraries SONAME
>  SOMAJOR="4"
>  SOMINOR="0"
>  SOMICRO="0"
>  SONAME="${SOMAJOR}.${SOMINOR}.${SOMICRO}"
> -# Special for libcpg & libconfdb
> -CPG_SOMICRO="1"
> -CPG_SONAME="${SOMAJOR}.${SOMINOR}.${CPG_SOMICRO}"
> -CONFDB_SOMICRO="0"
> -CONFDB_SOMINOR="1"
> -CONFDB_SONAME="${SOMAJOR}.${CONFDB_SOMINOR}.${CONFDB_SOMICRO}"
> +
> +# specific libraries SONAME
> +LIB_SONAME_IMPORT([cpg])
> +LIB_SONAME_IMPORT([confdb])
>  
>  # local options
>  AC_ARG_ENABLE([ansi],
> @@ -437,8 +460,6 @@ AC_SUBST([SOMAJOR])
>  AC_SUBST([SOMINOR])
>  AC_SUBST([SOMICRO])
>  AC_SUBST([SONAME])
> -AC_SUBST([CPG_SONAME])
> -AC_SUBST([CONFDB_SONAME])
>  AC_SUBST([COVERAGE_LCRSO_EXTRA_LDFLAGS])
>  AC_SUBST([OS_DYFLAGS])
>  
> @@ -488,8 +509,7 @@ AC_MSG_RESULT([  Features                 =${PACKAGE_FEATURES}])
>  AC_MSG_RESULT([])
>  AC_MSG_RESULT([$PACKAGE build info:])
>  AC_MSG_RESULT([  Library SONAME           = ${SONAME}])
> -AC_MSG_RESULT([  CPG Library SONAME       = ${CPG_SONAME}])
> -AC_MSG_RESULT([  CONFDB Library SONAME    = ${CONFDB_SONAME}])
> +LIB_MSG_RESULT(m4_shift(local_soname_list))dnl
>  AC_MSG_RESULT([  Default optimization     = ${OPT_CFLAGS}])
>  AC_MSG_RESULT([  Default debug options    = ${GDB_CFLAGS}])
>  AC_MSG_RESULT([  Extra compiler warnings  = ${EXTRA_WARNING}])
> diff --git a/trunk/lib/Makefile.am b/trunk/lib/Makefile.am
> index d7c43e6..7e4974e 100644
> --- a/trunk/lib/Makefile.am
> +++ b/trunk/lib/Makefile.am
> @@ -30,6 +30,13 @@
>  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
>  # THE POSSIBILITY OF SUCH DAMAGE.
>  
> +# Functions
> +uc=$(shell echo $1 | tr a-z A-Z)
> +get_soname=$(if $($(call uc,$1)_SONAME),$($(call uc,$1)_SONAME),$(SONAME))
> +get_major=$(firstword $(subst ., ,$(call get_soname,$1)))
> +get_sharedlibs=$(foreach lib,$(SHARED_LIBS_SO:lib%.so=%),lib$(lib).so.$(call get_soname,$(lib)))
> +get_sharedlibs_two=$(foreach lib,$(SHARED_LIBS_SO:lib%.so=%),lib$(lib).so.$(call get_major,$(lib)))
> +
>  MAINTAINERCLEANFILES    = Makefile.in
>  
>  AM_CFLAGS		= -fPIC
> @@ -40,10 +47,7 @@ INCLUDES		= -I$(top_builddir)/include -I$(top_srcdir)/include
>  
>  lib_LIBRARIES		= libcpg.a libconfdb.a libevs.a libcfg.a libquorum.a \
>  			  libvotequorum.a libpload.a libcoroipcc.a libsam.a
> -SHARED_LIBS		= $(filter-out libcpg.so.$(SONAME) libconfdb.so.$(SONAME), $(lib_LIBRARIES:%.a=%.so.$(SONAME))) \
> -			  libcpg.so.$(CPG_SONAME) libconfdb.so.$(CONFDB_SONAME)
>  SHARED_LIBS_SO		= $(lib_LIBRARIES:%.a=%.so)
> -SHARED_LIBS_SO_TWO	= $(lib_LIBRARIES:%.a=%.so.$(SOMAJOR))
>  
>  libcpg_a_SOURCES	= cpg.c
>  libcfg_a_SOURCES	= cfg.c
> @@ -52,6 +56,7 @@ libpload_a_SOURCES	= pload.c
>  libquorum_a_SOURCES	= quorum.c
>  libvotequorum_a_SOURCES	= votequorum.c
>  libconfdb_a_SOURCES	= confdb.c sa-confdb.c
> +libconfdb_a_LIBADD	= ../lcr/lcr_ifact.o
>  libcoroipcc_a_SOURCES	= coroipcc.c
>  libsam_a_SOURCES	= sam.c
>  
> @@ -72,21 +77,10 @@ libcoroipcc.so.$(SONAME): coroipcc.o
>  	ln -sf libcoroipcc.so.$(SONAME) libcoroipcc.so
>  	ln -sf libcoroipcc.so.$(SONAME) libcoroipcc.so.$(SOMAJOR)
>  
> -libconfdb.so.$(CONFDB_SONAME): confdb.o sa-confdb.o libcoroipcc.so.$(SONAME)
> -	$(CC) $(LDFLAGS) $(DARWIN_OPTS) coroipcc.o confdb.o \
> -		sa-confdb.o ../lcr/lcr_ifact.o -o $@ -ldl $(AM_LDFLAGS)
> -	ln -sf libconfdb.so.$(CONFDB_SONAME) libconfdb.so
> -	ln -sf libconfdb.so.$(CONFDB_SONAME) libconfdb.so.$(SOMAJOR)
> -
> -libcpg.so.$(CPG_SONAME): cpg.o libcoroipcc.so.$(SONAME)
> -	$(CC) $(DARWIN_OPTS) $^ -o $@
> -	ln -sf $@ libcpg.so
> -	ln -sf $@ libcpg.so.$(SOMAJOR)
> -
> -lib%.so.$(SONAME): %.o libcoroipcc.so.$(SONAME)
> -	$(CC) $(DARWIN_OPTS) $^ -o $@
> -	ln -sf lib$*.so.$(SONAME) lib$*.so
> -	ln -sf lib$*.so.$(SONAME) lib$*.so.$(SOMAJOR)
> +lib%.so: lib%.a libcoroipcc.so.$(SONAME)
> +	$(CC) $(DARWIN_OPTS) -Wl,-whole-archive $^ -Wl,-no-whole-archive -o $@
> +	ln -sf lib$*.so.$(call get_soname,$*) lib$*.so
> +	ln -sf lib$*.so.$(call get_soname,$*) lib$*.so.$(call get_major,$*)
>  
>  else
>  
> @@ -97,21 +91,10 @@ libcoroipcc.so.$(SONAME): coroipcc.o
>  	ln -sf libcoroipcc.so.$(SONAME) libcoroipcc.so
>  	ln -sf libcoroipcc.so.$(SONAME) libcoroipcc.so.$(SOMAJOR)
>  
> -libconfdb.so.$(CONFDB_SONAME): confdb.o sa-confdb.o libcoroipcc.so.$(SONAME)
> -	$(LD) $(LDFLAGS) $(SOLARIS_OPTS) -G coroipcc.o confdb.o \
> -		sa-confdb.o ../lcr/lcr_ifact.o -o $@ -ldl $(AM_LDFLAGS)
> -	ln -sf libconfdb.so.$(CONFDB_SONAME) libconfdb.so
> -	ln -sf libconfdb.so.$(CONFDB_SONAME) libconfdb.so.$(SOMAJOR)
> -
> -libcpg.so.$(CPG_SONAME): cpg.o libcoroipcc.so.$(SONAME)
> -	$(LD) $(SOLARIS_OPTS) -G $^ -o $@
> -	ln -sf $@ libcpg.so
> -	ln -sf $@ libcpg.so.$(SOMAJOR)
> -
> -lib%.so.$(SONAME): %.o libcoroipcc.so.$(SONAME)
> -	$(LD) $(SOLARIS_OPTS) -G $^ -o $@
> -	ln -sf lib$*.so.$(SONAME) lib$*.so
> -	ln -sf lib$*.so.$(SONAME) lib$*.so.$(SOMAJOR)
> +lib%.so.$(SONAME): lib%.a libcoroipcc.so.$(SONAME)
> +	$(LD) $(SOLARIS_OPTS) -G -whole-archive $^ -no-whole-archive -o $@
> +	ln -sf lib$*.so.$(call get_soname,$*) lib$*.so
> +	ln -sf lib$*.so.$(call get_soname,$*) lib$*.so.$(call get_major,$*)
>  
>  else
>  
> @@ -123,45 +106,29 @@ libcoroipcc.so.$(SONAME): coroipcc.o
>  	ln -sf libcoroipcc.so.$(SONAME) libcoroipcc.so
>  	ln -sf libcoroipcc.so.$(SONAME) libcoroipcc.so.$(SOMAJOR)
>  
> -libconfdb.so.$(CONFDB_SONAME): confdb.o sa-confdb.o ../lcr/lcr_ifact.o libcoroipcc.so.$(SONAME)
> -	$(CC) -shared -o $@ \
> -		-Wl,-soname=libconfdb.so.$(SOMAJOR) \
> -		-Wl,-version-script=$(srcdir)/libconfdb.versions \
> -		$^ $(LDFLAGS) $(OS_DYFLAGS) $(OS_LDL) $(AM_LDFLAGS)
> -	ln -sf libconfdb.so.$(CONFDB_SONAME) libconfdb.so
> -	ln -sf libconfdb.so.$(CONFDB_SONAME) libconfdb.so.$(SOMAJOR)
> -
> -libcpg.so.$(CPG_SONAME): cpg.o libcoroipcc.so.$(SONAME)
> -	$(CC) -shared -o $@ \
> -		-Wl,-soname=libcpg.so.$(SOMAJOR) \
> -		-Wl,-version-script=$(srcdir)/libcpg.versions \
> -		$^ $(LDFLAGS) $(AM_LDFLAGS)
> -	ln -sf $@ libcpg.so
> -	ln -sf $@ libcpg.so.$(SOMAJOR)
> -
> -lib%.so.$(SONAME): %.o libcoroipcc.so.$(SONAME)
> -	$(CC) -shared -o $@ \
> -		-Wl,-soname=lib$*.so.$(SOMAJOR) \
> +lib%.so: lib%.a libcoroipcc.so.$(SONAME)
> +	$(CC) -shared -o $@.$(call get_soname,$*) \
> +		-Wl,-soname=lib$*.so.$(call get_major,$*) \
>  		-Wl,-version-script=$(srcdir)/lib$*.versions \
> -		$^ $(LDFLAGS) $(AM_LDFLAGS)
> -	ln -sf lib$*.so.$(SONAME) lib$*.so
> -	ln -sf lib$*.so.$(SONAME) lib$*.so.$(SOMAJOR)
> +		-Wl,-whole-archive $^ -Wl,-no-whole-archive $(LDFLAGS) $(AM_LDFLAGS)
> +	ln -sf lib$*.so.$(call get_soname,$*) lib$*.so
> +	ln -sf lib$*.so.$(call get_soname,$*) lib$*.so.$(call get_major,$*)
>  
>  endif
>  
>  endif
>  
> -all-local: $(SHARED_LIBS)
> +all-local: $(SHARED_LIBS_SO)
>  	@echo Built shared libs
>  
>  install-exec-local:
>  	$(INSTALL) -d $(DESTDIR)/$(libdir)
> -	$(INSTALL) -m 755 $(SHARED_LIBS) $(DESTDIR)/$(libdir)
> -	$(CP) -a $(SHARED_LIBS_SO) $(SHARED_LIBS_SO_TWO) $(DESTDIR)/$(libdir)
> +	$(INSTALL) -m 755 $(get_sharedlibs) $(DESTDIR)/$(libdir)
> +	$(CP) -a $(SHARED_LIBS_SO) $(get_sharedlibs_two) $(DESTDIR)/$(libdir)
>  
>  uninstall-local:
>  	cd $(DESTDIR)/$(libdir)/ && \
> -		rm -f $(SHARED_LIBS) $(SHARED_LIBS_SO) $(SHARED_LIBS_SO_TWO)
> +		rm -f $(get_sharedlibs) $(SHARED_LIBS_SO) $(get_sharedlibs_two)
>  
>  clean-local:
>  	rm -f *.o *.a *.so* *.da *.bb *.bbg
> diff --git a/trunk/lib/libconfdb.verso b/trunk/lib/libconfdb.verso
> new file mode 100644
> index 0000000..ee74734
> --- /dev/null
> +++ b/trunk/lib/libconfdb.verso
> @@ -0,0 +1 @@
> +4.1.0
> diff --git a/trunk/lib/libcpg.verso b/trunk/lib/libcpg.verso
> new file mode 100644
> index 0000000..1454f6e
> --- /dev/null
> +++ b/trunk/lib/libcpg.verso
> @@ -0,0 +1 @@
> +4.0.1
> _______________________________________________
> Openais mailing list
> Openais at lists.linux-foundation.org
> https://lists.linux-foundation.org/mailman/listinfo/openais



More information about the Openais mailing list