Correctly export Linux Headers, Modules
When building a Kernel Driver out of tree,
i run make like this in the drivers directory, where KERNELDIR
either is the path to the kernel source, or to the headers.
make -C $(KERNELDIR) M=$(PWD) modules
when trying to build headers myself using:
make headers_install ARCH=i386 INSTALL_HDR_PATH=$(HEADERSDIR)
i find the e开发者_如何学Cxport unsuitable to build modules against (without a full kernel source tree)
Several files and folders seem to be missing, like a Makefile, scripts , include/generated/autoconf.h
or include/config/auto.conf
etc.
Debian does things in an usable way, as described in rules.real, although it does more than is described in Documentation/make/headers_install.txt
, which seems to be not the "standard" way.
In short: how do i correctly export linux headers, so i can build external modules against it?
headers_install is meant to export a set of header files suitable to use from a user space point of view. It is the userspace exposed API of the kernel. Let's say you create a wonderful new ioctl, with a custome data structure. This is the kind of information you wan't userspace to know, so that userspace program can use your wonderful new ioctl.
But everything that is not visible from userspace, that is "private" to the kernel, or in other word the internal API, is not exposed to userspace.
So to build an out of tree module, you need either a full configured source tree, or the kernel headers as packaged by your distro. Look for the linux-headers or linux-kernel-headers package on a Ubuntu / Debian for example.
I believe the kernel make file target of headers_install is meant for the production of Linux header for the production of C library and tool chain and not for the purpose of enabling to build out of tree kernel modules sans full configured kernel source code.
In fact, I'm guessing building out of tree kernel modules without full kernel source code is not supported and is in fact a "hack" created by distributions.
精彩评论