@@ -99,6 +99,7 @@ OVS_CHECK_PYTHON3
OVS_CHECK_FLAKE8
OVS_CHECK_SPHINX
OVS_CHECK_DOT
+OVS_CHECK_STATIC_BINARIES
OVS_CHECK_IF_PACKET
OVS_CHECK_IF_DL
OVS_CHECK_STRTOK_R
@@ -620,3 +620,24 @@ AC_DEFUN([OVS_LIBTOOL_VERSIONS],
AC_MSG_RESULT([libX-$OVS_MAJOR.$OVS_MINOR.so.$LT_CURRENT.0.$OVS_MICRO)])
AC_SUBST(OVS_LTINFO)
])
+
+dnl Checks for --enable-static-binaries.
+AC_DEFUN([OVS_CHECK_STATIC_BINARIES],
+ [AC_ARG_ENABLE(
+ [static-binaries],
+ [AC_HELP_STRING([--enable-static-binaries],
+ [Build binaries statically linked with openvswitch libraries.])],
+ [case "${enableval}" in
+ (yes) static_binaries=true ;;
+ (no) static_binaries=false ;;
+ (*) AC_MSG_ERROR([bad value ${enableval} for --enable-static-binaries]) ;;
+ esac],
+ [static_binaries=false])
+ if test x$static_binaries = xtrue && test x$enable_static = xyes &&
+ test x$enable_shared = xyes; then
+ STATIC_BINARIES_LDFLAGS=-static
+ else
+ STATIC_BINARIES_LDFLAGS=
+ fi
+ AC_SUBST([STATIC_BINARIES_LDFLAGS])
+ ])
@@ -9,6 +9,7 @@ ovn_controller_vtep_ovn_controller_vtep_SOURCES = \
ovn/controller-vtep/vtep.c \
ovn/controller-vtep/vtep.h
ovn_controller_vtep_ovn_controller_vtep_LDADD = ovn/lib/libovn.la lib/libopenvswitch.la vtep/libvtep.la
+ovn_controller_vtep_ovn_controller_vtep_LDFLAGS = $(AM_LDFLAGS) $(STATIC_BINARIES_LDFLAGS)
man_MANS += ovn/controller-vtep/ovn-controller-vtep.8
EXTRA_DIST += ovn/controller-vtep/ovn-controller-vtep.8.xml
CLEANFILES += ovn/controller-vtep/ovn-controller-vtep.8
@@ -21,6 +21,7 @@ ovn_controller_ovn_controller_SOURCES = \
ovn/controller/physical.c \
ovn/controller/physical.h
ovn_controller_ovn_controller_LDADD = ovn/lib/libovn.la lib/libopenvswitch.la
+ovn_controller_ovn_controller_LDFLAGS = $(AM_LDFLAGS) $(STATIC_BINARIES_LDFLAGS)
man_MANS += ovn/controller/ovn-controller.8
EXTRA_DIST += ovn/controller/ovn-controller.8.xml
CLEANFILES += ovn/controller/ovn-controller.8
@@ -5,6 +5,7 @@ ovn_northd_ovn_northd_LDADD = \
ovn/lib/libovn.la \
ovsdb/libovsdb.la \
lib/libopenvswitch.la
+ovn_northd_ovn_northd_LDFLAGS = $(AM_LDFLAGS) $(STATIC_BINARIES_LDFLAGS)
man_MANS += ovn/northd/ovn-northd.8
EXTRA_DIST += ovn/northd/ovn-northd.8.xml
CLEANFILES += ovn/northd/ovn-northd.8
@@ -41,15 +41,18 @@ CLEANFILES += \
bin_PROGRAMS += ovn/utilities/ovn-nbctl
ovn_utilities_ovn_nbctl_SOURCES = ovn/utilities/ovn-nbctl.c
ovn_utilities_ovn_nbctl_LDADD = ovn/lib/libovn.la ovsdb/libovsdb.la lib/libopenvswitch.la
+ovn_utilities_ovn_nbctl_LDFLAGS = $(AM_LDFLAGS) $(STATIC_BINARIES_LDFLAGS)
# ovn-sbctl
bin_PROGRAMS += ovn/utilities/ovn-sbctl
ovn_utilities_ovn_sbctl_SOURCES = ovn/utilities/ovn-sbctl.c
ovn_utilities_ovn_sbctl_LDADD = ovn/lib/libovn.la ovsdb/libovsdb.la lib/libopenvswitch.la
+ovn_utilities_ovn_sbctl_LDFLAGS = $(AM_LDFLAGS) $(STATIC_BINARIES_LDFLAGS)
# ovn-trace
bin_PROGRAMS += ovn/utilities/ovn-trace
ovn_utilities_ovn_trace_SOURCES = ovn/utilities/ovn-trace.c
ovn_utilities_ovn_trace_LDADD = ovn/lib/libovn.la ovsdb/libovsdb.la lib/libopenvswitch.la
+ovn_utilities_ovn_trace_LDFLAGS = $(AM_LDFLAGS) $(STATIC_BINARIES_LDFLAGS)
include ovn/utilities/bugtool/automake.mk
@@ -60,6 +60,7 @@ EXTRA_DIST += \
bin_PROGRAMS += ovsdb/ovsdb-tool
ovsdb_ovsdb_tool_SOURCES = ovsdb/ovsdb-tool.c
ovsdb_ovsdb_tool_LDADD = ovsdb/libovsdb.la lib/libopenvswitch.la
+ovsdb_ovsdb_tool_LDFLAGS = $(AM_LDFLAGS) $(STATIC_BINARIES_LDFLAGS)
# ovsdb-tool.1
man_MANS += ovsdb/ovsdb-tool.1
CLEANFILES += ovsdb/ovsdb-tool.1
@@ -69,6 +70,7 @@ MAN_ROOTS += ovsdb/ovsdb-tool.1.in
bin_PROGRAMS += ovsdb/ovsdb-client
ovsdb_ovsdb_client_SOURCES = ovsdb/ovsdb-client.c
ovsdb_ovsdb_client_LDADD = ovsdb/libovsdb.la lib/libopenvswitch.la
+ovsdb_ovsdb_client_LDFLAGS = $(AM_LDFLAGS) $(STATIC_BINARIES_LDFLAGS)
# ovsdb-client.1
man_MANS += ovsdb/ovsdb-client.1
CLEANFILES += ovsdb/ovsdb-client.1
@@ -78,6 +80,7 @@ MAN_ROOTS += ovsdb/ovsdb-client.1.in
sbin_PROGRAMS += ovsdb/ovsdb-server
ovsdb_ovsdb_server_SOURCES = ovsdb/ovsdb-server.c
ovsdb_ovsdb_server_LDADD = ovsdb/libovsdb.la lib/libopenvswitch.la
+ovsdb_ovsdb_server_LDFLAGS = $(AM_LDFLAGS) $(STATIC_BINARIES_LDFLAGS)
# ovsdb-server.1
man_MANS += ovsdb/ovsdb-server.1
CLEANFILES += ovsdb/ovsdb-server.1
@@ -286,11 +286,13 @@ tests_test_ovsdb_SOURCES = tests/test-ovsdb.c
nodist_tests_test_ovsdb_SOURCES = tests/idltest.c tests/idltest.h
EXTRA_DIST += tests/uuidfilt.pl tests/ovsdb-monitor-sort.pl
tests_test_ovsdb_LDADD = ovsdb/libovsdb.la lib/libopenvswitch.la
+tests_test_ovsdb_LDFLAGS = $(AM_LDFLAGS) $(STATIC_BINARIES_LDFLAGS)
noinst_PROGRAMS += tests/test-lib
tests_test_lib_SOURCES = \
tests/test-lib.c
tests_test_lib_LDADD = lib/libopenvswitch.la
+tests_test_lib_LDFLAGS = $(AM_LDFLAGS) $(STATIC_BINARIES_LDFLAGS)
# idltest schema and IDL
OVSIDL_BUILT += tests/idltest.c tests/idltest.h tests/idltest.ovsidl
@@ -362,6 +364,7 @@ tests_ovstest_SOURCES += \
endif
tests_ovstest_LDADD = lib/libopenvswitch.la ovn/lib/libovn.la
+tests_ovstest_LDFLAGS = $(AM_LDFLAGS) $(STATIC_BINARIES_LDFLAGS)
dist_check_SCRIPTS = tests/flowgen.pl
noinst_PROGRAMS += tests/test-strtok_r
@@ -119,29 +119,36 @@ man_MANS += \
utilities_ovs_appctl_SOURCES = utilities/ovs-appctl.c
utilities_ovs_appctl_LDADD = lib/libopenvswitch.la
+utilities_ovs_appctl_LDFLAGS = $(AM_LDFLAGS) $(STATIC_BINARIES_LDFLAGS)
utilities_ovs_testcontroller_SOURCES = utilities/ovs-testcontroller.c
utilities_ovs_testcontroller_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+utilities_ovs_testcontroller_LDFLAGS = $(AM_LDFLAGS) $(STATIC_BINARIES_LDFLAGS)
utilities_ovs_dpctl_SOURCES = utilities/ovs-dpctl.c
utilities_ovs_dpctl_LDADD = lib/libopenvswitch.la
+utilities_ovs_dpctl_LDFLAGS = $(AM_LDFLAGS) $(STATIC_BINARIES_LDFLAGS)
utilities_ovs_ofctl_SOURCES = utilities/ovs-ofctl.c
utilities_ovs_ofctl_LDADD = \
ofproto/libofproto.la \
lib/libopenvswitch.la
+utilities_ovs_ofctl_LDLAGS = $(AM_LDFLAGS) $(STATIC_BINARIES_LDFLAGS)
utilities_ovs_vsctl_SOURCES = utilities/ovs-vsctl.c
utilities_ovs_vsctl_LDADD = lib/libopenvswitch.la
+utilities_ovs_vsctl_LDFLAGS = $(AM_LDFLAGS) $(STATIC_BINARIES_LDFLAGS)
if LINUX
sbin_PROGRAMS += utilities/ovs-vlan-bug-workaround
utilities_ovs_vlan_bug_workaround_SOURCES = utilities/ovs-vlan-bug-workaround.c
utilities_ovs_vlan_bug_workaround_LDADD = lib/libopenvswitch.la
+utilities_ovs_vlan_bug_workaround_LDFLAGS = $(AM_LDFLAGS) $(STATIC_BINARIES_LDFLAGS)
noinst_PROGRAMS += utilities/nlmon
utilities_nlmon_SOURCES = utilities/nlmon.c
utilities_nlmon_LDADD = lib/libopenvswitch.la
+utilities_nlmon_LDFLAGS = $(AM_LDFLAGS) $(STATIC_BINARIES_LDFLAGS)
endif
FLAKE8_PYFILES += utilities/ovs-pcap.in \
@@ -15,7 +15,7 @@ vswitchd_ovs_vswitchd_LDADD = \
ofproto/libofproto.la \
lib/libsflow.la \
lib/libopenvswitch.la
-vswitchd_ovs_vswitchd_LDFLAGS = $(AM_LDFLAGS) $(DPDK_vswitchd_LDFLAGS)
+vswitchd_ovs_vswitchd_LDFLAGS = $(AM_LDFLAGS) $(DPDK_vswitchd_LDFLAGS) $(STATIC_BINARIES_LDFLAGS)
MAN_ROOTS += vswitchd/ovs-vswitchd.8.in
# vswitch schema and IDL
@@ -35,6 +35,7 @@ man_MANS += \
vtep_vtep_ctl_SOURCES = vtep/vtep-ctl.c
vtep_vtep_ctl_LDADD = vtep/libvtep.la lib/libopenvswitch.la
+vtep_vtep_ctl_LDFLAGS = $(AM_LDFLAGS) $(STATIC_BINARIES_LDFLAGS)
# ovs-vtep
scripts_SCRIPTS += \
Add --enable-static-binaries configuration option for enabling or disabling static linking with libopenvswitch, libsflow, libovsdb, libvtep, libovn and libofproto also when --enable-shared is specified. This is needed to avoid link binaries with position-independent code (PIC) that generates slower code, but to permit building the ovs shared librares, since it's needed, for example, by the C extension wrapper for Python JSON parsing. --enable-static-binaries option can only be used when both --enable-static (default) and --enable-shared options are specified since if only --enable-static is specified the binaries are already statically linked and if only --enable-shared is specified the binaries cannot link with nonbuilt static libraries. Signed-off-by: Timothy Redaelli <tredaelli@redhat.com> --- configure.ac | 1 + m4/openvswitch.m4 | 21 +++++++++++++++++++++ ovn/controller-vtep/automake.mk | 1 + ovn/controller/automake.mk | 1 + ovn/northd/automake.mk | 1 + ovn/utilities/automake.mk | 3 +++ ovsdb/automake.mk | 3 +++ tests/automake.mk | 3 +++ utilities/automake.mk | 7 +++++++ vswitchd/automake.mk | 2 +- vtep/automake.mk | 1 + 11 files changed, 43 insertions(+), 1 deletion(-)