【问题标题】:Hello world kconfig and makefile to make it similar to linux kernel menuconfigHello world kconfig 和 makefile 使其类似于 linux 内核 menuconfig
【发布时间】:2015-10-06 05:59:06
【问题描述】:

如何实现 hello world Makefile 和 Kconfig?

我知道怎么写Makefile,但是如何写Makefile和Kconfig类似于Linux Kernel。
我想写一个可以打开menuconfig的小程序,类似于Linux Kernel?

我不希望它用于 Linux Kernel 模块编译,我知道那部分,我想学习将任何应用程序转换为这样的可配置应用程序。

我应该从哪里开始的任何示例指针?

【问题讨论】:

  • where should I start from? - 从内核的 Makefile 代码开始。 make menuconfig 实际上调用了一些程序,该程序是使用 ncurses 库构建的。

标签: linux makefile gnu kbuild


【解决方案1】:

如果我正确理解了您的问题,那么您一定是在使用内核构建过程在可加载模块的树构建中询问。 Kconfig 负责使相应的 value/loadable 模块在 menuconfig 中可见(我使用 menuconfig 进行内核配置)。

为简单起见,让我们按照以下步骤操作: 在名为 mymod 的 ~/drivers 目录上创建目录。 在 ~/drivers/mymod 创建 Kconfig 和 Makefile 文件并保留你的 helloKernelmod.c

在 Kconfig 中保留以下内容

menu "Menu Name of Your Driver"

config HELLO_MODULE 
      tristate "Inside Menu Name"
      help
          This is help/informational content for your module
endmenu

在makefile中保持下面的内容

obj-$(CONFIG_HELLO_MODULE)     +=helloKernelmod.o

这些更新将起到作用,您的模块将被构建。 为缩进添加标签 欲了解更多信息,请访问https://www.kernel.org/doc/Documentation/kbuild/kconfig-language.txt

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-04-04
    • 1970-01-01
    • 2019-10-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多