* [Buildroot] [PATCH 01/11] package-infra: add helper to build kernel modules
2015-06-06 22:20 [Buildroot] [PATCH 0/11] pkg-kernel-module: new infra to ease building kernel modules (branch yem/kernel-modules) Yann E. MORIN
@ 2015-06-06 22:20 ` Yann E. MORIN
2015-06-07 3:22 ` Baruch Siach
` (2 more replies)
2015-06-06 22:20 ` [Buildroot] [PATCH 02/11] docs/manual: add kernel-module Yann E. MORIN
` (9 subsequent siblings)
10 siblings, 3 replies; 34+ messages in thread
From: Yann E. MORIN @ 2015-06-06 22:20 UTC (permalink / raw)
To: buildroot
The Linux kernel offers a nice and easy-to-use infra to build
out-of-tree kernel modules.
Currently, we have quite a few packages that build kernel modules, and
most dupliacte (or rewrite) the same code over-and-over again.
Introduce a new infrastructure that provides helpers to build kernel
modules, so packages do not have to duplicate/rewrite that.
The infrastrucutre, unlike any other package infra, is not standalone.
It needs another package infra to be used. This is so that packages that
provide both userland and kernel modules can be built easily. So, this
infra only defines post-build and post-install hooks, that will build
the kernel modules after the rest of the package.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
package/Makefile.in | 1 +
package/pkg-kernel-module.mk | 94 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 95 insertions(+)
create mode 100644 package/pkg-kernel-module.mk
diff --git a/package/Makefile.in b/package/Makefile.in
index c02d31f..180fd46 100644
--- a/package/Makefile.in
+++ b/package/Makefile.in
@@ -398,3 +398,4 @@ include package/pkg-virtual.mk
include package/pkg-generic.mk
include package/pkg-kconfig.mk
include package/pkg-rebar.mk
+include package/pkg-kernel-module.mk
diff --git a/package/pkg-kernel-module.mk b/package/pkg-kernel-module.mk
new file mode 100644
index 0000000..2a2a2cb
--- /dev/null
+++ b/package/pkg-kernel-module.mk
@@ -0,0 +1,94 @@
+################################################################################
+# kernel module infrastructure for building Linux kernel modules
+#
+# This file implements an frastructure that eases development of package .mk
+# files for out-of-tree Linux kernel modules. It should be used for all
+# packages that build a Linux kernel module.
+#
+# In terms of implementation, this infrastructure requires the .mk file to
+# only specify metadata information about the package: name, version,
+# download URL, etc.
+#
+# It defines post-build and post-install hooks, so that packages can both
+# build user-space (with any of the other *-package infra) and/or build
+# kernel modules.
+#
+# As such, it is to be used in conjunction with another *-package infra,
+# like so:
+#
+# $(eval $(kernel-module))
+# $(eval $(generic-package))
+#
+# Note: if the caller needs access to the kernel modules (either after they
+# are built or after they are installed), it will have to define its own
+# post-build/install hooks after calling kernel-module, but before calling
+# the other *-package infra, like so:
+#
+# $(eval $(kernel-module))
+# define FOO_MOD_TWEAK
+# # do something
+# endef
+# FOO_POST_BUILD_HOOKS += FOO_MOD_TWEAK
+# $(eval $(generic-package))
+#
+# Note: this infra does not check that the kernel is enabled; it is expected
+# to be enforced at the Kconfig level with proper 'depends on'.
+################################################################################
+
+################################################################################
+# inner-kernel-module -- generates the make targets needed to support building
+# a kernel module
+#
+# argument 1 is the lowercase package name
+# argument 2 is the uppercase package name, including a HOST_ prefix
+# for host packages
+# argument 3 is the uppercase package name, without the HOST_ prefix
+# for host packages
+# argument 4 is the type (always 'target')
+################################################################################
+
+define inner-kernel-module
+
+# The kernel must be built first.
+$(2)_DEPENDENCIES += linux
+
+# Duplicate that from pkg-generic because we need it now
+ifndef $(2)_MAKE
+ $(2)_MAKE = $(MAKE)
+endif
+
+ifndef $(2)_MODULE_SUBDIRS
+ $(2)_MODULE_SUBDIRS = .
+endif
+
+# Build the kernel module(s)
+define $(2)_KERNEL_MODULES_BUILD
+ $$(foreach d,$$($(2)_MODULE_SUBDIRS), \
+ @$$(call MESSAGE,"Building kernel module '$$(d)'")$$(sep) \
+ $$($$(PKG)_MAKE) -C $$(LINUX_DIR) \
+ $$(LINUX_MAKE_FLAGS) \
+ $$($(2)_MODULE_MAKE_OPTS) \
+ M=$$($(2)_DIR)/$$(d) \
+ modules$$(sep))
+endef
+$(2)_POST_BUILD_HOOKS += $(2)_KERNEL_MODULES_BUILD
+
+# Install the kernel module(s)
+define $(2)_KERNEL_MODULES_INSTALL
+ $$(foreach d,$$($(2)_MODULE_SUBDIRS), \
+ @$$(call MESSAGE,"Installing kernel module '$$(d)'")$$(sep) \
+ $$($$(PKG)_MAKE) -C $$(LINUX_DIR) \
+ $$(LINUX_MAKE_FLAGS) \
+ $$($(2)_MODULE_MAKE_OPTS) \
+ M=$$($(2)_DIR)/$$(d) \
+ modules_install$$(sep))
+endef
+$(2)_POST_INSTALL_TARGET_HOOKS += $(2)_KERNEL_MODULES_INSTALL
+
+endef
+
+################################################################################
+# kernel-module -- the target generator macro for kernel module packages
+################################################################################
+
+kernel-module = $(call inner-kernel-module,$(pkgname),$(call UPPERCASE,$(pkgname)),$(call UPPERCASE,$(pkgname)),target)
--
1.9.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 02/11] docs/manual: add kernel-module
2015-06-06 22:20 [Buildroot] [PATCH 0/11] pkg-kernel-module: new infra to ease building kernel modules (branch yem/kernel-modules) Yann E. MORIN
2015-06-06 22:20 ` [Buildroot] [PATCH 01/11] package-infra: add helper to build kernel modules Yann E. MORIN
@ 2015-06-06 22:20 ` Yann E. MORIN
2015-06-08 21:46 ` Arnout Vandecappelle
2015-06-06 22:20 ` [Buildroot] [PATCH 03/11] package/lttng-modules: use kernel-module helper Yann E. MORIN
` (8 subsequent siblings)
10 siblings, 1 reply; 34+ messages in thread
From: Yann E. MORIN @ 2015-06-06 22:20 UTC (permalink / raw)
To: buildroot
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Samuel Martin <s.martin49@gmail.com>
---
docs/manual/adding-packages-kernel-module.txt | 120 ++++++++++++++++++++++++++
docs/manual/adding-packages.txt | 2 +
2 files changed, 122 insertions(+)
create mode 100644 docs/manual/adding-packages-kernel-module.txt
diff --git a/docs/manual/adding-packages-kernel-module.txt b/docs/manual/adding-packages-kernel-module.txt
new file mode 100644
index 0000000..1fe359a
--- /dev/null
+++ b/docs/manual/adding-packages-kernel-module.txt
@@ -0,0 +1,120 @@
+// -*- mode:doc; -*-
+// vim: set syntax=asciidoc:
+
+=== Infrastructure for packages building kernel modules
+
+Some packages, in addition to the usual user-space components it builds,
+may also need to build and install kernel modules.
+
+Buildroot offers a helper infrastructure to ease writing such packages.
+
+[[kernel-module-tutorial]]
+==== +kernel-module+ tutorial
+
+Let's start with an example on how to prepare a simple package that only
+builds a kernel module, and no other component:
+
+----
+01: ################################################################################
+02: #
+03: # foo
+04: #
+05: ################################################################################
+06:
+07: FOO_VERSION = 1.2.3
+08: FOO_SOURCE = foo-$(FOO_VERSION).tar.xz
+09: FOO_SITE = http://www.foosoftware.org/download
+10:
+11: $(eval $(kernel-module))
+12: $(eval $(generic-package))
+----
+
+Lines 7-9 define the usual meta-data to specify the version, archive name
+and remote URI where to find the package source.
+
+On line 11, we invoke the +kernel-module+ helper infrastructure, that
+generates all the appropriate Makefile rules and variables to build
+that kernel module.
+
+Finally, on line 12, we invoke the
+xref:generic-package-tutorial[+generic-package+ infrastructure].
+
+The dependency on +linux+ is automatically added, so it is not needed to
+specify it in +FOO_DEPENDENCIES+.
+
+What you may have noticed is that, unlike other package infrastructures,
+we explicitly invoke a second infrastructure. This allows a package to
+build a kernel module, but also, if needed, use any one of other package
+inftrastructures to build normal userland components (libraries,
+executables...). Using the +kernel-module+ infrastructure on its own is
+not sufficient; another package infrastructure *must* be used.
+
+Let's look at a more complex example:
+
+----
+01: ################################################################################
+02: #
+03: # foo
+04: #
+05: ################################################################################
+06:
+07: FOO_VERSION = 1.2.3
+08: FOO_SOURCE = foo-$(FOO_VERSION).tar.xz
+09: FOO_SITE = http://www.foosoftware.org/download
+10: FOO_DEPENDENCIES = libbar
+11:
+12: FOO_CONF_OPTS = --enable-bar
+13:
+14: FOO_MODULE_SUBDIRS = driver-base driver-bar
+15: FOO_MODULE_MAKE_OPTS = FOO_STUFF=some-value
+16:
+17: $(eval $(kernel-module))
+18: $(eval $(autotools-package))
+----
+
+Here, we see that we have an autotools-based package, that also builds
+kernel modules located into sub-directories +driver-base+ and +driver-bar+,
+and defines the variable +FOO_STUFF+ to be passed to the Linux buildsystem
+when building the module(s) (see below for the reference for those two
+variables).
+
+
+[[kernel-module-reference]]
+==== +kernel-module+ reference
+
+The main macro for the kernel module infrastructure is +kernel-module+.
+Unlike other package infrastructures, it is not stand-alone, and requires
+any of the other +*-package+ macro be called after it.
+
+The +kernel-module+ macro defines post-build and post-target-install
+hooks to build the kernel modules. If the package's +.mk+ needs access
+to the built kernel modules, it should do so in a post-build hook,
+registered after the call to +kernel-module+. Similarly, if the package's
++.mk+ needs access to the kernel module after it has been installed, it
+should do so in a post-install hook, registered after the call to
++kernel-module+. Here's an example:
+
+----
+$(eval $(kernel-module))
+
+define FOO_DO_STUFF_WITH_KERNEL_MODULE
+ # Do something with it...
+endef
+FOO_POST_BUILD_HOOKS += FOO_DO_STUFF_WITH_KERNEL_MODULE
+
+$(eval $(generic-package))
+----
+
+Finally, unlike the other package infrastructures, there is no
++host-kernel-module+ variant to build a host kernel module.
+
+Additional variable are available to further configure the build of
+the kernel module:
+
+* +FOO_MODULE_SUBDIRS+ may be set to one or more sub-directories (relative
+ to the package source top-directory) where the kernel module sources are.
+ If empty or not set, the sources for the kernel module(s) are considered
+ to be located at the top of the package source tree.
+
+* +FOO_MODULE_MAKE_OPTS+ may be set to contain extra variable definitions
+ to pass to the Linux buildsystem.
diff --git a/docs/manual/adding-packages.txt b/docs/manual/adding-packages.txt
index b8674f8..721fe39 100644
--- a/docs/manual/adding-packages.txt
+++ b/docs/manual/adding-packages.txt
@@ -29,6 +29,8 @@ include::adding-packages-kconfig.txt[]
include::adding-packages-rebar.txt[]
+include::adding-packages-kernel-module.txt[]
+
include::adding-packages-asciidoc.txt[]
include::adding-packages-hooks.txt[]
--
1.9.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 03/11] package/lttng-modules: use kernel-module helper
2015-06-06 22:20 [Buildroot] [PATCH 0/11] pkg-kernel-module: new infra to ease building kernel modules (branch yem/kernel-modules) Yann E. MORIN
2015-06-06 22:20 ` [Buildroot] [PATCH 01/11] package-infra: add helper to build kernel modules Yann E. MORIN
2015-06-06 22:20 ` [Buildroot] [PATCH 02/11] docs/manual: add kernel-module Yann E. MORIN
@ 2015-06-06 22:20 ` Yann E. MORIN
2015-06-06 22:20 ` [Buildroot] [PATCH 04/11] package/igh-ethercat: " Yann E. MORIN
` (7 subsequent siblings)
10 siblings, 0 replies; 34+ messages in thread
From: Yann E. MORIN @ 2015-06-06 22:20 UTC (permalink / raw)
To: buildroot
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
package/lttng-modules/lttng-modules.mk | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/package/lttng-modules/lttng-modules.mk b/package/lttng-modules/lttng-modules.mk
index 6833ad2..30c581e 100644
--- a/package/lttng-modules/lttng-modules.mk
+++ b/package/lttng-modules/lttng-modules.mk
@@ -10,14 +10,5 @@ LTTNG_MODULES_SOURCE = lttng-modules-$(LTTNG_MODULES_VERSION).tar.bz2
LTTNG_MODULES_LICENSE = LGPLv2.1/GPLv2 for kernel modules; MIT for lib/bitfield.h and lib/prio_heap/*
LTTNG_MODULES_LICENSE_FILES = lgpl-2.1.txt gpl-2.0.txt mit-license.txt LICENSE
-LTTNG_MODULES_DEPENDENCIES = linux
-
-define LTTNG_MODULES_BUILD_CMDS
- $(MAKE) -C $(@D) $(LINUX_MAKE_FLAGS) KERNELDIR=$(LINUX_DIR)
-endef
-
-define LTTNG_MODULES_INSTALL_TARGET_CMDS
- $(MAKE) -C $(@D) $(LINUX_MAKE_FLAGS) KERNELDIR=$(LINUX_DIR) modules_install
-endef
-
+$(eval $(kernel-module))
$(eval $(generic-package))
--
1.9.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 04/11] package/igh-ethercat: use kernel-module helper
2015-06-06 22:20 [Buildroot] [PATCH 0/11] pkg-kernel-module: new infra to ease building kernel modules (branch yem/kernel-modules) Yann E. MORIN
` (2 preceding siblings ...)
2015-06-06 22:20 ` [Buildroot] [PATCH 03/11] package/lttng-modules: use kernel-module helper Yann E. MORIN
@ 2015-06-06 22:20 ` Yann E. MORIN
2015-06-06 22:20 ` [Buildroot] [PATCH 05/11] package/ktap: " Yann E. MORIN
` (6 subsequent siblings)
10 siblings, 0 replies; 34+ messages in thread
From: Yann E. MORIN @ 2015-06-06 22:20 UTC (permalink / raw)
To: buildroot
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
package/igh-ethercat/igh-ethercat.mk | 14 +-------------
1 file changed, 1 insertion(+), 13 deletions(-)
diff --git a/package/igh-ethercat/igh-ethercat.mk b/package/igh-ethercat/igh-ethercat.mk
index b5221f8..32c49a3 100644
--- a/package/igh-ethercat/igh-ethercat.mk
+++ b/package/igh-ethercat/igh-ethercat.mk
@@ -10,7 +10,6 @@ IGH_ETHERCAT_SOURCE = ethercat-$(IGH_ETHERCAT_VERSION).tar.bz2
IGH_ETHERCAT_LICENSE = GPLv2 (IgH EtherCAT master), LGPLv2.1 (libraries)
IGH_ETHERCAT_LICENSE_FILES = COPYING COPYING.LESSER
-IGH_ETHERCAT_DEPENDENCIES = linux
IGH_ETHERCAT_INSTALL_STAGING = YES
IGH_ETHERCAT_CONF_OPTS = \
@@ -22,16 +21,5 @@ IGH_ETHERCAT_CONF_OPTS += $(if $(BR2_PACKAGE_IGH_ETHERCAT_E1000),--enable-e1000,
IGH_ETHERCAT_CONF_OPTS += $(if $(BR2_PACKAGE_IGH_ETHERCAT_E1000E),--enable-e1000e,--disable-e1000e)
IGH_ETHERCAT_CONF_OPTS += $(if $(BR2_PACKAGE_IGH_ETHERCAT_R8169),--enable-r8169,--disable-r8169)
-define IGH_ETHERCAT_BUILD_MODULES
- $(MAKE) -C $(@D) $(LINUX_MAKE_FLAGS) modules
-endef
-
-IGH_ETHERCAT_POST_BUILD_HOOKS += IGH_ETHERCAT_BUILD_MODULES
-
-define IGH_ETHERCAT_INSTALL_MODULES
- $(MAKE) -C $(@D) $(LINUX_MAKE_FLAGS) modules_install
-endef
-
-IGH_ETHERCAT_POST_INSTALL_TARGET_HOOKS += IGH_ETHERCAT_INSTALL_MODULES
-
+$(eval $(kernel-module))
$(eval $(autotools-package))
--
1.9.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 05/11] package/ktap: use kernel-module helper
2015-06-06 22:20 [Buildroot] [PATCH 0/11] pkg-kernel-module: new infra to ease building kernel modules (branch yem/kernel-modules) Yann E. MORIN
` (3 preceding siblings ...)
2015-06-06 22:20 ` [Buildroot] [PATCH 04/11] package/igh-ethercat: " Yann E. MORIN
@ 2015-06-06 22:20 ` Yann E. MORIN
2015-06-08 21:25 ` Thomas Petazzoni
2015-06-06 22:20 ` [Buildroot] [PATCH 06/11] package/cryptodev-linux: use the " Yann E. MORIN
` (5 subsequent siblings)
10 siblings, 1 reply; 34+ messages in thread
From: Yann E. MORIN @ 2015-06-06 22:20 UTC (permalink / raw)
To: buildroot
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
package/ktap/ktap.mk | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/package/ktap/ktap.mk b/package/ktap/ktap.mk
index 4a0e51c..966b51c 100644
--- a/package/ktap/ktap.mk
+++ b/package/ktap/ktap.mk
@@ -9,8 +9,6 @@ KTAP_SITE = $(call github,ktap,ktap,$(KTAP_VERSION))
KTAP_LICENSE = GPLv2
KTAP_LICENSE_FILES = LICENSE-GPL
-KTAP_DEPENDENCIES = linux
-
ifeq ($(BR2_PACKAGE_ELFUTILS),y)
KTAP_DEPENDENCIES += elfutils
else
@@ -19,12 +17,13 @@ endif
define KTAP_BUILD_CMDS
$(MAKE) -C $(@D) $(TARGET_CONFIGURE_OPTS) $(KTAP_FLAGS) ktap
- $(MAKE) -C $(@D) $(LINUX_MAKE_FLAGS) KERNEL_SRC=$(LINUX_DIR) KVERSION=$(LINUX_VERSION_PROBED) mod
endef
define KTAP_INSTALL_TARGET_CMDS
$(INSTALL) -D -m755 $(@D)/ktap $(TARGET_DIR)/usr/bin/ktap
- $(MAKE) -C $(@D) $(LINUX_MAKE_FLAGS) KERNEL_SRC=$(LINUX_DIR) KVERSION=$(LINUX_VERSION_PROBED) modules_install
endef
+KTAP_MODULE_MAKE_OPTS = KVERSION=$(LINUX_VERSION_PROBED)
+
+$(eval $(kernel-module))
$(eval $(generic-package))
--
1.9.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 06/11] package/cryptodev-linux: use the kernel-module helper
2015-06-06 22:20 [Buildroot] [PATCH 0/11] pkg-kernel-module: new infra to ease building kernel modules (branch yem/kernel-modules) Yann E. MORIN
` (4 preceding siblings ...)
2015-06-06 22:20 ` [Buildroot] [PATCH 05/11] package/ktap: " Yann E. MORIN
@ 2015-06-06 22:20 ` Yann E. MORIN
2015-06-08 12:33 ` rdkehn at yahoo.com
2015-06-06 22:20 ` [Buildroot] [PATCH 07/11] package/ocf-linux: use " Yann E. MORIN
` (4 subsequent siblings)
10 siblings, 1 reply; 34+ messages in thread
From: Yann E. MORIN @ 2015-06-06 22:20 UTC (permalink / raw)
To: buildroot
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
package/cryptodev-linux/cryptodev-linux.mk | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/package/cryptodev-linux/cryptodev-linux.mk b/package/cryptodev-linux/cryptodev-linux.mk
index 6f41930..02f59f8 100644
--- a/package/cryptodev-linux/cryptodev-linux.mk
+++ b/package/cryptodev-linux/cryptodev-linux.mk
@@ -6,23 +6,18 @@
CRYPTODEV_LINUX_VERSION = 1.7
CRYPTODEV_LINUX_SITE = http://download.gna.org/cryptodev-linux
-CRYPTODEV_LINUX_DEPENDENCIES = linux
CRYPTODEV_LINUX_INSTALL_STAGING = YES
CRYPTODEV_LINUX_LICENSE = GPLv2+
CRYPTODEV_LINUX_LICENSE_FILES = COPYING
-define CRYPTODEV_LINUX_BUILD_CMDS
- $(MAKE) -C $(@D) $(LINUX_MAKE_FLAGS) KERNEL_DIR=$(LINUX_DIR)
-endef
-
-define CRYPTODEV_LINUX_INSTALL_TARGET_CMDS
- $(MAKE) -C $(@D) $(LINUX_MAKE_FLAGS) KERNEL_DIR=$(LINUX_DIR) \
- PREFIX=$(TARGET_DIR) modules_install
-endef
+CRYPTODEV_LINUX_MODULE_MAKE_OPTS = \
+ KERNEL_DIR=$(LINUX_DIR) \
+ PREFIX=$(TARGET_DIR)
define CRYPTODEV_LINUX_INSTALL_STAGING_CMDS
$(INSTALL) -D -m 644 $(@D)/crypto/cryptodev.h \
$(STAGING_DIR)/usr/include/crypto/cryptodev.h
endef
+$(eval $(kernel-module))
$(eval $(generic-package))
--
1.9.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 0/11] pkg-kernel-module: new infra to ease building kernel modules (branch yem/kernel-modules)
@ 2015-06-06 22:20 Yann E. MORIN
2015-06-06 22:20 ` [Buildroot] [PATCH 01/11] package-infra: add helper to build kernel modules Yann E. MORIN
` (10 more replies)
0 siblings, 11 replies; 34+ messages in thread
From: Yann E. MORIN @ 2015-06-06 22:20 UTC (permalink / raw)
To: buildroot
Hello All!
This series introduces a new infrastructure to help writing packages
that build kernel modules.
Unlike other package infrastrucutre, this new kernel-module
infrastructure is not stand-alone, but is made as a complement to
existing infrastructures, so that packages can build both userland and
kernel modules.
A few packages (9) are converted to use that new infrastructure, and it
greatly simplifies most of them (even allowing us to drop some of our
patches).
Furthermore, as a side effect of converting it to this new inra, it also
fixes the sysdig package, which is cirrently broken because it tries to
build with the host kernel.
Unfortunately, not all packages that build kernel headers were
converted, becasue they use very custom (aka convoluted) Makefiles to
reinvent out-of-tree module building, and it is too much work to fix
them.
Regards,
Yann E. MORIN.
The following changes since commit de823a5bd3976ac9fcf039c57869ccf8e9fc0a45:
opkg: gpg support needs libgpg-error (2015-06-06 15:38:56 +0200)
are available in the git repository at:
git://git.busybox.net/~ymorin/git/buildroot yem/kernel-modules
for you to fetch changes up to e2ea306fbb76707d821144673bf6805cd2f3e532:
package/sysdig: use kernel-module helper (2015-06-07 00:04:03 +0200)
----------------------------------------------------------------
Yann E. MORIN (11):
package-infra: add helper to build kernel modules
docs/manual: add kernel-module
package/lttng-modules: use kernel-module helper
package/igh-ethercat: use kernel-module helper
package/ktap: use kernel-module helper
package/cryptodev-linux: use the kernel-module helper
package/ocf-linux: use kernel-module helper
package/on2-8170-modules: use kernel-module helper
package/owl-linux: use kernel-module helper
package/simicsfs: use kernel-module helper
package/sysdig: use kernel-module helper
docs/manual/adding-packages-kernel-module.txt | 120 +++++++++++++++++++++
docs/manual/adding-packages.txt | 2 +
package/Makefile.in | 1 +
package/cryptodev-linux/cryptodev-linux.mk | 13 +--
package/igh-ethercat/igh-ethercat.mk | 14 +--
package/ktap/ktap.mk | 7 +-
package/lttng-modules/lttng-modules.mk | 11 +-
package/ocf-linux/0001-modules-cross.patch | 42 --------
package/ocf-linux/ocf-linux.mk | 17 ++-
package/on2-8170-modules/on2-8170-modules.mk | 11 +-
.../0001-fix-CROSS_COMPILE-usage-in-Makefile.patch | 16 ---
...-3.3.x.patch => 0001-fix-for-linux-3.3.x.patch} | 0
package/owl-linux/owl-linux.mk | 11 +-
package/pkg-kernel-module.mk | 94 ++++++++++++++++
package/simicsfs/simicsfs.mk | 10 +-
package/sysdig/sysdig.mk | 22 +++-
16 files changed, 254 insertions(+), 137 deletions(-)
create mode 100644 docs/manual/adding-packages-kernel-module.txt
delete mode 100644 package/ocf-linux/0001-modules-cross.patch
delete mode 100644 package/owl-linux/0001-fix-CROSS_COMPILE-usage-in-Makefile.patch
rename package/owl-linux/{0002-fix-for-linux-3.3.x.patch => 0001-fix-for-linux-3.3.x.patch} (100%)
create mode 100644 package/pkg-kernel-module.mk
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 07/11] package/ocf-linux: use kernel-module helper
2015-06-06 22:20 [Buildroot] [PATCH 0/11] pkg-kernel-module: new infra to ease building kernel modules (branch yem/kernel-modules) Yann E. MORIN
` (5 preceding siblings ...)
2015-06-06 22:20 ` [Buildroot] [PATCH 06/11] package/cryptodev-linux: use the " Yann E. MORIN
@ 2015-06-06 22:20 ` Yann E. MORIN
2015-06-08 21:35 ` Yann E. MORIN
2015-06-06 22:20 ` [Buildroot] [PATCH 08/11] package/on2-8170-modules: " Yann E. MORIN
` (3 subsequent siblings)
10 siblings, 1 reply; 34+ messages in thread
From: Yann E. MORIN @ 2015-06-06 22:20 UTC (permalink / raw)
To: buildroot
Remove our patch since it is no longer needed.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
package/ocf-linux/0001-modules-cross.patch | 42 ------------------------------
package/ocf-linux/ocf-linux.mk | 17 +++++-------
2 files changed, 7 insertions(+), 52 deletions(-)
delete mode 100644 package/ocf-linux/0001-modules-cross.patch
diff --git a/package/ocf-linux/0001-modules-cross.patch b/package/ocf-linux/0001-modules-cross.patch
deleted file mode 100644
index f80ef06..0000000
--- a/package/ocf-linux/0001-modules-cross.patch
+++ /dev/null
@@ -1,42 +0,0 @@
-Remove the OCF linux kernel extension instead opting to build ocf-linux
-modules out of tree.
-This is easier for users since no kernel config tweaking is required.
-On the downside the OCF drivers can't be used, but then all of the
-kernel crypto drivers are available to users via cryptosoft which is
-preferred.
-
-Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
-
-diff -Nura ocf-linux-20120127.orig/ocf/Makefile ocf-linux-20120127/ocf/Makefile
---- ocf-linux-20120127.orig/ocf/Makefile 2013-04-27 09:27:04.413911866 -0300
-+++ ocf-linux-20120127/ocf/Makefile 2013-04-27 09:27:31.131775576 -0300
-@@ -2,6 +2,7 @@
- -include $(ROOTDIR)/modules/.config
-
- OCF_OBJS = crypto.o criov.o
-+KDIR ?= /lib/modules/$(shell uname -r)/build
-
- ifdef CONFIG_OCF_RANDOMHARVEST
- OCF_OBJS += random.o
-@@ -78,20 +79,13 @@
- #
-
- ocf_make:
-- make -C /lib/modules/$(shell uname -r)/build M=`pwd` $(OCF_TARGET) CONFIG_OCF_OCF=m
-- make -C /lib/modules/$(shell uname -r)/build M=`pwd` $(OCF_TARGET) CONFIG_OCF_OCF=m CONFIG_OCF_CRYPTOSOFT=m
-- -make -C /lib/modules/$(shell uname -r)/build M=`pwd` $(OCF_TARGET) CONFIG_OCF_OCF=m CONFIG_OCF_BENCH=m
-- -make -C /lib/modules/$(shell uname -r)/build M=`pwd` $(OCF_TARGET) CONFIG_OCF_OCF=m CONFIG_OCF_OCFNULL=m
-- -make -C /lib/modules/$(shell uname -r)/build M=`pwd` $(OCF_TARGET) CONFIG_OCF_OCF=m CONFIG_OCF_HIFN=m
-+ make -C $(KDIR) M=`pwd` $(OCF_TARGET) CONFIG_OCF_OCF=m CONFIG_OCF_CRYPTOSOFT=m CONFIG_OCF_BENCH=m CONFIG_OCF_OCFNULL=m
-
- ocf_modules:
- $(MAKE) ocf_make OCF_TARGET=modules
-
- ocf_install:
- $(MAKE) ocf_make OCF_TARGET="modules modules_install"
-- depmod
-- mkdir -p /usr/include/crypto
-- cp cryptodev.h /usr/include/crypto/.
-
- #
- # generate full kernel patches for 2.4 and 2.6 kernels to make patching
diff --git a/package/ocf-linux/ocf-linux.mk b/package/ocf-linux/ocf-linux.mk
index 8ca5578..3ebf462 100644
--- a/package/ocf-linux/ocf-linux.mk
+++ b/package/ocf-linux/ocf-linux.mk
@@ -6,22 +6,19 @@
OCF_LINUX_VERSION = 20120127
OCF_LINUX_SITE = http://downloads.sourceforge.net/project/ocf-linux/ocf-linux/$(OCF_LINUX_VERSION)
-OCF_LINUX_DEPENDENCIES = linux
OCF_LINUX_INSTALL_STAGING = YES
-define OCF_LINUX_BUILD_CMDS
- $(MAKE) -C $(@D)/ocf $(LINUX_MAKE_FLAGS) KDIR=$(LINUX_DIR) \
- ocf_modules
-endef
-
-define OCF_LINUX_INSTALL_TARGET_CMDS
- $(MAKE) -C $(@D)/ocf $(LINUX_MAKE_FLAGS) KDIR=$(LINUX_DIR) \
- ocf_install
-endef
+OCF_LINUX_MODULE_DIR = ocf
+OCF_LINUX_MODULE_MAKE_OPTS = \
+ CONFIG_OCF_OCF=m \
+ CONFIG_OCF_CRYPTOSOFT=m \
+ CONFIG_OCF_BENCH=m \
+ CONFIG_OCF_OCFNULL=m
define OCF_LINUX_INSTALL_STAGING_CMDS
$(INSTALL) -D -m 644 $(@D)/ocf/cryptodev.h \
$(STAGING_DIR)/usr/include/crypto/cryptodev.h
endef
+$(eval $(kernel-module))
$(eval $(generic-package))
--
1.9.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 08/11] package/on2-8170-modules: use kernel-module helper
2015-06-06 22:20 [Buildroot] [PATCH 0/11] pkg-kernel-module: new infra to ease building kernel modules (branch yem/kernel-modules) Yann E. MORIN
` (6 preceding siblings ...)
2015-06-06 22:20 ` [Buildroot] [PATCH 07/11] package/ocf-linux: use " Yann E. MORIN
@ 2015-06-06 22:20 ` Yann E. MORIN
2015-06-06 22:20 ` [Buildroot] [PATCH 09/11] package/owl-linux: " Yann E. MORIN
` (2 subsequent siblings)
10 siblings, 0 replies; 34+ messages in thread
From: Yann E. MORIN @ 2015-06-06 22:20 UTC (permalink / raw)
To: buildroot
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
package/on2-8170-modules/on2-8170-modules.mk | 11 +----------
1 file changed, 1 insertion(+), 10 deletions(-)
diff --git a/package/on2-8170-modules/on2-8170-modules.mk b/package/on2-8170-modules/on2-8170-modules.mk
index 209bcb5..b40ed86 100644
--- a/package/on2-8170-modules/on2-8170-modules.mk
+++ b/package/on2-8170-modules/on2-8170-modules.mk
@@ -7,17 +7,8 @@
ON2_8170_MODULES_VERSION = 73b08061d30789178e692bc332b73d1d9922bf39
ON2_8170_MODULES_SITE = $(call github,alexandrebelloni,on2-8170-modules,$(ON2_8170_MODULES_VERSION))
-ON2_8170_MODULES_DEPENDENCIES = linux
-
ON2_8170_MODULES_LICENSE = GPLv2+
#There is no license file
-define ON2_8170_MODULES_BUILD_CMDS
- $(MAKE) -C $(LINUX_DIR) $(LINUX_MAKE_FLAGS) M=$(@D)
-endef
-
-define ON2_8170_MODULES_INSTALL_TARGET_CMDS
- $(MAKE) -C $(LINUX_DIR) $(LINUX_MAKE_FLAGS) M=$(@D) modules_install
-endef
-
+$(eval $(kernel-module))
$(eval $(generic-package))
--
1.9.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 09/11] package/owl-linux: use kernel-module helper
2015-06-06 22:20 [Buildroot] [PATCH 0/11] pkg-kernel-module: new infra to ease building kernel modules (branch yem/kernel-modules) Yann E. MORIN
` (7 preceding siblings ...)
2015-06-06 22:20 ` [Buildroot] [PATCH 08/11] package/on2-8170-modules: " Yann E. MORIN
@ 2015-06-06 22:20 ` Yann E. MORIN
2015-06-06 22:20 ` [Buildroot] [PATCH 10/11] package/simicsfs: " Yann E. MORIN
2015-06-06 22:20 ` [Buildroot] [PATCH 11/11] package/sysdig: " Yann E. MORIN
10 siblings, 0 replies; 34+ messages in thread
From: Yann E. MORIN @ 2015-06-06 22:20 UTC (permalink / raw)
To: buildroot
Git rid of first patch, no longer needed; rename remaining patch.
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
.../0001-fix-CROSS_COMPILE-usage-in-Makefile.patch | 16 ----------------
...-linux-3.3.x.patch => 0001-fix-for-linux-3.3.x.patch} | 0
package/owl-linux/owl-linux.mk | 11 +----------
3 files changed, 1 insertion(+), 26 deletions(-)
delete mode 100644 package/owl-linux/0001-fix-CROSS_COMPILE-usage-in-Makefile.patch
rename package/owl-linux/{0002-fix-for-linux-3.3.x.patch => 0001-fix-for-linux-3.3.x.patch} (100%)
diff --git a/package/owl-linux/0001-fix-CROSS_COMPILE-usage-in-Makefile.patch b/package/owl-linux/0001-fix-CROSS_COMPILE-usage-in-Makefile.patch
deleted file mode 100644
index 14b4631..0000000
--- a/package/owl-linux/0001-fix-CROSS_COMPILE-usage-in-Makefile.patch
+++ /dev/null
@@ -1,16 +0,0 @@
-Fix the owl-linux Makefile so that it protects spaces in the CROSS_COMPILE
-variable. For example, this variable will contain spaces if ccache is used.
-
-Signed-off-by: Simon Dawson <spdawson@gmail.com>
-diff -Nurp a/Makefile b/Makefile
---- a/Makefile 2012-06-14 10:51:45.000000000 +0100
-+++ b/Makefile 2012-07-20 10:46:41.636752148 +0100
-@@ -35,7 +35,7 @@ else
- PWD := $(shell pwd)
-
- default:
-- $(MAKE) -C $(KERNELDIR) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) M=$(PWD) MODE=$(MODE) modules
-+ $(MAKE) -C $(KERNELDIR) ARCH=$(ARCH) CROSS_COMPILE="$(CROSS_COMPILE)" M=$(PWD) MODE=$(MODE) modules
-
- clean:
- -rm -f *.o *.mod.c *.ko modules.order Module.symvers
diff --git a/package/owl-linux/0002-fix-for-linux-3.3.x.patch b/package/owl-linux/0001-fix-for-linux-3.3.x.patch
similarity index 100%
rename from package/owl-linux/0002-fix-for-linux-3.3.x.patch
rename to package/owl-linux/0001-fix-for-linux-3.3.x.patch
diff --git a/package/owl-linux/owl-linux.mk b/package/owl-linux/owl-linux.mk
index 371cc02..1262425 100644
--- a/package/owl-linux/owl-linux.mk
+++ b/package/owl-linux/owl-linux.mk
@@ -10,14 +10,5 @@ OWL_LINUX_LICENSE = PROPRIETARY
OWL_LINUX_LICENSE_FILES = LICENSE
OWL_LINUX_REDISTRIBUTE = NO
-OWL_LINUX_DEPENDENCIES = linux
-
-define OWL_LINUX_BUILD_CMDS
- $(MAKE) -C $(@D) $(LINUX_MAKE_FLAGS) KERNELDIR=$(LINUX_DIR)
-endef
-
-define OWL_LINUX_INSTALL_TARGET_CMDS
- $(MAKE) -C $(LINUX_DIR) $(LINUX_MAKE_FLAGS) M="$(@D)" modules_install
-endef
-
+$(eval $(kernel-module))
$(eval $(generic-package))
--
1.9.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 10/11] package/simicsfs: use kernel-module helper
2015-06-06 22:20 [Buildroot] [PATCH 0/11] pkg-kernel-module: new infra to ease building kernel modules (branch yem/kernel-modules) Yann E. MORIN
` (8 preceding siblings ...)
2015-06-06 22:20 ` [Buildroot] [PATCH 09/11] package/owl-linux: " Yann E. MORIN
@ 2015-06-06 22:20 ` Yann E. MORIN
2015-06-06 22:20 ` [Buildroot] [PATCH 11/11] package/sysdig: " Yann E. MORIN
10 siblings, 0 replies; 34+ messages in thread
From: Yann E. MORIN @ 2015-06-06 22:20 UTC (permalink / raw)
To: buildroot
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
---
package/simicsfs/simicsfs.mk | 10 +---------
1 file changed, 1 insertion(+), 9 deletions(-)
diff --git a/package/simicsfs/simicsfs.mk b/package/simicsfs/simicsfs.mk
index 51987c5..91ed413 100644
--- a/package/simicsfs/simicsfs.mk
+++ b/package/simicsfs/simicsfs.mk
@@ -8,14 +8,6 @@ SIMICSFS_VERSION = 1.18
SIMICSFS_SITE = http://download.simics.net/pub
SIMICSFS_LICENSE = GPLv2+
SIMICSFS_LICENSE_FILES = hostfs.h
-SIMICSFS_DEPENDENCIES = linux
-
-define SIMICSFS_BUILD_CMDS
- $(MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) M=$(@D) modules
-endef
-
-define SIMICSFS_INSTALL_TARGET_CMDS
- $(MAKE) $(LINUX_MAKE_FLAGS) -C $(LINUX_DIR) M=$(@D) INSTALL_MOD_PATH=$(TARGET_DIR) modules_install
-endef
+$(eval $(kernel-module))
$(eval $(generic-package))
--
1.9.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 11/11] package/sysdig: use kernel-module helper
2015-06-06 22:20 [Buildroot] [PATCH 0/11] pkg-kernel-module: new infra to ease building kernel modules (branch yem/kernel-modules) Yann E. MORIN
` (9 preceding siblings ...)
2015-06-06 22:20 ` [Buildroot] [PATCH 10/11] package/simicsfs: " Yann E. MORIN
@ 2015-06-06 22:20 ` Yann E. MORIN
10 siblings, 0 replies; 34+ messages in thread
From: Yann E. MORIN @ 2015-06-06 22:20 UTC (permalink / raw)
To: buildroot
This has the benefit of making sysdig actually buildable, otherwise it
fails because it tries to use the kernel headers from the host:
make: *** /lib/modules/3.13.0-53-generic/build: No such file or directory. Stop.
make[5]: *** [all] Error 2
make[4]: *** [driver/CMakeFiles/driver] Error 2
make[3]: *** [driver/CMakeFiles/driver.dir/all] Error 2
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
---
package/sysdig/sysdig.mk | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/package/sysdig/sysdig.mk b/package/sysdig/sysdig.mk
index fb348ff..fde1810 100644
--- a/package/sysdig/sysdig.mk
+++ b/package/sysdig/sysdig.mk
@@ -10,13 +10,27 @@ SYSDIG_LICENSE = GPLv2
SYSDIG_LICENSE_FILES = COPYING
SYSDIG_CONF_OPTS = -DUSE_BUNDLED_LUAJIT=OFF -DUSE_BUNDLED_ZLIB=OFF \
-DUSE_BUNDLED_JSONCPP=OFF
-SYSDIG_DEPENDENCIES = zlib luajit jsoncpp linux
+SYSDIG_DEPENDENCIES = zlib luajit jsoncpp
SYSDIG_SUPPORTS_IN_SOURCE_BUILD = NO
-define SYSDIG_INSTALL_DRIVER
- $(MAKE) -C $(SYSDIG_BUILDDIR) $(LINUX_MAKE_FLAGS) KERNELDIR="$(LINUX_DIR)" install_driver
+# sysdig creates the module Makefile from a template, which contains a
+# single place-holder, KBUILD_FLAGS, wich is only replaced with two
+# things:
+# - debug flags, which we don't care about here,
+# - 'sysdig-feature' flags, which are never set, so always empty
+# So, just replace the place-holder with the only meaningful value: nothing.
+define SYSDIG_KERNEL_MAKEFILE
+ $(INSTALL) -m 0644 $(@D)/driver/Makefile.in $(@D)/driver/Makefile
+ $(SED) 's/@KBUILD_FLAGS@//;' $(@D)/driver/Makefile
endef
+SYSDIG_POST_PATCH_HOOKS += SYSDIG_KERNEL_MAKEFILE
-SYSDIG_POST_INSTALL_TARGET_HOOKS += SYSDIG_INSTALL_DRIVER
+# Don't build the driver as part of the 'standard' procedure, we'll
+# build it on our own with the kernel-module infra.
+SYSDIG_CONF_OPTS += -DBUILD_DRIVER=OFF
+SYSDIG_MODULE_SUBDIRS = driver
+SYSDIG_MODULE_MAKE_OPTS = KERNELDIR=$(LINUX_DIR)
+
+$(eval $(kernel-module))
$(eval $(cmake-package))
--
1.9.1
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 01/11] package-infra: add helper to build kernel modules
2015-06-06 22:20 ` [Buildroot] [PATCH 01/11] package-infra: add helper to build kernel modules Yann E. MORIN
@ 2015-06-07 3:22 ` Baruch Siach
2015-06-07 9:59 ` Yann E. MORIN
2015-06-08 12:49 ` rdkehn at yahoo.com
2015-06-08 21:09 ` Arnout Vandecappelle
2 siblings, 1 reply; 34+ messages in thread
From: Baruch Siach @ 2015-06-07 3:22 UTC (permalink / raw)
To: buildroot
Hi Yann,
On Sun, Jun 07, 2015 at 12:20:37AM +0200, Yann E. MORIN wrote:
> +################################################################################
> +# inner-kernel-module -- generates the make targets needed to support building
> +# a kernel module
> +#
> +# argument 1 is the lowercase package name
> +# argument 2 is the uppercase package name, including a HOST_ prefix
> +# for host packages
> +# argument 3 is the uppercase package name, without the HOST_ prefix
> +# for host packages
What is the meaning of building "host" kernel module? These are the target
kernel headers we are using here. Besides, you do not provide a
host-kernel-module macro, at least in this patch.
> +# argument 4 is the type (always 'target')
And here only target is allowed.
baruch
--
http://baruch.siach.name/blog/ ~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- baruch at tkos.co.il - tel: +972.2.679.5364, http://www.tkos.co.il -
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 01/11] package-infra: add helper to build kernel modules
2015-06-07 3:22 ` Baruch Siach
@ 2015-06-07 9:59 ` Yann E. MORIN
0 siblings, 0 replies; 34+ messages in thread
From: Yann E. MORIN @ 2015-06-07 9:59 UTC (permalink / raw)
To: buildroot
Baruch, All,
On 2015-06-07 06:22 +0300, Baruch Siach spake thusly:
> On Sun, Jun 07, 2015 at 12:20:37AM +0200, Yann E. MORIN wrote:
> > +################################################################################
> > +# inner-kernel-module -- generates the make targets needed to support building
> > +# a kernel module
> > +#
> > +# argument 1 is the lowercase package name
> > +# argument 2 is the uppercase package name, including a HOST_ prefix
> > +# for host packages
> > +# argument 3 is the uppercase package name, without the HOST_ prefix
> > +# for host packages
>
> What is the meaning of building "host" kernel module? These are the target
> kernel headers we are using here.
Indeed, I just forgot to strip it out when I copied from another infra.
> Besides, you do not provide a
> host-kernel-module macro, at least in this patch.
And I explicitly dociument that it is not availble (see below, as you
already noticed, and the manual, in the following patch).
> > +# argument 4 is the type (always 'target')
>
> And here only target is allowed.
Yup.
I'll fix that before resubmitting. Thanks! :-)
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 06/11] package/cryptodev-linux: use the kernel-module helper
2015-06-06 22:20 ` [Buildroot] [PATCH 06/11] package/cryptodev-linux: use the " Yann E. MORIN
@ 2015-06-08 12:33 ` rdkehn at yahoo.com
2015-06-08 17:12 ` Yann E. MORIN
0 siblings, 1 reply; 34+ messages in thread
From: rdkehn at yahoo.com @ 2015-06-08 12:33 UTC (permalink / raw)
To: buildroot
Hi Yann,
On Sun, Jun 07, 2015 at 12:20:42AM +0200, Yann E. MORIN wrote:
> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> ---
> package/cryptodev-linux/cryptodev-linux.mk | 13 ++++---------
> 1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/package/cryptodev-linux/cryptodev-linux.mk b/package/cryptodev-linux/cryptodev-linux.mk
> index 6f41930..02f59f8 100644
> --- a/package/cryptodev-linux/cryptodev-linux.mk
> +++ b/package/cryptodev-linux/cryptodev-linux.mk
> @@ -6,23 +6,18 @@
>
> CRYPTODEV_LINUX_VERSION = 1.7
> CRYPTODEV_LINUX_SITE = http://download.gna.org/cryptodev-linux
> -CRYPTODEV_LINUX_DEPENDENCIES = linux
> CRYPTODEV_LINUX_INSTALL_STAGING = YES
> CRYPTODEV_LINUX_LICENSE = GPLv2+
> CRYPTODEV_LINUX_LICENSE_FILES = COPYING
>
> -define CRYPTODEV_LINUX_BUILD_CMDS
> - $(MAKE) -C $(@D) $(LINUX_MAKE_FLAGS) KERNEL_DIR=$(LINUX_DIR)
> -endef
> -
> -define CRYPTODEV_LINUX_INSTALL_TARGET_CMDS
> - $(MAKE) -C $(@D) $(LINUX_MAKE_FLAGS) KERNEL_DIR=$(LINUX_DIR) \
> - PREFIX=$(TARGET_DIR) modules_install
> -endef
> +CRYPTODEV_LINUX_MODULE_MAKE_OPTS = \
> + KERNEL_DIR=$(LINUX_DIR) \
> + PREFIX=$(TARGET_DIR)
>
> define CRYPTODEV_LINUX_INSTALL_STAGING_CMDS
> $(INSTALL) -D -m 644 $(@D)/crypto/cryptodev.h \
> $(STAGING_DIR)/usr/include/crypto/cryptodev.h
> endef
>
> +$(eval $(kernel-module))
> $(eval $(generic-package))
> --
> 1.9.1
cryptodev-linux fails to build because version.h does not get
generated before compiling the source. Adding a PRE_BUILD_HOOK
resolves the problem.
Regards,
...doug
diff --git a/package/cryptodev-linux/cryptodev-linux.mk b/package/cryptodev-linux/cryptodev-linux.mk
index 6f41930..9e1d53d 100644
--- a/package/cryptodev-linux/cryptodev-linux.mk
+++ b/package/cryptodev-linux/cryptodev-linux.mk
@@ -6,23 +6,24 @@
CRYPTODEV_LINUX_VERSION = 1.7
CRYPTODEV_LINUX_SITE = http://download.gna.org/cryptodev-linux
-CRYPTODEV_LINUX_DEPENDENCIES = linux
CRYPTODEV_LINUX_INSTALL_STAGING = YES
CRYPTODEV_LINUX_LICENSE = GPLv2+
CRYPTODEV_LINUX_LICENSE_FILES = COPYING
-define CRYPTODEV_LINUX_BUILD_CMDS
- $(MAKE) -C $(@D) $(LINUX_MAKE_FLAGS) KERNEL_DIR=$(LINUX_DIR)
+define CRYPTODEV_LINUX_VERSION_H
+ $(MAKE) -C $(@D) version.h
endef
-define CRYPTODEV_LINUX_INSTALL_TARGET_CMDS
- $(MAKE) -C $(@D) $(LINUX_MAKE_FLAGS) KERNEL_DIR=$(LINUX_DIR) \
- PREFIX=$(TARGET_DIR) modules_install
-endef
+CRYPTODEV_LINUX_PRE_BUILD_HOOKS += CRYPTODEV_LINUX_VERSION_H
+
+CRYPTODEV_LINUX_MODULE_MAKE_OPTS = \
+ KERNEL_DIR=$(LINUX_DIR) \
+ PREFIX=$(TARGET_DIR)
define CRYPTODEV_LINUX_INSTALL_STAGING_CMDS
$(INSTALL) -D -m 644 $(@D)/crypto/cryptodev.h \
$(STAGING_DIR)/usr/include/crypto/cryptodev.h
endef
+$(eval $(kernel-module))
$(eval $(generic-package))
^ permalink raw reply related [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 01/11] package-infra: add helper to build kernel modules
2015-06-06 22:20 ` [Buildroot] [PATCH 01/11] package-infra: add helper to build kernel modules Yann E. MORIN
2015-06-07 3:22 ` Baruch Siach
@ 2015-06-08 12:49 ` rdkehn at yahoo.com
2015-06-08 21:09 ` Arnout Vandecappelle
2 siblings, 0 replies; 34+ messages in thread
From: rdkehn at yahoo.com @ 2015-06-08 12:49 UTC (permalink / raw)
To: buildroot
On Sun, Jun 07, 2015 at 12:20:37AM +0200, Yann E. MORIN wrote:
> The Linux kernel offers a nice and easy-to-use infra to build
> out-of-tree kernel modules.
>
> Currently, we have quite a few packages that build kernel modules, and
> most dupliacte (or rewrite) the same code over-and-over again.
>
> Introduce a new infrastructure that provides helpers to build kernel
> modules, so packages do not have to duplicate/rewrite that.
>
> The infrastrucutre, unlike any other package infra, is not standalone.
> It needs another package infra to be used. This is so that packages that
> provide both userland and kernel modules can be built easily. So, this
> infra only defines post-build and post-install hooks, that will build
> the kernel modules after the rest of the package.
>
> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Tested-by: Doug Kehn <rdkehn@yahoo.com>
> ---
> package/Makefile.in | 1 +
> package/pkg-kernel-module.mk | 94 ++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 95 insertions(+)
> create mode 100644 package/pkg-kernel-module.mk
>
> diff --git a/package/Makefile.in b/package/Makefile.in
> index c02d31f..180fd46 100644
> --- a/package/Makefile.in
> +++ b/package/Makefile.in
> @@ -398,3 +398,4 @@ include package/pkg-virtual.mk
> include package/pkg-generic.mk
> include package/pkg-kconfig.mk
> include package/pkg-rebar.mk
> +include package/pkg-kernel-module.mk
> diff --git a/package/pkg-kernel-module.mk b/package/pkg-kernel-module.mk
> new file mode 100644
> index 0000000..2a2a2cb
> --- /dev/null
> +++ b/package/pkg-kernel-module.mk
> @@ -0,0 +1,94 @@
> +################################################################################
> +# kernel module infrastructure for building Linux kernel modules
> +#
> +# This file implements an frastructure that eases development of package .mk
> +# files for out-of-tree Linux kernel modules. It should be used for all
> +# packages that build a Linux kernel module.
> +#
> +# In terms of implementation, this infrastructure requires the .mk file to
> +# only specify metadata information about the package: name, version,
> +# download URL, etc.
> +#
> +# It defines post-build and post-install hooks, so that packages can both
> +# build user-space (with any of the other *-package infra) and/or build
> +# kernel modules.
> +#
> +# As such, it is to be used in conjunction with another *-package infra,
> +# like so:
> +#
> +# $(eval $(kernel-module))
> +# $(eval $(generic-package))
> +#
> +# Note: if the caller needs access to the kernel modules (either after they
> +# are built or after they are installed), it will have to define its own
> +# post-build/install hooks after calling kernel-module, but before calling
> +# the other *-package infra, like so:
> +#
> +# $(eval $(kernel-module))
> +# define FOO_MOD_TWEAK
> +# # do something
> +# endef
> +# FOO_POST_BUILD_HOOKS += FOO_MOD_TWEAK
> +# $(eval $(generic-package))
> +#
> +# Note: this infra does not check that the kernel is enabled; it is expected
> +# to be enforced at the Kconfig level with proper 'depends on'.
> +################################################################################
> +
> +################################################################################
> +# inner-kernel-module -- generates the make targets needed to support building
> +# a kernel module
> +#
> +# argument 1 is the lowercase package name
> +# argument 2 is the uppercase package name, including a HOST_ prefix
> +# for host packages
> +# argument 3 is the uppercase package name, without the HOST_ prefix
> +# for host packages
> +# argument 4 is the type (always 'target')
> +################################################################################
> +
> +define inner-kernel-module
> +
> +# The kernel must be built first.
> +$(2)_DEPENDENCIES += linux
> +
> +# Duplicate that from pkg-generic because we need it now
> +ifndef $(2)_MAKE
> + $(2)_MAKE = $(MAKE)
> +endif
> +
> +ifndef $(2)_MODULE_SUBDIRS
> + $(2)_MODULE_SUBDIRS = .
> +endif
> +
> +# Build the kernel module(s)
> +define $(2)_KERNEL_MODULES_BUILD
> + $$(foreach d,$$($(2)_MODULE_SUBDIRS), \
> + @$$(call MESSAGE,"Building kernel module '$$(d)'")$$(sep) \
> + $$($$(PKG)_MAKE) -C $$(LINUX_DIR) \
> + $$(LINUX_MAKE_FLAGS) \
> + $$($(2)_MODULE_MAKE_OPTS) \
> + M=$$($(2)_DIR)/$$(d) \
> + modules$$(sep))
> +endef
> +$(2)_POST_BUILD_HOOKS += $(2)_KERNEL_MODULES_BUILD
> +
> +# Install the kernel module(s)
> +define $(2)_KERNEL_MODULES_INSTALL
> + $$(foreach d,$$($(2)_MODULE_SUBDIRS), \
> + @$$(call MESSAGE,"Installing kernel module '$$(d)'")$$(sep) \
> + $$($$(PKG)_MAKE) -C $$(LINUX_DIR) \
> + $$(LINUX_MAKE_FLAGS) \
> + $$($(2)_MODULE_MAKE_OPTS) \
> + M=$$($(2)_DIR)/$$(d) \
> + modules_install$$(sep))
> +endef
> +$(2)_POST_INSTALL_TARGET_HOOKS += $(2)_KERNEL_MODULES_INSTALL
> +
> +endef
> +
> +################################################################################
> +# kernel-module -- the target generator macro for kernel module packages
> +################################################################################
> +
> +kernel-module = $(call inner-kernel-module,$(pkgname),$(call UPPERCASE,$(pkgname)),$(call UPPERCASE,$(pkgname)),target)
> --
> 1.9.1
>
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 06/11] package/cryptodev-linux: use the kernel-module helper
2015-06-08 12:33 ` rdkehn at yahoo.com
@ 2015-06-08 17:12 ` Yann E. MORIN
2015-06-08 18:55 ` rdkehn at yahoo.com
0 siblings, 1 reply; 34+ messages in thread
From: Yann E. MORIN @ 2015-06-08 17:12 UTC (permalink / raw)
To: buildroot
Doug, All,
On 2015-06-08 07:33 -0500, rdkehn at yahoo.com spake thusly:
> On Sun, Jun 07, 2015 at 12:20:42AM +0200, Yann E. MORIN wrote:
> > Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> > ---
> > package/cryptodev-linux/cryptodev-linux.mk | 13 ++++---------
> > 1 file changed, 4 insertions(+), 9 deletions(-)
> >
> > diff --git a/package/cryptodev-linux/cryptodev-linux.mk b/package/cryptodev-linux/cryptodev-linux.mk
> > index 6f41930..02f59f8 100644
> > --- a/package/cryptodev-linux/cryptodev-linux.mk
> > +++ b/package/cryptodev-linux/cryptodev-linux.mk
> > @@ -6,23 +6,18 @@
> >
> > CRYPTODEV_LINUX_VERSION = 1.7
> > CRYPTODEV_LINUX_SITE = http://download.gna.org/cryptodev-linux
> > -CRYPTODEV_LINUX_DEPENDENCIES = linux
> > CRYPTODEV_LINUX_INSTALL_STAGING = YES
> > CRYPTODEV_LINUX_LICENSE = GPLv2+
> > CRYPTODEV_LINUX_LICENSE_FILES = COPYING
> >
> > -define CRYPTODEV_LINUX_BUILD_CMDS
> > - $(MAKE) -C $(@D) $(LINUX_MAKE_FLAGS) KERNEL_DIR=$(LINUX_DIR)
> > -endef
> > -
> > -define CRYPTODEV_LINUX_INSTALL_TARGET_CMDS
> > - $(MAKE) -C $(@D) $(LINUX_MAKE_FLAGS) KERNEL_DIR=$(LINUX_DIR) \
> > - PREFIX=$(TARGET_DIR) modules_install
> > -endef
> > +CRYPTODEV_LINUX_MODULE_MAKE_OPTS = \
> > + KERNEL_DIR=$(LINUX_DIR) \
> > + PREFIX=$(TARGET_DIR)
> >
> > define CRYPTODEV_LINUX_INSTALL_STAGING_CMDS
> > $(INSTALL) -D -m 644 $(@D)/crypto/cryptodev.h \
> > $(STAGING_DIR)/usr/include/crypto/cryptodev.h
> > endef
> >
> > +$(eval $(kernel-module))
> > $(eval $(generic-package))
> > --
> > 1.9.1
>
> cryptodev-linux fails to build because version.h does not get
> generated before compiling the source. Adding a PRE_BUILD_HOOK
> resolves the problem.
Weird, I'm pretty sure it did build here without that hook.
But you're right, it does not.
Maybe I tested the wrong patch... Who knows? ;-)
> Regards,
> ...doug
>
> diff --git a/package/cryptodev-linux/cryptodev-linux.mk b/package/cryptodev-linux/cryptodev-linux.mk
> index 6f41930..9e1d53d 100644
> --- a/package/cryptodev-linux/cryptodev-linux.mk
> +++ b/package/cryptodev-linux/cryptodev-linux.mk
> @@ -6,23 +6,24 @@
>
> CRYPTODEV_LINUX_VERSION = 1.7
> CRYPTODEV_LINUX_SITE = http://download.gna.org/cryptodev-linux
> -CRYPTODEV_LINUX_DEPENDENCIES = linux
> CRYPTODEV_LINUX_INSTALL_STAGING = YES
> CRYPTODEV_LINUX_LICENSE = GPLv2+
> CRYPTODEV_LINUX_LICENSE_FILES = COPYING
>
> -define CRYPTODEV_LINUX_BUILD_CMDS
> - $(MAKE) -C $(@D) $(LINUX_MAKE_FLAGS) KERNEL_DIR=$(LINUX_DIR)
> +define CRYPTODEV_LINUX_VERSION_H
> + $(MAKE) -C $(@D) version.h
Indeed, that makes it work. Thanks! :-)
May I add your Signed-off-by to the patch?
Regards,
Yann E. MORIN.
> endef
>
> -define CRYPTODEV_LINUX_INSTALL_TARGET_CMDS
> - $(MAKE) -C $(@D) $(LINUX_MAKE_FLAGS) KERNEL_DIR=$(LINUX_DIR) \
> - PREFIX=$(TARGET_DIR) modules_install
> -endef
> +CRYPTODEV_LINUX_PRE_BUILD_HOOKS += CRYPTODEV_LINUX_VERSION_H
> +
> +CRYPTODEV_LINUX_MODULE_MAKE_OPTS = \
> + KERNEL_DIR=$(LINUX_DIR) \
> + PREFIX=$(TARGET_DIR)
>
> define CRYPTODEV_LINUX_INSTALL_STAGING_CMDS
> $(INSTALL) -D -m 644 $(@D)/crypto/cryptodev.h \
> $(STAGING_DIR)/usr/include/crypto/cryptodev.h
> endef
>
> +$(eval $(kernel-module))
> $(eval $(generic-package))
>
> _______________________________________________
> buildroot mailing list
> buildroot at busybox.net
> http://lists.busybox.net/mailman/listinfo/buildroot
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 06/11] package/cryptodev-linux: use the kernel-module helper
2015-06-08 17:12 ` Yann E. MORIN
@ 2015-06-08 18:55 ` rdkehn at yahoo.com
0 siblings, 0 replies; 34+ messages in thread
From: rdkehn at yahoo.com @ 2015-06-08 18:55 UTC (permalink / raw)
To: buildroot
Hi Yann,
On Mon, Jun 08, 2015 at 07:12:06PM +0200, Yann E. MORIN wrote:
> Doug, All,
>
>
> Indeed, that makes it work. Thanks! :-)
> May I add your Signed-off-by to the patch?
>
Yes.
Regards,
...doug
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 01/11] package-infra: add helper to build kernel modules
2015-06-06 22:20 ` [Buildroot] [PATCH 01/11] package-infra: add helper to build kernel modules Yann E. MORIN
2015-06-07 3:22 ` Baruch Siach
2015-06-08 12:49 ` rdkehn at yahoo.com
@ 2015-06-08 21:09 ` Arnout Vandecappelle
2015-06-08 21:25 ` Yann E. MORIN
2015-06-08 21:44 ` Yann E. MORIN
2 siblings, 2 replies; 34+ messages in thread
From: Arnout Vandecappelle @ 2015-06-08 21:09 UTC (permalink / raw)
To: buildroot
On 06/07/15 00:20, Yann E. MORIN wrote:
> The Linux kernel offers a nice and easy-to-use infra to build
> out-of-tree kernel modules.
>
> Currently, we have quite a few packages that build kernel modules, and
> most dupliacte (or rewrite) the same code over-and-over again.
duplicate
>
> Introduce a new infrastructure that provides helpers to build kernel
> modules, so packages do not have to duplicate/rewrite that.
>
> The infrastrucutre, unlike any other package infra, is not standalone.
infrastructure
> It needs another package infra to be used. This is so that packages that
> provide both userland and kernel modules can be built easily. So, this
> infra only defines post-build and post-install hooks, that will build
> the kernel modules after the rest of the package.
>
> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> ---
> package/Makefile.in | 1 +
> package/pkg-kernel-module.mk | 94 ++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 95 insertions(+)
> create mode 100644 package/pkg-kernel-module.mk
>
> diff --git a/package/Makefile.in b/package/Makefile.in
> index c02d31f..180fd46 100644
> --- a/package/Makefile.in
> +++ b/package/Makefile.in
> @@ -398,3 +398,4 @@ include package/pkg-virtual.mk
> include package/pkg-generic.mk
> include package/pkg-kconfig.mk
> include package/pkg-rebar.mk
> +include package/pkg-kernel-module.mk
I think we should at some point put this either in alphabetical or some other
logical order. But for now, it's chaos anyway so OK to just add at the end.
> diff --git a/package/pkg-kernel-module.mk b/package/pkg-kernel-module.mk
> new file mode 100644
> index 0000000..2a2a2cb
> --- /dev/null
> +++ b/package/pkg-kernel-module.mk
> @@ -0,0 +1,94 @@
> +################################################################################
> +# kernel module infrastructure for building Linux kernel modules
> +#
> +# This file implements an frastructure that eases development of package .mk
infrastructure
> +# files for out-of-tree Linux kernel modules. It should be used for all
> +# packages that build a Linux kernel module.
Well, as you say in the cover text, there are a few packages with awkward build
systems that can't use this infra.
> +#
> +# In terms of implementation, this infrastructure requires the .mk file to
> +# only specify metadata information about the package: name, version,
> +# download URL, etc.
I think this is another cut&paste from pkg-generic that is not appropriate.
> +#
> +# It defines post-build and post-install hooks, so that packages can both
> +# build user-space (with any of the other *-package infra) and/or build
> +# kernel modules.
> +#
> +# As such, it is to be used in conjunction with another *-package infra,
> +# like so:
> +#
> +# $(eval $(kernel-module))
> +# $(eval $(generic-package))
> +#
> +# Note: if the caller needs access to the kernel modules (either after they
> +# are built or after they are installed), it will have to define its own
> +# post-build/install hooks after calling kernel-module, but before calling
> +# the other *-package infra, like so:
> +#
> +# $(eval $(kernel-module))
> +# define FOO_MOD_TWEAK
> +# # do something
> +# endef
> +# FOO_POST_BUILD_HOOKS += FOO_MOD_TWEAK
> +# $(eval $(generic-package))
That is not so nice, but I don't see a better alternative.
> +#
> +# Note: this infra does not check that the kernel is enabled; it is expected
> +# to be enforced at the Kconfig level with proper 'depends on'.
> +################################################################################
> +
> +################################################################################
> +# inner-kernel-module -- generates the make targets needed to support building
> +# a kernel module
> +#
> +# argument 1 is the lowercase package name
> +# argument 2 is the uppercase package name, including a HOST_ prefix
> +# for host packages
> +# argument 3 is the uppercase package name, without the HOST_ prefix
> +# for host packages
> +# argument 4 is the type (always 'target')
$(2) is the only one that is used...
> +################################################################################
> +
> +define inner-kernel-module
> +
> +# The kernel must be built first.
> +$(2)_DEPENDENCIES += linux
> +
> +# Duplicate that from pkg-generic because we need it now
> +ifndef $(2)_MAKE
> + $(2)_MAKE = $(MAKE)
> +endif
I don't see why this is needed... The defines below will only be expanded when
the rule is executed (otherwise $(PKG) would not even be defined), so the
definition from pkg-generic is enough, no?
> +
> +ifndef $(2)_MODULE_SUBDIRS
> + $(2)_MODULE_SUBDIRS = .
> +endif
> +
> +# Build the kernel module(s)
> +define $(2)_KERNEL_MODULES_BUILD
> + $$(foreach d,$$($(2)_MODULE_SUBDIRS), \
> + @$$(call MESSAGE,"Building kernel module '$$(d)'")$$(sep) \
I think that "Building kernel module '.'" looks a bit weird... But again, I
can't think of an alternative.
> + $$($$(PKG)_MAKE) -C $$(LINUX_DIR) \
Missing $(LINUX_MAKE_ENV) (or at least TARGET_MAKE_ENV, but I think
LINUX_MAKE_ENV is more appropriate even if it just adds BR_BINARIES_DIR).
> + $$(LINUX_MAKE_FLAGS) \
> + $$($(2)_MODULE_MAKE_OPTS) \
> + M=$$($(2)_DIR)/$$(d) \
We usually use $(@D) instead of $(2)_DIR.
> + modules$$(sep))
> +endef
> +$(2)_POST_BUILD_HOOKS += $(2)_KERNEL_MODULES_BUILD
> +
> +# Install the kernel module(s)
> +define $(2)_KERNEL_MODULES_INSTALL
> + $$(foreach d,$$($(2)_MODULE_SUBDIRS), \
> + @$$(call MESSAGE,"Installing kernel module '$$(d)'")$$(sep) \
> + $$($$(PKG)_MAKE) -C $$(LINUX_DIR) \
> + $$(LINUX_MAKE_FLAGS) \
> + $$($(2)_MODULE_MAKE_OPTS) \
> + M=$$($(2)_DIR)/$$(d) \
> + modules_install$$(sep))
> +endef
> +$(2)_POST_INSTALL_TARGET_HOOKS += $(2)_KERNEL_MODULES_INSTALL
> +
> +endef
> +
> +################################################################################
> +# kernel-module -- the target generator macro for kernel module packages
> +################################################################################
> +
> +kernel-module = $(call inner-kernel-module,$(pkgname),$(call UPPERCASE,$(pkgname)),$(call UPPERCASE,$(pkgname)),target)
$(2) is the only one used, so just
kernel-module = $(call inner-kernel-module,$(call UPPERCASE,$(pkgname)))
Regards,
Arnout
>
--
Arnout Vandecappelle arnout at mind be
Senior Embedded Software Architect +32-16-286500
Essensium/Mind http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint: 7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 01/11] package-infra: add helper to build kernel modules
2015-06-08 21:09 ` Arnout Vandecappelle
@ 2015-06-08 21:25 ` Yann E. MORIN
2015-06-08 21:33 ` Thomas Petazzoni
2015-06-08 21:44 ` Yann E. MORIN
1 sibling, 1 reply; 34+ messages in thread
From: Yann E. MORIN @ 2015-06-08 21:25 UTC (permalink / raw)
To: buildroot
Arnout, All,
On 2015-06-08 23:09 +0200, Arnout Vandecappelle spake thusly:
> On 06/07/15 00:20, Yann E. MORIN wrote:
> > The Linux kernel offers a nice and easy-to-use infra to build
> > out-of-tree kernel modules.
> >
> > Currently, we have quite a few packages that build kernel modules, and
> > most dupliacte (or rewrite) the same code over-and-over again.
>
> duplicate
>
> >
> > Introduce a new infrastructure that provides helpers to build kernel
> > modules, so packages do not have to duplicate/rewrite that.
> >
> > The infrastrucutre, unlike any other package infra, is not standalone.
>
> infrastructure
Will fix both.
> > It needs another package infra to be used. This is so that packages that
> > provide both userland and kernel modules can be built easily. So, this
> > infra only defines post-build and post-install hooks, that will build
> > the kernel modules after the rest of the package.
> >
> > Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> > Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> > ---
> > package/Makefile.in | 1 +
> > package/pkg-kernel-module.mk | 94 ++++++++++++++++++++++++++++++++++++++++++++
> > 2 files changed, 95 insertions(+)
> > create mode 100644 package/pkg-kernel-module.mk
> >
> > diff --git a/package/Makefile.in b/package/Makefile.in
> > index c02d31f..180fd46 100644
> > --- a/package/Makefile.in
> > +++ b/package/Makefile.in
> > @@ -398,3 +398,4 @@ include package/pkg-virtual.mk
> > include package/pkg-generic.mk
> > include package/pkg-kconfig.mk
> > include package/pkg-rebar.mk
> > +include package/pkg-kernel-module.mk
>
> I think we should at some point put this either in alphabetical or some other
> logical order. But for now, it's chaos anyway so OK to just add at the end.
Yup, the rule so far has been "append new infra". So I did the same...
> > diff --git a/package/pkg-kernel-module.mk b/package/pkg-kernel-module.mk
> > new file mode 100644
> > index 0000000..2a2a2cb
> > --- /dev/null
> > +++ b/package/pkg-kernel-module.mk
> > @@ -0,0 +1,94 @@
> > +################################################################################
> > +# kernel module infrastructure for building Linux kernel modules
> > +#
> > +# This file implements an frastructure that eases development of package .mk
>
> infrastructure
Yup.
> > +# files for out-of-tree Linux kernel modules. It should be used for all
> > +# packages that build a Linux kernel module.
>
> Well, as you say in the cover text, there are a few packages with awkward build
> systems that can't use this infra.
Will rephrase.
> > +#
> > +# In terms of implementation, this infrastructure requires the .mk file to
> > +# only specify metadata information about the package: name, version,
> > +# download URL, etc.
>
> I think this is another cut&paste from pkg-generic that is not appropriate.
Yup, will remove.
> > +#
> > +# It defines post-build and post-install hooks, so that packages can both
> > +# build user-space (with any of the other *-package infra) and/or build
> > +# kernel modules.
> > +#
> > +# As such, it is to be used in conjunction with another *-package infra,
> > +# like so:
> > +#
> > +# $(eval $(kernel-module))
> > +# $(eval $(generic-package))
> > +#
> > +# Note: if the caller needs access to the kernel modules (either after they
> > +# are built or after they are installed), it will have to define its own
> > +# post-build/install hooks after calling kernel-module, but before calling
> > +# the other *-package infra, like so:
> > +#
> > +# $(eval $(kernel-module))
> > +# define FOO_MOD_TWEAK
> > +# # do something
> > +# endef
> > +# FOO_POST_BUILD_HOOKS += FOO_MOD_TWEAK
> > +# $(eval $(generic-package))
>
> That is not so nice, but I don't see a better alternative.
>
> > +#
> > +# Note: this infra does not check that the kernel is enabled; it is expected
> > +# to be enforced at the Kconfig level with proper 'depends on'.
> > +################################################################################
> > +
> > +################################################################################
> > +# inner-kernel-module -- generates the make targets needed to support building
> > +# a kernel module
> > +#
> > +# argument 1 is the lowercase package name
> > +# argument 2 is the uppercase package name, including a HOST_ prefix
> > +# for host packages
> > +# argument 3 is the uppercase package name, without the HOST_ prefix
> > +# for host packages
> > +# argument 4 is the type (always 'target')
>
> $(2) is the only one that is used...
Already fixed locally, see:
http://git.buildroot.org/~ymorin/git/buildroot/commit/?h=yem/kernel-modules&id=37668dc37654cdcb9e874e62ba994990f8835486
> > +################################################################################
> > +
> > +define inner-kernel-module
> > +
> > +# The kernel must be built first.
> > +$(2)_DEPENDENCIES += linux
> > +
> > +# Duplicate that from pkg-generic because we need it now
> > +ifndef $(2)_MAKE
> > + $(2)_MAKE = $(MAKE)
> > +endif
>
> I don't see why this is needed... The defines below will only be expanded when
> the rule is executed (otherwise $(PKG) would not even be defined), so the
> definition from pkg-generic is enough, no?
That's what I thought, too, but encountered an error in the beginings of
this infra. I'll retest without that.
> > +ifndef $(2)_MODULE_SUBDIRS
> > + $(2)_MODULE_SUBDIRS = .
> > +endif
> > +
> > +# Build the kernel module(s)
> > +define $(2)_KERNEL_MODULES_BUILD
> > + $$(foreach d,$$($(2)_MODULE_SUBDIRS), \
> > + @$$(call MESSAGE,"Building kernel module '$$(d)'")$$(sep) \
>
> I think that "Building kernel module '.'" looks a bit weird... But again, I
> can't think of an alternative.
Neither do I. I'll see if I can do something about that...
> > + $$($$(PKG)_MAKE) -C $$(LINUX_DIR) \
>
> Missing $(LINUX_MAKE_ENV) (or at least TARGET_MAKE_ENV, but I think
> LINUX_MAKE_ENV is more appropriate even if it just adds BR_BINARIES_DIR).
>
>
> > + $$(LINUX_MAKE_FLAGS) \
> > + $$($(2)_MODULE_MAKE_OPTS) \
> > + M=$$($(2)_DIR)/$$(d) \
>
> We usually use $(@D) instead of $(2)_DIR.
Ack.
> > + modules$$(sep))
> > +endef
> > +$(2)_POST_BUILD_HOOKS += $(2)_KERNEL_MODULES_BUILD
> > +
> > +# Install the kernel module(s)
> > +define $(2)_KERNEL_MODULES_INSTALL
> > + $$(foreach d,$$($(2)_MODULE_SUBDIRS), \
> > + @$$(call MESSAGE,"Installing kernel module '$$(d)'")$$(sep) \
> > + $$($$(PKG)_MAKE) -C $$(LINUX_DIR) \
> > + $$(LINUX_MAKE_FLAGS) \
> > + $$($(2)_MODULE_MAKE_OPTS) \
> > + M=$$($(2)_DIR)/$$(d) \
> > + modules_install$$(sep))
> > +endef
> > +$(2)_POST_INSTALL_TARGET_HOOKS += $(2)_KERNEL_MODULES_INSTALL
> > +
> > +endef
> > +
> > +################################################################################
> > +# kernel-module -- the target generator macro for kernel module packages
> > +################################################################################
> > +
> > +kernel-module = $(call inner-kernel-module,$(pkgname),$(call UPPERCASE,$(pkgname)),$(call UPPERCASE,$(pkgname)),target)
>
> $(2) is the only one used, so just
>
> kernel-module = $(call inner-kernel-module,$(call UPPERCASE,$(pkgname)))
Yup, already done. ;-)
Thanks! :-)
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 05/11] package/ktap: use kernel-module helper
2015-06-06 22:20 ` [Buildroot] [PATCH 05/11] package/ktap: " Yann E. MORIN
@ 2015-06-08 21:25 ` Thomas Petazzoni
2015-06-08 21:31 ` Yann E. MORIN
0 siblings, 1 reply; 34+ messages in thread
From: Thomas Petazzoni @ 2015-06-08 21:25 UTC (permalink / raw)
To: buildroot
Yann,
On Sun, 7 Jun 2015 00:20:41 +0200, Yann E. MORIN wrote:
> define KTAP_BUILD_CMDS
> $(MAKE) -C $(@D) $(TARGET_CONFIGURE_OPTS) $(KTAP_FLAGS) ktap
> - $(MAKE) -C $(@D) $(LINUX_MAKE_FLAGS) KERNEL_SRC=$(LINUX_DIR) KVERSION=$(LINUX_VERSION_PROBED) mod
> endef
>
> define KTAP_INSTALL_TARGET_CMDS
> $(INSTALL) -D -m755 $(@D)/ktap $(TARGET_DIR)/usr/bin/ktap
> - $(MAKE) -C $(@D) $(LINUX_MAKE_FLAGS) KERNEL_SRC=$(LINUX_DIR) KVERSION=$(LINUX_VERSION_PROBED) modules_install
> endef
I think you are effectively getting rid of the KERNEL_SRC definition
here. Did you test that it was working OK without this variable?
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 05/11] package/ktap: use kernel-module helper
2015-06-08 21:25 ` Thomas Petazzoni
@ 2015-06-08 21:31 ` Yann E. MORIN
2015-06-08 21:34 ` Yann E. MORIN
0 siblings, 1 reply; 34+ messages in thread
From: Yann E. MORIN @ 2015-06-08 21:31 UTC (permalink / raw)
To: buildroot
Thomas, All,
On 2015-06-08 23:25 +0200, Thomas Petazzoni spake thusly:
> On Sun, 7 Jun 2015 00:20:41 +0200, Yann E. MORIN wrote:
> > define KTAP_BUILD_CMDS
> > $(MAKE) -C $(@D) $(TARGET_CONFIGURE_OPTS) $(KTAP_FLAGS) ktap
> > - $(MAKE) -C $(@D) $(LINUX_MAKE_FLAGS) KERNEL_SRC=$(LINUX_DIR) KVERSION=$(LINUX_VERSION_PROBED) mod
> > endef
> >
> > define KTAP_INSTALL_TARGET_CMDS
> > $(INSTALL) -D -m755 $(@D)/ktap $(TARGET_DIR)/usr/bin/ktap
> > - $(MAKE) -C $(@D) $(LINUX_MAKE_FLAGS) KERNEL_SRC=$(LINUX_DIR) KVERSION=$(LINUX_VERSION_PROBED) modules_install
> > endef
>
> I think you are effectively getting rid of the KERNEL_SRC definition
> here. Did you test that it was working OK without this variable?
Well, it does build a kernel module, yes.
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 01/11] package-infra: add helper to build kernel modules
2015-06-08 21:25 ` Yann E. MORIN
@ 2015-06-08 21:33 ` Thomas Petazzoni
2015-06-08 21:35 ` Yann E. MORIN
0 siblings, 1 reply; 34+ messages in thread
From: Thomas Petazzoni @ 2015-06-08 21:33 UTC (permalink / raw)
To: buildroot
Dear Yann E. MORIN,
On Mon, 8 Jun 2015 23:25:19 +0200, Yann E. MORIN wrote:
> > > +# Build the kernel module(s)
> > > +define $(2)_KERNEL_MODULES_BUILD
> > > + $$(foreach d,$$($(2)_MODULE_SUBDIRS), \
> > > + @$$(call MESSAGE,"Building kernel module '$$(d)'")$$(sep) \
> >
> > I think that "Building kernel module '.'" looks a bit weird... But again, I
> > can't think of an alternative.
>
> Neither do I. I'll see if I can do something about that...
Just don't show a message for each subdir, only one for the overall
build command:
$$(call MESAGE,"Building kernel module(s)")
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 05/11] package/ktap: use kernel-module helper
2015-06-08 21:31 ` Yann E. MORIN
@ 2015-06-08 21:34 ` Yann E. MORIN
2015-06-08 22:11 ` Thomas Petazzoni
0 siblings, 1 reply; 34+ messages in thread
From: Yann E. MORIN @ 2015-06-08 21:34 UTC (permalink / raw)
To: buildroot
Thomas, All,
On 2015-06-08 23:31 +0200, Yann E. MORIN spake thusly:
> On 2015-06-08 23:25 +0200, Thomas Petazzoni spake thusly:
> > On Sun, 7 Jun 2015 00:20:41 +0200, Yann E. MORIN wrote:
> > > define KTAP_BUILD_CMDS
> > > $(MAKE) -C $(@D) $(TARGET_CONFIGURE_OPTS) $(KTAP_FLAGS) ktap
> > > - $(MAKE) -C $(@D) $(LINUX_MAKE_FLAGS) KERNEL_SRC=$(LINUX_DIR) KVERSION=$(LINUX_VERSION_PROBED) mod
> > > endef
> > >
> > > define KTAP_INSTALL_TARGET_CMDS
> > > $(INSTALL) -D -m755 $(@D)/ktap $(TARGET_DIR)/usr/bin/ktap
> > > - $(MAKE) -C $(@D) $(LINUX_MAKE_FLAGS) KERNEL_SRC=$(LINUX_DIR) KVERSION=$(LINUX_VERSION_PROBED) modules_install
> > > endef
> >
> > I think you are effectively getting rid of the KERNEL_SRC definition
> > here. Did you test that it was working OK without this variable?
>
> Well, it does build a kernel module, yes.
Sorry, I sent too early, forgot to say:
KERNEL_SRC is used i ktap's Makefile only to run commands like:
$(MAKE) -C $(KERNEL_SRC) M=$(PWD) modules
So, since that's our infra now doing that, KERNEL_SRC is no longer
needed.
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 07/11] package/ocf-linux: use kernel-module helper
2015-06-06 22:20 ` [Buildroot] [PATCH 07/11] package/ocf-linux: use " Yann E. MORIN
@ 2015-06-08 21:35 ` Yann E. MORIN
0 siblings, 0 replies; 34+ messages in thread
From: Yann E. MORIN @ 2015-06-08 21:35 UTC (permalink / raw)
To: buildroot
All,
On 2015-06-07 00:20 +0200, Yann E. MORIN spake thusly:
> Remove our patch since it is no longer needed.
>
> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
[--SNIP--]
> diff --git a/package/ocf-linux/ocf-linux.mk b/package/ocf-linux/ocf-linux.mk
> index 8ca5578..3ebf462 100644
> --- a/package/ocf-linux/ocf-linux.mk
> +++ b/package/ocf-linux/ocf-linux.mk
> @@ -6,22 +6,19 @@
>
> OCF_LINUX_VERSION = 20120127
> OCF_LINUX_SITE = http://downloads.sourceforge.net/project/ocf-linux/ocf-linux/$(OCF_LINUX_VERSION)
> -OCF_LINUX_DEPENDENCIES = linux
> OCF_LINUX_INSTALL_STAGING = YES
>
> -define OCF_LINUX_BUILD_CMDS
> - $(MAKE) -C $(@D)/ocf $(LINUX_MAKE_FLAGS) KDIR=$(LINUX_DIR) \
> - ocf_modules
> -endef
> -
> -define OCF_LINUX_INSTALL_TARGET_CMDS
> - $(MAKE) -C $(@D)/ocf $(LINUX_MAKE_FLAGS) KDIR=$(LINUX_DIR) \
> - ocf_install
> -endef
> +OCF_LINUX_MODULE_DIR = ocf
Before any notices: that's wrong, and already fixed locally.
Regards,
Yann E. MORIN.
> +OCF_LINUX_MODULE_MAKE_OPTS = \
> + CONFIG_OCF_OCF=m \
> + CONFIG_OCF_CRYPTOSOFT=m \
> + CONFIG_OCF_BENCH=m \
> + CONFIG_OCF_OCFNULL=m
>
> define OCF_LINUX_INSTALL_STAGING_CMDS
> $(INSTALL) -D -m 644 $(@D)/ocf/cryptodev.h \
> $(STAGING_DIR)/usr/include/crypto/cryptodev.h
> endef
>
> +$(eval $(kernel-module))
> $(eval $(generic-package))
> --
> 1.9.1
>
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 01/11] package-infra: add helper to build kernel modules
2015-06-08 21:33 ` Thomas Petazzoni
@ 2015-06-08 21:35 ` Yann E. MORIN
0 siblings, 0 replies; 34+ messages in thread
From: Yann E. MORIN @ 2015-06-08 21:35 UTC (permalink / raw)
To: buildroot
Thomas, All,
On 2015-06-08 23:33 +0200, Thomas Petazzoni spake thusly:
> On Mon, 8 Jun 2015 23:25:19 +0200, Yann E. MORIN wrote:
> > > > +# Build the kernel module(s)
> > > > +define $(2)_KERNEL_MODULES_BUILD
> > > > + $$(foreach d,$$($(2)_MODULE_SUBDIRS), \
> > > > + @$$(call MESSAGE,"Building kernel module '$$(d)'")$$(sep) \
> > >
> > > I think that "Building kernel module '.'" looks a bit weird... But again, I
> > > can't think of an alternative.
> >
> > Neither do I. I'll see if I can do something about that...
>
> Just don't show a message for each subdir, only one for the overall
> build command:
>
> $$(call MESAGE,"Building kernel module(s)")
Yep, I was going to do so. Thanks for confirming! :-)
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 01/11] package-infra: add helper to build kernel modules
2015-06-08 21:09 ` Arnout Vandecappelle
2015-06-08 21:25 ` Yann E. MORIN
@ 2015-06-08 21:44 ` Yann E. MORIN
2015-06-08 21:52 ` Arnout Vandecappelle
1 sibling, 1 reply; 34+ messages in thread
From: Yann E. MORIN @ 2015-06-08 21:44 UTC (permalink / raw)
To: buildroot
Arnout, All,
On 2015-06-08 23:09 +0200, Arnout Vandecappelle spake thusly:
> On 06/07/15 00:20, Yann E. MORIN wrote:
[--SNIP--]
> > +# Duplicate that from pkg-generic because we need it now
> > +ifndef $(2)_MAKE
> > + $(2)_MAKE = $(MAKE)
> > +endif
>
> I don't see why this is needed... The defines below will only be expanded when
> the rule is executed (otherwise $(PKG) would not even be defined), so the
> definition from pkg-generic is enough, no?
Well, I tried to remove it, and it does not work (indetation added by me):
>>> cryptodev-linux 1.7 Building kernel module(s)
C /home/ymorin/dev/buildroot/O/build/linux-4.0.4 HOSTCC="/usr/bin/gcc" HOSTCFLAGS="" ARCH=i386
INSTALL_MOD_PATH=/home/ymorin/dev/buildroot/O/target CROSS_COMPILE="/home/ymorin/dev/buildroot/O/host/usr/bin/i686-pc-linux-gnu-"
DEPMOD=/home/ymorin/dev/buildroot/O/host/sbin/depmod KERNEL_DIR=/home/ymorin/dev/buildroot/O/build/linux-4.0.4
PREFIX=/home/ymorin/dev/buildroot/O/target M=/home/ymorin/dev/buildroot/O/build/cryptodev-linux-1.7/. modules
/bin/sh: C: command not found
make[1]:
[/home/ymorin/dev/buildroot/O/build/cryptodev-linux-1.7/.stamp_built]
Error 127 (ignored)
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 02/11] docs/manual: add kernel-module
2015-06-06 22:20 ` [Buildroot] [PATCH 02/11] docs/manual: add kernel-module Yann E. MORIN
@ 2015-06-08 21:46 ` Arnout Vandecappelle
2015-06-08 22:02 ` Arnout Vandecappelle
0 siblings, 1 reply; 34+ messages in thread
From: Arnout Vandecappelle @ 2015-06-08 21:46 UTC (permalink / raw)
To: buildroot
On 06/07/15 00:20, Yann E. MORIN wrote:
> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
> Cc: Samuel Martin <s.martin49@gmail.com>
> ---
> docs/manual/adding-packages-kernel-module.txt | 120 ++++++++++++++++++++++++++
> docs/manual/adding-packages.txt | 2 +
> 2 files changed, 122 insertions(+)
> create mode 100644 docs/manual/adding-packages-kernel-module.txt
>
> diff --git a/docs/manual/adding-packages-kernel-module.txt b/docs/manual/adding-packages-kernel-module.txt
> new file mode 100644
> index 0000000..1fe359a
> --- /dev/null
> +++ b/docs/manual/adding-packages-kernel-module.txt
> @@ -0,0 +1,120 @@
> +// -*- mode:doc; -*-
> +// vim: set syntax=asciidoc:
> +
> +=== Infrastructure for packages building kernel modules
> +
> +Some packages, in addition to the usual user-space components it builds,
> +may also need to build and install kernel modules.
How about:
Buildroot offers a helper infrastructure to make it easy to write packages that
build and install Linux kernel modules. Some packages only contain a kernel
module, other packages contain programs and libraries in addition to kernel
modules. Buildroot's helper infrastructure supports either case.
> +
> +Buildroot offers a helper infrastructure to ease writing such packages.
> +
> +[[kernel-module-tutorial]]
> +==== +kernel-module+ tutorial
> +
> +Let's start with an example on how to prepare a simple package that only
> +builds a kernel module, and no other component:
> +
> +----
> +01: ################################################################################
> +02: #
> +03: # foo
> +04: #
> +05: ################################################################################
> +06:
> +07: FOO_VERSION = 1.2.3
> +08: FOO_SOURCE = foo-$(FOO_VERSION).tar.xz
> +09: FOO_SITE = http://www.foosoftware.org/download
> +10:
> +11: $(eval $(kernel-module))
> +12: $(eval $(generic-package))
> +----
> +
> +Lines 7-9 define the usual meta-data to specify the version, archive name
> +and remote URI where to find the package source.
> +
> +On line 11, we invoke the +kernel-module+ helper infrastructure, that
> +generates all the appropriate Makefile rules and variables to build
> +that kernel module.
> +
> +Finally, on line 12, we invoke the
> +xref:generic-package-tutorial[+generic-package+ infrastructure].
> +
> +The dependency on +linux+ is automatically added, so it is not needed to
> +specify it in +FOO_DEPENDENCIES+.
> +
> +What you may have noticed is that, unlike other package infrastructures,
> +we explicitly invoke a second infrastructure. This allows a package to
> +build a kernel module, but also, if needed, use any one of other package
> +inftrastructures to build normal userland components (libraries,
infrastructures
> +executables...). Using the +kernel-module+ infrastructure on its own is
> +not sufficient; another package infrastructure *must* be used.
It's a pity that it's not possible to add a check for that...
> +
> +Let's look at a more complex example:
> +
> +----
> +01: ################################################################################
> +02: #
> +03: # foo
> +04: #
> +05: ################################################################################
> +06:
> +07: FOO_VERSION = 1.2.3
> +08: FOO_SOURCE = foo-$(FOO_VERSION).tar.xz
> +09: FOO_SITE = http://www.foosoftware.org/download
> +10: FOO_DEPENDENCIES = libbar
> +11:
> +12: FOO_CONF_OPTS = --enable-bar
> +13:
> +14: FOO_MODULE_SUBDIRS = driver-base driver-bar
> +15: FOO_MODULE_MAKE_OPTS = FOO_STUFF=some-value
I think this is a little too abstract to understand. Perhaps use a more
concrete example, e.g. the one from ktap:
FOO_MODULE_MAKE_OPTS = KVERSION=$(LINUX_VERSION_PROBED)
(which is also an opportunity to talk about the otherwise undocumented but in
this context important LINUX_VERSION_PROBED variable).
> +16:
> +17: $(eval $(kernel-module))
> +18: $(eval $(autotools-package))
> +----
> +
> +Here, we see that we have an autotools-based package, that also builds
> +kernel modules located into sub-directories +driver-base+ and +driver-bar+,
> +and defines the variable +FOO_STUFF+ to be passed to the Linux buildsystem
> +when building the module(s) (see below for the reference for those two
> +variables).
> +
> +
> +[[kernel-module-reference]]
> +==== +kernel-module+ reference
> +
> +The main macro for the kernel module infrastructure is +kernel-module+.
> +Unlike other package infrastructures, it is not stand-alone, and requires
> +any of the other +*-package+ macro be called after it.
^^^^^
macros
> +
> +The +kernel-module+ macro defines post-build and post-target-install
> +hooks to build the kernel modules. If the package's +.mk+ needs access
> +to the built kernel modules, it should do so in a post-build hook,
> +registered after the call to +kernel-module+. Similarly, if the package's
> ++.mk+ needs access to the kernel module after it has been installed, it
> +should do so in a post-install hook, registered after the call to
> ++kernel-module+. Here's an example:
> +
> +----
> +$(eval $(kernel-module))
> +
> +define FOO_DO_STUFF_WITH_KERNEL_MODULE
> + # Do something with it...
> +endef
> +FOO_POST_BUILD_HOOKS += FOO_DO_STUFF_WITH_KERNEL_MODULE
> +
> +$(eval $(generic-package))
> +----
> +
> +Finally, unlike the other package infrastructures, there is no
> ++host-kernel-module+ variant to build a host kernel module.
> +
> +Additional variable are available to further configure the build of
> +the kernel module:
The following additional variables can optionally be defined to further
configure the build of the kernel module:
Regards,
Arnout
> +
> +* +FOO_MODULE_SUBDIRS+ may be set to one or more sub-directories (relative
> + to the package source top-directory) where the kernel module sources are.
> + If empty or not set, the sources for the kernel module(s) are considered
> + to be located at the top of the package source tree.
> +
> +* +FOO_MODULE_MAKE_OPTS+ may be set to contain extra variable definitions
> + to pass to the Linux buildsystem.
> diff --git a/docs/manual/adding-packages.txt b/docs/manual/adding-packages.txt
> index b8674f8..721fe39 100644
> --- a/docs/manual/adding-packages.txt
> +++ b/docs/manual/adding-packages.txt
> @@ -29,6 +29,8 @@ include::adding-packages-kconfig.txt[]
>
> include::adding-packages-rebar.txt[]
>
> +include::adding-packages-kernel-module.txt[]
> +
> include::adding-packages-asciidoc.txt[]
>
> include::adding-packages-hooks.txt[]
>
--
Arnout Vandecappelle arnout at mind be
Senior Embedded Software Architect +32-16-286500
Essensium/Mind http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint: 7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 01/11] package-infra: add helper to build kernel modules
2015-06-08 21:44 ` Yann E. MORIN
@ 2015-06-08 21:52 ` Arnout Vandecappelle
2015-06-08 21:58 ` Yann E. MORIN
0 siblings, 1 reply; 34+ messages in thread
From: Arnout Vandecappelle @ 2015-06-08 21:52 UTC (permalink / raw)
To: buildroot
On 06/08/15 23:44, Yann E. MORIN wrote:
> Arnout, All,
>
> On 2015-06-08 23:09 +0200, Arnout Vandecappelle spake thusly:
>> On 06/07/15 00:20, Yann E. MORIN wrote:
> [--SNIP--]
>>> +# Duplicate that from pkg-generic because we need it now
>>> +ifndef $(2)_MAKE
>>> + $(2)_MAKE = $(MAKE)
>>> +endif
>>
>> I don't see why this is needed... The defines below will only be expanded when
>> the rule is executed (otherwise $(PKG) would not even be defined), so the
>> definition from pkg-generic is enough, no?
>
> Well, I tried to remove it, and it does not work (indetation added by me):
D'oh, it's actually defined in pkg-autotools, not pkg-generic, but the comment
above confused me. Which in fact makes the comment redundant, because it's not a
redifinition.
That said, I think it's better like this:
$(2)_MAKE ?= $$(MAKE)
Regards,
Arnout
>
>>>> cryptodev-linux 1.7 Building kernel module(s)
> C /home/ymorin/dev/buildroot/O/build/linux-4.0.4 HOSTCC="/usr/bin/gcc" HOSTCFLAGS="" ARCH=i386
> INSTALL_MOD_PATH=/home/ymorin/dev/buildroot/O/target CROSS_COMPILE="/home/ymorin/dev/buildroot/O/host/usr/bin/i686-pc-linux-gnu-"
> DEPMOD=/home/ymorin/dev/buildroot/O/host/sbin/depmod KERNEL_DIR=/home/ymorin/dev/buildroot/O/build/linux-4.0.4
> PREFIX=/home/ymorin/dev/buildroot/O/target M=/home/ymorin/dev/buildroot/O/build/cryptodev-linux-1.7/. modules
> /bin/sh: C: command not found
> make[1]:
> [/home/ymorin/dev/buildroot/O/build/cryptodev-linux-1.7/.stamp_built]
> Error 127 (ignored)
>
> Regards,
> Yann E. MORIN.
>
--
Arnout Vandecappelle arnout at mind be
Senior Embedded Software Architect +32-16-286500
Essensium/Mind http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint: 7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 01/11] package-infra: add helper to build kernel modules
2015-06-08 21:52 ` Arnout Vandecappelle
@ 2015-06-08 21:58 ` Yann E. MORIN
2015-06-08 21:59 ` Arnout Vandecappelle
0 siblings, 1 reply; 34+ messages in thread
From: Yann E. MORIN @ 2015-06-08 21:58 UTC (permalink / raw)
To: buildroot
Arnout, All,
On 2015-06-08 23:52 +0200, Arnout Vandecappelle spake thusly:
> On 06/08/15 23:44, Yann E. MORIN wrote:
> > On 2015-06-08 23:09 +0200, Arnout Vandecappelle spake thusly:
> >> On 06/07/15 00:20, Yann E. MORIN wrote:
> >>> +# Duplicate that from pkg-generic because we need it now
> >>> +ifndef $(2)_MAKE
> >>> + $(2)_MAKE = $(MAKE)
> >>> +endif
> >>
> >> I don't see why this is needed... The defines below will only be expanded when
> >> the rule is executed (otherwise $(PKG) would not even be defined), so the
> >> definition from pkg-generic is enough, no?
> >
> > Well, I tried to remove it, and it does not work (indetation added by me):
>
> D'oh, it's actually defined in pkg-autotools, not pkg-generic, but the comment
> above confused me. Which in fact makes the comment redundant, because it's not a
> redifinition.
Ah, yes, right, my bad.
I tested with a generic-package. Maybe an autotools-package (or any
other infra) would have no issue, since it is defined for them.
> That said, I think it's better like this:
>
> $(2)_MAKE ?= $$(MAKE)
Yup, I'll do (already usinf $$(MaKE) locally.
Thanks! :-)
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 01/11] package-infra: add helper to build kernel modules
2015-06-08 21:58 ` Yann E. MORIN
@ 2015-06-08 21:59 ` Arnout Vandecappelle
0 siblings, 0 replies; 34+ messages in thread
From: Arnout Vandecappelle @ 2015-06-08 21:59 UTC (permalink / raw)
To: buildroot
On 06/08/15 23:58, Yann E. MORIN wrote:
> Arnout, All,
>
> On 2015-06-08 23:52 +0200, Arnout Vandecappelle spake thusly:
>> On 06/08/15 23:44, Yann E. MORIN wrote:
>>> On 2015-06-08 23:09 +0200, Arnout Vandecappelle spake thusly:
>>>> On 06/07/15 00:20, Yann E. MORIN wrote:
>>>>> +# Duplicate that from pkg-generic because we need it now
>>>>> +ifndef $(2)_MAKE
>>>>> + $(2)_MAKE = $(MAKE)
>>>>> +endif
>>>>
>>>> I don't see why this is needed... The defines below will only be expanded when
>>>> the rule is executed (otherwise $(PKG) would not even be defined), so the
>>>> definition from pkg-generic is enough, no?
>>>
>>> Well, I tried to remove it, and it does not work (indetation added by me):
>>
>> D'oh, it's actually defined in pkg-autotools, not pkg-generic, but the comment
>> above confused me. Which in fact makes the comment redundant, because it's not a
>> redifinition.
>
> Ah, yes, right, my bad.
>
> I tested with a generic-package. Maybe an autotools-package (or any
> other infra) would have no issue, since it is defined for them.
>
>> That said, I think it's better like this:
>>
>> $(2)_MAKE ?= $$(MAKE)
>
> Yup, I'll do (already usinf $$(MaKE) locally.
I also mean ?= is better than ifndef.
Regards,
Arnout
>
> Thanks! :-)
>
> Regards,
> Yann E. MORIN.
>
--
Arnout Vandecappelle arnout at mind be
Senior Embedded Software Architect +32-16-286500
Essensium/Mind http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint: 7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 02/11] docs/manual: add kernel-module
2015-06-08 21:46 ` Arnout Vandecappelle
@ 2015-06-08 22:02 ` Arnout Vandecappelle
2015-06-08 22:24 ` Yann E. MORIN
0 siblings, 1 reply; 34+ messages in thread
From: Arnout Vandecappelle @ 2015-06-08 22:02 UTC (permalink / raw)
To: buildroot
On 06/08/15 23:46, Arnout Vandecappelle wrote:
> On 06/07/15 00:20, Yann E. MORIN wrote:
>> Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
>> Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
>> Cc: Samuel Martin <s.martin49@gmail.com>
>> ---
>> docs/manual/adding-packages-kernel-module.txt | 120 ++++++++++++++++++++++++++
>> docs/manual/adding-packages.txt | 2 +
>> 2 files changed, 122 insertions(+)
>> create mode 100644 docs/manual/adding-packages-kernel-module.txt
>>
>> diff --git a/docs/manual/adding-packages-kernel-module.txt b/docs/manual/adding-packages-kernel-module.txt
>> new file mode 100644
>> index 0000000..1fe359a
>> --- /dev/null
>> +++ b/docs/manual/adding-packages-kernel-module.txt
>> @@ -0,0 +1,120 @@
>> +// -*- mode:doc; -*-
>> +// vim: set syntax=asciidoc:
>> +
>> +=== Infrastructure for packages building kernel modules
>> +
>> +Some packages, in addition to the usual user-space components it builds,
>> +may also need to build and install kernel modules.
>
> How about:
>
> Buildroot offers a helper infrastructure to make it easy to write packages that
> build and install Linux kernel modules. Some packages only contain a kernel
> module, other packages contain programs and libraries in addition to kernel
> modules. Buildroot's helper infrastructure supports either case.
>
>> +
>> +Buildroot offers a helper infrastructure to ease writing such packages.
>> +
>> +[[kernel-module-tutorial]]
>> +==== +kernel-module+ tutorial
>> +
>> +Let's start with an example on how to prepare a simple package that only
>> +builds a kernel module, and no other component:
>> +
>> +----
>> +01: ################################################################################
>> +02: #
>> +03: # foo
>> +04: #
>> +05: ################################################################################
>> +06:
>> +07: FOO_VERSION = 1.2.3
>> +08: FOO_SOURCE = foo-$(FOO_VERSION).tar.xz
>> +09: FOO_SITE = http://www.foosoftware.org/download
One more thing: we want to encourage adding license info, so perhaps include in
the example:
FOO_LICENSE = GPLv2
FOO_LICENSE_FILES = COPYING
Regards,
Arnout
>> +10:
>> +11: $(eval $(kernel-module))
>> +12: $(eval $(generic-package))
>> +----
>> +
[snip]
--
Arnout Vandecappelle arnout at mind be
Senior Embedded Software Architect +32-16-286500
Essensium/Mind http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint: 7CB5 E4CC 6C2E EFD4 6E3D A754 F963 ECAB 2450 2F1F
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 05/11] package/ktap: use kernel-module helper
2015-06-08 21:34 ` Yann E. MORIN
@ 2015-06-08 22:11 ` Thomas Petazzoni
0 siblings, 0 replies; 34+ messages in thread
From: Thomas Petazzoni @ 2015-06-08 22:11 UTC (permalink / raw)
To: buildroot
Dear Yann E. MORIN,
On Mon, 8 Jun 2015 23:34:13 +0200, Yann E. MORIN wrote:
> Sorry, I sent too early, forgot to say:
>
> KERNEL_SRC is used i ktap's Makefile only to run commands like:
>
> $(MAKE) -C $(KERNEL_SRC) M=$(PWD) modules
>
> So, since that's our infra now doing that, KERNEL_SRC is no longer
> needed.
Ok, makes sense. Might be worth mentioning in the commit log.
Thanks!
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 34+ messages in thread
* [Buildroot] [PATCH 02/11] docs/manual: add kernel-module
2015-06-08 22:02 ` Arnout Vandecappelle
@ 2015-06-08 22:24 ` Yann E. MORIN
0 siblings, 0 replies; 34+ messages in thread
From: Yann E. MORIN @ 2015-06-08 22:24 UTC (permalink / raw)
To: buildroot
Arnout, All,
On 2015-06-09 00:02 +0200, Arnout Vandecappelle spake thusly:
> On 06/08/15 23:46, Arnout Vandecappelle wrote:
> > On 06/07/15 00:20, Yann E. MORIN wrote:
[--SNIP--]
> >> +01: ################################################################################
> >> +02: #
> >> +03: # foo
> >> +04: #
> >> +05: ################################################################################
> >> +06:
> >> +07: FOO_VERSION = 1.2.3
> >> +08: FOO_SOURCE = foo-$(FOO_VERSION).tar.xz
> >> +09: FOO_SITE = http://www.foosoftware.org/download
>
> One more thing: we want to encourage adding license info, so perhaps include in
> the example:
>
> FOO_LICENSE = GPLv2
> FOO_LICENSE_FILES = COPYING
That and your previous comments acted upon. Thanks! :-)
Regards,
Yann E. MORIN.
--
.-----------------.--------------------.------------------.--------------------.
| Yann E. MORIN | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software Designer | \ / CAMPAIGN | ___ |
| +33 223 225 172 `------------.-------: X AGAINST | \e/ There is no |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL | v conspiracy. |
'------------------------------^-------^------------------^--------------------'
^ permalink raw reply [flat|nested] 34+ messages in thread
end of thread, other threads:[~2015-06-08 22:24 UTC | newest]
Thread overview: 34+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-06-06 22:20 [Buildroot] [PATCH 0/11] pkg-kernel-module: new infra to ease building kernel modules (branch yem/kernel-modules) Yann E. MORIN
2015-06-06 22:20 ` [Buildroot] [PATCH 01/11] package-infra: add helper to build kernel modules Yann E. MORIN
2015-06-07 3:22 ` Baruch Siach
2015-06-07 9:59 ` Yann E. MORIN
2015-06-08 12:49 ` rdkehn at yahoo.com
2015-06-08 21:09 ` Arnout Vandecappelle
2015-06-08 21:25 ` Yann E. MORIN
2015-06-08 21:33 ` Thomas Petazzoni
2015-06-08 21:35 ` Yann E. MORIN
2015-06-08 21:44 ` Yann E. MORIN
2015-06-08 21:52 ` Arnout Vandecappelle
2015-06-08 21:58 ` Yann E. MORIN
2015-06-08 21:59 ` Arnout Vandecappelle
2015-06-06 22:20 ` [Buildroot] [PATCH 02/11] docs/manual: add kernel-module Yann E. MORIN
2015-06-08 21:46 ` Arnout Vandecappelle
2015-06-08 22:02 ` Arnout Vandecappelle
2015-06-08 22:24 ` Yann E. MORIN
2015-06-06 22:20 ` [Buildroot] [PATCH 03/11] package/lttng-modules: use kernel-module helper Yann E. MORIN
2015-06-06 22:20 ` [Buildroot] [PATCH 04/11] package/igh-ethercat: " Yann E. MORIN
2015-06-06 22:20 ` [Buildroot] [PATCH 05/11] package/ktap: " Yann E. MORIN
2015-06-08 21:25 ` Thomas Petazzoni
2015-06-08 21:31 ` Yann E. MORIN
2015-06-08 21:34 ` Yann E. MORIN
2015-06-08 22:11 ` Thomas Petazzoni
2015-06-06 22:20 ` [Buildroot] [PATCH 06/11] package/cryptodev-linux: use the " Yann E. MORIN
2015-06-08 12:33 ` rdkehn at yahoo.com
2015-06-08 17:12 ` Yann E. MORIN
2015-06-08 18:55 ` rdkehn at yahoo.com
2015-06-06 22:20 ` [Buildroot] [PATCH 07/11] package/ocf-linux: use " Yann E. MORIN
2015-06-08 21:35 ` Yann E. MORIN
2015-06-06 22:20 ` [Buildroot] [PATCH 08/11] package/on2-8170-modules: " Yann E. MORIN
2015-06-06 22:20 ` [Buildroot] [PATCH 09/11] package/owl-linux: " Yann E. MORIN
2015-06-06 22:20 ` [Buildroot] [PATCH 10/11] package/simicsfs: " Yann E. MORIN
2015-06-06 22:20 ` [Buildroot] [PATCH 11/11] package/sysdig: " Yann E. MORIN
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox