Creating `kmod-` packages: How to set kernel options (bool, int) and check for kernel options in package `Makefile`?

Dear build system knowledgables,

To keep things clean, I am currently creating new kernel modules as separate packages in a separate feed.

I think I have already found out how to create kernel module packages, but one kernel module needs to set some other kernel features which are not available as modules but just as simple y/n and with an integer number in the kernel configuration.

That are:


CONFIG_CMA by itself depends on CONFIG_MMU, which seems to be automatically set or unset by the kernel config depending on the selected architecture or so.
CONFIG_DMA_CMA depends on CONFIG_HAVE_DMA_CONTIGUOUS, which also seems to be something automatically determined by the kernel config.

To make things clean, I want to add one OpenWrt configuration item for CONFIG_CMA and CONFIG_DMA_CMA and CONFIG_CMA_SIZE_SEL_MBYTES, and if selected two sub-configuration-items to specify CONFIG_CMA_SIZE_MBYTES and CONFIG_CMA_ALIGNMENT, with sensible defaults.

Also, I want to check for the needed options CONFIG_MMU=y and CONFIG_HAVE_DMA_CONTIGUOUS=y.

How do I do that in a package Makefile I create within a feed? Can anyone give an explanation + example, or one of them, how to

  • set kernel options which do not result in a module file,
  • check if some kernel configuration is present?

That would help me getting hardware functionality of my board more properly supported than hacking CONFIG_<something>=y into target/linux/*/config-5.10, and would allow to build loadable modules.

Moreover, one module is provided by external sources, and that module also has some in-kernel dependencies, so there I need to write a package and include dependencies for kernel options.