Skip to content

kernel: add Pre/Post hooks to Kernel/Configure - #25217

Open
alewi-westermo wants to merge 1 commit into
openwrt:mainfrom
alewi-westermo:kernel-configure-hooks
Open

alewi-westermo wants to merge 1 commit into
openwrt:mainfrom
alewi-westermo:kernel-configure-hooks

Conversation

@alewi-westermo

Copy link
Copy Markdown

Kernel/Configure is a plain one-liner that calls Kernel/Configure/Default. A target that needs to run an extra configuration step has to override the whole define and re-issue the Kernel/Configure/Default call, coupling the target to build-system internals.

Frame the Kernel/Configure/Default call with additive Pre/Post hook lists, mirroring the Hooks/Configure/{Pre,Post} pattern already used for package builds in include/package.mk. Kernel/Configure is expanded as a normal multi-line recipe, so the hooks are separated with $(sep) exactly like the package hooks. Targets can then append to Hooks/KernelConfigure/{Pre,Post} without touching the shared define. Default behaviour is unchanged: with no hooks registered both loops expand to nothing and only Kernel/Configure/Default runs.

Assisted-by: Claude:claude-opus-4.8

Kernel/Configure is a plain one-liner that calls Kernel/Configure/Default.
A target that needs to run an extra configuration step has to override
the whole define and re-issue the Kernel/Configure/Default call, coupling
the target to build-system internals.

Frame the Kernel/Configure/Default call with additive Pre/Post hook
lists, mirroring the Hooks/Configure/{Pre,Post} pattern already used for
package builds in include/package.mk. Kernel/Configure is expanded as a
normal multi-line recipe, so the hooks are separated with $(sep) exactly
like the package hooks. Targets can then append to
Hooks/KernelConfigure/{Pre,Post} without touching the shared define.
Default behaviour is unchanged: with no hooks registered both loops
expand to nothing and only Kernel/Configure/Default runs.

Assisted-by: Claude:claude-opus-4.8
Signed-off-by: Alexander Wilhelm <[email protected]>
@openwrt openwrt Bot added the build/scripts/tools pull request/issues for build, scripts and tools related changes label Sep 16, 2026

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 new commit.


Generated by Claude Code

Comment thread include/kernel-build.mk
define Kernel/Configure
$(foreach hook,$(Hooks/KernelConfigure/Pre),$(call $(hook))$(sep))
$(call Kernel/Configure/Default)
$(foreach hook,$(Hooks/KernelConfigure/Post),$(call $(hook))$(sep))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A Post hook lands after headers_install and the .vermagic md5 at kernel-defaults.mk:128-129, which are derived from .config.set. So a hook doing the "extra configuration step" the commit message motivates — editing $(LINUX_DIR)/.config — would silently leave .vermagic and user_headers describing the pre-hook config. Is the Post point meant only for non-config side effects, or should it sit before that tail?


Generated by Claude Code

Comment thread include/kernel-build.mk
endef

define Kernel/Configure
$(foreach hook,$(Hooks/KernelConfigure/Pre),$(call $(hook))$(sep))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: nothing in the tree assigns Hooks/KernelConfigure/{Pre,Post}, so this lands as an unused extension point. Is there a follow-up target patch that could go in the same series?


Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build/scripts/tools pull request/issues for build, scripts and tools related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants