[LTP] [PATCH v2 1/1] Makefile: Add kernel modules related make targets

Li Wang liwang@redhat.com
Sat Aug 2 05:59:06 CEST 2025


On Fri, Aug 1, 2025 at 6:21 PM Petr Vorel <pvorel@suse.cz> wrote:

> Hi,
>
> > Changes v1->v2:
> > * Add also modules-clean and modules-install
> > This is needed as 'make modules clean' or 'make modules install'
> > would be running 2 separate targets.
>
> Also, I wondered about fail when kernel modules aren't build:
>
> include/mk/module.mk contains:
>
> ifeq ($(WITH_MODULES),no)
> SKIP := 1
> else
> ifeq ($(LINUX_VERSION_MAJOR)$(LINUX_VERSION_PATCH),)
> SKIP := 1
> else
> SKIP ?= $(shell \
>         [ "$(LINUX_VERSION_MAJOR)" -gt "$(REQ_VERSION_MAJOR)" ] || \
>         [ "$(LINUX_VERSION_MAJOR)" -eq "$(REQ_VERSION_MAJOR)" -a \
>           "$(LINUX_VERSION_PATCH)" -ge "$(REQ_VERSION_PATCH)" ]; echo $$?)
> endif
> endif
>
> ifneq ($(SKIP),0)
> MAKE_TARGETS := $(filter-out %.ko, $(MAKE_TARGETS))
> endif
>
> # Ignoring the exit status of commands is done to be forward compatible
> with
> # kernel internal API changes. The user-space test will return TCONF, if it
> # doesn't find the module (i.e. it wasn't built either due to kernel-devel
> # missing or module build failure).
> %.ko: %.c .dep_modules ;
> -----
>
> We could allow to fail build with:
> $ make modules FORCE=1
>
> with these changes to include/mk/module.mk:
>
> ifneq ($(SKIP),0)
> MAKE_TARGETS := $(filter-out %.ko, $(MAKE_TARGETS))
>


> ifeq ($(FORCE),1)
> $(error Modules not built)
>

This suggestion looks good, maybe we can also add a helpful error
message showing how to fix it:

ifeq ($(FORCE),1)
$(error Kernel modules not built! \
Check that kernel-devel/kernel-headers for
$(LINUX_VERSION_MAJOR).$(LINUX_VERSION_PATCH) are installed, \
and try again. You can build anyway by omitting FORCE=1.)


endif
> endif
>
> ifneq ($(FORCE),1)
> %.ko: %.c .dep_modules ;
> endif
>
> Kind regards,
> Petr
>
>

-- 
Regards,
Li Wang


More information about the ltp mailing list