Adding support for menuconfig / Kconfig in my project

岁酱吖の 提交于 2019-12-12 08:28:34

问题


I am planning to add support for menuconfig in my project. The project is not associated with Linux kernel so, I have to write everything from scratch in menuconfig and Makefile.

How do I add support for menuconfig and create Kconfig and make the makefile read the defines in .config?

Any good tutorial to begin with?


回答1:


If you are interested on using KBuild/KConfig for your custom applications, you may try the following Github projects. They aim to provide an initial template for projects using KBuild/KConfig and, therefore, supporting menuconfig.

  • Kbuild skeleton: https://github.com/masahir0y/kbuild_skeleton
  • Kbuild template: https://github.com/embedded-it/kbuild-template



回答2:


I'll assume you are making a driver that is outside of the kernel directory. Information for that can be found here: https://www.kernel.org/doc/Documentation/kbuild/modules.txt.

Outside of that, if you want a userspace file to see the .config variables, you can have it depend on the kernel build, and then include autoconf.h, which is in the include/generated folder for recent versions of the kernel. Userspace does not use kbuild directly.




回答3:


First you need to copy the folders and files below from linux folder 'scripts' into your own project

  • basic
  • kconfig
  • Kbuild.include
  • Makefile.build
  • Makefile.host
  • Makefile.lib

Sources in folders basic and kconfig need to be built for your processor architecture. How to do it is written in the linux Makefile. You can change some names using next variables

  • KCONFIG_CONFIG = .config
  • KCONFIG_AUTOHEADER = application/autoconf.h
  • KCONFIG_AUTOCONFIG = build/include/config/auto.conf
  • KCONFIG_TRISTATE = build/include/config/tristate.conf

The following project initially created for ARM MCUs can help you to understand kconfig

https://github.com/mcu/kconfig



来源:https://stackoverflow.com/questions/18841101/adding-support-for-menuconfig-kconfig-in-my-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!