While trying to add extra lock debugging to LinuxKPI it became
apparent that the order in which we process CFLAGS+= with the so far
common ${LINUXKPI_INCLUDES} does not work as it will add the
LinuxKPI specifc -include for kconfig.h before the global -inlcude
for opt_global.h. This meant that a #if defined(WITNESS) check in
kconfig.h would always fail given the include order.
Further we do have various LinuxKPI modules, which will add CFLAGS+=
after including kmod.mk. It is unclear as to which extend that was
a copy and paste problem or a real issue and will have to be
investigated independent of this change.
Rework the way we add ${LINUXKPI_INCLUDES} to the build by adding a
LINUXKPI_FEATURES+= INCLUDES option to the Makefiles and remove the
manual CFLAGS+= lines. Then in kmod.mk make sure that LinuxKPI
options are added after the global options.
Also add a LINUXKPI_FEATURES+= GENSRC option to add LINUXKPI_GENSRC
instead of manually adding them in the Makefiles.
Lastly add a (so far) optional LINUXKPI_FEATURES+= VER=Mmmnn option
to define the LINUXKPI_VERSION the module is supporting.
We currently do not set this on any semi-native drivers and more
work is needed to update all of them in order to enforce a set
version in the future. This will ease figuring out the minimum
Linux version we (still) need to support in LinuxKPI and will make
changes like 9d18e2c12629 a lot easier.
Lastly this will allow for an easier integration of a (new)
LinuxKPI USB (and possible other features) and drivers using them
as, e.g., USB they will need conditional compiler dependent options.
It should be noted that for code which is not affected or does
not affect kernel build options normal CFLAGS+= can be kept for all
other -I or -D lines. It will be the responsibility of the driver
maintainers (of semi-native drivers) to see if current way of handling
includes may have (had) unexpected effects and to add VER= options.
Out-of-tree consumers should update their module build frameworks
accordingly to make use of these new features (especially in order
to allow lock debugging).
Fixes: 41283b454b7a ("LinuxKPI: always include linux/kconfig.h")
MFC after: 3 days