I have an out of tree linux kernel module that has a public header. This header is intended to be shared with other modules, as it declares exported functions of the module, and not with userspace.
I read about the Kbuild header-y
variable but it does not seem to be in use in current kernel any more. There is the header_install
and headers_install_all
target. But this are intended to generate userspace api headers that are placed in /usr/include
?
And finaly just placing the headers in normal includepath (e.g. /usr/include
) would not work as this is not part of the normal kernel includepath during module build.
so after weeks of search it seems that this is it. there is no predefined place for out of tree build module dependency headers.
my current solution is to add this on the modules that export headers:
INSTALL_MOD_PATH ?= /
INSTALL_HDR_PATH ?= $(INSTALL_MOD_PATH)/usr/include/
INSTALL_HDR_PATH_KERNEL ?= $(INSTALL_MOD_PATH)/usr/src/include/
header_install:
install -d $(INSTALL_HDR_PATH)
install -d $(INSTALL_HDR_PATH_KERNEL)
install -Dm 0655 ./user.h $(INSTALL_HDR_PATH)/user.h
install -Dm 0655 ./mod-external.h $(INSTALL_HDR_PATH_KERNEL)/mod-external.h
and in the dependen modules do this on build
export KCFLAGS="-I$(INSTALL_MOD_PATH)/usr/src/include/"
make
this promotes /usr/src/include
to be the folder for header exchange