adding-packages-kconfig.adoc 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // -*- mode:doc; -*-
  2. // vim: set syntax=asciidoc:
  3. === Infrastructure for packages using kconfig for configuration files
  4. A popular way for a software package to handle user-specified
  5. configuration is +kconfig+. Among others, it is used by the Linux
  6. kernel, Busybox, and Buildroot itself. The presence of a .config file
  7. and a +menuconfig+ target are two well-known symptoms of kconfig being
  8. used.
  9. Buildroot features an infrastructure for packages that use kconfig for
  10. their configuration. This infrastructure provides the necessary logic to
  11. expose the package's +menuconfig+ target as +foo-menuconfig+ in
  12. Buildroot, and to handle the copying back and forth of the configuration
  13. file in a correct way.
  14. The main macro of the kconfig package infrastructure is
  15. +kconfig-package+. It is similar to the +generic-package+ macro.
  16. Just like the generic infrastructure, the kconfig infrastructure works
  17. by defining a number of variables before calling the +kconfig-package+
  18. macro.
  19. All the package metadata information variables that exist in the
  20. xref:generic-package-reference[generic package infrastructure] also
  21. exist in the kconfig infrastructure.
  22. In order to use the +kconfig-package+ infrastructure for a Buildroot
  23. package, the minimally required lines in the +.mk+ file, in addition to
  24. the variables required by the +generic-package+ infrastructure, are:
  25. ----
  26. FOO_KCONFIG_FILE = reference-to-source-configuration-file
  27. $(eval $(kconfig-package))
  28. ----
  29. This snippet creates the following make targets:
  30. * +foo-menuconfig+, which calls the package's +menuconfig+ target
  31. * +foo-update-config+, which copies the configuration back to the
  32. source configuration file. It is not possible to use this target
  33. when fragment files are set.
  34. * +foo-update-defconfig+, which copies the configuration back to the
  35. source configuration file. The configuration file will only list the
  36. options that differ from the default values. It is not possible to
  37. use this target when fragment files are set.
  38. * +foo-diff-config+, which outputs the differences between the current
  39. configuration and the one defined in the Buildroot configuration for
  40. this kconfig package. The output is useful to identify the
  41. configuration changes that may have to be propagated to
  42. configuration fragments for example.
  43. and ensures that the source configuration file is copied to the build
  44. directory at the right moment.
  45. There are two options to specify a configuration file to use, either
  46. +FOO_KCONFIG_FILE+ (as in the example, above) or +FOO_KCONFIG_DEFCONFIG+.
  47. It is mandatory to provide either, but not both:
  48. * +FOO_KCONFIG_FILE+ specifies the path to a defconfig or full-config file
  49. to be used to configure the package.
  50. * +FOO_KCONFIG_DEFCONFIG+ specifies the defconfig 'make' rule to call to
  51. configure the package.
  52. In addition to these minimally required lines, several optional variables can
  53. be set to suit the needs of the package under consideration:
  54. * +FOO_KCONFIG_EDITORS+: a space-separated list of kconfig editors to
  55. support, for example 'menuconfig xconfig'. By default, 'menuconfig'.
  56. * +FOO_KCONFIG_FRAGMENT_FILES+: a space-separated list of configuration
  57. fragment files that are merged to the main configuration file.
  58. Fragment files are typically used when there is a desire to stay in sync
  59. with an upstream (def)config file, with some minor modifications.
  60. * +FOO_KCONFIG_OPTS+: extra options to pass when calling the kconfig
  61. editors. This may need to include '$(FOO_MAKE_OPTS)', for example. By
  62. default, empty.
  63. * +FOO_KCONFIG_FIXUP_CMDS+: a list of shell commands needed to fixup the
  64. configuration file after copying it or running a kconfig editor. Such
  65. commands may be needed to ensure a configuration consistent with other
  66. configuration of Buildroot, for example. By default, empty.
  67. * +FOO_KCONFIG_DOTCONFIG+: path (with filename) of the +.config+ file,
  68. relative to the package source tree. The default, +.config+, should
  69. be well suited for all packages that use the standard kconfig
  70. infrastructure as inherited from the Linux kernel; some packages use
  71. a derivative of kconfig that use a different location.
  72. * +FOO_KCONFIG_DEPENDENCIES+: the list of packages (most probably, host
  73. packages) that need to be built before this package's kconfig is
  74. interpreted. Seldom used. By default, empty.
  75. * +FOO_KCONFIG_SUPPORTS_DEFCONFIG+: whether the package's kconfig system
  76. supports using defconfig files; few packages do not. By default, 'YES'.