2012-11-11 04:14:51 +01:00
|
|
|
// -*- mode:doc; -*-
|
2013-02-13 13:59:02 +01:00
|
|
|
// vim: set syntax=asciidoc:
|
2012-11-11 04:14:51 +01:00
|
|
|
|
2012-11-27 12:59:17 +01:00
|
|
|
Coding style
|
|
|
|
------------
|
2012-11-11 04:14:51 +01:00
|
|
|
|
2012-11-27 12:59:17 +01:00
|
|
|
Overall, these coding style rules are here to help you to add new files in
|
2012-11-11 04:14:51 +01:00
|
|
|
Buildroot or refactor existing ones.
|
|
|
|
|
|
|
|
If you slightly modify some existing file, the important thing is
|
2012-11-27 12:59:17 +01:00
|
|
|
to keep the consistency of the whole file, so you can:
|
|
|
|
|
|
|
|
* either follow the potentially deprecated coding style used in this
|
|
|
|
file,
|
|
|
|
|
|
|
|
* or entirely rework it in order to make it comply with these rules.
|
2012-11-11 04:14:51 +01:00
|
|
|
|
|
|
|
[[writing-rules-config-in]]
|
|
|
|
|
|
|
|
+Config.in+ file
|
|
|
|
~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
+Config.in+ files contain entries for almost anything configurable in
|
|
|
|
Buildroot.
|
|
|
|
|
|
|
|
An entry has the following pattern:
|
|
|
|
|
|
|
|
---------------------
|
|
|
|
config BR2_PACKAGE_LIBFOO
|
|
|
|
bool "libfoo"
|
|
|
|
depends on BR2_PACKAGE_LIBBAZ
|
|
|
|
select BR2_PACKAGE_LIBBAR
|
|
|
|
help
|
|
|
|
This is a comment that explains what libfoo is.
|
|
|
|
|
|
|
|
http://foosoftware.org/libfoo/
|
|
|
|
---------------------
|
|
|
|
|
|
|
|
* The +bool+, +depends on+, +select+ and +help+ lines are indented
|
|
|
|
with one tab.
|
|
|
|
|
|
|
|
* The help text itself should be indented with one tab and two
|
|
|
|
spaces.
|
|
|
|
|
2012-11-27 12:59:17 +01:00
|
|
|
The +Config.in+ files are the input for the configuration tool
|
|
|
|
used in Buildroot, which is the regular _Kconfig_. For further
|
|
|
|
details about the _Kconfig_ language, refer to
|
2012-11-11 04:14:51 +01:00
|
|
|
http://kernel.org/doc/Documentation/kbuild/kconfig-language.txt[].
|
|
|
|
|
|
|
|
[[writing-rules-mk]]
|
|
|
|
|
|
|
|
The +.mk+ file
|
|
|
|
~~~~~~~~~~~~~~
|
|
|
|
|
2013-06-08 00:34:38 +02:00
|
|
|
* Header: The file starts with a header. It contains the module name,
|
|
|
|
preferably in lowercase, enclosed between separators made of 80 hashes. A
|
|
|
|
blank line is mandatory after the header:
|
|
|
|
+
|
|
|
|
---------------------
|
|
|
|
################################################################################
|
|
|
|
#
|
|
|
|
# libfoo
|
|
|
|
#
|
|
|
|
################################################################################
|
|
|
|
---------------------
|
|
|
|
+
|
2012-11-11 04:14:51 +01:00
|
|
|
* Assignment: use +=+ preceded and followed by one space:
|
|
|
|
+
|
|
|
|
---------------------
|
|
|
|
LIBFOO_VERSION = 1.0
|
|
|
|
LIBFOO_CONF_OPT += --without-python-support
|
|
|
|
---------------------
|
2012-11-27 12:59:17 +01:00
|
|
|
+
|
|
|
|
It is also possible to align the +=+ signs:
|
|
|
|
+
|
|
|
|
---------------------
|
|
|
|
LIBFOO_VERSION = 1.0
|
|
|
|
LIBFOO_SOURCE = foo-$(LIBFOO_VERSION).tar.gz
|
|
|
|
LIBFOO_CONF_OPT += --without-python-support
|
|
|
|
---------------------
|
2012-11-11 04:14:51 +01:00
|
|
|
|
|
|
|
* Indentation: use tab only:
|
|
|
|
+
|
|
|
|
---------------------
|
|
|
|
define LIBFOO_REMOVE_DOC
|
2012-11-27 12:59:17 +01:00
|
|
|
$(RM) -fr $(TARGET_DIR)/usr/share/libfoo/doc \
|
|
|
|
$(TARGET_DIR)/usr/share/man/man3/libfoo*
|
2012-11-11 04:14:51 +01:00
|
|
|
endef
|
|
|
|
---------------------
|
2012-11-27 12:59:17 +01:00
|
|
|
+
|
|
|
|
Note that commands inside a +define+ block should always start with a tab,
|
|
|
|
so _make_ recognizes them as commands.
|
2012-11-11 04:14:51 +01:00
|
|
|
|
|
|
|
* Optional dependency:
|
|
|
|
|
|
|
|
** Prefer multi-line syntax.
|
|
|
|
+
|
|
|
|
YES:
|
|
|
|
+
|
|
|
|
---------------------
|
|
|
|
ifeq ($(BR2_PACKAGE_PYTHON),y)
|
|
|
|
LIBFOO_CONF_OPT += --with-python-support
|
|
|
|
LIBFOO_DEPENDENCIES += python
|
|
|
|
else
|
|
|
|
LIBFOO_CONF_OPT += --without-python-support
|
|
|
|
endif
|
|
|
|
---------------------
|
|
|
|
+
|
|
|
|
NO:
|
|
|
|
+
|
|
|
|
---------------------
|
|
|
|
LIBFOO_CONF_OPT += --with$(if $(BR2_PACKAGE_PYTHON),,out)-python-support
|
|
|
|
LIBFOO_DEPENDENCIES += $(if $(BR2_PACKAGE_PYTHON),python,)
|
|
|
|
---------------------
|
|
|
|
|
|
|
|
** Keep configure options and dependencies close together.
|
|
|
|
|
|
|
|
* Optional hooks: keep hook definition and assignment together in one
|
|
|
|
if block.
|
|
|
|
+
|
|
|
|
YES:
|
|
|
|
+
|
|
|
|
---------------------
|
|
|
|
ifneq ($(BR2_LIBFOO_INSTALL_DATA),y)
|
|
|
|
define LIBFOO_REMOVE_DATA
|
|
|
|
$(RM) -fr $(TARGET_DIR)/usr/share/libfoo/data
|
|
|
|
endef
|
|
|
|
LIBFOO_POST_INSTALL_TARGET_HOOKS += LIBFOO_REMOVE_DATA
|
|
|
|
endif
|
|
|
|
---------------------
|
|
|
|
+
|
|
|
|
NO:
|
|
|
|
+
|
|
|
|
---------------------
|
|
|
|
define LIBFOO_REMOVE_DATA
|
|
|
|
$(RM) -fr $(TARGET_DIR)/usr/share/libfoo/data
|
|
|
|
endef
|
|
|
|
|
|
|
|
ifneq ($(BR2_LIBFOO_INSTALL_DATA),y)
|
|
|
|
LIBFOO_POST_INSTALL_TARGET_HOOKS += LIBFOO_REMOVE_DATA
|
|
|
|
endif
|
|
|
|
---------------------
|
|
|
|
|
|
|
|
The documentation
|
|
|
|
~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
The documentation uses the
|
|
|
|
http://www.methods.co.nz/asciidoc/[asciidoc] format.
|
|
|
|
|
2012-11-27 12:59:16 +01:00
|
|
|
For further details about the http://www.methods.co.nz/asciidoc/[asciidoc]
|
|
|
|
syntax, refer to http://www.methods.co.nz/asciidoc/userguide.html[].
|