12

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?

Claudio
  • 10,614
  • 4
  • 31
  • 71
  • Good point to start is U-Boot sources. They migrated to kernel build system recently, so it's good reference for how to do that. You can start with `git log -- scripts/kconfig/` in U-Boot sources dir to investigate the process. – Sam Protsenko Jan 27 '17 at 19:26
  • I have same question as yours. Can you let everyone know what you eventually did? – Amit128 Apr 06 '17 at 10:58
  • @user435739 were you able to find a solution for this? I need to do the same for cortex-M microcontroller based projects, so nothing to do with Linux. If you were able to add the menuconfig to your project please share. – m4l490n Jul 27 '18 at 15:54

3 Answers3

4

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.

Jaime
  • 5,435
  • 2
  • 18
  • 21
0

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

devnull
  • 1
  • 1
-1

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.

blackghost
  • 1,730
  • 11
  • 24