Skip to contentSkip to conversation

package/libmnl: add options to build examples

PATCH Superseded Dario Binacchi via buildroot 2 participants 2 messages May 1, 2022

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/libmnl: add options to build examples

The example applications, which are minimal, can be of great help in understanding how the library works.

As there is no configure option to enable examples compilation, building and installation instructions had to be added to libmnl.mk. By default, which is always the case for buildroot, they are disabled.

---
 package/libmnl/Config.in | 37 +++++++++++++++++++++++++++++++++++++
 package/libmnl/libmnl.mk | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+)
package/libmnl/Config.in +37 -0
index 5acfb2447e..81b3811270 100644
@@ -5,3 +5,40 @@ config BR2_PACKAGE_LIBMNL
 	  to Netlink developers.
 
 	  http://netfilter.org/projects/libmnl/
+
+if BR2_PACKAGE_LIBMNL
+
+config BR2_PACKAGE_LIBMNL_EXAMPLES
+	bool "install examples"
+	help
+	  Install binary examples.
+
+if BR2_PACKAGE_LIBMNL_EXAMPLES
+
+config BR2_PACKAGE_LIBMNL_EXAMPLES_GENL
+	bool "genl"
+	help
+	  This option will build and install the genl examples for
+	  the target.
+
+config BR2_PACKAGE_LIBMNL_EXAMPLES_KOBJECT
+	bool "kobject"
+	help
+	  This option will build and install the kobject examples
+	  for the target.
+
+config BR2_PACKAGE_LIBMNL_EXAMPLES_NETFILTER
+	bool "netfilter"
+	help
+	  This option will build and install the netfilter examples
+	  for the target.
+
+config BR2_PACKAGE_LIBMNL_EXAMPLES_RTNL
+	bool "rtnl"
+	help
+	  This option will build and install the rtnl examples for
+	  the target.
+
+endif
+
+endif
package/libmnl/libmnl.mk +39 -0
index 3361d05248..cb31b0f75f 100644
@@ -12,4 +12,43 @@ LIBMNL_LICENSE = LGPL-2.1+
 LIBMNL_LICENSE_FILES = COPYING
 LIBMNL_CPE_ID_VENDOR = netfilter
 
+ifeq ($(BR2_PACKAGE_LIBMNL_EXAMPLES),y)
+define LIBMNL_EXAMPLES_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) check -C $(@D)
+endef
+LIBMNL_POST_BUILD_HOOKS += LIBMNL_EXAMPLES_BUILD_CMDS
+
+ifeq ($(BR2_PACKAGE_LIBMNL_EXAMPLES_GENL),y)
+LIBMNL_EXAMPLES_INSTALL_TARGETS += \
+	$(addprefix examples/genl/, genl-family-get genl-group-events)
+endif
+
+ifeq ($(BR2_PACKAGE_LIBMNL_EXAMPLES_KOBJECT),y)
+LIBMNL_EXAMPLES_INSTALL_TARGETS += \
+	$(addprefix examples/kobject/, kobject-event)
+endif
+
+ifeq ($(BR2_PACKAGE_LIBMNL_EXAMPLES_NETFILTER),y)
+LIBMNL_EXAMPLES_INSTALL_TARGETS += \
+	$(addprefix examples/netfilter/, nfct-create-batch \
+		nfct-daemon nfct-dump nfct-event nf-log \
+		nf-queue)
+endif
+
+ifeq ($(BR2_PACKAGE_LIBMNL_EXAMPLES_RTNL),y)
+LIBMNL_EXAMPLES_INSTALL_TARGETS += \
+	$(addprefix examples/rtnl/, rtnl-addr-add rtnl-addr-dump \
+		rtnl-link-dump rtnl-link-dump2 rtnl-link-dump3 \
+		rtnl-link-event rtnl-link-set rtnl-neigh-dump \
+		rtnl-route-add rtnl-route-dump rtnl-route-event)
+endif
+
+define LIBMNL_EXAMPLES_INSTALL_TARGET_CMDS
+	$(foreach t,$(LIBMNL_EXAMPLES_INSTALL_TARGETS), \
+		$(INSTALL) -D -m 0755 $(@D)/$(t) \
+			$(TARGET_DIR)/usr/bin/$(notdir $(t))$(sep))
+endef
+LIBMNL_POST_INSTALL_TARGET_HOOKS += LIBMNL_EXAMPLES_INSTALL_TARGET_CMDS
+endif
+
 $(eval $(autotools-package))
Signature · 6 lines
2.17.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Dario, All,

On 2022-05-01 16:18 +0200, Dario Binacchi via buildroot spake thusly:

Quoted 6 lines

The example applications, which are minimal, can be of great help in understanding how the library works.

As there is no configure option to enable examples compilation, building and installation instructions had to be added to libmnl.mk. By default, which is always the case for buildroot, they are disabled.

I thjink it does not make much sense to add an option for each example. Instead, just build all of them when BR2_PACKAGE_LIBMNL_EXAMPLES is set.

Can you rework and respin, please?

Regards,
Yann E. MORIN.

Quoted 106 lines
---
 package/libmnl/Config.in | 37 +++++++++++++++++++++++++++++++++++++
 package/libmnl/libmnl.mk | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 76 insertions(+)
package/libmnl/Config.in +37 -0
index 5acfb2447e..81b3811270 100644
@@ -5,3 +5,40 @@ config BR2_PACKAGE_LIBMNL
 	  to Netlink developers.
 
 	  http://netfilter.org/projects/libmnl/
+
+if BR2_PACKAGE_LIBMNL
+
+config BR2_PACKAGE_LIBMNL_EXAMPLES
+	bool "install examples"
+	help
+	  Install binary examples.
+
+if BR2_PACKAGE_LIBMNL_EXAMPLES
+
+config BR2_PACKAGE_LIBMNL_EXAMPLES_GENL
+	bool "genl"
+	help
+	  This option will build and install the genl examples for
+	  the target.
+
+config BR2_PACKAGE_LIBMNL_EXAMPLES_KOBJECT
+	bool "kobject"
+	help
+	  This option will build and install the kobject examples
+	  for the target.
+
+config BR2_PACKAGE_LIBMNL_EXAMPLES_NETFILTER
+	bool "netfilter"
+	help
+	  This option will build and install the netfilter examples
+	  for the target.
+
+config BR2_PACKAGE_LIBMNL_EXAMPLES_RTNL
+	bool "rtnl"
+	help
+	  This option will build and install the rtnl examples for
+	  the target.
+
+endif
+
+endif
package/libmnl/libmnl.mk +39 -0
index 3361d05248..cb31b0f75f 100644
@@ -12,4 +12,43 @@ LIBMNL_LICENSE = LGPL-2.1+
 LIBMNL_LICENSE_FILES = COPYING
 LIBMNL_CPE_ID_VENDOR = netfilter
 
+ifeq ($(BR2_PACKAGE_LIBMNL_EXAMPLES),y)
+define LIBMNL_EXAMPLES_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(MAKE) check -C $(@D)
+endef
+LIBMNL_POST_BUILD_HOOKS += LIBMNL_EXAMPLES_BUILD_CMDS
+
+ifeq ($(BR2_PACKAGE_LIBMNL_EXAMPLES_GENL),y)
+LIBMNL_EXAMPLES_INSTALL_TARGETS += \
+	$(addprefix examples/genl/, genl-family-get genl-group-events)
+endif
+
+ifeq ($(BR2_PACKAGE_LIBMNL_EXAMPLES_KOBJECT),y)
+LIBMNL_EXAMPLES_INSTALL_TARGETS += \
+	$(addprefix examples/kobject/, kobject-event)
+endif
+
+ifeq ($(BR2_PACKAGE_LIBMNL_EXAMPLES_NETFILTER),y)
+LIBMNL_EXAMPLES_INSTALL_TARGETS += \
+	$(addprefix examples/netfilter/, nfct-create-batch \
+		nfct-daemon nfct-dump nfct-event nf-log \
+		nf-queue)
+endif
+
+ifeq ($(BR2_PACKAGE_LIBMNL_EXAMPLES_RTNL),y)
+LIBMNL_EXAMPLES_INSTALL_TARGETS += \
+	$(addprefix examples/rtnl/, rtnl-addr-add rtnl-addr-dump \
+		rtnl-link-dump rtnl-link-dump2 rtnl-link-dump3 \
+		rtnl-link-event rtnl-link-set rtnl-neigh-dump \
+		rtnl-route-add rtnl-route-dump rtnl-route-event)
+endif
+
+define LIBMNL_EXAMPLES_INSTALL_TARGET_CMDS
+	$(foreach t,$(LIBMNL_EXAMPLES_INSTALL_TARGETS), \
+		$(INSTALL) -D -m 0755 $(@D)/$(t) \
+			$(TARGET_DIR)/usr/bin/$(notdir $(t))$(sep))
+endef
+LIBMNL_POST_INSTALL_TARGET_HOOKS += LIBMNL_EXAMPLES_INSTALL_TARGET_CMDS
+endif
+
 $(eval $(autotools-package))
Signature · 6 lines
2.17.1

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Signature · 10 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot