如何在树外内核模块中为make headers_install指定头文件? [英] How do I specify header files for make headers_install in an out-of-tree kernel module?

查看:190
本文介绍了如何在树外内核模块中为make headers_install指定头文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在kbuild 模块中找不到与此有关的任何信息.文档和 headers_install 中只有一个斜引用(建议可能).文档.

I couldn't find any information regarding this in kbuild modules documentation and only an oblique reference (suggesting that it's possible) in the headers_install documentation.

"make headers_install"命令可以在以下目录的顶级目录中运行内核源代码(或使用标准的树外构建).

The "make headers_install" command can be run in the top level directory of the kernel source code (or using a standard out-of-tree build).

我有一个树外内核模块和一个关联的头文件(我对IOCTL有#defines),并且我想在模块安装过程中提供该头文件.内核模块提供头文件(供用户空间使用)的树内方式似乎是将它们放置在include/linux/中.要在树外工作,我该怎么办?

I have an out-of-tree kernel module with an associated header file (I have #defines for an IOCTL), and I want to provide that header file as part of the module installation. It seems like the in-tree way for kernel modules to provide header files (for userspace use) is to place them in include/linux/. What do I have to do for this to work for out-of-tree?

推荐答案

好吧,这似乎是另一种情况,我没有阅读所有手册...所需的手册是

Ok, this seems to be another case where I didn't read all the manuals... the manual needed is the makefiles documentation for kbuild...

内核包括一组导出到用户空间的标头.可以按原样导出许多标头,但其他标头需要在准备好用于用户空间之前进行最少的预处理.预处理可以:

The kernel includes a set of headers that is exported to userspace. Many headers can be exported as-is but other headers require a minimal pre-processing before they are ready for user-space. The pre-processing does:

  • 删除特定于内核的注释
  • 删除编译器的包含文件.h
  • 删除内核内部的所有部分(由ifdef KERNEL 保护)

每个相关目录都包含一个文件名"Kbuild",该文件名指定了要导出的标头.有关Kbuild文件的语法,请参见下一章.

Each relevant directory contains a file name "Kbuild" which specifies the headers to be exported. See subsequent chapter for the syntax of the Kbuild file.

--- 7.1标头-y

--- 7.1 header-y

header-y指定要导出的头文件.

header-y specifies header files to be exported.

  Example:
        #include/linux/Kbuild
        header-y += usb/
        header-y += aio_abi.h

这篇关于如何在树外内核模块中为make headers_install指定头文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆