OpenBricks Configuration System
===============================

Introduction
------------

OpenBricks uses a Kconfig-based interface to allow the user to customize the
system to suit his requirements. The configuration menu is built from several
sources:

* the main Kconfig definition file (config/Kconfig.main)
* the architecture Kconfig file (config/Kconfig.arch)
* the generated Kconfig files (build/config/Kconfig.*)

The following table details the various generated Kconfig files:

.Generated Kconfig files
[options="header"]
|============================================================================================================================
|Kconfig file     |Creator script           |Source material                        |Kconfig menu
|Kconfig.version  |scripts/version2kconfig  |VERSION                                |Version header
|Kconfig.flavours |scripts/flavours2kconfig |config/flavours/*/meta                 |Flavour, Distribution name
|Kconfig.arch     |scripts/archs2kconfig    |config/platforms/*/meta                |General setup -> Target arch
|Kconfig.platform |scripts/platforms2kconfig|config/platforms/\*/*/meta             |General setup -> Target platform
|Kconfig.machine  |scripts/machines2kconfig |config/platforms/\*/\*/machines/*/meta |General setup -> Target machine
|Kconfig.remote   |scripts/remotes2kconfig  |packages/lirc*/config/lircd*           |Settings -> Remote, Settings -> Receiver
|Kconfig.use      |scripts/use2kconfig      |config/use                             |Features
|Kconfig.packages |scripts/meta2kconfig     |packages/*/meta                        |Packages
|============================================================================================================================

After the user has completed the configuration selections, a .config file is
created. The .config file is used by scripts/kconfig2options to create
build/config/options, which is the file actually used by the rest of the
OpenBricks build system (it is sourced through config/options).

Kconfig syntax
--------------

For general informations about the Kconfig syntax refer to
DOCS/kconfig-language.txt. In addition to the syntax specifications, OpenBricks
uses some conventions in its Kconfig files:

* hand-written Kconfig entries (e.g. TARGET_LIBC) are in uppercase, but
  subentries can be in lowercase (e.g. TARGET_LIBC_eglibc);
* all entries starting with the 'OPT_' prefix are exported to 
  build/config/options; for example, OPT_TOOLCHAIN_CXX=y in .config will become
  TOOLCHAIN_CXX=yes in build/config/options;
* all features have a USE_feature entry (e.g. USE_bluetooth)
* all packages have a PKG_package entry (e.g. PKG_MPlayer)

Configuration menu elements
---------------------------

Flavours
~~~~~~~~

Flavours are defined in config/flavours, where every flavour has a
subdirectory. Most settings are defined in the meta file:

* FLAVOUR_NAME
 ** the name of the flavour
 ** must coincide with the flavour directory name
* FLAVOUR_DISTRONAME
 ** the user-visible flavour name
* FLAVOUR_DEPENDS
 ** the packages the flavour requires to be installed
 ** can be 'all' to require all packages
 ** defaults to "" (no package)
* FLAVOUR_USE
 ** the features (i.e. use flags) the flavours requires to be enabled by
    default
 ** can be 'all' to require all features
 ** defaults to "" (no feature)
* FLAVOUR_SHORTDESC
 ** used as the short description for the flavour
 ** should be one-line summary
* FLAVOUR_LONGDESC
 ** used as the long description for the flavour

In addition, a flavour can define arch-specific depends using
FLAVOUR_DEPENDS_$arch (e.g. FLAVOUR_DEPENDS_arm). A flavour can
override the default BusyBox configuration with a busybox.conf file in its 
directory.

Architectures
~~~~~~~~~~~~~

Platforms are defined in config/platforms, where every architecture has a
subdirectory. The arch settings are defined in a meta file:

* ARCH_NAME
 ** the name of the architecture
 ** must coincide with the arch directory name
* ARCH_DESC
 ** the user-visible name of the architecture
 ** will be displayed in the Kconfig menu
 ** defaults to ARCH_NAME
* ARCH_HELP
 ** the user-visible help text of the architecture
 ** will be displayed in the Kconfig menu
* ARCH_SUBARCHS
 ** a space-separated list of sub-architecture names (as understood by gcc)
 ** defaults to "" (no subarchs)
* ARCH_CPUS
 ** a space-separated list of CPU names (as understood by gcc)
 ** these CPUs will be common to all the define subarchs

The ARCH_DESC and ARCH_CPUS variables can also be defined for each subarch,
using ARCH_DESC_$subarch and ARCH_CPUS_$subarch.

Platforms
~~~~~~~~~

Platforms are defined in config/platforms; every architecture has a
subdirectory, and all platforms have a subdirectory under one of the arch
subdirectories. Most settings are defined in a meta file:

* PLATFORM_NAME
 ** the name of the platform
 ** must coincide with the platform directory name
* PLATFORM_DESC
 ** the user-visible name of the platform
 ** will be displayed in the Kconfig menu
 ** defaults to PLATFORM_NAME
* PLATFORM_CPU
 ** the default CPU to be selected
 ** defaults to "" (no selection"
* PLATFORM_DEPENDS
 ** the packages the platform requires to be installed
 ** defaults to "" (no package)

In addition, a platform can declare a list of use flags in PLATFORM_USE, to be
able to specify per-useflag dependencies using PLATFORM_DEPENDS_$flag. A 
platform can also override the default kernel configuration with a linux.conf
file, and the default bootargs (for ARM systems using u-boot) with boot.cfg.

A platform can override any package by creating a directory with the package
name (i.e. config/platforms/$arch/$platform/packages/$package/). This can be
used, e.g., to implement platform-specific kernels; in this case the plaform
overrides the linux and linux-headers packages. Refer to the OMAP4 platform
(config/platforms/arm/omap4) for an implementation example.

Machines
~~~~~~~~

Machines are defined in the machines/ subdirectory in the platform directory;
each machine has a subdirectory. Most settings are defined in the meta file:

* MACHINE_NAME
 ** the name of the machine
 ** must coincide with the machine directory name
* MACHINE_DESC
 ** the user-visible name of the machine
 ** will be displayed in the Kconfig menu
 ** defaults to MACHINE_NAME
* MACHINE_CPU
 ** the default CPU to be selected
 ** defaults to "" (no selection"
* MACHINE_DEPENDS
 ** the packages the machine requires to be installed
 ** defaults to "" (no package)
* MACHINE_UBOOT_CONFIG
 ** the name of the u-boot configuration to be used
 ** defaults to "" (no configuration)
* MACHINE_XLOADER_CONFIG
 ** the name of the X-loader configuration to be used
 ** defaults to "" (no configuration)

In addition, a machine can declare a list of use flags in MACHINE_USE, to be
able to specify per-useflag dependencies using MACHINE_DEPENDS_$flag. A machine
can also override the default kernel configuration with a linux.conf file,
and the default bootargs (for ARM systems using u-boot) with boot.cfg.

A machine can override any package by creating a directory with the package
name (i.e. config/platforms/$arch/$platform/machines/$machine/packages/$package/).
This can be used, e.g., to implement machine-specific bootloaders (one example
could be X-loader, which has no generic implementation and is machine-specific).

Remotes
~~~~~~~

Remotes are defined by LIRC configuration files in packages/lirc/config, and a
Kconfig menu is created to allow the used to select the default remote and
receiver to use.

Features
~~~~~~~~

Features are defined in config/use and implemented through use flags. Packages
can define package-specific use flags, but flags common to many packages or
defining user-visible features are declared in config/use and exposed in the
Kconfig interface in the Features menu. Each feature is defined through several
variables:

* PKG_USE_NAME_$flag
 ** the user-visible feature name
* PKG_USE_SECTION_$flag
 ** the section the feature should be placed into
* PKG_USE_DEPENDS_$flag
 ** a list of packages the feature requires to be installed
 ** defaults to "" (no packages)
* PKG_USE_ARCH_$flag
 ** a list of architecture the feature is defined for
 ** defaults to "" (all architectures)

Features are grouped into sections, which are rendered as separate menues in
the Kconfig interface. Sections are defined through several variables:

* PKG_USE_SECTION_DESC_$section
 ** the user-visible section name
* PKG_USE_SECTION_KCONFIG_hwaccel
 ** an optional block of Kconfig instructions which will be rendered in the
    section menu
 ** defaults to ""

Packages
~~~~~~~~

Packages are defined by meta files under the packages/ directory. The Packages
menu in Kconfig is created by reading the meta files and grouping the packages
by sections. Please refer to package-format.txt for more details on packages
creation.

// vim: set syntax=asciidoc:
