writing-rules.txt 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. // -*- mode:doc; -*-
  2. Writing rules
  3. -------------
  4. Overall, these writing rules are here to help you add new files in
  5. Buildroot or refactor existing ones.
  6. If you slightly modify some existing file, the important thing is
  7. keeping the consistency of the whole file, so you can:
  8. * either follow the potentially deprecated rules used all over this
  9. file
  10. * or entirely rework it in order to make it comply with those rules.
  11. [[writing-rules-config-in]]
  12. +Config.in+ file
  13. ~~~~~~~~~~~~~~~~
  14. +Config.in+ files contain entries for almost anything configurable in
  15. Buildroot.
  16. An entry has the following pattern:
  17. ---------------------
  18. config BR2_PACKAGE_LIBFOO
  19. bool "libfoo"
  20. depends on BR2_PACKAGE_LIBBAZ
  21. select BR2_PACKAGE_LIBBAR
  22. help
  23. This is a comment that explains what libfoo is.
  24. http://foosoftware.org/libfoo/
  25. ---------------------
  26. * The +bool+, +depends on+, +select+ and +help+ lines are indented
  27. with one tab.
  28. * The help text itself should be indented with one tab and two
  29. spaces.
  30. The configuration system used in Buildroot, so the content of the
  31. +Config.in+ files, is regular _Kconfig_. Further details about
  32. _Kconfig_: refer to
  33. http://kernel.org/doc/Documentation/kbuild/kconfig-language.txt[].
  34. [[writing-rules-mk]]
  35. The +.mk+ file
  36. ~~~~~~~~~~~~~~
  37. * Assignment: use +=+ preceded and followed by one space:
  38. +
  39. ---------------------
  40. LIBFOO_VERSION = 1.0
  41. LIBFOO_CONF_OPT += --without-python-support
  42. ---------------------
  43. * Indentation: use tab only:
  44. +
  45. ---------------------
  46. define LIBFOO_REMOVE_DOC
  47. $(RM) -fr $(TARGET_DIR)/usr/share/libfoo/doc \
  48. $(TARGET_DIR)/usr/share/man/man3/libfoo*
  49. endef
  50. ---------------------
  51. * Optional dependency:
  52. ** Prefer multi-line syntax.
  53. +
  54. YES:
  55. +
  56. ---------------------
  57. ifeq ($(BR2_PACKAGE_PYTHON),y)
  58. LIBFOO_CONF_OPT += --with-python-support
  59. LIBFOO_DEPENDENCIES += python
  60. else
  61. LIBFOO_CONF_OPT += --without-python-support
  62. endif
  63. ---------------------
  64. +
  65. NO:
  66. +
  67. ---------------------
  68. LIBFOO_CONF_OPT += --with$(if $(BR2_PACKAGE_PYTHON),,out)-python-support
  69. LIBFOO_DEPENDENCIES += $(if $(BR2_PACKAGE_PYTHON),python,)
  70. ---------------------
  71. ** Keep configure options and dependencies close together.
  72. * Optional hooks: keep hook definition and assignment together in one
  73. if block.
  74. +
  75. YES:
  76. +
  77. ---------------------
  78. ifneq ($(BR2_LIBFOO_INSTALL_DATA),y)
  79. define LIBFOO_REMOVE_DATA
  80. $(RM) -fr $(TARGET_DIR)/usr/share/libfoo/data
  81. endef
  82. LIBFOO_POST_INSTALL_TARGET_HOOKS += LIBFOO_REMOVE_DATA
  83. endif
  84. ---------------------
  85. +
  86. NO:
  87. +
  88. ---------------------
  89. define LIBFOO_REMOVE_DATA
  90. $(RM) -fr $(TARGET_DIR)/usr/share/libfoo/data
  91. endef
  92. ifneq ($(BR2_LIBFOO_INSTALL_DATA),y)
  93. LIBFOO_POST_INSTALL_TARGET_HOOKS += LIBFOO_REMOVE_DATA
  94. endif
  95. ---------------------
  96. The documentation
  97. ~~~~~~~~~~~~~~~~~
  98. The documentation uses the
  99. http://www.methods.co.nz/asciidoc/[asciidoc] format.
  100. Further details about the http://www.methods.co.nz/asciidoc/[asciidoc]
  101. syntax: refer to http://www.methods.co.nz/asciidoc/userguide.html[].