These changes cause shared libraries to be built by default. In particular, lib/libopenvwitch.so, lib/libsflow.so, ofproto/libofproto.so, and ovsdb/libovsdb.so will be built. Original behavior of building static objects excusively may be accomplished by providing the --disable-shared argument to configure.
Additionally, versioning is introduced to each of the libraries objects paving the way for APIs to be built around them. A detailed comment outlining the rules for changing a version number is provided in configure.ac. Note that at this time, the version number is set to 1.0.0, no API is specified yet, and there are no requirements to maintain any sort of compatibility in any of the libraries. Signed-off-by: Scott Mann <sm...@noironetworks.com> --- .travis/build.sh | 2 ++ INSTALL | 5 +++++ acinclude.m4 | 2 +- configure.ac | 48 +++++++++++++++++++++++++++++++++++++++++++++-- lib/automake.mk | 8 ++++++-- lib/libopenvswitch.sym.in | 4 ++++ lib/libsflow.sym.in | 4 ++++ lib/util.c | 8 +++++++- lib/vlog.h | 9 ++++++--- ofproto/automake.mk | 4 +++- ofproto/libofproto.sym.in | 4 ++++ ovsdb/automake.mk | 4 +++- ovsdb/libovsdb.sym.in | 4 ++++ 13 files changed, 95 insertions(+), 11 deletions(-) create mode 100644 lib/libopenvswitch.sym.in create mode 100644 lib/libsflow.sym.in create mode 100644 ofproto/libofproto.sym.in create mode 100644 ovsdb/libovsdb.sym.in diff --git a/.travis/build.sh b/.travis/build.sh index 5dba4fe..d56350f 100755 --- a/.travis/build.sh +++ b/.travis/build.sh @@ -24,6 +24,8 @@ function install_dpdk() cd dpdk-1.7.1 find ./ -type f | xargs sed -i 's/max-inline-insns-single=100/max-inline-insns-single=400/' sed -ri 's,(CONFIG_RTE_BUILD_COMBINE_LIBS=).*,\1y,' config/common_linuxapp + sed -ri '/CONFIG_RTE_LIBNAME/a CONFIG_RTE_BUILD_FPIC=y' config/common_linuxapp + sed -ri '/EXECENV_CFLAGS = -pthread -fPIC/{s/$/\nelse ifeq ($(CONFIG_RTE_BUILD_FPIC),y)/;s/$/\nEXECENV_CFLAGS = -pthread -fPIC/}' mk/exec-env/linuxapp/rte.vars.mk make config CC=gcc T=x86_64-native-linuxapp-gcc make CC=gcc RTE_KERNELDIR=$KERNELSRC echo "Installed DPDK source in $(pwd)" diff --git a/INSTALL b/INSTALL index 3cfdc04..a4b129c 100644 --- a/INSTALL +++ b/INSTALL @@ -166,6 +166,11 @@ Prerequisites section, follow the procedure below to build. % ./configure --prefix=/usr --localstatedir=/var + By default, shared libraries are built and linked against. If you + want to use static libraries instead: + + % ./configure --disable-shared + To use a specific C compiler for compiling Open vSwitch user programs, also specify it on the configure command line, like so: diff --git a/acinclude.m4 b/acinclude.m4 index f0617df..c4d9b8e 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -170,7 +170,7 @@ AC_DEFUN([OVS_CHECK_DPDK], [ DPDK_INCLUDE=$RTE_SDK/include DPDK_LIB_DIR=$RTE_SDK/lib - DPDK_LIB=-lintel_dpdk + DPDK_LIB=$RTE_SDK/lib/libintel_dpdk.a ovs_save_CFLAGS="$CFLAGS" ovs_save_LDFLAGS="$LDFLAGS" diff --git a/configure.ac b/configure.ac index 62224b9..554469c 100644 --- a/configure.ac +++ b/configure.ac @@ -40,9 +40,47 @@ AC_USE_SYSTEM_EXTENSIONS AC_C_BIGENDIAN AC_SYS_LARGEFILE -LT_INIT([disable-shared]) +# LT_INIT causes shared objects to be built by default. Use the +# --disable-shared argument to configure in order to build static +# objects. +LT_INIT m4_pattern_forbid([LT_INIT]) dnl Make autoconf fail if libtool is missing. +# The following explanation may help to understand the use of the +# version number fields: current, revision, and age. +# +# Consider that there are three possible kinds of reactions from +# users of your library to changes in a shared library: +# +# 1. Programs using the previous version may use the new version as drop-in +# replacement, and programs using the new version can also work with the +# previous one. In other words, no recompiling nor relinking is needed. +# In short, there are no changes to any symbols, no symbols removed, +# and no symbols added. In this case, bump revision only, don't touch +# current nor age. +# +# 2. Programs using the previous version may use the new version as drop-in +# replacement, but programs using the new version may use APIs not +# present in the previous one. In other words, new symbols have been +# added and a program linking against the new version may fail with +# “unresolved symbols.” If linking against the old version at runtime: +# set revision to 0, bump current and age. +# +# 3. Programs may need to be changed, recompiled, relinked in order to use +# the new version. This is the case when symbols have been modified or +# deleted. Bump current, set revision and age to 0. + +m4_define([libopenvswitch_lt_current], [1]) +m4_define([libopenvswitch_lt_revision], [0]) +m4_define([libopenvswitch_lt_age], [0]) + +LT_CURRENT=libopenvswitch_lt_current +AC_SUBST(LT_CURRENT) +LT_REVISION=libopenvswitch_lt_revision +AC_SUBST(LT_REVISION) +LT_AGE=libopenvswitch_lt_age +AC_SUBST(LT_AGE) + AC_SEARCH_LIBS([pow], [m]) AC_SEARCH_LIBS([clock_gettime], [rt]) AC_SEARCH_LIBS([timer_create], [rt]) @@ -94,7 +132,13 @@ OVS_CHECK_LINUX_HOST AX_FUNC_POSIX_MEMALIGN OVS_CHECK_INCLUDE_NEXT([stdio.h string.h]) -AC_CONFIG_FILES([lib/stdio.h lib/string.h]) +AC_CONFIG_FILES([ + lib/stdio.h + lib/string.h + ovsdb/libovsdb.sym + ofproto/libofproto.sym + lib/libsflow.sym + lib/libopenvswitch.sym]) OVS_ENABLE_OPTION([-Wall]) OVS_ENABLE_OPTION([-Wextra]) diff --git a/lib/automake.mk b/lib/automake.mk index b618f8f..a74d88e 100644 --- a/lib/automake.mk +++ b/lib/automake.mk @@ -13,7 +13,9 @@ if WIN32 lib_libopenvswitch_la_LIBADD += ${PTHREAD_LIBS} endif -lib_libopenvswitch_la_LDFLAGS = -release $(VERSION) +lib_libopenvswitch_la_LDFLAGS = \ + -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ + -Wl,--version-script=$(top_builddir)/lib/libopenvswitch.sym lib_libopenvswitch_la_SOURCES = \ lib/aes128.c \ @@ -286,7 +288,9 @@ nodist_lib_libopenvswitch_la_SOURCES = \ CLEANFILES += $(nodist_lib_libopenvswitch_la_SOURCES) lib_LTLIBRARIES += lib/libsflow.la -lib_libsflow_la_LDFLAGS = -release $(VERSION) +lib_libsflow_la_LDFLAGS = \ + -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ + -Wl,--version-script=$(top_builddir)/lib/libsflow.sym lib_libsflow_la_SOURCES = \ lib/sflow_api.h \ lib/sflow.h \ diff --git a/lib/libopenvswitch.sym.in b/lib/libopenvswitch.sym.in new file mode 100644 index 0000000..fdfc5bb --- /dev/null +++ b/lib/libopenvswitch.sym.in @@ -0,0 +1,4 @@ +libopenvswitch_@LT_CURRENT@ { +global: + *; +}; diff --git a/lib/libsflow.sym.in b/lib/libsflow.sym.in new file mode 100644 index 0000000..88b9cc1 --- /dev/null +++ b/lib/libsflow.sym.in @@ -0,0 +1,4 @@ +libsflow_@LT_CURRENT@ { +global: + *; +}; diff --git a/lib/util.c b/lib/util.c index fb2ff51..3270b32 100644 --- a/lib/util.c +++ b/lib/util.c @@ -471,9 +471,15 @@ set_program_name__(const char *argv0, const char *version, const char *date, assert_single_threaded(); free(program_name); + /* Remove libtool prefix, if it is there */ + if(strncmp(basename,"lt-",3) == 0) { + char *tmp_name = basename; + basename = xstrdup(basename+3); + free(tmp_name); + } program_name = basename; - free(program_version); + free(program_version); if (!strcmp(version, VERSION)) { program_version = xasprintf("%s (Open vSwitch) "VERSION"\n" "Compiled %s %s\n", diff --git a/lib/vlog.h b/lib/vlog.h index 974a301..ca7c553 100644 --- a/lib/vlog.h +++ b/lib/vlog.h @@ -91,10 +91,13 @@ extern struct list vlog_modules; /* Creates and initializes a global instance of a module named MODULE. */ #define VLOG_DEFINE_MODULE(MODULE) \ - VLOG_DEFINE_MODULE__(MODULE) \ - OVS_CONSTRUCTOR(init_##MODULE) { \ - list_insert(&vlog_modules, &VLM_##MODULE.list); \ + VLOG_DEFINE_MODULE__(MODULE) \ + OVS_CONSTRUCTOR(init_##MODULE) { \ + struct vlog_module *mp = vlog_module_from_name(#MODULE); \ + if (mp == NULL) { \ + list_insert(&vlog_modules, &VLM_##MODULE.list); \ } \ + } \ const char *vlog_get_module_name(const struct vlog_module *); struct vlog_module *vlog_module_from_name(const char *name); diff --git a/ofproto/automake.mk b/ofproto/automake.mk index 399f2b6..bb4bc7e 100644 --- a/ofproto/automake.mk +++ b/ofproto/automake.mk @@ -6,7 +6,9 @@ # without warranty of any kind. lib_LTLIBRARIES += ofproto/libofproto.la -ofproto_libofproto_la_LDFLAGS = -release $(VERSION) +ofproto_libofproto_la_LDFLAGS = \ + -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ + -Wl,--version-script=$(top_builddir)/ofproto/libofproto.sym ofproto_libofproto_la_SOURCES = \ ofproto/bond.c \ ofproto/bond.h \ diff --git a/ofproto/libofproto.sym.in b/ofproto/libofproto.sym.in new file mode 100644 index 0000000..cdd4327 --- /dev/null +++ b/ofproto/libofproto.sym.in @@ -0,0 +1,4 @@ +libofproto_@LT_CURRENT@ { +global: + *; +}; diff --git a/ovsdb/automake.mk b/ovsdb/automake.mk index 00a0b01..7a8d7d2 100644 --- a/ovsdb/automake.mk +++ b/ovsdb/automake.mk @@ -1,6 +1,8 @@ # libovsdb lib_LTLIBRARIES += ovsdb/libovsdb.la -ovsdb_libovsdb_la_LDFLAGS = -release $(VERSION) +ovsdb_libovsdb_la_LDFLAGS = \ + -version-info $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) \ + -Wl,--version-script=$(top_builddir)/ovsdb/libovsdb.sym ovsdb_libovsdb_la_SOURCES = \ ovsdb/column.c \ ovsdb/column.h \ diff --git a/ovsdb/libovsdb.sym.in b/ovsdb/libovsdb.sym.in new file mode 100644 index 0000000..71ae4e8 --- /dev/null +++ b/ovsdb/libovsdb.sym.in @@ -0,0 +1,4 @@ +libovsdb_@LT_CURRENT@ { +global: + *; +}; -- 1.9.3 _______________________________________________ dev mailing list dev@openvswitch.org http://openvswitch.org/mailman/listinfo/dev