customize-outside-br.txt 4.0 KB

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