From 69ca60e890a513fdc0bc62d37420c0584231817e Mon Sep 17 00:00:00 2001 From: Pierre Pfister Date: Tue, 25 Apr 2017 11:05:37 +0200 Subject: librtnl: Add out-of-tree compilation See README.md changes for the new way to compile the plugin/library. Change-Id: I54ac5b9e7558ec8bb07430dc4a6f8e24d69cebbd Signed-off-by: Pierre Pfister --- netlink/Makefile.am | 25 ++++++++++++++++++++----- netlink/README.md | 11 +++++++++++ netlink/configure.ac | 16 +++++++++------- netlink/test/test.c | 18 +++++------------- 4 files changed, 45 insertions(+), 25 deletions(-) diff --git a/netlink/Makefile.am b/netlink/Makefile.am index 85023f8..f760b86 100644 --- a/netlink/Makefile.am +++ b/netlink/Makefile.am @@ -13,7 +13,21 @@ AUTOMAKE_OPTIONS = foreign subdir-objects -AM_CFLAGS = -Wall -I@TOOLKIT_INCLUDE@ +AM_CFLAGS = -Wall -fstack-protector -fPIC -Werror -g -DFORTIFY_SOURCE=2 +if DEBUG +AM_CFLAGS += -O0 -DCLIB_DEBUG +vpp_build = vpp_debug-native +else +AM_CFLAGS += -O2 +vpp_build = vpp-native +endif + +if VPP_DIR_SET +vpp_install = @VPP_DIR@/build-root/install-$(vpp_build) +AM_CFLAGS += -I$(vpp_install)/vpp/include/ +else +AM_CFLAGS += -Wall +endif lib_LTLIBRARIES = librtnl.la @@ -33,8 +47,9 @@ testrtnl_plugin_la_SOURCES = test/test.c testrtnl_plugin_la_LDFLAGS = -module testrtnl_plugin_la_LIBADD = librtnl.la -if WITH_PLUGIN_TOOLKIT -install-data-hook: - mkdir /usr/lib/vpp_plugins || true - cp $(prefix)/lib/testnl_plugin.so.*.*.* /usr/lib/vpp_plugins +if VPP_DIR_SET +install: install-am + mkdir -p $(vpp_install)/vpp/lib64/vpp_plugins/ + cp $(prefix)/lib/testrtnl_plugin.so.*.*.* $(vpp_install)/vpp/lib64/vpp_plugins/testrtnl_plugin.so + cp $(prefix)/lib/librtnl.so $(vpp_install)/vpp/lib64/librtnl.so endif diff --git a/netlink/README.md b/netlink/README.md index 02f4c18..ef60f63 100644 --- a/netlink/README.md +++ b/netlink/README.md @@ -4,6 +4,17 @@ This VPP package provides a rtnetlink-based library to be used by [VPP](http://f ## HowTo +The library and test plugin can be compiled by running the following commands from the plugin directory: +```bash +libtoolize +aclocal +autoconf +automake --add-missing +./configure +make +sudo make install +``` + The library and test plugin can be compiled by copying netlink.mk into VPP's build tree build-data/packages/ directory and using VPP make target netlink-install. Note that VPP build system can be configured to look in other directories for additional build-data/packages/ directories by adding those to build-root/build-config.mk SOURCE_PATH variable. diff --git a/netlink/configure.ac b/netlink/configure.ac index 5fdd345..7e8380a 100644 --- a/netlink/configure.ac +++ b/netlink/configure.ac @@ -6,13 +6,15 @@ AM_PROG_AS AC_PROG_CC AM_PROG_CC_C_O -AC_ARG_WITH(plugin-toolkit, - AC_HELP_STRING([--with-plugin-toolkit], - [build using the vpp toolkit]), - [with_plugin_toolkit=${prefix}/include], - [with_plugin_toolkit=.]) +AC_ARG_VAR(VPP_DIR,[ vpp build directory ]) +AM_CONDITIONAL([VPP_DIR_SET], [test ! -z "$VPP_DIR"]) -AC_SUBST(TOOLKIT_INCLUDE,[${with_plugin_toolkit}]) -AM_CONDITIONAL(WITH_PLUGIN_TOOLKIT, test "$with_plugin_toolkit" != ".") +AC_ARG_ENABLE([debug], +[ --enable-debug Turn on debugging], + [if test x$enableval = xyes; then + AC_DEFINE(DEBUG, 1, [Define this to enable debug.]) + debug=true + fi], [debug=false]) +AM_CONDITIONAL([DEBUG], [test x$debug = xtrue]) AC_OUTPUT([Makefile]) diff --git a/netlink/test/test.c b/netlink/test/test.c index 2922a40..916e1f8 100644 --- a/netlink/test/test.c +++ b/netlink/test/test.c @@ -18,6 +18,7 @@ #include #include #include +#include u32 handles[10]; @@ -121,17 +122,8 @@ mapper_ns_add_command_fn (vlib_main_t * vm, if (!strcmp(nsname, "default")) nsname[0] = 0; -#ifdef find_ip4_fib_by_table_index_or_id - u32 fib4 = find_ip4_fib_by_table_index_or_id(&ip4_main, table_id, 0) - ip4_main.fibs; -#else - u32 fib4 = fib_table_id_find_fib_index (FIB_PROTOCOL_IP4, table_id); -#endif - -#ifdef find_ip6_fib_by_table_index_or_id - u32 fib6 = find_ip6_fib_by_table_index_or_id(&ip6_main, table_id, 0) - ip6_main.fibs; -#else - u32 fib6 = fib_table_id_find_fib_index (FIB_PROTOCOL_IP6, table_id); -#endif + u32 fib4 = ip4_fib_index_from_table_id(table_id); + u32 fib6 = ip6_fib_index_from_table_id(table_id); if (mapper_add_ns(nsname, fib4, fib6, &mapper_indexes[index])) return clib_error_return(0, "Could not add ns %s", nsname); @@ -202,8 +194,8 @@ VLIB_CLI_COMMAND (mapper_iface_command, static) = { /* *INDENT-OFF* */ VLIB_PLUGIN_REGISTER () = { - // .version = VPP_BUILD_VER, FIXME - .description = "netlink", + //.version = VPP_BUILD_VER, FIXME + .description = "netlink", }; /* *INDENT-ON* */ -- cgit 1.2.3-korg