Skip to contentSkip to conversation

pkg-kernel-module: new infra to ease building kernel modules (branch yem/kernel-modules)

PATCH Superseded Yann E. MORIN 4 participants 33 messages Jun 10, 2015 – Jun 12, 2015 Arm/actions semi architecture

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover pkg-kernel-module: new infra to ease building kernel modules (branch yem/kernel-modules)

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.

Changes v1 -> v2:
- drop third and fourth args to inner macros (unneeded), fix comments about inner macros (Arnout, Baruch)
- add LINU_MAKE_ENV (Arnout)
- be less verbose, print a single MESSAGE (Thomas, Arnout)
- rephrase parts of the manual (Arnout)
- explain now-missing variable in ktap (Thomas)
- fix crypto-dev (Doug)
- fix owl-linux

Regards,
Yann E. MORIN.

The following changes since commit 74c67922edbfcf1b1aaa04ab68fce218e2b903e9:

valgrind: backport support for glibc 2.20+ (2015-06-10 11:47:46 +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 d5dd0daf87cc08d3da3d20f37ac6c62c5f781df2:

package/sysdig: use kernel-module helper (2015-06-10 21:19:37 +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      | 129 +++++++++++++++++++++
 docs/manual/adding-packages.txt                    |   2 +
 package/Makefile.in                                |   1 +
 package/cryptodev-linux/cryptodev-linux.mk         |  14 +--
 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                     |  15 +--
 package/pkg-kernel-module.mk                       |  89 ++++++++++++++
 package/simicsfs/simicsfs.mk                       |  10 +-
 package/sysdig/sysdig.mk                           |  22 +++-
 16 files changed, 266 insertions(+), 134 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
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  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.  |
'------------------------------^-------^------------------^--------------------'
#1 lore raw

PATCH v2 1/11 package-infra: add helper to build kernel modules

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 duplicate (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 infrastructure, 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.

Also, no host version is provided, since it does not make sense to build kernel modules for the host.

Cc Thomas Petazzoni <[email protected]>
Cc Baruch Siach <[email protected]>
Cc Arnout Vandecappelle <[email protected]>

---
Changes v1 -> v2:
- drop third and fourth args to inner macro: we're never going to build kernel modules for the host (Baruch, Arnout)
- add missing LINUX_MAKE_ENV (Arnout)
- use $$(@D), not $$($(2)_DIR) (Arnout)
- print a single MESSAGE (Arnout, Thomas)
- typoes (Arnout)

---
 package/Makefile.in          |  1 +
 package/pkg-kernel-module.mk | 89 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 90 insertions(+)
 create mode 100644 package/pkg-kernel-module.mk
package/Makefile.in +1 -0
index c02d31f..180fd46 100644
@@ -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
package/pkg-kernel-module.mk new file +89 -0

89 lines not on this page · raw message

Signature · 1 line
1.9.1
#2 lore raw

PATCH v2 1/11 package-infra: add helper to build kernel modules

Quoted 15 lines · Yann E. MORIN

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 duplicate (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 infrastructure, 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.

Quoted 7 lines

Also, no host version is provided, since it does not make sense to build kernel modules for the host.

Cc Thomas Petazzoni <[email protected]>
Cc Baruch Siach <[email protected]>
Cc Arnout Vandecappelle <[email protected]>
Quoted 126 lines

---
Changes v1 -> v2:
- drop third and fourth args to inner macro: we're never going to build kernel modules for the host (Baruch, Arnout)
- add missing LINUX_MAKE_ENV (Arnout)
- use $$(@D), not $$($(2)_DIR) (Arnout)
- print a single MESSAGE (Arnout, Thomas)
- typoes (Arnout)

---
 package/Makefile.in          |  1 +
 package/pkg-kernel-module.mk | 89 ++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 90 insertions(+)
 create mode 100644 package/pkg-kernel-module.mk
package/Makefile.in +1 -0
index c02d31f..180fd46 100644
@@ -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
package/pkg-kernel-module.mk new file +89 -0
new file mode 100644
index 0000000..608c9e6
@@ -0,0 +1,89 @@
+################################################################################
+# kernel module infrastructure for building Linux kernel modules
+#
+# This file implements an infrastructure 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 using the kernel's out-of-tree
+# buildsystem, unless they use a complex custom build-system.
+#
+# In terms of implementation, this infrastructure relies on another package
+# infrastructure, and only 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
+################################################################################
+
+define inner-kernel-module
+
+# The kernel must be built first.
+$(2)_DEPENDENCIES += linux
+
+# This is only defined in some infrastructures (e.g. autotools, cmake), but
+# not in others (generic). So define it if not already defined.
+$(2)_MAKE ?= $$(MAKE)
+
+# If not specified, consider the source of the kernel module to be at
+# the root of the package.
+$(2)_MODULE_SUBDIRS ?= .
+
+# Build the kernel module(s)
+define $(2)_KERNEL_MODULES_BUILD
+	@$$(call MESSAGE,"Building kernel module(s)")
+	$$(foreach d,$$($(2)_MODULE_SUBDIRS), \
+		$$(LINUX_MAKE_ENV) $$($$(PKG)_MAKE) \
+			-C $$(LINUX_DIR) \
+			$$(LINUX_MAKE_FLAGS) \
+			$$($(2)_MODULE_MAKE_OPTS) \
+			M=$$(@D)/$$(d) \
+			modules$$(sep))
+endef
+$(2)_POST_BUILD_HOOKS += $(2)_KERNEL_MODULES_BUILD
+
+# Install the kernel module(s)
+define $(2)_KERNEL_MODULES_INSTALL
+	@$$(call MESSAGE,"Installing kernel module(s)")
+	$$(foreach d,$$($(2)_MODULE_SUBDIRS), \
+		$$(LINUX_MAKE_ENV) $$($$(PKG)_MAKE) \
+			-C $$(LINUX_DIR) \
+			$$(LINUX_MAKE_FLAGS) \
+			$$($(2)_MODULE_MAKE_OPTS) \
+			M=$$(@D)/$$(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)))
Signature · 6 lines
1.9.1

_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
#3 lore raw

PATCH v2 1/11 package-infra: add helper to build kernel modules

Doug, All,

On 2015-06-10 16:08 -0500, rdkehn at yahoo.com spake thusly:

Quoted 16 lines · Yann E. MORIN
Quoted 15 lines

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 duplicate (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 infrastructure, 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.

Quoted 8 lines
Quoted 7 lines

Also, no host version is provided, since it does not make sense to build kernel modules for the host.

Cc Thomas Petazzoni <[email protected]>
Cc Baruch Siach <[email protected]>
Cc Arnout Vandecappelle <[email protected]>

Sorry, I forgot to propagate your Tested-by tag from the previous iteration. I'll do for the next one.

Thanks! :-)

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  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.  |
'------------------------------^-------^------------------^--------------------'
#4 lore raw

PATCH v2 1/11 package-infra: add helper to build kernel modules

In reply to Yann E. MORIN
Quoted 15 lines · Yann E. MORIN

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 duplicate (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 infrastructure, 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.

Quoted 7 lines

Also, no host version is provided, since it does not make sense to build kernel modules for the host.

Cc Thomas Petazzoni <[email protected]>
Cc Baruch Siach <[email protected]>
Cc Arnout Vandecappelle <[email protected]>

Just some comments about the comments, and an optional remark, so after fixing
those you can add my

[snip]

package/pkg-kernel-module.mk line 7

Quoted 13 lines
package/pkg-kernel-module.mk new file +7 -0
new file mode 100644
index 0000000..608c9e6
@@ -0,0 +1,89 @@
+################################################################################
+# kernel module infrastructure for building Linux kernel modules
+#
+# This file implements an infrastructure 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 using the kernel's out-of-tree
+# buildsystem, unless they use a complex custom build-system.

buildsystem, build-system. What about consistently choosing "build system"? :-)

package/pkg-kernel-module.mk line 12

Quoted 5 lines
package/pkg-kernel-module.mk new file +5 -0
+#
+# In terms of implementation, this infrastructure relies on another package
+# infrastructure, and only 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.

# The kernel-module infrastructure requires the packages that use it to also

# include another package infrastructure. kernel-module only defines post-build
# and post-install hooks. This allows the package to build both kernel modules
# and/or user-space components (with any of the other *-package infra).

package/pkg-kernel-module.mk line 22

Quoted 10 lines
package/pkg-kernel-module.mk new file +10 -0
+#
+# 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

after -> *after*

Quoted 8 lines
package/pkg-kernel-module.mk new file +8 -0
+# 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))

package/pkg-kernel-module.mk line 40

Quoted 10 lines
package/pkg-kernel-module.mk new file +10 -0
+#
+# 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

Is there any reason to keep this, since it's not used?

package/pkg-kernel-module.mk line 50

Quoted 10 lines
package/pkg-kernel-module.mk new file +10 -0
+#  argument 2 is the uppercase package name
+################################################################################
+
+define inner-kernel-module
+
+# The kernel must be built first.
+$(2)_DEPENDENCIES += linux
+
+# This is only defined in some infrastructures (e.g. autotools, cmake), but
+# not in others (generic). So define it if not already defined.

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ So define it here as well.

Regards,
Arnout

Quoted 40 lines
package/pkg-kernel-module.mk new file +39 -0
+$(2)_MAKE ?= $$(MAKE)
+
+# If not specified, consider the source of the kernel module to be at
+# the root of the package.
+$(2)_MODULE_SUBDIRS ?= .
+
+# Build the kernel module(s)
+define $(2)_KERNEL_MODULES_BUILD
+	@$$(call MESSAGE,"Building kernel module(s)")
+	$$(foreach d,$$($(2)_MODULE_SUBDIRS), \
+		$$(LINUX_MAKE_ENV) $$($$(PKG)_MAKE) \
+			-C $$(LINUX_DIR) \
+			$$(LINUX_MAKE_FLAGS) \
+			$$($(2)_MODULE_MAKE_OPTS) \
+			M=$$(@D)/$$(d) \
+			modules$$(sep))
+endef
+$(2)_POST_BUILD_HOOKS += $(2)_KERNEL_MODULES_BUILD
+
+# Install the kernel module(s)
+define $(2)_KERNEL_MODULES_INSTALL
+	@$$(call MESSAGE,"Installing kernel module(s)")
+	$$(foreach d,$$($(2)_MODULE_SUBDIRS), \
+		$$(LINUX_MAKE_ENV) $$($$(PKG)_MAKE) \
+			-C $$(LINUX_DIR) \
+			$$(LINUX_MAKE_FLAGS) \
+			$$($(2)_MODULE_MAKE_OPTS) \
+			M=$$(@D)/$$(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)))
Signature · 6 lines
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
#5 lore raw

PATCH v2 1/11 package-infra: add helper to build kernel modules

Arnout, All,

On 2015-06-12 00:44 +0200, Arnout Vandecappelle spake thusly:

Quoted 3 lines · Yann E. MORIN
Quoted 2 lines

The Linux kernel offers a nice and easy-to-use infra to build out-of-tree kernel modules.

[--SNIP--]

Quoted 7 lines
Quoted 7 lines
package/pkg-kernel-module.mk new file +1 -0
new file mode 100644
index 0000000..608c9e6
@@ -0,0 +1,89 @@
+################################################################################
Quoted 8 lines

package/pkg-kernel-module.mk line 7

Quoted 6 lines
package/pkg-kernel-module.mk new file +6 -0
+# kernel module infrastructure for building Linux kernel modules
+#
+# This file implements an infrastructure 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 using the kernel's out-of-tree
+# buildsystem, unless they use a complex custom build-system.

buildsystem, build-system. What about consistently choosing "build system"? :-)

I think we've settled for "buildsystem" in other places, so I'll stick to that (and fix here).

Quoted 7 lines

package/pkg-kernel-module.mk line 12

Quoted 4 lines
package/pkg-kernel-module.mk new file +4 -0
+# In terms of implementation, this infrastructure relies on another package
+# infrastructure, and only 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.

# The kernel-module infrastructure requires the packages that use it to also

# include another package infrastructure. kernel-module only defines post-build

s/include/use/ because we're not 'including' pkg infras, we're not even calling them, we're evaluating them. So I'd still word that as 'use' if you don't mind. ;-)

Quoted 2 lines
# and post-install hooks. This allows the package to build both kernel modules
# and/or user-space components (with any of the other *-package infra).

Otherwise, OK, it's simpler and more explixit thn what I wrote.

Quoted 4 lines
Quoted 4 lines
package/pkg-kernel-module.mk new file +4 -0
+#
+# As such, it is to be used in conjunction with another *-package infra,
+# like so:
+#
Quoted 8 lines

package/pkg-kernel-module.mk line 22

Quoted 6 lines
package/pkg-kernel-module.mk new file +6 -0
+#   $(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

after -> *after*

OK. I guess ditto for: before -> *before* , no?

Quoted 12 lines
Quoted 12 lines
package/pkg-kernel-module.mk new file +12 -0
+# 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'.
+################################################################################
Quoted 8 lines

package/pkg-kernel-module.mk line 40

Quoted 6 lines
package/pkg-kernel-module.mk new file +6 -0
+
+################################################################################
+# inner-kernel-module -- generates the make targets needed to support building
+# a kernel module
+#
+#  argument 1 is the lowercase package name

Is there any reason to keep this, since it's not used?

Well, I wanted to keep it as much aligned to existing infras as possible, even though we're not using it.

Quoted 4 lines
Quoted 4 lines
package/pkg-kernel-module.mk new file +4 -0
+#  argument 2 is the uppercase package name
+################################################################################
+
+define inner-kernel-module
Quoted 8 lines

package/pkg-kernel-module.mk line 50

Quoted 6 lines
package/pkg-kernel-module.mk new file +6 -0
+
+# The kernel must be built first.
+$(2)_DEPENDENCIES += linux
+
+# This is only defined in some infrastructures (e.g. autotools, cmake), but
+# not in others (generic). So define it if not already defined.

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ So define it here as well.

OK.

Thanks! :-)

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  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.  |
'------------------------------^-------^------------------^--------------------'
#6 lore raw

PATCH v2 1/11 package-infra: add helper to build kernel modules

Quoted 23 lines · Yann E. MORIN

Arnout, All,

On 2015-06-12 00:44 +0200, Arnout Vandecappelle spake thusly:

Quoted 3 lines · Yann E. MORIN
Quoted 2 lines

The Linux kernel offers a nice and easy-to-use infra to build out-of-tree kernel modules.

[--SNIP--]

Quoted 7 lines
Quoted 7 lines
package/pkg-kernel-module.mk new file +1 -0
new file mode 100644
index 0000000..608c9e6
@@ -0,0 +1,89 @@
+################################################################################
Quoted 8 lines

package/pkg-kernel-module.mk line 7

Quoted 6 lines
package/pkg-kernel-module.mk new file +6 -0
+# kernel module infrastructure for building Linux kernel modules
+#
+# This file implements an infrastructure 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 using the kernel's out-of-tree
+# buildsystem, unless they use a complex custom build-system.

buildsystem, build-system. What about consistently choosing "build system"? :-)

Quoted 2 lines

I think we've settled for "buildsystem" in other places, so I'll stick to that (and fix here).

OK. I was joking about the "build system".

Quoted 9 lines
Quoted 8 lines

package/pkg-kernel-module.mk line 12

Quoted 5 lines
package/pkg-kernel-module.mk new file +4 -0
+# In terms of implementation, this infrastructure relies on another package
+# infrastructure, and only 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.

# The kernel-module infrastructure requires the packages that use it to also

# include another package infrastructure. kernel-module only defines post-build
Quoted 3 lines

s/include/use/ because we're not 'including' pkg infras, we're not even calling them, we're evaluating them. So I'd still word that as 'use' if you don't mind. ;-)

Yep that's better.

Quoted 19 lines
Quoted 3 lines
# and post-install hooks. This allows the package to build both kernel modules
# and/or user-space components (with any of the other *-package infra).

Otherwise, OK, it's simpler and more explixit thn what I wrote.

Quoted 4 lines
Quoted 4 lines
package/pkg-kernel-module.mk new file +4 -0
+#
+# As such, it is to be used in conjunction with another *-package infra,
+# like so:
+#
Quoted 8 lines

package/pkg-kernel-module.mk line 22

Quoted 6 lines
package/pkg-kernel-module.mk new file +6 -0
+#   $(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

after -> *after*

Quoted 1 line

OK. I guess ditto for: before -> *before* , no?

Yeah you're right.

Quoted 22 lines
Quoted 13 lines
Quoted 13 lines
package/pkg-kernel-module.mk new file +12 -0
+# 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'.
+################################################################################
Quoted 8 lines

package/pkg-kernel-module.mk line 40

Quoted 6 lines
package/pkg-kernel-module.mk new file +6 -0
+
+################################################################################
+# inner-kernel-module -- generates the make targets needed to support building
+# a kernel module
+#
+#  argument 1 is the lowercase package name

Is there any reason to keep this, since it's not used?

Quoted 2 lines

Well, I wanted to keep it as much aligned to existing infras as possible, even though we're not using it.

Yeah, but you did remove the rest of the usual arguments... Anyway, I'm OK with
keeping the first argument if you want.

Regards,
Arnout

Quoted 21 lines
Quoted 13 lines

package/pkg-kernel-module.mk line 50

Quoted 11 lines
package/pkg-kernel-module.mk new file +10 -0
+#  argument 2 is the uppercase package name
+################################################################################
+
+define inner-kernel-module
+
+# The kernel must be built first.
+$(2)_DEPENDENCIES += linux
+
+# This is only defined in some infrastructures (e.g. autotools, cmake), but
+# not in others (generic). So define it if not already defined.

^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ So define it here as well.

OK.

Thanks! :-)

Regards,
Yann E. MORIN.

Signature · 6 lines
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
#7 lore raw

PATCH v2 2/11 docs/manual: add kernel-module

In reply to Yann E. MORIN
Cc Thomas Petazzoni <[email protected]>
Cc Samuel Martin <[email protected]>
Cc Arnout Vandecappelle <[email protected]>

---
Changes v1 -> v2:
- some rephrasing and refactoring (Arnout)

---
 docs/manual/adding-packages-kernel-module.txt | 129 ++++++++++++++++++++++++++
 docs/manual/adding-packages.txt               |   2 +
 2 files changed, 131 insertions(+)
 create mode 100644 docs/manual/adding-packages-kernel-module.txt
docs/manual/adding-packages-kernel-module.txt new file +129 -0
new file mode 100644
index 0000000..39927b2
@@ -0,0 +1,129 @@
+// -*- mode:doc; -*-
+// vim: set syntax=asciidoc:
+
+=== Infrastructure for packages building kernel modules
+
+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.
+
+[[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: FOO_LICENSE = GPLv2
+11: FOO_LICENSE_FILES = COPYING
+12: 
+13: $(eval $(kernel-module))
+14: $(eval $(generic-package))
+----
+
+Lines 7-11 define the usual meta-data to specify the version, archive name,
+remote URI where to find the package source, licensing information.
+
+On line 13, we invoke the +kernel-module+ helper infrastructure, that
+generates all the appropriate Makefile rules and variables to build
+that kernel module.
+
+Finally, on line 14, 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
+infrastructures 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_LICENSE = GPLv2
+11: FOO_LICENSE_FILES = COPYING
+12: 
+13: FOO_MODULE_SUBDIRS = driver/base
+14: FOO_MODULE_MAKE_OPTS = KVERSION=$(LINUX_VERSION_PROBED)
+15: 
+16: ifeq ($(BR2_PACKAGE_LIBBAR),y)
+17: FOO_DEPENDENCIES = libbar
+18: FOO_CONF_OPTS = --enable-bar
+19: FOO_MODULE_SUBDIRS += driver/bar
+20: else
+21: FOO_CONF_OPTS = --disable-bar
+22: endif
+23: 
+24: $(eval $(kernel-module))
+26: $(eval $(autotools-package))
+----
+
+Here, we see that we have an autotools-based package, that also builds
+the kernel module located in sub-directory +driver/base+ and, if libbar
+is enabled, the kernel module located in sub-directory +driver/bar+, and
+defines the variable +KVERSION+ to be passed to the Linux buildsystem
+when building the module(s).
+
+
+[[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+ macros 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.
+
+The following additional variables can optionally be defined 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.
docs/manual/adding-packages.txt +2 -0
index b8674f8..721fe39 100644
@@ -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[]
Signature · 1 line
1.9.1
#8 lore raw

PATCH v2 2/11 docs/manual: add kernel-module

Hey, thx interesting work, a slight comment below....

Quoted 13 lines
docs/manual/adding-packages-kernel-module.txt new file +5 -0
+
+Let's look at a more complex example:
+
+----
+01:

################################################################################
+02: #
+03: # foo
+04: #
+05:
################################################################################
+06:
+07: FOO_VERSION = 1.2.3

Quoted 8 lines

+08: FOO_SOURCE = foo-$(FOO_VERSION).tar.xz
+09: FOO_SITE = http://www.foosoftware.org/download
+10: FOO_LICENSE = GPLv2
+11: FOO_LICENSE_FILES = COPYING
+12:
+13: FOO_MODULE_SUBDIRS = driver/base
+14: FOO_MODULE_MAKE_OPTS = KVERSION=$(LINUX_VERSION_PROBED) +15:

^ This variable is not documented anywhere, you might want to do that...

Regards

Jeremy

#9 lore raw

PATCH v2 2/11 docs/manual: add kernel-module

Jeremy, All,

On 2015-06-11 09:32 +0200, Jeremy Rosen spake thusly:

Quoted 13 lines
Quoted 13 lines
docs/manual/adding-packages-kernel-module.txt new file +4 -0
+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

Quoted 8 lines
Quoted 6 lines

+09: FOO_SITE = http://www.foosoftware.org/download
+10: FOO_LICENSE = GPLv2
+11: FOO_LICENSE_FILES = COPYING
+12:
+13: FOO_MODULE_SUBDIRS = driver/base
+14: FOO_MODULE_MAKE_OPTS = KVERSION=$(LINUX_VERSION_PROBED)

^ This variable is not documented anywhere, you might want to do that...

Yup, thanks.

What about:

    http://git.buildroot.org/~ymorin/git/buildroot/commit/?h=yem/kernel-modules&id=663ab1ec1c3e5b80eae0bdb355bc0e2e0d58497c

(toward the end).

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  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.  |
'------------------------------^-------^------------------^--------------------'
#10 lore raw

PATCH v2 2/11 docs/manual: add kernel-module

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

+13: FOO_MODULE_SUBDIRS = driver/base
+14: FOO_MODULE_MAKE_OPTS = KVERSION=$(LINUX_VERSION_PROBED)

^ This variable is not documented anywhere, you might want to do that...

Quoted 7 lines

Yup, thanks.

What about:

    http://git.buildroot.org/~ymorin/git/buildroot/commit/?h=yem/kernel-modules&id=663ab1ec1c3e5b80eae0bdb355bc0e2e0d58497c

(toward the end).

Awesome, sounds good to me

Quoted 15 lines

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.  |

'------------------------------^-------^------------------^--------------------'

#11 lore raw

PATCH v2 3/11 package/lttng-modules: use kernel-module helper

In reply to Yann E. MORIN
---
 package/lttng-modules/lttng-modules.mk | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
package/lttng-modules/lttng-modules.mk +1 -10
index 6833ad2..30c581e 100644
@@ -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))
Signature · 1 line
1.9.1
#12 lore raw

PATCH v2 3/11 package/lttng-modules: use kernel-module helper

Quoted 1 line · Yann E. MORIN

Regards,
Arnout

Quoted 25 lines
---
 package/lttng-modules/lttng-modules.mk | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
package/lttng-modules/lttng-modules.mk +1 -10
index 6833ad2..30c581e 100644
@@ -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))
Signature · 6 lines
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
#13 lore raw

PATCH v2 4/11 package/igh-ethercat: use kernel-module helper

In reply to Yann E. MORIN
---
 package/igh-ethercat/igh-ethercat.mk | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)
package/igh-ethercat/igh-ethercat.mk +1 -13
index b5221f8..32c49a3 100644
@@ -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))
Signature · 1 line
1.9.1
#14 lore raw

PATCH v2 4/11 package/igh-ethercat: use kernel-module helper

Quoted 1 line · Yann E. MORIN

Perhaps it would be better for changes like this to mention in the commit
message what the Makefile does. If there is a commit message like this, I trust the patch a whole lot more:

igh-ethercat's Makefile has these rules, so our kernel-module helper does exactly the same:

modules:

        $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(@D)" modules

modules_install:

        $(MAKE) -C "$(LINUX_SOURCE_DIR)" M="$(@D)" \
                INSTALL_MOD_DIR="$(INSTALL_MOD_DIR)" modules_install

(for convenience I replaced the full path with $(@D)).

Regards,
Arnout

Quoted 35 lines
---
 package/igh-ethercat/igh-ethercat.mk | 14 +-------------
 1 file changed, 1 insertion(+), 13 deletions(-)
package/igh-ethercat/igh-ethercat.mk +1 -13
index b5221f8..32c49a3 100644
@@ -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))
Signature · 6 lines
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
#15 lore raw

PATCH v2 5/11 package/ktap: use kernel-module helper

In reply to Yann E. MORIN

Passing the KERNEL_SRC variable is no longer needed, since it was only used to run commands like:

    $(MAKE) -C $(KERNEL_SRC) M=$(PWD) modules

which is basically what the new kernel-module infra is now doing.

Cc Thomas Petazzoni <[email protected]>

---
Changes v1 -> v2;
- explain why we get rid of a variable (Thomas)

---
 package/ktap/ktap.mk | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
package/ktap/ktap.mk +3 -4
index 4a0e51c..966b51c 100644
@@ -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))
Signature · 1 line
1.9.1
#16 lore raw

PATCH v2 5/11 package/ktap: use kernel-module helper

Quoted 8 lines · Yann E. MORIN

Passing the KERNEL_SRC variable is no longer needed, since it was only used to run commands like:

    $(MAKE) -C $(KERNEL_SRC) M=$(PWD) modules

which is basically what the new kernel-module infra is now doing.

Cc Thomas Petazzoni <[email protected]>

Regards,
Arnout

Quoted 38 lines

---
Changes v1 -> v2;
- explain why we get rid of a variable (Thomas)

---
 package/ktap/ktap.mk | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
package/ktap/ktap.mk +3 -4
index 4a0e51c..966b51c 100644
@@ -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))
Signature · 6 lines
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
#17 lore raw

PATCH v2 6/11 package/cryptodev-linux: use the kernel-module helper

In reply to Yann E. MORIN
[Doug: add pre-build hook to build version.h]

---
Cyhanges v1 -> v2:
- fix missing version.h (Doug)

---
 package/cryptodev-linux/cryptodev-linux.mk | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
package/cryptodev-linux/cryptodev-linux.mk +7 -7
index 6f41930..6eec602 100644
@@ -6,23 +6,23 @@
 
 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
+CRYPTODEV_LINUX_PRE_BUILD_HOOKS += CRYPTODEV_LINUX_VERSION_H
 
-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))
Signature · 1 line
1.9.1
#18 lore raw

PATCH v2 6/11 package/cryptodev-linux: use the kernel-module helper

Quoted 2 lines · Yann E. MORIN
[Doug: add pre-build hook to build version.h]

The version.h thing deserves a slightly more explicit commit message, like:

The cryptodev-linux Makefile defines the following:

build: version.h

        make ${KERNEL_MAKE_OPTS} modules

modules_install:

        make -C $(KERNEL_DIR) SUBDIRS=`pwd` modules_install
        @echo "Installing cryptodev.h in $(PREFIX)/usr/include/crypto ..."
        @install -D crypto/cryptodev.h $(PREFIX)/usr/include/crypto/cryptodev.h

So when we use the kernel-module infrastructure, we have to explicitly handle version.h and cryptodev.h. cryptodev.h was already handled specifically because it goes to STAGING_DIR. For version.h, we add a pre-build hook.

That said, SUBDIRS= does not behave exactly the same as M=, but I don't know
what the difference is. So that part should probably be mentioned explicitly in the commit message as well.

Quoted 1 line

[snip]

package/cryptodev-linux/cryptodev-linux.mk line 20

Quoted 7 lines
package/cryptodev-linux/cryptodev-linux.mk +3 -4
-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)

PREFIX is only used for installing cryptodev.h, which is now no longer done. So
we don't need to define it, right? Same for KERNEL_DIR, it's only used by the rules we no longer use.

If you remove these, it should of course also be mentioned explicitly in the
commit message.

Regards,
Arnout

Quoted 9 lines

define CRYPTODEV_LINUX_INSTALL_STAGING_CMDS

package/cryptodev-linux/cryptodev-linux.mk +1 -0
 	$(INSTALL) -D -m 644 $(@D)/crypto/cryptodev.h \
 		$(STAGING_DIR)/usr/include/crypto/cryptodev.h
 endef
 
+$(eval $(kernel-module))
 $(eval $(generic-package))
Signature · 6 lines
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
#19 lore raw

PATCH v2 6/11 package/cryptodev-linux: use the kernel-module helper

Arnout, All,

On 2015-06-12 01:02 +0200, Arnout Vandecappelle spake thusly:

Quoted 8 lines · Yann E. MORIN
Quoted 2 lines
[Doug: add pre-build hook to build version.h]

The version.h thing deserves a slightly more explicit commit message, like:

The cryptodev-linux Makefile defines the following:

Quoted 7 lines

build: version.h

        make ${KERNEL_MAKE_OPTS} modules

modules_install:

        make -C $(KERNEL_DIR) SUBDIRS=`pwd` modules_install
        @echo "Installing cryptodev.h in $(PREFIX)/usr/include/crypto ..."
        @install -D crypto/cryptodev.h $(PREFIX)/usr/include/crypto/cryptodev.h

I'm not too fond of quoting that much, so I trimmed it down to what I believe is the strict minimum for udnerstanding the change, no more.

If you still think that is not enough, you'll have the opportunity to say so when I respin. OK? ;-)

Quoted 8 lines

So when we use the kernel-module infrastructure, we have to explicitly handle version.h and cryptodev.h. cryptodev.h was already handled specifically because it goes to STAGING_DIR. For version.h, we add a pre-build hook.

That said, SUBDIRS= does not behave exactly the same as M=, but I don't know
what the difference is. So that part should probably be mentioned explicitly in the commit message as well.

From my understanding, the end result is the same, but using SUBDIRS makes the Linux buildsystem it is building in in-tree module, while M tells it it is building an out-of-tree module.

Quoted 15 lines
Quoted 1 line

[snip]

package/cryptodev-linux/cryptodev-linux.mk line 20

Quoted 7 lines
package/cryptodev-linux/cryptodev-linux.mk +3 -4
-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)

PREFIX is only used for installing cryptodev.h, which is now no longer done. So
we don't need to define it, right? Same for KERNEL_DIR, it's only used by the rules we no longer use.

Quoted 2 lines

If you remove these, it should of course also be mentioned explicitly in the
commit message.

Right, I've dropped both and explained in the commit log.

Thanks! :-)

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  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.  |
'------------------------------^-------^------------------^--------------------'
#20 lore raw

PATCH v2 7/11 package/ocf-linux: use kernel-module helper

In reply to Yann E. MORIN

Remove our patch since it is no longer needed.

---
Changs v1 -> v2:
- fix spelling of the SUBDIRS variable

---
 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
package/ocf-linux/0001-modules-cross.patch deleted +0 -42
deleted file mode 100644
index f80ef06..0000000
@@ -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 <[email protected]>
-
-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
package/ocf-linux/ocf-linux.mk +7 -10
index 8ca5578..35968d5 100644
@@ -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_SUBDIRS = 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))
Signature · 1 line
1.9.1
#21 lore raw

PATCH v2 8/11 package/on2-8170-modules: use kernel-module helper

In reply to Yann E. MORIN
---
 package/on2-8170-modules/on2-8170-modules.mk | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
package/on2-8170-modules/on2-8170-modules.mk +1 -10
index 209bcb5..b40ed86 100644
@@ -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))
Signature · 1 line
1.9.1
#22 lore raw

PATCH v2 8/11 package/on2-8170-modules: use kernel-module helper

Quoted 1 line · Yann E. MORIN

Regards,
Arnout

Quoted 28 lines
---
 package/on2-8170-modules/on2-8170-modules.mk | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)
package/on2-8170-modules/on2-8170-modules.mk +1 -10
index 209bcb5..b40ed86 100644
@@ -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))
Signature · 6 lines
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
#23 lore raw

PATCH v2 9/11 package/owl-linux: use kernel-module helper

In reply to Yann E. MORIN

Git rid of first patch, no longer needed; rename remaining patch.

---
Changes v1 -> v2:
- override $(PWD)

---
 .../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                           | 15 ++++++---------
 3 files changed, 6 insertions(+), 25 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%)
package/owl-linux/0001-fix-CROSS_COMPILE-usage-in-Makefile.patch deleted +0 -16
deleted file mode 100644
index 14b4631..0000000
@@ -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 <[email protected]>
-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
package/owl-linux/0001-fix-for-linux-3.3.x.patch renamed from package/owl-linux/0002-fix-for-linux-3.3.x.patch +0 -0
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
package/owl-linux/owl-linux.mk +6 -9
index 371cc02..844b11e 100644
@@ -10,14 +10,11 @@ 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
+# owl-linux wants to use $(PWD) to find its includes, however $(PWD) is not
+# the top of the package's source tree, but the top of Buildroot source tree
+# $(TOPDIR)  (i.e. the place where make is run from).
+# So, override PWD to the proper value.
+OWL_LINUX_MODULE_MAKE_OPTS = PWD=$(@D)
 
+$(eval $(kernel-module))
 $(eval $(generic-package))
Signature · 1 line
1.9.1
#24 lore raw

PATCH v2 9/11 package/owl-linux: use kernel-module helper

Quoted 4 lines · Yann E. MORIN

Git rid of first patch, no longer needed; rename remaining patch.

[snip]

Quoted 9 lines
package/owl-linux/owl-linux.mk +0 -1
index 371cc02..844b11e 100644
@@ -10,14 +10,11 @@ OWL_LINUX_LICENSE = PROPRIETARY
 OWL_LINUX_LICENSE_FILES = LICENSE
 OWL_LINUX_REDISTRIBUTE = NO
 
-OWL_LINUX_DEPENDENCIES = linux

package/owl-linux/owl-linux.mk OWL_LINUX_LICENSE = PROPRIETARY · line 14

Quoted 10 lines
package/owl-linux/owl-linux.mk +2 -8
-
-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
+# owl-linux wants to use $(PWD) to find its includes, however $(PWD) is not
+# the top of the package's source tree, but the top of Buildroot source tree

Unless I'm very much mistaken, PWD will be $(LINUX_DIR) when the Makefile is
included.

With that small thing fixed:

Regards,
Arnout

Quoted 7 lines
package/owl-linux/owl-linux.mk +4 -0
+# $(TOPDIR)  (i.e. the place where make is run from).
+# So, override PWD to the proper value.
+OWL_LINUX_MODULE_MAKE_OPTS = PWD=$(@D)
 
+$(eval $(kernel-module))
 $(eval $(generic-package))
Signature · 6 lines
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
#25 lore raw

PATCH v2 9/11 package/owl-linux: use kernel-module helper

Arnout, All,

On 2015-06-12 01:13 +0200, Arnout Vandecappelle spake thusly:

Quoted 2 lines · Yann E. MORIN
Quoted 1 line

Git rid of first patch, no longer needed; rename remaining patch.

s/Git/Get/ Damn... :-]

Quoted 11 lines
Quoted 2 lines

[snip]

Quoted 8 lines
package/owl-linux/owl-linux.mk +0 -0
index 371cc02..844b11e 100644
@@ -10,14 +10,11 @@ OWL_LINUX_LICENSE = PROPRIETARY
 OWL_LINUX_LICENSE_FILES = LICENSE
 OWL_LINUX_REDISTRIBUTE = NO
 
Quoted 14 lines

package/owl-linux/owl-linux.mk OWL_LINUX_LICENSE = PROPRIETARY · line 14

Quoted 11 lines
package/owl-linux/owl-linux.mk +2 -9
-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
+# owl-linux wants to use $(PWD) to find its includes, however $(PWD) is not
+# the top of the package's source tree, but the top of Buildroot source tree

Unless I'm very much mistaken, PWD will be $(LINUX_DIR) when the Makefile is
included.

I think you are very much mistaken, indeed! ;-)

What happens is that all commands we run are run from Buildroot's $(TOPDIR). So $(PWD) is set to that location.

So, this command, which we run from our Makefile:

    make -C $(LINUX_DIR) M=$(@D) foo-bar

would get its $(PWD) make-variable set from whatever value it had in the shell that called make, which happens to itself be called by Buildroot's Makefile, which runs from $(TOPDIR), always (even for out-of-tree builds).

Then, the Linux buildsystem does *not* chdir() when it builds modules, it just includes $(M)/Kbuild (or if it does not exist, $(M)/Makefile ), so $(PWD) as used in those will still be Buildroot's $(TOPDIR).

Quoted 3 lines

With that small thing fixed:

Still valid with that small thing *not* fixed? ;-)

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  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.  |
'------------------------------^-------^------------------^--------------------'
#26 lore raw

PATCH v2 9/11 package/owl-linux: use kernel-module helper

Quoted 39 lines · Yann E. MORIN

Arnout, All,

On 2015-06-12 01:13 +0200, Arnout Vandecappelle spake thusly:

Quoted 2 lines · Yann E. MORIN
Quoted 1 line

Git rid of first patch, no longer needed; rename remaining patch.

s/Git/Get/ Damn... :-]

Quoted 11 lines
Quoted 2 lines

[snip]

Quoted 8 lines
package/owl-linux/owl-linux.mk +0 -0
index 371cc02..844b11e 100644
@@ -10,14 +10,11 @@ OWL_LINUX_LICENSE = PROPRIETARY
 OWL_LINUX_LICENSE_FILES = LICENSE
 OWL_LINUX_REDISTRIBUTE = NO
 
Quoted 14 lines

package/owl-linux/owl-linux.mk OWL_LINUX_LICENSE = PROPRIETARY · line 14

Quoted 11 lines
package/owl-linux/owl-linux.mk +2 -9
-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
+# owl-linux wants to use $(PWD) to find its includes, however $(PWD) is not
+# the top of the package's source tree, but the top of Buildroot source tree

Unless I'm very much mistaken, PWD will be $(LINUX_DIR) when the Makefile is
included.

I think you are very much mistaken, indeed! ;-)

What happens is that all commands we run are run from Buildroot's $(TOPDIR). So $(PWD) is set to that location.

Quoted 7 lines

So, this command, which we run from our Makefile:

    make -C $(LINUX_DIR) M=$(@D) foo-bar

would get its $(PWD) make-variable set from whatever value it had in the shell that called make, which happens to itself be called by Buildroot's Makefile, which runs from $(TOPDIR), always (even for out-of-tree builds).

Oh yes indeed, I missed the fact that the PWD := $(shell pwd) is only included
when it's *not* the kbuild call...

Crazy Makefile...

Quoted 10 lines

Then, the Linux buildsystem does *not* chdir() when it builds modules, it just includes $(M)/Kbuild (or if it does not exist, $(M)/Makefile ), so $(PWD) as used in those will still be Buildroot's $(TOPDIR).

Quoted 3 lines

With that small thing fixed:

Still valid with that small thing *not* fixed? ;-)

Yep!

Regards,
Arnout

Quoted 4 lines

Regards,
Yann E. MORIN.

Signature · 6 lines
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
#27 lore raw

PATCH v2 10/11 package/simicsfs: use kernel-module helper

In reply to Yann E. MORIN
---
 package/simicsfs/simicsfs.mk | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
package/simicsfs/simicsfs.mk +1 -9
index 51987c5..91ed413 100644
@@ -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))
Signature · 1 line
1.9.1
#28 lore raw

PATCH v2 10/11 package/simicsfs: use kernel-module helper

Quoted 1 line · Yann E. MORIN

Regards,
Arnout

Quoted 25 lines
---
 package/simicsfs/simicsfs.mk | 10 +---------
 1 file changed, 1 insertion(+), 9 deletions(-)
package/simicsfs/simicsfs.mk +1 -9
index 51987c5..91ed413 100644
@@ -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))
Signature · 6 lines
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
#29 lore raw

PATCH v2 11/11 package/sysdig: use kernel-module helper

In reply to Yann E. MORIN

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
Cc Thomas Petazzoni <[email protected]>
---
 package/sysdig/sysdig.mk | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)
package/sysdig/sysdig.mk +18 -4
index fb348ff..fde1810 100644
@@ -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))
Signature · 1 line
1.9.1
#30 lore raw

v2 cover pkg-kernel-module: new infra to ease building kernel modules (branch yem/kernel-modules)

In reply to Yann E. MORIN

Hello All,

On 2015-06-10 21:22 +0200, Yann E. MORIN spake thusly:

Quoted 2 lines

This series introduces a new infrastructure to help writing packages that build kernel modules.

I'll mark this series as "Changes Requested" in patchwork, because I took Jeremy's comment into account, and because I was able to improve it yet a bit more and convert one more kernel-module-providing package (namely, nvidia-driver; who would have thought it would be possible? ;-) ).

So, I'll respin later, but I'm still interested in reviews on this iteration.

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  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.  |
'------------------------------^-------^------------------^--------------------'
#31 lore raw

v2 cover pkg-kernel-module: new infra to ease building kernel modules (branch yem/kernel-modules)

Quoted 10 lines · Yann E. MORIN

Hello All,

On 2015-06-10 21:22 +0200, Yann E. MORIN spake thusly:

Quoted 2 lines

This series introduces a new infrastructure to help writing packages that build kernel modules.

I'll mark this series as "Changes Requested" in patchwork, because I took Jeremy's comment into account, and because I was able to improve it yet a bit more and convert one more kernel-module-providing package (namely, nvidia-driver; who would have thought it would be possible? ;-) ).

Early feedback on that one:

NVIDIA_DRIVER_HEADERS_H -> NVIDIA_DRIVER_MODULE_BUILD_HEADERS

Commit message should explain why the custom install isn't needed anymore either.

Regards,
Arnout

Quoted 7 lines

So, I'll respin later, but I'm still interested in reviews on this iteration.

Regards,
Yann E. MORIN.

Signature · 6 lines
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
#32 lore raw

v2 cover pkg-kernel-module: new infra to ease building kernel modules (branch yem/kernel-modules)

Arnout, All,

On 2015-06-12 01:18 +0200, Arnout Vandecappelle spake thusly:

Quoted 7 lines · Yann E. MORIN
Quoted 6 lines

Hello All,

On 2015-06-10 21:22 +0200, Yann E. MORIN spake thusly:

Quoted 2 lines

This series introduces a new infrastructure to help writing packages that build kernel modules.

Quoted 8 lines
Quoted 4 lines

I'll mark this series as "Changes Requested" in patchwork, because I took Jeremy's comment into account, and because I was able to improve it yet a bit more and convert one more kernel-module-providing package (namely, nvidia-driver; who would have thought it would be possible? ;-) ).

Early feedback on that one:

NVIDIA_DRIVER_HEADERS_H -> NVIDIA_DRIVER_MODULE_BUILD_HEADERS

OK.

Quoted 1 line

Commit message should explain why the custom install isn't needed anymore either.

OK.

Thanks! :-)

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  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.  |
'------------------------------^-------^------------------^--------------------'