如何将包含目录添加到内核源代码的 makefile 中?

发布于 2024-12-25 21:41:17 字数 692 浏览 0 评论 0原文

我正在尝试构建一些添加到 Ubuntu 源代码中的内核模块。经过多次编译尝试失败后,我发现相同的错误不断发生在不同的地方。编译器无法找到位于文件夹中包含目录中的一组标头。

EX

主文件夹:drivers/scst/

子文件夹:drivers/scst/iscsi-scst/

包含文件夹:drivers/scst/include

如何将该包含文件夹添加到 makefile 中?

这是生成文件;

ccflags-y += -Wno-unused-parameter

scst-y        += scst_main.o
scst-y        += scst_pres.o
scst-y        += scst_targ.o
scst-y        += scst_lib.o
scst-y        += scst_sysfs.o
scst-y        += scst_mem.o
scst-y        += scst_tg.o
scst-y        += scst_debug.o

obj-$(CONFIG_SCST)   += scst.o dev_handlers/ iscsi-scst/

我大约 50% 确定如何使用“正常”makefile 来完成此操作,就像不与内核源代码一起使用的 makefile 一样,但是我如何使用上面的 makefile 来完成此操作?

I am trying to build some kernel modules I added to my Ubuntu source code. After many failed attempts to compile I found out that the same error keep happening in different places. The compiler is not able to find a set of headers which sit in an include directory in the folder.

E.X.

Main folder: drivers/scst/

Sub folder: drivers/scst/iscsi-scst/

Include folder: drivers/scst/include

How can I add that include folder to the makefile?

Here is the makefile;

ccflags-y += -Wno-unused-parameter

scst-y        += scst_main.o
scst-y        += scst_pres.o
scst-y        += scst_targ.o
scst-y        += scst_lib.o
scst-y        += scst_sysfs.o
scst-y        += scst_mem.o
scst-y        += scst_tg.o
scst-y        += scst_debug.o

obj-$(CONFIG_SCST)   += scst.o dev_handlers/ iscsi-scst/

I am about 50% sure of how to do it with a "normal" makefile as in one that not work with the kernel source but how can I do it with one like above?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

暮色兮凉城 2025-01-01 21:41:17

驱动程序代码的约定是将特定驱动程序的包含文件插入到与驱动程序相同的目录中,并包含为#include "header.h"。但是,如果您想按照自己的方式进行操作,请使用 gcc 的 -I 选项,因此它可能看起来像 -Idrivers/scst/include 或类似的内容,并且应该添加到 ccflags 中。注意:此路径可能会根据您正在编辑的 Makefile 所在的位置而变化。

Convention for driver code is to insert the include file for specific drivers into the same directory as the driver and include as #include "header.h". But if you want to do it your way use the -I option for gcc, so it might look like -Idrivers/scst/include or something along those lines and it should be added to the ccflags. Note: This path may change depending on where the Makefile you are editing is located.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文