python-pathvalidate: bump version to 0.14.1
[buildroot-gz.git] / docs / manual / writing-rules.txt
blobec1ddb1915caa6b337fe3325d7ca6898b726aa09
1 // -*- mode:doc; -*-
2 // vim: set syntax=asciidoc:
4 == Coding style
6 Overall, these coding style rules are here to help you to add new files in
7 Buildroot or refactor existing ones.
9 If you slightly modify some existing file, the important thing is
10 to keep the consistency of the whole file, so you can:
12 * either follow the potentially deprecated coding style used in this
13 file,
15 * or entirely rework it in order to make it comply with these rules.
17 [[writing-rules-config-in]]
19 === +Config.in+ file
21 +Config.in+ files contain entries for almost anything configurable in
22 Buildroot.
24 An entry has the following pattern:
26 ---------------------
27 config BR2_PACKAGE_LIBFOO
28         bool "libfoo"
29         depends on BR2_PACKAGE_LIBBAZ
30         select BR2_PACKAGE_LIBBAR
31         help
32           This is a comment that explains what libfoo is.
34           http://foosoftware.org/libfoo/
35 ---------------------
37 * The +bool+, +depends on+, +select+ and +help+ lines are indented
38   with one tab.
40 * The help text itself should be indented with one tab and two
41   spaces.
43 * The help text should be wrapped to fit 72 columns.
45 The +Config.in+ files are the input for the configuration tool
46 used in Buildroot, which is the regular _Kconfig_. For further
47 details about the _Kconfig_ language, refer to
48 http://kernel.org/doc/Documentation/kbuild/kconfig-language.txt[].
50 [[writing-rules-mk]]
52 === The +.mk+ file
54 * Header: The file starts with a header. It contains the module name,
55 preferably in lowercase, enclosed between separators made of 80 hashes. A
56 blank line is mandatory after the header:
58 ---------------------
59 ################################################################################
61 # libfoo
63 ################################################################################
64 ---------------------
66 * Assignment: use +=+ preceded and followed by one space:
68 ---------------------
69 LIBFOO_VERSION = 1.0
70 LIBFOO_CONF_OPTS += --without-python-support
71 ---------------------
73 Do not align the +=+ signs.
75 * Indentation: use tab only:
77 ---------------------
78 define LIBFOO_REMOVE_DOC
79         $(RM) -fr $(TARGET_DIR)/usr/share/libfoo/doc \
80                 $(TARGET_DIR)/usr/share/man/man3/libfoo*
81 endef
82 ---------------------
84 Note that commands inside a +define+ block should always start with a tab,
85 so _make_ recognizes them as commands.
87 * Optional dependency:
89 ** Prefer multi-line syntax.
91 YES:
93 ---------------------
94 ifeq ($(BR2_PACKAGE_PYTHON),y)
95 LIBFOO_CONF_OPTS += --with-python-support
96 LIBFOO_DEPENDENCIES += python
97 else
98 LIBFOO_CONF_OPTS += --without-python-support
99 endif
100 ---------------------
104 ---------------------
105 LIBFOO_CONF_OPTS += --with$(if $(BR2_PACKAGE_PYTHON),,out)-python-support
106 LIBFOO_DEPENDENCIES += $(if $(BR2_PACKAGE_PYTHON),python,)
107 ---------------------
109 ** Keep configure options and dependencies close together.
111 * Optional hooks: keep hook definition and assignment together in one
112   if block.
114 YES:
116 ---------------------
117 ifneq ($(BR2_LIBFOO_INSTALL_DATA),y)
118 define LIBFOO_REMOVE_DATA
119         $(RM) -fr $(TARGET_DIR)/usr/share/libfoo/data
120 endef
121 LIBFOO_POST_INSTALL_TARGET_HOOKS += LIBFOO_REMOVE_DATA
122 endif
123 ---------------------
127 ---------------------
128 define LIBFOO_REMOVE_DATA
129         $(RM) -fr $(TARGET_DIR)/usr/share/libfoo/data
130 endef
132 ifneq ($(BR2_LIBFOO_INSTALL_DATA),y)
133 LIBFOO_POST_INSTALL_TARGET_HOOKS += LIBFOO_REMOVE_DATA
134 endif
135 ---------------------
137 === The documentation
139 The documentation uses the
140 http://www.methods.co.nz/asciidoc/[asciidoc] format.
142 For further details about the http://www.methods.co.nz/asciidoc/[asciidoc]
143 syntax, refer to http://www.methods.co.nz/asciidoc/userguide.html[].