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

Li Wang liwang@redhat.com
Thu Aug 7 01:22:43 CEST 2025


Hi Petr,

On Thu, Aug 7, 2025 at 5:14 AM Petr Vorel <pvorel@suse.cz> wrote:

> LTP contains few kernel modules and tests which are using them.  These
> require to be built with the same kernel headers as the running kernel
> (SUT). Sometimes the best way to achieve this is to compile them on the
> SUT.
>
> Add 'modules', 'modules-clean' and 'modules-install' make targets to
> make it easier to build them.
>

Maybe better to keep the make target consistent with the kernel build
command:
  make modules_install
  make modules_clean



>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
>

Reviewed-by: Li Wang <liwang@redhat.com>


> ---
> Changes v2->v3:
> * Automatic detection (Li), note: without 'sort -u' as there should be
>   single Makefile in directory.
>
> Link to v2:
>
> https://patchwork.ozlabs.org/project/ltp/patch/20250801100935.974351-1-pvorel@suse.cz/
> https://lore.kernel.org/ltp/20250801100935.974351-1-pvorel@suse.cz/
>
>  INSTALL  | 10 ++++++++++
>  Makefile | 21 +++++++++++++++++++++
>  2 files changed, 31 insertions(+)
>
> diff --git a/INSTALL b/INSTALL
> index cbe27f32ea..10c19d4105 100644
> --- a/INSTALL
> +++ b/INSTALL
> @@ -165,6 +165,16 @@ PKG_CONFIG_LIBDIR=/usr/lib/i386-linux-gnu/pkgconfig
> CFLAGS=-m32 LDFLAGS=-m32 ./c
>  * Arch Linux
>  PKG_CONFIG_LIBDIR=/usr/lib32/pkgconfig CFLAGS=-m32 LDFLAGS=-m32
> ./configure
>
> +Kernel modules
> +--------------
> +
> +LTP contains few kernel modules and tests which are using them.
> +These require to be built with the same kernel headers as the running
> kernel (SUT).
> +Sometimes the best way to achieve this is to compile them on the SUT.
> +
> +'modules', 'modules-clean' and 'modules-install' make targets are
> shortcuts
> +to build just these modules and tests.
> +
>  Android Users
>  -------------
>
> diff --git a/Makefile b/Makefile
> index eab40da8a6..cdad8b10ce 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -212,6 +212,27 @@ endif
>  test-metadata: metadata-all
>         $(MAKE) -C $(abs_srcdir)/metadata test
>
> +MODULE_DIRS :=  $(shell \
> +       dirname $$(grep -l 'include.*module\.mk' $$(find testcases/ -type
> f -name 'Makefile')))
> +
> +
> +.PHONY: modules modules-clean modules-install
> +modules:
> +       @$(foreach dir,$(MODULE_DIRS),\
> +               echo "Build $(dir)";\
> +               $(MAKE) -C $(abs_srcdir)/$(dir); \
> +)
> +modules-clean:
> +       @$(foreach dir,$(MODULE_DIRS),\
> +               echo "Build $(dir)";\
> +               $(MAKE) -C $(abs_srcdir)/$(dir) clean; \
> +)
> +modules-install: modules
> +       @$(foreach dir,$(MODULE_DIRS),\
> +               echo "Build $(dir)";\
> +               $(MAKE) -C $(abs_srcdir)/$(dir) install; \
> +)
> +
>  ## Help
>  .PHONY: help
>  help:
> --
> 2.50.1
>
>

-- 
Regards,
Li Wang


More information about the ltp mailing list