Skip to content

Commit 38b7a52

Browse files
helmut-jacobblp
authored andcommitted
openvswitch: Use libtool and allow building shared libs
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 <helmut.schaa@googlemail.com> Signed-off-by: Ben Pfaff <blp@nicira.com>
1 parent 45ebaaf commit 38b7a52

15 files changed

Lines changed: 95 additions & 71 deletions

File tree

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ Guolin Yang gyang@nicira.com
4949
Gurucharan Shetty gshetty@nicira.com
5050
Henry Mai hmai@nicira.com
5151
Hao Zheng hzheng@nicira.com
52+
Helmut Schaa helmut.schaa@googlemail.com
5253
Ian Campbell Ian.Campbell@citrix.com
5354
Isaku Yamahata yamahata@valinux.co.jp
5455
James P. roampune@gmail.com

Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ MAN_FRAGMENTS =
9393
MAN_ROOTS =
9494
noinst_DATA =
9595
noinst_HEADERS =
96-
noinst_LIBRARIES =
96+
lib_LTLIBRARIES =
9797
noinst_man_MANS =
9898
noinst_PROGRAMS =
9999
noinst_SCRIPTS =

acinclude.m4

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ AC_DEFUN([OVS_ENABLE_SPARSE],
523523
AC_SUBST([SPARSE])
524524
AC_CONFIG_COMMANDS_PRE(
525525
[if test $ovs_cv_gnu_make_if = yes; then
526-
CC='$(if $(C),REAL_CC="'"$CC"'" CHECK="$(SPARSE) -I $(top_srcdir)/include/sparse $(SPARSEFLAGS) $(SPARSE_EXTRA_INCLUDES) " cgcc $(CGCCFLAGS),'"$CC"')'
526+
CC='$(if $(C),env REAL_CC="'"$CC"'" CHECK="$(SPARSE) -I $(top_srcdir)/include/sparse $(SPARSEFLAGS) $(SPARSE_EXTRA_INCLUDES) " cgcc $(CGCCFLAGS),'"$CC"')'
527527
fi])])
528528

529529
dnl OVS_PTHREAD_SET_NAME

build-aux/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33
/config.sub
44
/depcomp
55
/install-sh
6+
/ltmain.sh
67
/missing

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ AM_INIT_AUTOMAKE
2424
AC_PROG_CC
2525
AM_PROG_CC_C_O
2626
AC_PROG_CPP
27-
AC_PROG_RANLIB
2827
AC_PROG_MKDIR_P
2928
AC_PROG_FGREP
3029
AC_PROG_EGREP
@@ -41,6 +40,7 @@ AC_USE_SYSTEM_EXTENSIONS
4140
AC_C_BIGENDIAN
4241
AC_SYS_LARGEFILE
4342

43+
LT_INIT([disable-shared])
4444
AC_SEARCH_LIBS([pow], [m])
4545
AC_SEARCH_LIBS([clock_gettime], [rt])
4646
AC_SEARCH_LIBS([timer_create], [rt])

lib/automake.mk

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,12 @@
55
# notice and this notice are preserved. This file is offered as-is,
66
# without warranty of any kind.
77

8-
noinst_LIBRARIES += lib/libopenvswitch.a
8+
lib_LTLIBRARIES += lib/libopenvswitch.la
99

10-
lib_libopenvswitch_a_SOURCES = \
10+
lib_libopenvswitch_la_LIBADD = $(SSL_LIBS)
11+
lib_libopenvswitch_la_LDFLAGS = -release $(VERSION)
12+
13+
lib_libopenvswitch_la_SOURCES = \
1114
lib/aes128.c \
1215
lib/aes128.h \
1316
lib/async-append.h \
@@ -233,28 +236,30 @@ lib_libopenvswitch_a_SOURCES = \
233236
lib/vtep-idl.h
234237
EXTRA_DIST += lib/string.h.in
235238

236-
nodist_lib_libopenvswitch_a_SOURCES = \
239+
nodist_lib_libopenvswitch_la_SOURCES = \
237240
lib/dirs.c
238-
CLEANFILES += $(nodist_lib_libopenvswitch_a_SOURCES)
241+
CLEANFILES += $(nodist_lib_libopenvswitch_la_SOURCES)
239242

240-
noinst_LIBRARIES += lib/libsflow.a
241-
lib_libsflow_a_SOURCES = \
243+
lib_LTLIBRARIES += lib/libsflow.la
244+
lib_libsflow_la_LDFLAGS = -release $(VERSION)
245+
lib_libsflow_la_SOURCES = \
242246
lib/sflow_api.h \
243247
lib/sflow.h \
244248
lib/sflow_agent.c \
245249
lib/sflow_sampler.c \
246250
lib/sflow_poller.c \
247251
lib/sflow_receiver.c
248-
lib_libsflow_a_CFLAGS = $(AM_CFLAGS)
252+
lib_libsflow_la_CPPFLAGS = $(AM_CPPFLAGS)
253+
lib_libsflow_la_CFLAGS = $(AM_CFLAGS)
249254
if HAVE_WNO_UNUSED
250-
lib_libsflow_a_CFLAGS += -Wno-unused
255+
lib_libsflow_la_CFLAGS += -Wno-unused
251256
endif
252257
if HAVE_WNO_UNUSED_PARAMETER
253-
lib_libsflow_a_CFLAGS += -Wno-unused-parameter
258+
lib_libsflow_la_CFLAGS += -Wno-unused-parameter
254259
endif
255260

256261
if LINUX_DATAPATH
257-
lib_libopenvswitch_a_SOURCES += \
262+
lib_libopenvswitch_la_SOURCES += \
258263
lib/dpif-linux.c \
259264
lib/dpif-linux.h \
260265
lib/netdev-linux.c \
@@ -271,27 +276,27 @@ lib_libopenvswitch_a_SOURCES += \
271276
endif
272277

273278
if HAVE_POSIX_AIO
274-
lib_libopenvswitch_a_SOURCES += lib/async-append-aio.c
279+
lib_libopenvswitch_la_SOURCES += lib/async-append-aio.c
275280
else
276-
lib_libopenvswitch_a_SOURCES += lib/async-append-null.c
281+
lib_libopenvswitch_la_SOURCES += lib/async-append-null.c
277282
endif
278283

279284
if ESX
280-
lib_libopenvswitch_a_SOURCES += \
285+
lib_libopenvswitch_la_SOURCES += \
281286
lib/route-table-stub.c
282287
endif
283288

284289
if HAVE_IF_DL
285-
lib_libopenvswitch_a_SOURCES += \
290+
lib_libopenvswitch_la_SOURCES += \
286291
lib/netdev-bsd.c \
287292
lib/rtbsd.c \
288293
lib/rtbsd.h \
289294
lib/route-table-bsd.c
290295
endif
291296

292297
if HAVE_OPENSSL
293-
lib_libopenvswitch_a_SOURCES += lib/stream-ssl.c
294-
nodist_lib_libopenvswitch_a_SOURCES += lib/dhparams.c
298+
lib_libopenvswitch_la_SOURCES += lib/stream-ssl.c
299+
nodist_lib_libopenvswitch_la_SOURCES += lib/dhparams.c
295300
lib/dhparams.c: lib/dh1024.pem lib/dh2048.pem lib/dh4096.pem
296301
(echo '#include "lib/dhparams.h"' && \
297302
openssl dhparam -C -in $(srcdir)/lib/dh1024.pem -noout && \
@@ -300,7 +305,7 @@ lib/dhparams.c: lib/dh1024.pem lib/dh2048.pem lib/dh4096.pem
300305
| sed 's/\(get_dh[0-9]*\)()/\1(void)/' > lib/dhparams.c.tmp
301306
mv lib/dhparams.c.tmp lib/dhparams.c
302307
else
303-
lib_libopenvswitch_a_SOURCES += lib/stream-nossl.c
308+
lib_libopenvswitch_la_SOURCES += lib/stream-nossl.c
304309
endif
305310

306311
EXTRA_DIST += \

m4/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/libtool.m4
2+
/ltoptions.m4
3+
/ltsugar.m4
4+
/ltversion.m4
5+
/lt~obsolete.m4

ofproto/automake.mk

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
# notice and this notice are preserved. This file is offered as-is,
66
# without warranty of any kind.
77

8-
noinst_LIBRARIES += ofproto/libofproto.a
9-
ofproto_libofproto_a_SOURCES = \
8+
lib_LTLIBRARIES += ofproto/libofproto.la
9+
ofproto_libofproto_la_LDFLAGS = -release $(VERSION)
10+
ofproto_libofproto_la_SOURCES = \
1011
ofproto/bond.c \
1112
ofproto/bond.h \
1213
ofproto/collectors.c \
@@ -45,10 +46,13 @@ ofproto_libofproto_a_SOURCES = \
4546
ofproto/pinsched.h \
4647
ofproto/tunnel.c \
4748
ofproto/tunnel.h
49+
ofproto_libofproto_la_CPPFLAGS = $(AM_CPPFLAGS)
50+
ofproto_libofproto_la_CFLAGS = $(AM_CFLAGS)
51+
ofproto_libofproto_la_LIBADD = lib/libsflow.la
4852

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

5357
BUILT_SOURCES += ofproto/ipfix-entities.def
5458

ovsdb/automake.mk

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# libovsdb
2-
noinst_LIBRARIES += ovsdb/libovsdb.a
3-
ovsdb_libovsdb_a_SOURCES = \
2+
lib_LTLIBRARIES += ovsdb/libovsdb.la
3+
ovsdb_libovsdb_la_LDFLAGS = -release $(VERSION)
4+
ovsdb_libovsdb_la_SOURCES = \
45
ovsdb/column.c \
56
ovsdb/column.h \
67
ovsdb/condition.c \
@@ -29,14 +30,17 @@ ovsdb_libovsdb_a_SOURCES = \
2930
ovsdb/trigger.h \
3031
ovsdb/transaction.c \
3132
ovsdb/transaction.h
33+
ovsdb_libovsdb_la_CFLAGS = $(AM_CFLAGS)
34+
ovsdb_libovsdb_la_CPPFLAGS = $(AM_CPPFLAGS)
35+
3236
MAN_FRAGMENTS += \
3337
ovsdb/remote-active.man \
3438
ovsdb/remote-passive.man
3539

3640
# ovsdb-tool
3741
bin_PROGRAMS += ovsdb/ovsdb-tool
3842
ovsdb_ovsdb_tool_SOURCES = ovsdb/ovsdb-tool.c
39-
ovsdb_ovsdb_tool_LDADD = ovsdb/libovsdb.a lib/libopenvswitch.a $(SSL_LIBS)
43+
ovsdb_ovsdb_tool_LDADD = ovsdb/libovsdb.la lib/libopenvswitch.la $(SSL_LIBS)
4044
# ovsdb-tool.1
4145
man_MANS += ovsdb/ovsdb-tool.1
4246
DISTCLEANFILES += ovsdb/ovsdb-tool.1
@@ -45,7 +49,7 @@ MAN_ROOTS += ovsdb/ovsdb-tool.1.in
4549
# ovsdb-client
4650
bin_PROGRAMS += ovsdb/ovsdb-client
4751
ovsdb_ovsdb_client_SOURCES = ovsdb/ovsdb-client.c
48-
ovsdb_ovsdb_client_LDADD = ovsdb/libovsdb.a lib/libopenvswitch.a $(SSL_LIBS)
52+
ovsdb_ovsdb_client_LDADD = ovsdb/libovsdb.la lib/libopenvswitch.la $(SSL_LIBS)
4953
# ovsdb-client.1
5054
man_MANS += ovsdb/ovsdb-client.1
5155
DISTCLEANFILES += ovsdb/ovsdb-client.1
@@ -54,7 +58,7 @@ MAN_ROOTS += ovsdb/ovsdb-client.1.in
5458
# ovsdb-server
5559
sbin_PROGRAMS += ovsdb/ovsdb-server
5660
ovsdb_ovsdb_server_SOURCES = ovsdb/ovsdb-server.c
57-
ovsdb_ovsdb_server_LDADD = ovsdb/libovsdb.a lib/libopenvswitch.a $(SSL_LIBS)
61+
ovsdb_ovsdb_server_LDADD = ovsdb/libovsdb.la lib/libopenvswitch.la $(SSL_LIBS)
5862
# ovsdb-server.1
5963
man_MANS += ovsdb/ovsdb-server.1
6064
DISTCLEANFILES += ovsdb/ovsdb-server.1

rhel/openvswitch-fedora.spec.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,9 @@ install python/compat/argparse.py $RPM_BUILD_ROOT/usr/share/openvswitch/python
6969

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

72+
# Get rid of stuff we don't want to make RPM happy.
73+
rm -rf $RPM_BUILD_ROOT/%{_lib}
74+
7275
%clean
7376
rm -rf $RPM_BUILD_ROOT
7477

0 commit comments

Comments
 (0)