Skip to content

Commit

Permalink
openvswitch: Use libtool and allow building shared libs
Browse files Browse the repository at this point in the history
Currently openvswitch builds all libraries static only. However,
libopenvswitch is linked into nearly all openvswitch executables
making it hardly possible to run openvswitch on embedded devices
(for example running OpenWrt).

Convert openvswitch to use libtool for building its internal libs.
This allows "--enable-shared" and "--enable-static" as configure
arguments. Default is "--disable-shared" thus keeping the current
behavior with the only change that static libs are installed by
"make install".

Since the openvswitch library interfaces are internal and thus not
stable (yet) encode the openvswitch version into the library name:
libopenvswitch-2.0.90.so

Binary size is reduced to around 1/3 when using shared libs.

Signed-off-by: Helmut Schaa <[email protected]>
Signed-off-by: Ben Pfaff <[email protected]>
  • Loading branch information
helmut-jacob authored and blp committed Dec 18, 2013
1 parent 45ebaaf commit 38b7a52
Show file tree
Hide file tree
Showing 15 changed files with 95 additions and 71 deletions.
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Guolin Yang [email protected]
Gurucharan Shetty [email protected]
Henry Mai [email protected]
Hao Zheng [email protected]
Helmut Schaa [email protected]
Ian Campbell [email protected]
Isaku Yamahata [email protected]
James P. [email protected]
Expand Down
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ MAN_FRAGMENTS =
MAN_ROOTS =
noinst_DATA =
noinst_HEADERS =
noinst_LIBRARIES =
lib_LTLIBRARIES =
noinst_man_MANS =
noinst_PROGRAMS =
noinst_SCRIPTS =
Expand Down
2 changes: 1 addition & 1 deletion acinclude.m4
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ AC_DEFUN([OVS_ENABLE_SPARSE],
AC_SUBST([SPARSE])
AC_CONFIG_COMMANDS_PRE(
[if test $ovs_cv_gnu_make_if = yes; then
CC='$(if $(C),REAL_CC="'"$CC"'" CHECK="$(SPARSE) -I $(top_srcdir)/include/sparse $(SPARSEFLAGS) $(SPARSE_EXTRA_INCLUDES) " cgcc $(CGCCFLAGS),'"$CC"')'
CC='$(if $(C),env REAL_CC="'"$CC"'" CHECK="$(SPARSE) -I $(top_srcdir)/include/sparse $(SPARSEFLAGS) $(SPARSE_EXTRA_INCLUDES) " cgcc $(CGCCFLAGS),'"$CC"')'
fi])])

dnl OVS_PTHREAD_SET_NAME
Expand Down
1 change: 1 addition & 0 deletions build-aux/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
/config.sub
/depcomp
/install-sh
/ltmain.sh
/missing
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ AM_INIT_AUTOMAKE
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_CPP
AC_PROG_RANLIB
AC_PROG_MKDIR_P
AC_PROG_FGREP
AC_PROG_EGREP
Expand All @@ -41,6 +40,7 @@ AC_USE_SYSTEM_EXTENSIONS
AC_C_BIGENDIAN
AC_SYS_LARGEFILE

LT_INIT([disable-shared])
AC_SEARCH_LIBS([pow], [m])
AC_SEARCH_LIBS([clock_gettime], [rt])
AC_SEARCH_LIBS([timer_create], [rt])
Expand Down
39 changes: 22 additions & 17 deletions lib/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
# notice and this notice are preserved. This file is offered as-is,
# without warranty of any kind.

noinst_LIBRARIES += lib/libopenvswitch.a
lib_LTLIBRARIES += lib/libopenvswitch.la

lib_libopenvswitch_a_SOURCES = \
lib_libopenvswitch_la_LIBADD = $(SSL_LIBS)
lib_libopenvswitch_la_LDFLAGS = -release $(VERSION)

lib_libopenvswitch_la_SOURCES = \
lib/aes128.c \
lib/aes128.h \
lib/async-append.h \
Expand Down Expand Up @@ -233,28 +236,30 @@ lib_libopenvswitch_a_SOURCES = \
lib/vtep-idl.h
EXTRA_DIST += lib/string.h.in

nodist_lib_libopenvswitch_a_SOURCES = \
nodist_lib_libopenvswitch_la_SOURCES = \
lib/dirs.c
CLEANFILES += $(nodist_lib_libopenvswitch_a_SOURCES)
CLEANFILES += $(nodist_lib_libopenvswitch_la_SOURCES)

noinst_LIBRARIES += lib/libsflow.a
lib_libsflow_a_SOURCES = \
lib_LTLIBRARIES += lib/libsflow.la
lib_libsflow_la_LDFLAGS = -release $(VERSION)
lib_libsflow_la_SOURCES = \
lib/sflow_api.h \
lib/sflow.h \
lib/sflow_agent.c \
lib/sflow_sampler.c \
lib/sflow_poller.c \
lib/sflow_receiver.c
lib_libsflow_a_CFLAGS = $(AM_CFLAGS)
lib_libsflow_la_CPPFLAGS = $(AM_CPPFLAGS)
lib_libsflow_la_CFLAGS = $(AM_CFLAGS)
if HAVE_WNO_UNUSED
lib_libsflow_a_CFLAGS += -Wno-unused
lib_libsflow_la_CFLAGS += -Wno-unused
endif
if HAVE_WNO_UNUSED_PARAMETER
lib_libsflow_a_CFLAGS += -Wno-unused-parameter
lib_libsflow_la_CFLAGS += -Wno-unused-parameter
endif

if LINUX_DATAPATH
lib_libopenvswitch_a_SOURCES += \
lib_libopenvswitch_la_SOURCES += \
lib/dpif-linux.c \
lib/dpif-linux.h \
lib/netdev-linux.c \
Expand All @@ -271,27 +276,27 @@ lib_libopenvswitch_a_SOURCES += \
endif

if HAVE_POSIX_AIO
lib_libopenvswitch_a_SOURCES += lib/async-append-aio.c
lib_libopenvswitch_la_SOURCES += lib/async-append-aio.c
else
lib_libopenvswitch_a_SOURCES += lib/async-append-null.c
lib_libopenvswitch_la_SOURCES += lib/async-append-null.c
endif

if ESX
lib_libopenvswitch_a_SOURCES += \
lib_libopenvswitch_la_SOURCES += \
lib/route-table-stub.c
endif

if HAVE_IF_DL
lib_libopenvswitch_a_SOURCES += \
lib_libopenvswitch_la_SOURCES += \
lib/netdev-bsd.c \
lib/rtbsd.c \
lib/rtbsd.h \
lib/route-table-bsd.c
endif

if HAVE_OPENSSL
lib_libopenvswitch_a_SOURCES += lib/stream-ssl.c
nodist_lib_libopenvswitch_a_SOURCES += lib/dhparams.c
lib_libopenvswitch_la_SOURCES += lib/stream-ssl.c
nodist_lib_libopenvswitch_la_SOURCES += lib/dhparams.c
lib/dhparams.c: lib/dh1024.pem lib/dh2048.pem lib/dh4096.pem
(echo '#include "lib/dhparams.h"' && \
openssl dhparam -C -in $(srcdir)/lib/dh1024.pem -noout && \
Expand All @@ -300,7 +305,7 @@ lib/dhparams.c: lib/dh1024.pem lib/dh2048.pem lib/dh4096.pem
| sed 's/\(get_dh[0-9]*\)()/\1(void)/' > lib/dhparams.c.tmp
mv lib/dhparams.c.tmp lib/dhparams.c
else
lib_libopenvswitch_a_SOURCES += lib/stream-nossl.c
lib_libopenvswitch_la_SOURCES += lib/stream-nossl.c
endif

EXTRA_DIST += \
Expand Down
5 changes: 5 additions & 0 deletions m4/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/libtool.m4
/ltoptions.m4
/ltsugar.m4
/ltversion.m4
/lt~obsolete.m4
10 changes: 7 additions & 3 deletions ofproto/automake.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
# notice and this notice are preserved. This file is offered as-is,
# without warranty of any kind.

noinst_LIBRARIES += ofproto/libofproto.a
ofproto_libofproto_a_SOURCES = \
lib_LTLIBRARIES += ofproto/libofproto.la
ofproto_libofproto_la_LDFLAGS = -release $(VERSION)
ofproto_libofproto_la_SOURCES = \
ofproto/bond.c \
ofproto/bond.h \
ofproto/collectors.c \
Expand Down Expand Up @@ -45,10 +46,13 @@ ofproto_libofproto_a_SOURCES = \
ofproto/pinsched.h \
ofproto/tunnel.c \
ofproto/tunnel.h
ofproto_libofproto_la_CPPFLAGS = $(AM_CPPFLAGS)
ofproto_libofproto_la_CFLAGS = $(AM_CFLAGS)
ofproto_libofproto_la_LIBADD = lib/libsflow.la

# Distribute this generated file in order not to require Python at
# build time if ofproto/ipfix.xml is not modified.
ofproto_libofproto_a_SOURCES += ofproto/ipfix-entities.def
ofproto_libofproto_la_SOURCES += ofproto/ipfix-entities.def

BUILT_SOURCES += ofproto/ipfix-entities.def

Expand Down
14 changes: 9 additions & 5 deletions ovsdb/automake.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# libovsdb
noinst_LIBRARIES += ovsdb/libovsdb.a
ovsdb_libovsdb_a_SOURCES = \
lib_LTLIBRARIES += ovsdb/libovsdb.la
ovsdb_libovsdb_la_LDFLAGS = -release $(VERSION)
ovsdb_libovsdb_la_SOURCES = \
ovsdb/column.c \
ovsdb/column.h \
ovsdb/condition.c \
Expand Down Expand Up @@ -29,14 +30,17 @@ ovsdb_libovsdb_a_SOURCES = \
ovsdb/trigger.h \
ovsdb/transaction.c \
ovsdb/transaction.h
ovsdb_libovsdb_la_CFLAGS = $(AM_CFLAGS)
ovsdb_libovsdb_la_CPPFLAGS = $(AM_CPPFLAGS)

MAN_FRAGMENTS += \
ovsdb/remote-active.man \
ovsdb/remote-passive.man

# ovsdb-tool
bin_PROGRAMS += ovsdb/ovsdb-tool
ovsdb_ovsdb_tool_SOURCES = ovsdb/ovsdb-tool.c
ovsdb_ovsdb_tool_LDADD = ovsdb/libovsdb.a lib/libopenvswitch.a $(SSL_LIBS)
ovsdb_ovsdb_tool_LDADD = ovsdb/libovsdb.la lib/libopenvswitch.la $(SSL_LIBS)
# ovsdb-tool.1
man_MANS += ovsdb/ovsdb-tool.1
DISTCLEANFILES += ovsdb/ovsdb-tool.1
Expand All @@ -45,7 +49,7 @@ MAN_ROOTS += ovsdb/ovsdb-tool.1.in
# ovsdb-client
bin_PROGRAMS += ovsdb/ovsdb-client
ovsdb_ovsdb_client_SOURCES = ovsdb/ovsdb-client.c
ovsdb_ovsdb_client_LDADD = ovsdb/libovsdb.a lib/libopenvswitch.a $(SSL_LIBS)
ovsdb_ovsdb_client_LDADD = ovsdb/libovsdb.la lib/libopenvswitch.la $(SSL_LIBS)
# ovsdb-client.1
man_MANS += ovsdb/ovsdb-client.1
DISTCLEANFILES += ovsdb/ovsdb-client.1
Expand All @@ -54,7 +58,7 @@ MAN_ROOTS += ovsdb/ovsdb-client.1.in
# ovsdb-server
sbin_PROGRAMS += ovsdb/ovsdb-server
ovsdb_ovsdb_server_SOURCES = ovsdb/ovsdb-server.c
ovsdb_ovsdb_server_LDADD = ovsdb/libovsdb.a lib/libopenvswitch.a $(SSL_LIBS)
ovsdb_ovsdb_server_LDADD = ovsdb/libovsdb.la lib/libopenvswitch.la $(SSL_LIBS)
# ovsdb-server.1
man_MANS += ovsdb/ovsdb-server.1
DISTCLEANFILES += ovsdb/ovsdb-server.1
Expand Down
3 changes: 3 additions & 0 deletions rhel/openvswitch-fedora.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ install python/compat/argparse.py $RPM_BUILD_ROOT/usr/share/openvswitch/python

install -d -m 755 $RPM_BUILD_ROOT/var/lib/openvswitch

# Get rid of stuff we don't want to make RPM happy.
rm -rf $RPM_BUILD_ROOT/%{_lib}

%clean
rm -rf $RPM_BUILD_ROOT

Expand Down
1 change: 1 addition & 0 deletions rhel/openvswitch.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ rm \
$RPM_BUILD_ROOT/usr/share/man/man8/ovs-l3ping.8 \
$RPM_BUILD_ROOT/usr/sbin/ovs-vlan-bug-workaround \
$RPM_BUILD_ROOT/usr/share/man/man8/ovs-vlan-bug-workaround.8
rm -rf $RPM_BUILD_ROOT/%{_lib}

install -d -m 755 $RPM_BUILD_ROOT/var/lib/openvswitch

Expand Down
Loading

0 comments on commit 38b7a52

Please sign in to comment.