pkg-kernel-module: new infra to ease building kernel modules (branch yem/kernel-modules)
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.
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.mkSignature · 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. | '------------------------------^-------^------------------^--------------------'
PATCH 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 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.
--- package/Makefile.in | 1 + package/pkg-kernel-module.mk | 94 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 package/pkg-kernel-module.mk
package/Makefile.in +1 -0
@@ -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 +94 -0
94 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH 1/11 package-infra: add helper to build kernel modules
Hi Yann,
package/pkg-kernel-module.mk line 46
Quoted 9 lines · Yann E. MORIN
package/pkg-kernel-module.mk new file +9
-0+################################################################################ +# 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.
Quoted 1 line
+# argument 4 is the type (always 'target')
And here only target is allowed.
baruch
Signature · 3 lines
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 -PATCH 1/11 package-infra: add helper to build kernel modules
Baruch, All,
On 2015-06-07 06:22 +0300, Baruch Siach spake thusly:
Quoted 5 lines · Yann E. MORIN
Quoted 4 lines
package/pkg-kernel-module.mk new file +4
-0+################################################################################ +# inner-kernel-module -- generates the make targets needed to support building +# a kernel module +#
Quoted 8 lines
package/pkg-kernel-module.mk line 46
Quoted 5 lines
package/pkg-kernel-module.mk new file +5
-0+# 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 packagesWhat 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.
Quoted 2 lines
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).
Quoted 3 lines
Quoted 1 line
+# 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.
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. | '------------------------------^-------^------------------^--------------------'
PATCH 1/11 package-infra: add helper to build kernel modules
In reply to Yann E. MORINQuoted 9 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 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.
Quoted 8 lines
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" <[email protected]>Cc Thomas Petazzoni <[email protected]>
Quoted 122 lines
--- package/Makefile.in | 1 + package/pkg-kernel-module.mk | 94 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 package/pkg-kernel-module.mkpackage/Makefile.in +1
-0@@ -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.mkpackage/pkg-kernel-module.mk new file +94
-0@@ -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)Signature · 6 lines
1.9.1 _______________________________________________ buildroot mailing list buildroot at busybox.net http://lists.busybox.net/mailman/listinfo/buildroot
PATCH 1/11 package-infra: add helper to build kernel modules
In reply to Yann E. MORINQuoted 5 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 dupliacte (or rewrite) the same code over-and-over again.
duplicate
Quoted 5 lines
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
Quoted 18 lines
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" <[email protected]>Cc Thomas Petazzoni <[email protected]>--- package/Makefile.in | 1 + package/pkg-kernel-module.mk | 94 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 package/pkg-kernel-module.mkpackage/Makefile.in +0
-0
package/Makefile.in include package/pkg-virtual.mk · line 401
Quoted 4 lines
package/Makefile.in +1
-0@@ -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.
package/pkg-kernel-module.mk line 4
Quoted 10 lines
package/pkg-kernel-module.mk new file +4
-0@@ -0,0 +1,94 @@ +################################################################################ +# kernel module infrastructure for building Linux kernel modules +# +# This file implements an frastructure that eases development of package .mk
infrastructure
package/pkg-kernel-module.mk line 6
Quoted 2 lines
package/pkg-kernel-module.mk new file +2
-0+# 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.
package/pkg-kernel-module.mk line 10
Quoted 4 lines
package/pkg-kernel-module.mk new file +4
-0+# +# 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.
Quoted 12 lines
package/pkg-kernel-module.mk new file +12
-0+# +# 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
package/pkg-kernel-module.mk line 32
Quoted 10 lines
package/pkg-kernel-module.mk new file +10
-0+# 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.
Quoted 5 lines
package/pkg-kernel-module.mk new file +5
-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'. +################################################################################ +
package/pkg-kernel-module.mk line 47
Quoted 10 lines
package/pkg-kernel-module.mk new file +10
-0+################################################################################ +# 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...
package/pkg-kernel-module.mk line 58
Quoted 11 lines
package/pkg-kernel-module.mk new file +11
-0+################################################################################ + +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?
package/pkg-kernel-module.mk line 67
Quoted 9 lines
package/pkg-kernel-module.mk new file +9
-0+ +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.
package/pkg-kernel-module.mk line 68
Quoted 1 line
package/pkg-kernel-module.mk new file +1
-0+ $$($$(PKG)_MAKE) -C $$(LINUX_DIR) \
Missing $(LINUX_MAKE_ENV) (or at least TARGET_MAKE_ENV, but I thinkLINUX_MAKE_ENV is more appropriate even if it just adds BR_BINARIES_DIR).
package/pkg-kernel-module.mk line 71
Quoted 3 lines
package/pkg-kernel-module.mk new file +3
-0+ $$(LINUX_MAKE_FLAGS) \ + $$($(2)_MODULE_MAKE_OPTS) \ + M=$$($(2)_DIR)/$$(d) \
We usually use $(@D) instead of $(2)_DIR.
Quoted 13 lines
package/pkg-kernel-module.mk new file +13
-0+ 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))
package/pkg-kernel-module.mk line 94
Quoted 10 lines
package/pkg-kernel-module.mk new file +10
-0+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
Quoted 1 line
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
PATCH 1/11 package-infra: add helper to build kernel modules
Arnout, All,
On 2015-06-08 23:09 +0200, Arnout Vandecappelle spake thusly:
Quoted 10 lines · Yann E. MORIN
Quoted 5 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 dupliacte (or rewrite) the same code over-and-over again.
duplicate
Quoted 1 line
Quoted 6 lines
Quoted 4 lines
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.
Quoted 13 lines
Quoted 13 lines
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" <[email protected]>Cc Thomas Petazzoni <[email protected]>--- package/Makefile.in | 1 + package/pkg-kernel-module.mk | 94 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 package/pkg-kernel-module.mk
Quoted 12 lines
package/Makefile.in include package/pkg-virtual.mk · line 401
Quoted 9 lines
package/Makefile.in +1
-0@@ -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.mkI 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...
Quoted 4 lines
Quoted 4 lines
package/pkg-kernel-module.mk new file +0
-1--- /dev/null
Quoted 8 lines
package/pkg-kernel-module.mk line 4
Quoted 6 lines
+++
b/package/pkg-kernel-module.mkpackage/pkg-kernel-module.mk new file +4
-0@@ -0,0 +1,94 @@ +################################################################################ +# kernel module infrastructure for building Linux kernel modules +# +# This file implements an frastructure that eases development of package .mkinfrastructure
Yup.
Quoted 5 lines
package/pkg-kernel-module.mk line 6
Quoted 2 lines
package/pkg-kernel-module.mk new file +2
-0+# 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.
Quoted 6 lines
package/pkg-kernel-module.mk line 10
Quoted 4 lines
package/pkg-kernel-module.mk new file +4
-0+# +# 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.
Quoted 34 lines
Quoted 12 lines
package/pkg-kernel-module.mk new file +12
-0+# +# 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 theypackage/pkg-kernel-module.mk line 32
Quoted 10 lines
package/pkg-kernel-module.mk new file +10
-0+# 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.
Quoted 9 lines
package/pkg-kernel-module.mk new file +9
-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 +#
Quoted 8 lines
package/pkg-kernel-module.mk line 47
Quoted 6 lines
package/pkg-kernel-module.mk new file +6
-0+# 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
Quoted 7 lines
Quoted 7 lines
package/pkg-kernel-module.mk new file +7
-0+################################################################################ + +define inner-kernel-module + +# The kernel must be built first. +$(2)_DEPENDENCIES += linux +
Quoted 8 lines
package/pkg-kernel-module.mk line 58
Quoted 4 lines
package/pkg-kernel-module.mk new file +4
-0+# Duplicate that from pkg-generic because we need it now +ifndef $(2)_MAKE + $(2)_MAKE = $(MAKE) +endifI 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.
Quoted 11 lines
package/pkg-kernel-module.mk line 67
Quoted 8 lines
package/pkg-kernel-module.mk new file +8
-0+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...
Quoted 11 lines
package/pkg-kernel-module.mk line 67
Quoted 1 line
package/pkg-kernel-module.mk new file +1
-0+ $$($$(PKG)_MAKE) -C $$(LINUX_DIR) \Missing $(LINUX_MAKE_ENV) (or at least
TARGET_MAKE_ENV, but I thinkLINUX_MAKE_ENVis more appropriate even if it just addsBR_BINARIES_DIR).package/pkg-kernel-module.mk line 71
Quoted 3 lines
package/pkg-kernel-module.mk new file +3
-0+ $$(LINUX_MAKE_FLAGS) \ + $$($(2)_MODULE_MAKE_OPTS) \ + M=$$($(2)_DIR)/$$(d) \We usually use $(@D) instead of $(2)_DIR.
Ack.
Quoted 26 lines
Quoted 13 lines
package/pkg-kernel-module.mk new file +13
-0+ 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))package/pkg-kernel-module.mk line 94
Quoted 10 lines
package/pkg-kernel-module.mk new file +10
-0+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
Quoted 1 line
kernel-module = $(call inner-kernel-module,$(call UPPERCASE,$(pkgname)))
Yup, already done. ;-)
Thanks! :-)
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. | '------------------------------^-------^------------------^--------------------'
PATCH 1/11 package-infra: add helper to build kernel modules
Dear Yann E. MORIN,
Quoted 9 lines · Yann E. MORIN
Quoted 7 lines
package/pkg-kernel-module.mk line 67
Quoted 4 lines
package/pkg-kernel-module.mk new file +4
-0+# 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
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 1/11 package-infra: add helper to build kernel modules
Thomas, All,
On 2015-06-08 23:33 +0200, Thomas Petazzoni spake thusly:
Quoted 9 lines · Yann E. MORIN
Quoted 8 lines
Quoted 7 lines
package/pkg-kernel-module.mk line 67
Quoted 4 lines
package/pkg-kernel-module.mk new file +4
-0+# 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.
Quoted 6 lines
Quoted 1 line
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.
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. | '------------------------------^-------^------------------^--------------------'
PATCH 1/11 package-infra: add helper to build kernel modules
In reply to Arnout VandecappelleArnout, All,
On 2015-06-08 23:09 +0200, Arnout Vandecappelle spake thusly:
Quoted 1 line · Yann E. MORIN
[--SNIP--]
Quoted 8 lines
package/pkg-kernel-module.mk line 58
Quoted 4 lines
package/pkg-kernel-module.mk new file +4
-0+# Duplicate that from pkg-generic because we need it now +ifndef $(2)_MAKE + $(2)_MAKE = $(MAKE) +endifI 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):
Quoted 1 line
Quoted 1 line
Quoted 1 line
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.
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. | '------------------------------^-------^------------------^--------------------'
PATCH 1/11 package-infra: add helper to build kernel modules
Quoted 14 lines · Yann E. MORIN
Arnout, All,
On 2015-06-08 23:09 +0200, Arnout Vandecappelle spake thusly:
Quoted 1 line · Yann E. MORIN
[--SNIP--]
Quoted 8 lines
package/pkg-kernel-module.mk line 58
Quoted 4 lines
package/pkg-kernel-module.mk new file +4
-0+# Duplicate that from pkg-generic because we need it now +ifndef $(2)_MAKE + $(2)_MAKE = $(MAKE) +endifI 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?
Quoted 1 line
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
Quoted 14 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
cryptodev-linux 1.7 Building kernel module(s)
C
/home/ymorin/dev/buildroot/O/build/linux-4.0.4HOSTCC="/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.
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
PATCH 1/11 package-infra: add helper to build kernel modules
Arnout, All,
On 2015-06-08 23:52 +0200, Arnout Vandecappelle spake thusly:
Quoted 12 lines · Yann E. MORIN
Quoted 11 lines
On 2015-06-08 23:09 +0200, Arnout Vandecappelle spake thusly:
Quoted 9 lines · Yann E. MORIN
package/pkg-kernel-module.mk line 58
Quoted 4 lines
package/pkg-kernel-module.mk new file +4
-0+# Duplicate that from pkg-generic because we need it now +ifndef $(2)_MAKE + $(2)_MAKE = $(MAKE) +endifI 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?
Quoted 5 lines
Quoted 1 line
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.
Quoted 3 lines
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.
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. | '------------------------------^-------^------------------^--------------------'
PATCH 1/11 package-infra: add helper to build kernel modules
Quoted 23 lines · Yann E. MORIN
Arnout, All,
On 2015-06-08 23:52 +0200, Arnout Vandecappelle spake thusly:
Quoted 12 lines · Yann E. MORIN
Quoted 11 lines
On 2015-06-08 23:09 +0200, Arnout Vandecappelle spake thusly:
Quoted 9 lines · Yann E. MORIN
package/pkg-kernel-module.mk line 58
Quoted 4 lines
package/pkg-kernel-module.mk new file +4
-0+# Duplicate that from pkg-generic because we need it now +ifndef $(2)_MAKE + $(2)_MAKE = $(MAKE) +endifI 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?Quoted 5 lines
Quoted 1 line
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.
Quoted 8 lines
I tested with a generic-package. Maybe an autotools-package (or any other infra) would have no issue, since it is defined for them.
Quoted 3 lines
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
Quoted 6 lines
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
PATCH 2/11 docs/manual: add kernel-module
In reply to Yann E. MORIN--- 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
docs/manual/adding-packages-kernel-module.txt new file +120 -0
@@ -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.
docs/manual/adding-packages.txt +2 -0
@@ -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
PATCH 2/11 docs/manual: add kernel-module
Quoted 15 lines · Yann E. MORIN
Signed-off-by "Yann E. MORIN" <[email protected]>Cc Thomas Petazzoni <[email protected]>Cc Samuel Martin <[email protected]>--- 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.txtdocs/manual/adding-packages-kernel-module.txt new file +0
-0
docs/manual/adding-packages-kernel-module.txt line 7
Quoted 7 lines
docs/manual/adding-packages-kernel-module.txt new file +7
-0@@ -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.
Quoted 31 lines
docs/manual/adding-packages-kernel-module.txt new file +31
-0+ +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. +
docs/manual/adding-packages-kernel-module.txt line 48
Quoted 10 lines
docs/manual/adding-packages-kernel-module.txt new file +10
-0+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
docs/manual/adding-packages-kernel-module.txt line 50
Quoted 2 lines
docs/manual/adding-packages-kernel-module.txt new file +2
-0+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...
Quoted 9 lines
docs/manual/adding-packages-kernel-module.txt new file +9
-0+ +Let's look at a more complex example: + +---- +01: ################################################################################ +02: # +03: # foo +04: # +05: ################################################################################
docs/manual/adding-packages-kernel-module.txt line 69
Quoted 10 lines
docs/manual/adding-packages-kernel-module.txt new file +10
-0+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).
Quoted 8 lines
docs/manual/adding-packages-kernel-module.txt new file +8
-0+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
docs/manual/adding-packages-kernel-module.txt line 87
Quoted 10 lines
docs/manual/adding-packages-kernel-module.txt new file +10
-0+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.
^^^^^
macrosQuoted 15 lines
docs/manual/adding-packages-kernel-module.txt new file +15
-0+ +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
docs/manual/adding-packages-kernel-module.txt line 112
Quoted 10 lines
docs/manual/adding-packages-kernel-module.txt new file +10
-0+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
Quoted 22 lines
docs/manual/adding-packages-kernel-module.txt new file +8
-0+ +* +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@@ -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 · 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
PATCH 2/11 docs/manual: add kernel-module
Quoted 42 lines · Arnout Vandecappelle
Quoted 15 lines · Yann E. MORIN
Signed-off-by "Yann E. MORIN" <[email protected]>Cc Thomas Petazzoni <[email protected]>Cc Samuel Martin <[email protected]>--- 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.txtdocs/manual/adding-packages-kernel-module.txt new file +0
-0docs/manual/adding-packages-kernel-module.txt line 7
Quoted 7 lines
docs/manual/adding-packages-kernel-module.txt new file +7
-0@@ -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.
Quoted 11 lines
docs/manual/adding-packages-kernel-module.txt new file +11
-0+ +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: ################################################################################
Quoted 8 lines
docs/manual/adding-packages-kernel-module.txt line 26
Quoted 8 lines
docs/manual/adding-packages-kernel-module.txt new file +8
-0+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 = GPLv2FOO_LICENSE_FILES = COPYING
Regards,
Arnout
Quoted 5 lines
Quoted 5 lines
docs/manual/adding-packages-kernel-module.txt new file +5
-0+10: +11: $(eval $(kernel-module)) +12: $(eval $(generic-package)) +---- +
[snip]
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
PATCH 2/11 docs/manual: add kernel-module
Arnout, All,
On 2015-06-09 00:02 +0200, Arnout Vandecappelle spake thusly:
Quoted 2 lines · Arnout Vandecappelle
Quoted 1 line · Yann E. MORIN
[--SNIP--]
Quoted 10 lines
Quoted 9 lines
Quoted 9 lines
+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
Quoted 5 lines
One more thing: we want to encourage adding license info, so perhaps include in
the example:
FOO_LICENSE= GPLv2FOO_LICENSE_FILES= COPYING
That and your previous comments acted upon. 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. | '------------------------------^-------^------------------^--------------------'
PATCH 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
@@ -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
PATCH 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
@@ -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
PATCH 5/11 package/ktap: use kernel-module helper
In reply to Yann E. MORIN--- package/ktap/ktap.mk | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
package/ktap/ktap.mk +3 -4
@@ -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
PATCH 5/11 package/ktap: use kernel-module helper
Yann,
package/ktap/ktap.mk endif · line 24
Quoted 9 lines · Yann E. MORIN
define
KTAP_BUILD_CMDSpackage/ktap/ktap.mk +0
-2$(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
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 5/11 package/ktap: use kernel-module helper
Thomas, All,
On 2015-06-08 23:25 +0200, Thomas Petazzoni spake thusly:
Quoted 6 lines · Yann E. MORIN
Quoted 5 lines
define
KTAP_BUILD_CMDSpackage/ktap/ktap.mk +0
-1$(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
Quoted 7 lines
package/ktap/ktap.mk endif · line 24
Quoted 4 lines
define
KTAP_INSTALL_TARGET_CMDSpackage/ktap/ktap.mk +0
-1$(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 endefI think you are effectively getting rid of the
KERNEL_SRCdefinition here. Did you test that it was working OK without this variable?
Well, it does build a kernel module, yes.
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. | '------------------------------^-------^------------------^--------------------'
PATCH 5/11 package/ktap: use kernel-module helper
Thomas, All,
On 2015-06-08 23:31 +0200, Yann E. MORIN spake thusly:
Quoted 15 lines
On 2015-06-08 23:25 +0200, Thomas Petazzoni spake thusly:
Quoted 6 lines · Yann E. MORIN
Quoted 5 lines
define
KTAP_BUILD_CMDSpackage/ktap/ktap.mk +0
-1$(MAKE) -C $(@D) $(TARGET_CONFIGURE_OPTS) $(KTAP_FLAGS) ktap - $(MAKE) -C $(@D) $(LINUX_MAKE_FLAGS) KERNEL_SRC=$(LINUX_DIR) KVERSION=$(LINUX_VERSION_PROBED) mod endefQuoted 7 lines
package/ktap/ktap.mk endif · line 24
Quoted 4 lines
define
KTAP_INSTALL_TARGET_CMDSpackage/ktap/ktap.mk +0
-1$(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 endefI think you are effectively getting rid of the
KERNEL_SRCdefinition here. Did you test that it was working OK without this variable?
Quoted 1 line
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.
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. | '------------------------------^-------^------------------^--------------------'
PATCH 5/11 package/ktap: use kernel-module helper
Dear Yann E. MORIN,
Quoted 8 lines · Yann E. MORIN
Sorry, I sent too early, forgot to say:
KERNEL_SRCis used i ktap'sMakefileonly to run commands like:$(MAKE) -C $(KERNEL_SRC) M=$(PWD) modulesSo, since that's our infra now doing that,
KERNEL_SRCis no longer needed.
Ok, makes sense. Might be worth mentioning in the commit log.
Thanks!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
PATCH 6/11 package/cryptodev-linux: use the kernel-module helper
In reply to Yann E. MORIN--- package/cryptodev-linux/cryptodev-linux.mk | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
package/cryptodev-linux/cryptodev-linux.mk +4 -9
@@ -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))
Signature · 1 line
1.9.1
PATCH 6/11 package/cryptodev-linux: use the kernel-module helper
Hi Yann,
Quoted 39 lines · Yann E. MORIN
Signed-off-by "Yann E. MORIN" <[email protected]>--- package/cryptodev-linux/cryptodev-linux.mk | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)package/cryptodev-linux/cryptodev-linux.mk +4
-9@@ -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))Signature · 1 line
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
package/cryptodev-linux/cryptodev-linux.mk +8 -7
@@ -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))
PATCH 6/11 package/cryptodev-linux: use the kernel-module helper
Doug, All,
On 2015-06-08 07:33 -0500, rdkehn at yahoo.com spake thusly:
Quoted 36 lines · Yann E. MORIN
Quoted 35 lines
Signed-off-by "Yann E. MORIN" <[email protected]>--- package/cryptodev-linux/cryptodev-linux.mk | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)package/cryptodev-linux/cryptodev-linux.mk +3
-9@@ -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
Quoted 8 lines
Quoted 4 lines
package/cryptodev-linux/cryptodev-linux.mk +1
-0+$(eval $(kernel-module)) $(eval $(generic-package))Signature · 1 line
1.9.1cryptodev-linux fails to build because
version.hdoes not get generated before compiling the source. Adding aPRE_BUILD_HOOKresolves 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? ;-)
Quoted 10 lines
Regards,
...dougpackage/cryptodev-linux/cryptodev-linux.mk +0
-0@@ -6,23 +6,24 @@ CRYPTODEV_LINUX_VERSION = 1.7
package/cryptodev-linux/cryptodev-linux.mk line 14
Quoted 10 lines
package/cryptodev-linux/cryptodev-linux.mk +2
-3CRYPTODEV_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.
Quoted 24 lines
package/cryptodev-linux/cryptodev-linux.mk +6
-4endef -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
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. | '------------------------------^-------^------------------^--------------------'
PATCH 6/11 package/cryptodev-linux: use the kernel-module helper
Hi Yann,
Quoted 6 lines · Yann E. MORIN
Doug, All,
Indeed, that makes it work. Thanks! :-)
May I add your Signed-off-by to the patch?
Yes.
Regards,
...doug
PATCH 7/11 package/ocf-linux: use kernel-module helper
In reply to Yann E. MORINRemove our patch since it is no longer needed.
--- 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
@@ -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
@@ -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))
Signature · 1 line
1.9.1
PATCH 7/11 package/ocf-linux: use kernel-module helper
All,
On 2015-06-07 00:20 +0200, Yann E. MORIN spake thusly:
Quoted 3 lines
Remove our patch since it is no longer needed.
Signed-off-by "Yann E. MORIN" <[email protected]>
[--SNIP--]
Quoted 11 lines
package/ocf-linux/ocf-linux.mk +0
-1@@ -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
package/ocf-linux/ocf-linux.mk line 11
Quoted 10 lines
package/ocf-linux/ocf-linux.mk +1
-9-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.
Quoted 16 lines
package/ocf-linux/ocf-linux.mk +6
-0+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
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. | '------------------------------^-------^------------------^--------------------'
PATCH 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
@@ -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
PATCH 9/11 package/owl-linux: use kernel-module helper
In reply to Yann E. MORINGit rid of first patch, no longer needed; rename remaining patch.
---
.../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%)package/owl-linux/0001-fix-CROSS_COMPILE-usage-in-Makefile.patch deleted +0 -16
@@ -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
package/owl-linux/owl-linux.mk +1 -10
@@ -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))
Signature · 1 line
1.9.1
PATCH 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
@@ -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
PATCH 11/11 package/sysdig: use kernel-module helper
In reply to Yann E. MORINThis 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--- package/sysdig/sysdig.mk | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-)
package/sysdig/sysdig.mk +18 -4
@@ -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