customize-outside-br.txt 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. // -*- mode:doc -*- ;
  2. [[outside-br-custom]]
  3. === Keeping customizations outside of Buildroot
  4. As already briefly mentioned in xref:customize-dir-structure[], you can
  5. place project-specific customizations in two locations:
  6. * directly within the Buildroot tree, typically maintaining them using
  7. branches in a version control system so that upgrading to a newer
  8. Buildroot release is easy.
  9. * outside of the Buildroot tree, using the +BR2_EXTERNAL+ mechanism.
  10. This mechanism allows to keep package recipes, board support and
  11. configuration files outside of the Buildroot tree, while still
  12. having them nicely integrated in the build logic. This section
  13. explains how to use +BR2_EXTERNAL+.
  14. +BR2_EXTERNAL+ is an environment variable that can be used to point to
  15. a directory that contains Buildroot customizations. It can be passed
  16. to any Buildroot +make+ invocation. It is automatically saved in the
  17. hidden +.br-external+ file in the output directory. Thanks to this,
  18. there is no need to pass +BR2_EXTERNAL+ at every +make+ invocation. It
  19. can however be changed at any time by passing a new value, and can be
  20. removed by passing an empty value.
  21. *Note:* the +BR2_EXTERNAL+ path can be either an absolute or a relative path,
  22. but if it's passed as a relative path, it is important to note that it
  23. is interpreted relative to the main Buildroot source directory, *not*
  24. to the Buildroot output directory.
  25. Some examples:
  26. -----
  27. buildroot/ $ make BR2_EXTERNAL=/path/to/foobar menuconfig
  28. -----
  29. From now on, external definitions from the +/path/to/foobar+
  30. directory will be used:
  31. -----
  32. buildroot/ $ make
  33. buildroot/ $ make legal-info
  34. -----
  35. We can switch to another external definitions directory at any time:
  36. -----
  37. buildroot/ $ make BR2_EXTERNAL=/where/we/have/barfoo xconfig
  38. -----
  39. Or disable the usage of external definitions:
  40. -----
  41. buildroot/ $ make BR2_EXTERNAL= xconfig
  42. -----
  43. +BR2_EXTERNAL+ allows three different things:
  44. * One can store all the board-specific configuration files there,
  45. such as the kernel configuration, the root filesystem overlay, or
  46. any other configuration file for which Buildroot allows to set its
  47. location. The +BR2_EXTERNAL+ value is available within the
  48. Buildroot configuration using +$(BR2_EXTERNAL)+. As an example, one
  49. could set the +BR2_ROOTFS_OVERLAY+ Buildroot option to
  50. +$(BR2_EXTERNAL)/board/<boardname>/overlay/+ (to specify a root
  51. filesystem overlay), or the +BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE+
  52. Buildroot option to
  53. +$(BR2_EXTERNAL)/board/<boardname>/kernel.config+ (to specify the
  54. location of the kernel configuration file).
  55. * One can store package recipes (i.e. +Config.in+ and
  56. +<packagename>.mk+), or even custom configuration options and make
  57. logic. Buildroot automatically includes +$(BR2_EXTERNAL)/Config.in+ to
  58. make it appear in the top-level configuration menu, and includes
  59. +$(BR2_EXTERNAL)/external.mk+ with the rest of the makefile logic.
  60. Providing those two files is mandatory, but they can be empty.
  61. +
  62. The main usage of this is to store package recipes. The recommended
  63. way to do this is to write a +$(BR2_EXTERNAL)/Config.in+ file that
  64. looks like:
  65. +
  66. ------
  67. source "$BR2_EXTERNAL/package/<boardname>/package1/Config.in"
  68. source "$BR2_EXTERNAL/package/<boardname>/package2/Config.in"
  69. ------
  70. +
  71. Then, have a +$(BR2_EXTERNAL)/external.mk+ file that looks like:
  72. +
  73. ------
  74. include $(sort $(wildcard $(BR2_EXTERNAL)/package/*/*/*.mk))
  75. ------
  76. +
  77. And then in +$(BR2_EXTERNAL)/package/<boardname>/package1+ and
  78. +$(BR2_EXTERNAL)/package/<boardname>/package2+ create normal Buildroot
  79. package recipes, as explained in xref:adding-packages[].
  80. * One can store Buildroot defconfigs in the +configs+ subdirectory of
  81. +$(BR2_EXTERNAL)+. Buildroot will automatically show them in the
  82. output of +make help+ and allow them to be loaded with the normal
  83. +make <name>_defconfig+ command. They will be visible under the
  84. +User-provided configs+' label in the 'make help' output.