While trying to add extra locking 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
CFLAGS_LINUXKPI= options to the Makefiles and removing the manual
CFLAGS+= lines. Then in kmod.mk make sure that LinuxKPI options
are added after the global options.
CFLAGS_LINUXKPI can either be defined empty as CFLAGS_LINUXKPI= ,
or set to YES (a common way of expressing options such as EXPORT_SYMS=),
or add further CFLAGS+= which will be added after the global and the
generic LinuxKPI CFLAGS.
It should be noteds 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.
Out-of-tree consumers should update their module build frameworks
accordingly.
Fixes: 41283b454b7a ("LinuxKPI: always include linux/kconfig.h")
MFC after: 3 days