[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[virt-tools-list] [PATCH 41/47] Add proper ELF versioning



Rename library to libosinfo-1.0.la to allow parallel install if
we need to break ABI in the future. Add per-symbol version tagging
to allow fine grained automatic RPM dependancies. Make version
script portable to Win32

* configure.ac: Detect args for linker symbol file / format
* osinfo/Makefile.am: Rename library and use symbol versioning
* osinfo/libosinfo.syms: Symbol version script
---
 configure.ac          |   42 +++++++++++++++++++++++-
 osinfo/Makefile.am    |   37 ++++++++++++++++----
 osinfo/libosinfo.syms |   86 +++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 156 insertions(+), 9 deletions(-)
 create mode 100644 osinfo/libosinfo.syms

diff --git a/configure.ac b/configure.ac
index 692328c..a088ae7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([libosinfo], [0.2], [virt-tools-list redhat com])
+AC_INIT([libosinfo], [0.2.0], [virt-tools-list redhat com])
 AC_CONFIG_AUX_DIR([build-aux])
 AC_CONFIG_MACRO_DIR([m4])
 AM_INIT_AUTOMAKE([1.11.1 foreign color-tests])
@@ -20,6 +20,46 @@ LIBXML_REQUIRED=2.6.0
 #PKG_CHECK_MODULES([GLIB], [glib-2.0], [GLIB_FOUND=yes], [GLIB_FOUND=no])
 PKG_CHECK_MODULES([GOBJECT], [gobject-2.0], [GOBJECT_FOUND=yes], [GOBJECT_FOUND=no])
 
+LIBOSINFO_MAJOR_VERSION=`echo $VERSION | awk -F. '{print $1}'`
+LIBOSINFO_MINOR_VERSION=`echo $VERSION | awk -F. '{print $2}'`
+LIBOSINFO_MICRO_VERSION=`echo $VERSION | awk -F. '{print $3}'`
+LIBOSINFO_VERSION=$LIBOSINFO_MAJOR_VERSION.$LIBOSINFO_MINOR_VERSION.$LIBOSINFO_MICRO_VERSION$LIBOSINFO_MICRO_VERSION_SUFFIX
+LIBOSINFO_VERSION_INFO=`expr $LIBOSINFO_MAJOR_VERSION + $LIBOSINFO_MINOR_VERSION`:$LIBOSINFO_MICRO_VERSION:$LIBOSINFO_MINOR_VERSION
+LIBOSINFO_VERSION_NUMBER=`expr $LIBOSINFO_MAJOR_VERSION \* 1000000 + $LIBOSINFO_MINOR_VERSION \* 1000 + $LIBOSINFO_MICRO_VERSION`
+
+AC_SUBST([LIBOSINFO_MAJOR_VERSION])
+AC_SUBST([LIBOSINFO_MINOR_VERSION])
+AC_SUBST([LIBOSINFO_MICRO_VERSION])
+AC_SUBST([LIBOSINFO_VERSION])
+AC_SUBST([LIBOSINFO_VERSION_INFO])
+AC_SUBST([LIBOSINFO_VERSION_NUMBER])
+
+NO_UNDEFINED_LDFLAGS=
+VERSION_SCRIPT_FLAGS=
+USE_VERSION_DEFS=0
+case "$host" in
+  *-*-mingw*)
+    VERSION_SCRIPT_FLAGS="-Wl,"
+    USE_VERSION_DEFS=1
+    NO_UNDEFINED_FLAGS="-no-undefined"
+    ;;
+
+  *-*-cygwin*)
+    NO_UNDEFINED_LDFLAGS="-no-undefined"
+    ;;
+
+  *)
+    NO_UNDEFINED_FLAGS="-Wl,--no-undefined"
+    VERSION_SCRIPT_FLAGS=-Wl,--version-script=
+    `ld --help 2>&1 | grep -- --version-script >/dev/null` || \
+      VERSION_SCRIPT_FLAGS="-Wl,-M -Wl,"
+    ;;
+esac
+AC_SUBST([NO_UNDEFINED_FLAGS])
+AC_SUBST([VERSION_SCRIPT_FLAGS])
+AM_CONDITIONAL([USE_VERSION_DEFS], [test "$USE_VERSION_DEFS" = "1"])
+
+
 dnl ==========================================================================
 dnl find libxml2 library, borrowed from xmlsec
 dnl ==========================================================================
diff --git a/osinfo/Makefile.am b/osinfo/Makefile.am
index cbe56d7..89ee4f9 100644
--- a/osinfo/Makefile.am
+++ b/osinfo/Makefile.am
@@ -1,18 +1,39 @@
 
-AM_CPPFLAGS = \
+EXTRA_DIST = libosinfo.syms
+
+if USE_VERSION_DEFS
+LIBOSINFO_VERSION_FILE = $(builddir)/libosinfo.def
+BUILT_SOURCES = $(LIBOSINFO_VERSION_FILE)
+
+%.def: %.syms
+	$(AM_V_GEN)rm -f -- $ -tmp $@ ; \
+	printf 'EXPORTS\n' > $ -tmp && \
+	sed -e '/^$$/d; /#/d; /:/d; /\}/d; /\*/d; /LIBVIRT_/d; s/[ \t]*\(.*\)\;/    \1/g' $^ >> $ -tmp && \
+	chmod a-w $ -tmp && \
+	mv $ -tmp $@
+
+else
+LIBOSINFO_VERSION_FILE = libosinfo.syms
+endif
+
+lib_LTLIBRARIES = libosinfo-1.0.la
+
+libosinfo_1_0_la_CFLAGS = \
 	$(WARN_CFLAGS) \
 	-I$(top_srcdir) \
 	$(LIBXML_CFLAGS) \
 	$(GOBJECT_CFLAGS)
-libosinfo_la_LDFLAGS = \
-	$(LIBXML_LIBS) \
-	$(GOBJECT_LIBS) -Wl,-no-undefined
 
-lib_LTLIBRARIES = libosinfo.la
+libosinfo_1_0_la_LDFLAGS = \
+	$(LIBXML_LIBS) \
+	$(GOBJECT_LIBS) \
+	$(VERSION_SCRIPT_FLAGS)$(LIBOSINFO_VERSION_FILE) \
+        -version-info $(LIBOSINFO_VERSION_INFO) \
+	$(NO_UNDEFINED_FLAGS)
 
-libosinfo_includedir = $(includedir)/osinfo-1.0/osinfo
+libosinfo_1_0_includedir = $(includedir)/osinfo-1.0/osinfo
 
-libosinfo_include_HEADERS = 		\
+libosinfo_1_0_include_HEADERS = 		\
   osinfo_db.h		\
   osinfo_device.h		\
   osinfo_devicelist.h		\
@@ -25,7 +46,7 @@ libosinfo_include_HEADERS = 		\
   osinfo_osfilter.h     \
   osinfo_oslist.h
 
-libosinfo_la_SOURCES =		\
+libosinfo_1_0_la_SOURCES =		\
   osinfo_entity.c		\
   osinfo_filter.c		\
   osinfo_list.c			\
diff --git a/osinfo/libosinfo.syms b/osinfo/libosinfo.syms
new file mode 100644
index 0000000..e407d47
--- /dev/null
+++ b/osinfo/libosinfo.syms
@@ -0,0 +1,86 @@
+LIBOSINFO_0.0.1 {
+    global:
+	osinfo_db_get_type;
+	osinfo_db_new;
+	osinfo_db_initialize;
+	osinfo_db_get_hypervisor;
+	osinfo_db_get_device;
+	osinfo_db_get_os;
+	osinfo_db_get_os_list;
+	osinfo_db_get_hypervisor_list;
+	osinfo_db_get_device_list;
+	osinfo_db_unique_values_for_property_in_os;
+	osinfo_db_unique_values_for_property_in_hv;
+	osinfo_db_unique_values_for_property_in_dev;
+	osinfo_db_unique_values_for_os_relationship;
+	osinfo_device_get_type;
+	osinfo_device_new;
+	osinfo_devicelist_get_type;
+	osinfo_devicelist_new;
+	osinfo_devicelist_new_filtered;
+	osinfo_devicelist_new_intersection;
+	osinfo_devicelist_new_union;
+	osinfo_entity_get_type;
+	osinfo_entity_get_id;
+	osinfo_entity_get_param_keys;
+	osinfo_entity_get_param_value;
+	osinfo_entity_get_param_value_list;
+	osinfo_entity_add_param;
+	osinfo_entity_clear_param;
+	osinfo_filter_get_type;
+	osinfo_filter_new;
+	osinfo_filter_add_constraint;
+	osinfo_filter_clear_constraint;
+	osinfo_filter_clear_constraints;
+	osinfo_filter_get_constraint_keys;
+	osinfo_filter_get_constraint_values;
+	osinfo_filter_matches;
+	osinfo_hypervisor_get_type;
+	osinfo_hypervisor_new;
+	osinfo_hypervisor_get_devices;
+	osinfo_hypervisor_add_device;
+	osinfo_hypervisorlist_get_type;
+	osinfo_hypervisorlist_new;
+	osinfo_hypervisorlist_new_filtered;
+	osinfo_hypervisorlist_new_intersection;
+	osinfo_hypervisorlist_new_union;
+	osinfo_list_get_type;
+	osinfo_list_get_length;
+	osinfo_list_get_nth;
+	osinfo_list_find_by_id;
+	osinfo_list_add;
+	osinfo_list_add_filtered;
+	osinfo_list_add_intersection;
+	osinfo_list_add_union;
+	osinfo_list_foreach;
+	osinfo_osfilter_get_type;
+	osinfo_osfilter_new;
+	osinfo_osfilter_add_os_constraint;
+	osinfo_osfilter_clear_os_constraint;
+	osinfo_osfilter_clear_os_constraints;
+	osinfo_osfilter_get_os_constraint_values;
+	osinfo_os_get_type;
+	osinfo_os_new;
+	osinfo_os_get_preferred_device;
+	osinfo_os_get_related;
+	osinfo_os_get_devices;
+	osinfo_os_add_device;
+	osinfo_os_add_related_os;
+	osinfo_oslist_get_type;
+	osinfo_oslist_new;
+	osinfo_oslist_new_filtered;
+	osinfo_oslist_new_intersection;
+	osinfo_oslist_new_union;
+
+    local:
+        *;
+};
+
+/* Symbols in next release...
+
+  LIBOSINFO_0.0.2 {
+    global:
+      ...
+  } LIBOSINFO_0.0.1;
+
+*/
-- 
1.7.2.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]