Browse Source

docs: kbuild: convert docs to ReST and rename to *.rst

The kbuild documentation clearly shows that the documents
there are written at different times: some use markdown,
some use their own peculiar logic to split sections.

Convert everything to ReST without affecting too much
the author's style and avoiding adding uneeded markups.

The conversion is actually:
  - add blank lines and identation in order to identify paragraphs;
  - fix tables markups;
  - add some lists markups;
  - mark literal blocks;
  - adjust title markups.

At its new index.rst, let's add a :orphan: while this is not linked to
the main index.rst file, in order to avoid build warnings.

Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
tags/v5.3-rc1
Mauro Carvalho Chehab 5 months ago
parent
commit
cd238effef
48 changed files with 846 additions and 567 deletions
  1. 1
    1
      Documentation/admin-guide/README.rst
  2. 3
    2
      Documentation/kbuild/headers_install.rst
  3. 27
    0
      Documentation/kbuild/index.rst
  4. 11
    0
      Documentation/kbuild/issues.rst
  5. 68
    51
      Documentation/kbuild/kbuild.rst
  6. 131
    111
      Documentation/kbuild/kconfig-language.rst
  7. 21
    16
      Documentation/kbuild/kconfig-macro-language.rst
  8. 82
    54
      Documentation/kbuild/kconfig.rst
  9. 335
    195
      Documentation/kbuild/makefiles.rst
  10. 100
    70
      Documentation/kbuild/modules.rst
  11. 2
    2
      Documentation/kernel-hacking/hacking.rst
  12. 1
    1
      Documentation/process/coding-style.rst
  13. 1
    1
      Documentation/process/submit-checklist.rst
  14. 2
    2
      Documentation/translations/it_IT/kernel-hacking/hacking.rst
  15. 1
    1
      Documentation/translations/it_IT/process/coding-style.rst
  16. 1
    1
      Documentation/translations/it_IT/process/submit-checklist.rst
  17. 1
    1
      Documentation/translations/zh_CN/process/coding-style.rst
  18. 1
    1
      Documentation/translations/zh_CN/process/submit-checklist.rst
  19. 1
    1
      Kconfig
  20. 1
    1
      arch/arc/plat-eznps/Kconfig
  21. 1
    1
      arch/c6x/Kconfig
  22. 1
    1
      arch/microblaze/Kconfig.debug
  23. 1
    1
      arch/microblaze/Kconfig.platform
  24. 1
    1
      arch/nds32/Kconfig
  25. 1
    1
      arch/openrisc/Kconfig
  26. 1
    1
      arch/powerpc/sysdev/Kconfig
  27. 1
    1
      arch/riscv/Kconfig
  28. 1
    1
      drivers/auxdisplay/Kconfig
  29. 1
    1
      drivers/firmware/Kconfig
  30. 1
    1
      drivers/mtd/devices/Kconfig
  31. 3
    3
      drivers/net/ethernet/smsc/Kconfig
  32. 2
    2
      drivers/net/wireless/intel/iwlegacy/Kconfig
  33. 1
    1
      drivers/net/wireless/intel/iwlwifi/Kconfig
  34. 1
    1
      drivers/parport/Kconfig
  35. 2
    2
      drivers/scsi/Kconfig
  36. 1
    1
      drivers/staging/sm750fb/Kconfig
  37. 2
    2
      drivers/usb/misc/Kconfig
  38. 7
    7
      drivers/video/fbdev/Kconfig
  39. 1
    1
      net/bridge/netfilter/Kconfig
  40. 1
    1
      net/ipv4/netfilter/Kconfig
  41. 1
    1
      net/ipv6/netfilter/Kconfig
  42. 8
    8
      net/netfilter/Kconfig
  43. 1
    1
      net/tipc/Kconfig
  44. 2
    2
      scripts/Kbuild.include
  45. 1
    1
      scripts/Makefile.host
  46. 1
    1
      scripts/kconfig/symbol.c
  47. 7
    7
      scripts/kconfig/tests/err_recursive_dep/expected_stderr
  48. 3
    3
      sound/oss/dmasound/Kconfig

+ 1
- 1
Documentation/admin-guide/README.rst View File

@@ -227,7 +227,7 @@ Configuring the kernel
"make tinyconfig" Configure the tiniest possible kernel.

You can find more information on using the Linux kernel config tools
in Documentation/kbuild/kconfig.txt.
in Documentation/kbuild/kconfig.rst.

- NOTES on ``make config``:


Documentation/kbuild/headers_install.txt → Documentation/kbuild/headers_install.rst View File

@@ -1,3 +1,4 @@
=============================================
Exporting kernel headers for use by userspace
=============================================

@@ -22,14 +23,14 @@ older kernel.

The "make headers_install" command can be run in the top level directory of the
kernel source code (or using a standard out-of-tree build). It takes two
optional arguments:
optional arguments::

make headers_install ARCH=i386 INSTALL_HDR_PATH=/usr

ARCH indicates which architecture to produce headers for, and defaults to the
current architecture. The linux/asm directory of the exported kernel headers
is platform-specific, to see a complete list of supported architectures use
the command:
the command::

ls -d include/asm-* | sed 's/.*-//'


+ 27
- 0
Documentation/kbuild/index.rst View File

@@ -0,0 +1,27 @@
:orphan:

===================
Kernel Build System
===================

.. toctree::
:maxdepth: 1

kconfig-language
kconfig-macro-language

kbuild
kconfig
makefiles
modules

headers_install

issues

.. only:: subproject and html

Indices
=======

* :ref:`genindex`

+ 11
- 0
Documentation/kbuild/issues.rst View File

@@ -0,0 +1,11 @@
Recursion issue #1
------------------

.. include:: Kconfig.recursion-issue-01
:literal:

Recursion issue #2
------------------

.. include:: Kconfig.recursion-issue-02
:literal:

Documentation/kbuild/kbuild.txt → Documentation/kbuild/kbuild.rst View File

@@ -1,13 +1,19 @@
======
Kbuild
======


Output files
============

modules.order
--------------------------------------------------
-------------
This file records the order in which modules appear in Makefiles. This
is used by modprobe to deterministically resolve aliases that match
multiple modules.

modules.builtin
--------------------------------------------------
---------------
This file lists all modules that are built into the kernel. This is used
by modprobe to not fail when trying to load something builtin.

@@ -18,84 +24,90 @@ Unlike modinfo of a separate module, all fields are prefixed with module name.


Environment variables
=====================

KCPPFLAGS
--------------------------------------------------
---------
Additional options to pass when preprocessing. The preprocessing options
will be used in all cases where kbuild does preprocessing including
building C files and assembler files.

KAFLAGS
--------------------------------------------------
-------
Additional options to the assembler (for built-in and modules).

AFLAGS_MODULE
--------------------------------------------------
-------------
Additional module specific options to use for $(AS).

AFLAGS_KERNEL
--------------------------------------------------
-------------
Additional options for $(AS) when used for assembler
code for code that is compiled as built-in.

KCFLAGS
--------------------------------------------------
-------
Additional options to the C compiler (for built-in and modules).

CFLAGS_KERNEL
--------------------------------------------------
-------------
Additional options for $(CC) when used to compile
code that is compiled as built-in.

CFLAGS_MODULE
--------------------------------------------------
-------------
Additional module specific options to use for $(CC).

LDFLAGS_MODULE
--------------------------------------------------
--------------
Additional options used for $(LD) when linking modules.

HOSTCFLAGS
--------------------------------------------------
----------
Additional flags to be passed to $(HOSTCC) when building host programs.

HOSTCXXFLAGS
--------------------------------------------------
------------
Additional flags to be passed to $(HOSTCXX) when building host programs.

HOSTLDFLAGS
--------------------------------------------------
-----------
Additional flags to be passed when linking host programs.

HOSTLDLIBS
--------------------------------------------------
----------
Additional libraries to link against when building host programs.

KBUILD_KCONFIG
--------------------------------------------------
--------------
Set the top-level Kconfig file to the value of this environment
variable. The default name is "Kconfig".

KBUILD_VERBOSE
--------------------------------------------------
--------------
Set the kbuild verbosity. Can be assigned same values as "V=...".

See make help for the full list.

Setting "V=..." takes precedence over KBUILD_VERBOSE.

KBUILD_EXTMOD
--------------------------------------------------
-------------
Set the directory to look for the kernel source when building external
modules.

Setting "M=..." takes precedence over KBUILD_EXTMOD.

KBUILD_OUTPUT
--------------------------------------------------
-------------
Specify the output directory when building the kernel.

The output directory can also be specified using "O=...".

Setting "O=..." takes precedence over KBUILD_OUTPUT.

KBUILD_DEBARCH
--------------------------------------------------
--------------
For the deb-pkg target, allows overriding the normal heuristics deployed by
deb-pkg. Normally deb-pkg attempts to guess the right architecture based on
the UTS_MACHINE variable, and on some architectures also the kernel config.
@@ -103,44 +115,48 @@ The value of KBUILD_DEBARCH is assumed (not checked) to be a valid Debian
architecture.

ARCH
--------------------------------------------------
----
Set ARCH to the architecture to be built.

In most cases the name of the architecture is the same as the
directory name found in the arch/ directory.

But some architectures such as x86 and sparc have aliases.
x86: i386 for 32 bit, x86_64 for 64 bit
sh: sh for 32 bit, sh64 for 64 bit
sparc: sparc32 for 32 bit, sparc64 for 64 bit

- x86: i386 for 32 bit, x86_64 for 64 bit
- sh: sh for 32 bit, sh64 for 64 bit
- sparc: sparc32 for 32 bit, sparc64 for 64 bit

CROSS_COMPILE
--------------------------------------------------
-------------
Specify an optional fixed part of the binutils filename.
CROSS_COMPILE can be a part of the filename or the full path.

CROSS_COMPILE is also used for ccache in some setups.

CF
--------------------------------------------------
--
Additional options for sparse.
CF is often used on the command-line like this:

CF is often used on the command-line like this::

make CF=-Wbitwise C=2

INSTALL_PATH
--------------------------------------------------
------------
INSTALL_PATH specifies where to place the updated kernel and system map
images. Default is /boot, but you can set it to other values.

INSTALLKERNEL
--------------------------------------------------
-------------
Install script called when using "make install".
The default name is "installkernel".

The script will be called with the following arguments:
$1 - kernel version
$2 - kernel image file
$3 - kernel map file
$4 - default install path (use root directory if blank)
- $1 - kernel version
- $2 - kernel image file
- $3 - kernel map file
- $4 - default install path (use root directory if blank)

The implementation of "make install" is architecture specific
and it may differ from the above.
@@ -149,32 +165,33 @@ INSTALLKERNEL is provided to enable the possibility to
specify a custom installer when cross compiling a kernel.

MODLIB
--------------------------------------------------
------
Specify where to install modules.
The default value is:
The default value is::

$(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)

The value can be overridden in which case the default value is ignored.

INSTALL_MOD_PATH
--------------------------------------------------
----------------
INSTALL_MOD_PATH specifies a prefix to MODLIB for module directory
relocations required by build roots. This is not defined in the
makefile but the argument can be passed to make if needed.

INSTALL_MOD_STRIP
--------------------------------------------------
-----------------
INSTALL_MOD_STRIP, if defined, will cause modules to be
stripped after they are installed. If INSTALL_MOD_STRIP is '1', then
the default option --strip-debug will be used. Otherwise,
INSTALL_MOD_STRIP value will be used as the options to the strip command.

INSTALL_HDR_PATH
--------------------------------------------------
----------------
INSTALL_HDR_PATH specifies where to install user space headers when
executing "make headers_*".
The default value is:

The default value is::

$(objtree)/usr

@@ -184,65 +201,65 @@ The output directory is often set using "O=..." on the commandline.
The value can be overridden in which case the default value is ignored.

KBUILD_SIGN_PIN
--------------------------------------------------
---------------
This variable allows a passphrase or PIN to be passed to the sign-file
utility when signing kernel modules, if the private key requires such.

KBUILD_MODPOST_WARN
--------------------------------------------------
-------------------
KBUILD_MODPOST_WARN can be set to avoid errors in case of undefined
symbols in the final module linking stage. It changes such errors
into warnings.

KBUILD_MODPOST_NOFINAL
--------------------------------------------------
----------------------
KBUILD_MODPOST_NOFINAL can be set to skip the final link of modules.
This is solely useful to speed up test compiles.

KBUILD_EXTRA_SYMBOLS
--------------------------------------------------
--------------------
For modules that use symbols from other modules.
See more details in modules.txt.

ALLSOURCE_ARCHS
--------------------------------------------------
---------------
For tags/TAGS/cscope targets, you can specify more than one arch
to be included in the databases, separated by blank space. E.g.:
to be included in the databases, separated by blank space. E.g.::

$ make ALLSOURCE_ARCHS="x86 mips arm" tags

To get all available archs you can also specify all. E.g.:
To get all available archs you can also specify all. E.g.::

$ make ALLSOURCE_ARCHS=all tags

KBUILD_ENABLE_EXTRA_GCC_CHECKS
--------------------------------------------------
------------------------------
If enabled over the make command line with "W=1", it turns on additional
gcc -W... options for more extensive build-time checking.

KBUILD_BUILD_TIMESTAMP
--------------------------------------------------
----------------------
Setting this to a date string overrides the timestamp used in the
UTS_VERSION definition (uname -v in the running kernel). The value has to
be a string that can be passed to date -d. The default value
is the output of the date command at one point during build.

KBUILD_BUILD_USER, KBUILD_BUILD_HOST
--------------------------------------------------
------------------------------------
These two variables allow to override the user@host string displayed during
boot and in /proc/version. The default value is the output of the commands
whoami and host, respectively.

KBUILD_LDS
--------------------------------------------------
----------
The linker script with full path. Assigned by the top-level Makefile.

KBUILD_VMLINUX_OBJS
--------------------------------------------------
-------------------
All object files for vmlinux. They are linked to vmlinux in the same
order as listed in KBUILD_VMLINUX_OBJS.

KBUILD_VMLINUX_LIBS
--------------------------------------------------
-------------------
All .a "lib" files for vmlinux. KBUILD_VMLINUX_OBJS and KBUILD_VMLINUX_LIBS
together specify all the object files used to link vmlinux.

Documentation/kbuild/kconfig-language.txt → Documentation/kbuild/kconfig-language.rst View File

@@ -1,8 +1,12 @@
================
Kconfig Language
================

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

The configuration database is a collection of configuration options
organized in a tree structure:
organized in a tree structure::

+- Code maturity level options
| +- Prompt for development and/or incomplete code/drivers
@@ -25,9 +29,9 @@ Menu entries
------------

Most entries define a config option; all other entries help to organize
them. A single configuration option is defined like this:
them. A single configuration option is defined like this::

config MODVERSIONS
config MODVERSIONS
bool "Set version information on all module symbols"
depends on MODULES
help
@@ -52,10 +56,12 @@ applicable everywhere (see syntax).
Every config option must have a type. There are only two basic types:
tristate and string; the other types are based on these two. The type
definition optionally accepts an input prompt, so these two examples
are equivalent:
are equivalent::

bool "Networking support"
and

and::

bool
prompt "Networking support"

@@ -98,8 +104,10 @@ applicable everywhere (see syntax).
d) Hardware or infrastructure that everybody expects, such as CONFIG_NET
or CONFIG_BLOCK. These are rare exceptions.

- type definition + default value:
- type definition + default value::

"def_bool"/"def_tristate" <expr> ["if" <expr>]

This is a shorthand notation for a type definition plus a value.
Optionally dependencies for this default value can be added with "if".

@@ -107,11 +115,13 @@ applicable everywhere (see syntax).
This defines a dependency for this menu entry. If multiple
dependencies are defined, they are connected with '&&'. Dependencies
are applied to all other options within this menu entry (which also
accept an "if" expression), so these two examples are equivalent:
accept an "if" expression), so these two examples are equivalent::

bool "foo" if BAR
default y if BAR
and

and::

depends on BAR
bool "foo"
default y
@@ -124,6 +134,7 @@ applicable everywhere (see syntax).
times, the limit is set to the largest selection.
Reverse dependencies can only be used with boolean or tristate
symbols.

Note:
select should be used with care. select will force
a symbol to a value without visiting the dependencies.
@@ -139,24 +150,26 @@ applicable everywhere (see syntax).
symbol except that the "implied" symbol's value may still be set to n
from a direct dependency or with a visible prompt.

Given the following example:
Given the following example::

config FOO
config FOO
tristate
imply BAZ

config BAZ
config BAZ
tristate
depends on BAR

The following values are possible:

=== === ============= ==============
FOO BAR BAZ's default choice for BAZ
--- --- ------------- --------------
=== === ============= ==============
n y n N/m/y
m y m M/y/n
y y y Y/n
y n * N
=== === ============= ==============

This is useful e.g. with multiple drivers that want to indicate their
ability to hook into a secondary subsystem while allowing the user to
@@ -208,9 +221,9 @@ Menu dependencies
Dependencies define the visibility of a menu entry and can also reduce
the input range of tristate symbols. The tristate logic used in the
expressions uses one more state than normal boolean logic to express the
module state. Dependency expressions have the following syntax:
module state. Dependency expressions have the following syntax::

<expr> ::= <symbol> (1)
<expr> ::= <symbol> (1)
<symbol> '=' <symbol> (2)
<symbol> '!=' <symbol> (3)
<symbol1> '<' <symbol2> (4)
@@ -222,7 +235,7 @@ module state. Dependency expressions have the following syntax:
<expr> '&&' <expr> (7)
<expr> '||' <expr> (8)

Expressions are listed in decreasing order of precedence.
Expressions are listed in decreasing order of precedence.

(1) Convert the symbol into an expression. Boolean and tristate symbols
are simply converted into the respective expression values. All
@@ -255,15 +268,15 @@ Menu structure
--------------

The position of a menu entry in the tree is determined in two ways. First
it can be specified explicitly:
it can be specified explicitly::

menu "Network device support"
menu "Network device support"
depends on NET

config NETDEVICES
config NETDEVICES
...

endmenu
endmenu

All entries within the "menu" ... "endmenu" block become a submenu of
"Network device support". All subentries inherit the dependencies from
@@ -275,17 +288,18 @@ dependencies. If a menu entry somehow depends on the previous entry, it
can be made a submenu of it. First, the previous (parent) symbol must
be part of the dependency list and then one of these two conditions
must be true:

- the child entry must become invisible, if the parent is set to 'n'
- the child entry must only be visible, if the parent is visible
- the child entry must only be visible, if the parent is visible::

config MODULES
config MODULES
bool "Enable loadable module support"

config MODVERSIONS
config MODVERSIONS
bool "Set version information on all module symbols"
depends on MODULES

comment "module support disabled"
comment "module support disabled"
depends on !MODULES

MODVERSIONS directly depends on MODULES, this means it's only visible if
@@ -299,6 +313,7 @@ Kconfig syntax
The configuration file describes a series of menu entries, where every
line starts with a keyword (except help texts). The following keywords
end a menu entry:

- config
- menuconfig
- choice/endchoice
@@ -306,17 +321,17 @@ end a menu entry:
- menu/endmenu
- if/endif
- source
The first five also start the definition of a menu entry.

config:
The first five also start the definition of a menu entry.

config::
"config" <symbol>
<config options>

This defines a config symbol <symbol> and accepts any of above
attributes as options.

menuconfig:
menuconfig::
"menuconfig" <symbol>
<config options>

@@ -325,43 +340,43 @@ hint to front ends, that all suboptions should be displayed as a
separate list of options. To make sure all the suboptions will really
show up under the menuconfig entry and not outside of it, every item
from the <config options> list must depend on the menuconfig symbol.
In practice, this is achieved by using one of the next two constructs:
(1):
menuconfig M
if M
config C1
config C2
endif
(2):
menuconfig M
config C1
depends on M
config C2
depends on M
In practice, this is achieved by using one of the next two constructs::
(1):
menuconfig M
if M
config C1
config C2
endif
(2):
menuconfig M
config C1
depends on M
config C2
depends on M

In the following examples (3) and (4), C1 and C2 still have the M
dependency, but will not appear under menuconfig M anymore, because
of C0, which doesn't depend on M:
(3):
menuconfig M
config C0
if M
config C1
config C2
endif
(4):
menuconfig M
config C0
config C1
depends on M
config C2
depends on M
choices:
of C0, which doesn't depend on M::
(3):
menuconfig M
config C0
if M
config C1
config C2
endif
(4):
menuconfig M
config C0
config C1
depends on M
config C2
depends on M
choices::

"choice" [symbol]
<choice options>
@@ -387,7 +402,7 @@ definitions of that choice. If a [symbol] is associated to the choice,
then you may define the same choice (i.e. with the same entries) in another
place.

comment:
comment::

"comment" <prompt>
<comment options>
@@ -396,7 +411,7 @@ This defines a comment which is displayed to the user during the
configuration process and is also echoed to the output files. The only
possible options are dependencies.

menu:
menu::

"menu" <prompt>
<menu options>
@@ -407,7 +422,7 @@ This defines a menu block, see "Menu structure" above for more
information. The only possible options are dependencies and "visible"
attributes.

if:
if::

"if" <expr>
<if block>
@@ -416,13 +431,13 @@ if:
This defines an if block. The dependency expression <expr> is appended
to all enclosed menu entries.

source:
source::

"source" <prompt>

This reads the specified configuration file. This file is always parsed.

mainmenu:
mainmenu::

"mainmenu" <prompt>

@@ -452,20 +467,21 @@ that is defined in a common Kconfig file and selected by the relevant
architectures.
An example is the generic IOMAP functionality.

We would in lib/Kconfig see:
We would in lib/Kconfig see::

# Generic IOMAP is used to ...
config HAVE_GENERIC_IOMAP
# Generic IOMAP is used to ...
config HAVE_GENERIC_IOMAP

config GENERIC_IOMAP
config GENERIC_IOMAP
depends on HAVE_GENERIC_IOMAP && FOO

And in lib/Makefile we would see:
obj-$(CONFIG_GENERIC_IOMAP) += iomap.o
And in lib/Makefile we would see::

For each architecture using the generic IOMAP functionality we would see:
obj-$(CONFIG_GENERIC_IOMAP) += iomap.o

config X86
For each architecture using the generic IOMAP functionality we would see::

config X86
select ...
select HAVE_GENERIC_IOMAP
select ...
@@ -484,25 +500,25 @@ Adding features that need compiler support

There are several features that need compiler support. The recommended way
to describe the dependency on the compiler feature is to use "depends on"
followed by a test macro.
followed by a test macro::

config STACKPROTECTOR
config STACKPROTECTOR
bool "Stack Protector buffer overflow detection"
depends on $(cc-option,-fstack-protector)
...

If you need to expose a compiler capability to makefiles and/or C source files,
CC_HAS_ is the recommended prefix for the config option.
`CC_HAS_` is the recommended prefix for the config option::

config CC_HAS_STACKPROTECTOR_NONE
config CC_HAS_STACKPROTECTOR_NONE
def_bool $(cc-option,-fno-stack-protector)

Build as module only
~~~~~~~~~~~~~~~~~~~~
To restrict a component build to module-only, qualify its config symbol
with "depends on m". E.g.:
with "depends on m". E.g.::

config FOO
config FOO
depends on BAR && m

limits FOO to module (=m) or disabled (=n).
@@ -529,18 +545,18 @@ Simple Kconfig recursive issue

Read: Documentation/kbuild/Kconfig.recursion-issue-01

Test with:
Test with::

make KBUILD_KCONFIG=Documentation/kbuild/Kconfig.recursion-issue-01 allnoconfig
make KBUILD_KCONFIG=Documentation/kbuild/Kconfig.recursion-issue-01 allnoconfig

Cumulative Kconfig recursive issue
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Read: Documentation/kbuild/Kconfig.recursion-issue-02

Test with:
Test with::

make KBUILD_KCONFIG=Documentation/kbuild/Kconfig.recursion-issue-02 allnoconfig
make KBUILD_KCONFIG=Documentation/kbuild/Kconfig.recursion-issue-02 allnoconfig

Practical solutions to kconfig recursive issue
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -551,7 +567,9 @@ historical issues resolved through these different solutions.

a) Remove any superfluous "select FOO" or "depends on FOO"
b) Match dependency semantics:

b1) Swap all "select FOO" to "depends on FOO" or,

b2) Swap all "depends on FOO" to "select FOO"

The resolution to a) can be tested with the sample Kconfig file
@@ -566,8 +584,9 @@ Documentation/kbuild/Kconfig.recursion-issue-02.
Below is a list of examples of prior fixes for these types of recursive issues;
all errors appear to involve one or more select's and one or more "depends on".

============ ===================================
commit fix
====== ===
============ ===================================
06b718c01208 select A -> depends on A
c22eacfe82f9 depends on A -> depends on B
6a91e854442c select A -> depends on A
@@ -590,6 +609,7 @@ d9f9ab51e55e select A -> depends on A
0c51a4d8abd6 depends on A -> select A (3)
e98062ed6dc4 select A -> depends on A (3)
91e5d284a7f1 select A -> (null)
============ ===================================

(1) Partial (or no) quote of error.
(2) That seems to be the gist of that fix.
@@ -616,11 +636,11 @@ Semantics of Kconfig
~~~~~~~~~~~~~~~~~~~~

The use of Kconfig is broad, Linux is now only one of Kconfig's users:
one study has completed a broad analysis of Kconfig use in 12 projects [0].
one study has completed a broad analysis of Kconfig use in 12 projects [0]_.
Despite its widespread use, and although this document does a reasonable job
in documenting basic Kconfig syntax a more precise definition of Kconfig
semantics is welcomed. One project deduced Kconfig semantics through
the use of the xconfig configurator [1]. Work should be done to confirm if
the use of the xconfig configurator [1]_. Work should be done to confirm if
the deduced semantics matches our intended Kconfig design goals.

Having well defined semantics can be useful for tools for practical
@@ -628,42 +648,42 @@ evaluation of depenencies, for instance one such use known case was work to
express in boolean abstraction of the inferred semantics of Kconfig to
translate Kconfig logic into boolean formulas and run a SAT solver on this to
find dead code / features (always inactive), 114 dead features were found in
Linux using this methodology [1] (Section 8: Threats to validity).
Linux using this methodology [1]_ (Section 8: Threats to validity).

Confirming this could prove useful as Kconfig stands as one of the the leading
industrial variability modeling languages [1] [2]. Its study would help
industrial variability modeling languages [1]_ [2]_. Its study would help
evaluate practical uses of such languages, their use was only theoretical
and real world requirements were not well understood. As it stands though
only reverse engineering techniques have been used to deduce semantics from
variability modeling languages such as Kconfig [3].
variability modeling languages such as Kconfig [3]_.

[0] http://www.eng.uwaterloo.ca/~shshe/kconfig_semantics.pdf
[1] http://gsd.uwaterloo.ca/sites/default/files/vm-2013-berger.pdf
[2] http://gsd.uwaterloo.ca/sites/default/files/ase241-berger_0.pdf
[3] http://gsd.uwaterloo.ca/sites/default/files/icse2011.pdf
.. [0] http://www.eng.uwaterloo.ca/~shshe/kconfig_semantics.pdf
.. [1] http://gsd.uwaterloo.ca/sites/default/files/vm-2013-berger.pdf
.. [2] http://gsd.uwaterloo.ca/sites/default/files/ase241-berger_0.pdf
.. [3] http://gsd.uwaterloo.ca/sites/default/files/icse2011.pdf

Full SAT solver for Kconfig
~~~~~~~~~~~~~~~~~~~~~~~~~~~

Although SAT solvers [0] haven't yet been used by Kconfig directly, as noted in
the previous subsection, work has been done however to express in boolean
Although SAT solvers [4]_ haven't yet been used by Kconfig directly, as noted
in the previous subsection, work has been done however to express in boolean
abstraction the inferred semantics of Kconfig to translate Kconfig logic into
boolean formulas and run a SAT solver on it [1]. Another known related project
is CADOS [2] (former VAMOS [3]) and the tools, mainly undertaker [4], which has
been introduced first with [5]. The basic concept of undertaker is to exract
variability models from Kconfig, and put them together with a propositional
formula extracted from CPP #ifdefs and build-rules into a SAT solver in order
to find dead code, dead files, and dead symbols. If using a SAT solver is
desirable on Kconfig one approach would be to evaluate repurposing such efforts
somehow on Kconfig. There is enough interest from mentors of existing projects
to not only help advise how to integrate this work upstream but also help
maintain it long term. Interested developers should visit:
boolean formulas and run a SAT solver on it [5]_. Another known related project
is CADOS [6]_ (former VAMOS [7]_) and the tools, mainly undertaker [8]_, which
has been introduced first with [9]_. The basic concept of undertaker is to
exract variability models from Kconfig, and put them together with a
propositional formula extracted from CPP #ifdefs and build-rules into a SAT
solver in order to find dead code, dead files, and dead symbols. If using a SAT
solver is desirable on Kconfig one approach would be to evaluate repurposing
such efforts somehow on Kconfig. There is enough interest from mentors of
existing projects to not only help advise how to integrate this work upstream
but also help maintain it long term. Interested developers should visit:

http://kernelnewbies.org/KernelProjects/kconfig-sat

[0] http://www.cs.cornell.edu/~sabhar/chapters/SATSolvers-KR-Handbook.pdf
[1] http://gsd.uwaterloo.ca/sites/default/files/vm-2013-berger.pdf
[2] https://cados.cs.fau.de
[3] https://vamos.cs.fau.de
[4] https://undertaker.cs.fau.de
[5] https://www4.cs.fau.de/Publications/2011/tartler_11_eurosys.pdf
.. [4] http://www.cs.cornell.edu/~sabhar/chapters/SATSolvers-KR-Handbook.pdf
.. [5] http://gsd.uwaterloo.ca/sites/default/files/vm-2013-berger.pdf
.. [6] https://cados.cs.fau.de
.. [7] https://vamos.cs.fau.de
.. [8] https://undertaker.cs.fau.de
.. [9] https://www4.cs.fau.de/Publications/2011/tartler_11_eurosys.pdf

Documentation/kbuild/kconfig-macro-language.txt → Documentation/kbuild/kconfig-macro-language.rst View File

@@ -1,3 +1,7 @@
======================
Kconfig macro language
======================

Concept
-------

@@ -7,7 +11,7 @@ targets and prerequisites. The other is a macro language for performing textual
substitution.

There is clear distinction between the two language stages. For example, you
can write a makefile like follows:
can write a makefile like follows::

APP := foo
SRC := foo.c
@@ -17,7 +21,7 @@ can write a makefile like follows:
$(CC) -o $(APP) $(SRC)

The macro language replaces the variable references with their expanded form,
and handles as if the source file were input like follows:
and handles as if the source file were input like follows::

foo: foo.c
gcc -o foo foo.c
@@ -26,7 +30,7 @@ Then, Make analyzes the dependency graph and determines the targets to be
updated.

The idea is quite similar in Kconfig - it is possible to describe a Kconfig
file like this:
file like this::

CC := gcc

@@ -34,7 +38,7 @@ file like this:
def_bool $(shell, $(srctree)/scripts/gcc-check-foo.sh $(CC))

The macro language in Kconfig processes the source file into the following
intermediate:
intermediate::

config CC_HAS_FOO
def_bool y
@@ -69,7 +73,7 @@ variable. The righthand side of += is expanded immediately if the lefthand
side was originally defined as a simple variable. Otherwise, its evaluation is
deferred.

The variable reference can take parameters, in the following form:
The variable reference can take parameters, in the following form::

$(name,arg1,arg2,arg3)

@@ -141,7 +145,7 @@ Make vs Kconfig
Kconfig adopts Make-like macro language, but the function call syntax is
slightly different.

A function call in Make looks like this:
A function call in Make looks like this::

$(func-name arg1,arg2,arg3)

@@ -149,14 +153,14 @@ The function name and the first argument are separated by at least one
whitespace. Then, leading whitespaces are trimmed from the first argument,
while whitespaces in the other arguments are kept. You need to use a kind of
trick to start the first parameter with spaces. For example, if you want
to make "info" function print " hello", you can write like follows:
to make "info" function print " hello", you can write like follows::

empty :=
space := $(empty) $(empty)
$(info $(space)$(space)hello)

Kconfig uses only commas for delimiters, and keeps all whitespaces in the
function call. Some people prefer putting a space after each comma delimiter:
function call. Some people prefer putting a space after each comma delimiter::

$(func-name, arg1, arg2, arg3)

@@ -166,7 +170,7 @@ Make - for example, $(subst .c, .o, $(sources)) is a typical mistake; it
replaces ".c" with " .o".

In Make, a user-defined function is referenced by using a built-in function,
'call', like this:
'call', like this::

$(call my-func,arg1,arg2,arg3)

@@ -179,12 +183,12 @@ Likewise, $(info hello, world) prints "hello, world" to stdout. You could say
this is _useful_ inconsistency.

In Kconfig, for simpler implementation and grammatical consistency, commas that
appear in the $( ) context are always delimiters. It means
appear in the $( ) context are always delimiters. It means::

$(shell, echo hello, world)

is an error because it is passing two parameters where the 'shell' function
accepts only one. To pass commas in arguments, you can use the following trick:
accepts only one. To pass commas in arguments, you can use the following trick::

comma := ,
$(shell, echo hello$(comma) world)
@@ -195,7 +199,7 @@ Caveats

A variable (or function) cannot be expanded across tokens. So, you cannot use
a variable as a shorthand for an expression that consists of multiple tokens.
The following works:
The following works::

RANGE_MIN := 1
RANGE_MAX := 3
@@ -204,7 +208,7 @@ The following works:
int "foo"
range $(RANGE_MIN) $(RANGE_MAX)

But, the following does not work:
But, the following does not work::

RANGES := 1 3

@@ -213,7 +217,7 @@ But, the following does not work:
range $(RANGES)

A variable cannot be expanded to any keyword in Kconfig. The following does
not work:
not work::

MY_TYPE := tristate

@@ -223,7 +227,8 @@ not work:

Obviously from the design, $(shell command) is expanded in the textual
substitution phase. You cannot pass symbols to the 'shell' function.
The following does not work as expected.

The following does not work as expected::

config ENDIAN_FLAG
string
@@ -234,7 +239,7 @@ The following does not work as expected.
def_bool $(shell $(srctree)/scripts/gcc-check-flag ENDIAN_FLAG)

Instead, you can do like follows so that any function call is statically
expanded.
expanded::

config CC_HAS_ENDIAN_FLAG
bool

Documentation/kbuild/kconfig.txt → Documentation/kbuild/kconfig.rst View File

@@ -1,4 +1,8 @@
This file contains some assistance for using "make *config".
===================
Kconfig make config
===================

This file contains some assistance for using `make *config`.

Use "make help" to list all of the possible configuration targets.

@@ -6,9 +10,8 @@ The xconfig ('qconf'), menuconfig ('mconf'), and nconfig ('nconf')
programs also have embedded help text. Be sure to check that for
navigation, search, and other general help text.

======================================================================
General
--------------------------------------------------
-------

New kernel releases often introduce new config symbols. Often more
important, new kernel releases may rename config symbols. When
@@ -17,51 +20,55 @@ this happens, using a previously working .config file and running
for you, so you may find that you need to see what NEW kernel
symbols have been introduced.

To see a list of new config symbols, use
To see a list of new config symbols, use::

cp user/some/old.config .config
make listnewconfig

and the config program will list any new symbols, one per line.

Alternatively, you can use the brute force method:
Alternatively, you can use the brute force method::

make oldconfig
scripts/diffconfig .config.old .config | less

______________________________________________________________________
Environment variables for '*config'
----------------------------------------------------------------------

Environment variables for `*config`

KCONFIG_CONFIG
--------------------------------------------------
--------------
This environment variable can be used to specify a default kernel config
file name to override the default name of ".config".

KCONFIG_OVERWRITECONFIG
--------------------------------------------------
-----------------------
If you set KCONFIG_OVERWRITECONFIG in the environment, Kconfig will not
break symlinks when .config is a symlink to somewhere else.

CONFIG_
--------------------------------------------------
If you set CONFIG_ in the environment, Kconfig will prefix all symbols
`CONFIG_`
---------
If you set `CONFIG_` in the environment, Kconfig will prefix all symbols
with its value when saving the configuration, instead of using the default,
"CONFIG_".
`CONFIG_`.

----------------------------------------------------------------------

______________________________________________________________________
Environment variables for '{allyes/allmod/allno/rand}config'

KCONFIG_ALLCONFIG
--------------------------------------------------
-----------------
(partially based on lkml email from/by Rob Landley, re: miniconfig)

--------------------------------------------------

The allyesconfig/allmodconfig/allnoconfig/randconfig variants can also
use the environment variable KCONFIG_ALLCONFIG as a flag or a filename
that contains config symbols that the user requires to be set to a
specific value. If KCONFIG_ALLCONFIG is used without a filename where
KCONFIG_ALLCONFIG == "" or KCONFIG_ALLCONFIG == "1", "make *config"
KCONFIG_ALLCONFIG == "" or KCONFIG_ALLCONFIG == "1", `make *config`
checks for a file named "all{yes/mod/no/def/random}.config"
(corresponding to the *config command that was used) for symbol values
(corresponding to the `*config` command that was used) for symbol values
that are to be forced. If this file is not found, it checks for a
file named "all.config" to contain forced values.

@@ -74,43 +81,55 @@ This 'KCONFIG_ALLCONFIG' file is a config file which contains
(usually a subset of all) preset config symbols. These variable
settings are still subject to normal dependency checks.

Examples:
Examples::

KCONFIG_ALLCONFIG=custom-notebook.config make allnoconfig
or

or::

KCONFIG_ALLCONFIG=mini.config make allnoconfig
or

or::

make KCONFIG_ALLCONFIG=mini.config allnoconfig

These examples will disable most options (allnoconfig) but enable or
disable the options that are explicitly listed in the specified
mini-config files.

______________________________________________________________________
----------------------------------------------------------------------

Environment variables for 'randconfig'

KCONFIG_SEED
--------------------------------------------------
------------
You can set this to the integer value used to seed the RNG, if you want
to somehow debug the behaviour of the kconfig parser/frontends.
If not set, the current time will be used.

KCONFIG_PROBABILITY
--------------------------------------------------
-------------------
This variable can be used to skew the probabilities. This variable can
be unset or empty, or set to three different formats:

======================= ================== =====================
KCONFIG_PROBABILITY y:n split y:m:n split
-----------------------------------------------------------------
======================= ================== =====================
unset or empty 50 : 50 33 : 33 : 34
N N : 100-N N/2 : N/2 : 100-N
[1] N:M N+M : 100-(N+M) N : M : 100-(N+M)
[2] N:M:L N : 100-N M : L : 100-(M+L)
======================= ================== =====================

where N, M and L are integers (in base 10) in the range [0,100], and so
that:

[1] N+M is in the range [0,100]

[2] M+L is in the range [0,100]

Examples:
Examples::

KCONFIG_PROBABILITY=10
10% of booleans will be set to 'y', 90% to 'n'
5% of tristates will be set to 'y', 5% to 'm', 90% to 'n'
@@ -121,34 +140,36 @@ Examples:
10% of booleans will be set to 'y', 90% to 'n'
15% of tristates will be set to 'y', 15% to 'm', 70% to 'n'

______________________________________________________________________
----------------------------------------------------------------------

Environment variables for 'syncconfig'

KCONFIG_NOSILENTUPDATE
--------------------------------------------------
----------------------
If this variable has a non-blank value, it prevents silent kernel
config updates (requires explicit updates).

KCONFIG_AUTOCONFIG
--------------------------------------------------
------------------
This environment variable can be set to specify the path & name of the
"auto.conf" file. Its default value is "include/config/auto.conf".

KCONFIG_TRISTATE
--------------------------------------------------
----------------
This environment variable can be set to specify the path & name of the
"tristate.conf" file. Its default value is "include/config/tristate.conf".

KCONFIG_AUTOHEADER
--------------------------------------------------
------------------
This environment variable can be set to specify the path & name of the
"autoconf.h" (header) file.
Its default value is "include/generated/autoconf.h".


======================================================================
----------------------------------------------------------------------

menuconfig
--------------------------------------------------
----------

SEARCHING for CONFIG symbols

@@ -158,7 +179,8 @@ Searching in menuconfig:
names, so you have to know something close to what you are
looking for.

Example:
Example::

/hotplug
This lists all config symbols that contain "hotplug",
e.g., HOTPLUG_CPU, MEMORY_HOTPLUG.
@@ -166,48 +188,55 @@ Searching in menuconfig:
For search help, enter / followed by TAB-TAB (to highlight
<Help>) and Enter. This will tell you that you can also use
regular expressions (regexes) in the search string, so if you
are not interested in MEMORY_HOTPLUG, you could try
are not interested in MEMORY_HOTPLUG, you could try::

/^hotplug

When searching, symbols are sorted thus:

- first, exact matches, sorted alphabetically (an exact match
is when the search matches the complete symbol name);
- then, other matches, sorted alphabetically.

For example: ^ATH.K matches:

ATH5K ATH9K ATH5K_AHB ATH5K_DEBUG [...] ATH6KL ATH6KL_DEBUG
[...] ATH9K_AHB ATH9K_BTCOEX_SUPPORT ATH9K_COMMON [...]

of which only ATH5K and ATH9K match exactly and so are sorted
first (and in alphabetical order), then come all other symbols,
sorted in alphabetical order.

______________________________________________________________________
----------------------------------------------------------------------

User interface options for 'menuconfig'

MENUCONFIG_COLOR
--------------------------------------------------
----------------
It is possible to select different color themes using the variable
MENUCONFIG_COLOR. To select a theme use:
MENUCONFIG_COLOR. To select a theme use::

make MENUCONFIG_COLOR=<theme> menuconfig

Available themes are:
mono => selects colors suitable for monochrome displays
blackbg => selects a color scheme with black background
classic => theme with blue background. The classic look
bluetitle => a LCD friendly version of classic. (default)
Available themes are::

- mono => selects colors suitable for monochrome displays
- blackbg => selects a color scheme with black background
- classic => theme with blue background. The classic look
- bluetitle => a LCD friendly version of classic. (default)

MENUCONFIG_MODE
--------------------------------------------------
---------------
This mode shows all sub-menus in one large tree.

Example:
Example::

make MENUCONFIG_MODE=single_menu menuconfig

----------------------------------------------------------------------

======================================================================
nconfig
--------------------------------------------------
-------

nconfig is an alternate text-based configurator. It lists function
keys across the bottom of the terminal (window) that execute commands.
@@ -231,16 +260,16 @@ Searching in nconfig:
given string or regular expression (regex).

NCONFIG_MODE
--------------------------------------------------
------------
This mode shows all sub-menus in one large tree.

Example:
Example::
make NCONFIG_MODE=single_menu nconfig

----------------------------------------------------------------------

======================================================================
xconfig
--------------------------------------------------
-------

Searching in xconfig:

@@ -260,13 +289,12 @@ Searching in xconfig:
to return to the main menu.


======================================================================
----------------------------------------------------------------------

gconfig
--------------------------------------------------
-------

Searching in gconfig:

There is no search command in gconfig. However, gconfig does
have several different viewing choices, modes, and options.

###

Documentation/kbuild/makefiles.txt → Documentation/kbuild/makefiles.rst View File

@@ -1,8 +1,10 @@
======================
Linux Kernel Makefiles
======================

This document describes the Linux kernel Makefiles.

=== Table of Contents
.. Table of Contents

=== 1 Overview
=== 2 Who does what
@@ -54,9 +56,10 @@ This document describes the Linux kernel Makefiles.
=== 10 Credits
=== 11 TODO

=== 1 Overview
1 Overview
==========

The Makefiles have five parts:
The Makefiles have five parts::

Makefile the top Makefile.
.config the kernel configuration file.
@@ -85,7 +88,8 @@ scripts/Makefile.* contains all the definitions/rules etc. that
are used to build the kernel based on the kbuild makefiles.


=== 2 Who does what
2 Who does what
===============

People have four different relationships with the kernel Makefiles.

@@ -110,7 +114,8 @@ These people need to know about all aspects of the kernel Makefiles.
This document is aimed towards normal developers and arch developers.


=== 3 The kbuild files
3 The kbuild files
==================

Most Makefiles within the kernel are kbuild Makefiles that use the
kbuild infrastructure. This chapter introduces the syntax used in the
@@ -122,7 +127,8 @@ file will be used.
Section 3.1 "Goal definitions" is a quick intro, further chapters provide
more details, with real examples.

--- 3.1 Goal definitions
3.1 Goal definitions
--------------------

Goal definitions are the main part (heart) of the kbuild Makefile.
These lines define the files to be built, any special compilation
@@ -130,7 +136,8 @@ more details, with real examples.

The most simple kbuild makefile contains one line:

Example:
Example::

obj-y += foo.o

This tells kbuild that there is one object in that directory, named
@@ -139,14 +146,16 @@ more details, with real examples.
If foo.o shall be built as a module, the variable obj-m is used.
Therefore the following pattern is often used:

Example:
Example::

obj-$(CONFIG_FOO) += foo.o

$(CONFIG_FOO) evaluates to either y (for built-in) or m (for module).
If CONFIG_FOO is neither y nor m, then the file will not be compiled
nor linked.

--- 3.2 Built-in object goals - obj-y
3.2 Built-in object goals - obj-y
---------------------------------

The kbuild Makefile specifies object files for vmlinux
in the $(obj-y) lists. These lists depend on the kernel
@@ -167,14 +176,16 @@ more details, with real examples.
order may e.g. change the order in which your SCSI
controllers are detected, and thus your disks are renumbered.

Example:
Example::

#drivers/isdn/i4l/Makefile
# Makefile for the kernel ISDN subsystem and device drivers.
# Each configuration option enables a list of files.
obj-$(CONFIG_ISDN_I4L) += isdn.o
obj-$(CONFIG_ISDN_PPP_BSDCOMP) += isdn_bsdcomp.o

--- 3.3 Loadable module goals - obj-m
3.3 Loadable module goals - obj-m
---------------------------------

$(obj-m) specifies object files which are built as loadable
kernel modules.
@@ -183,7 +194,8 @@ more details, with real examples.
files. In the case of one source file, the kbuild makefile
simply adds the file to $(obj-m).

Example:
Example::

#drivers/isdn/i4l/Makefile
obj-$(CONFIG_ISDN_PPP_BSDCOMP) += isdn_bsdcomp.o

@@ -195,7 +207,8 @@ more details, with real examples.
module from, so you have to tell it by setting a $(<module_name>-y)
variable.

Example:
Example::

#drivers/isdn/i4l/Makefile
obj-$(CONFIG_ISDN_I4L) += isdn.o
isdn-y := isdn_net_lib.o isdn_v110.o isdn_common.o
@@ -205,10 +218,11 @@ more details, with real examples.
"$(LD) -r" on the list of these files to generate isdn.o.

Due to kbuild recognizing $(<module_name>-y) for composite objects,
you can use the value of a CONFIG_ symbol to optionally include an
you can use the value of a `CONFIG_` symbol to optionally include an
object file as part of a composite object.

Example:
Example::

#fs/ext2/Makefile
obj-$(CONFIG_EXT2_FS) += ext2.o
ext2-y := balloc.o dir.o file.o ialloc.o inode.o ioctl.o \
@@ -225,12 +239,14 @@ more details, with real examples.
kbuild will build an ext2.o file for you out of the individual
parts and then link this into built-in.a, as you would expect.

--- 3.4 Objects which export symbols
3.4 Objects which export symbols
--------------------------------

No special notation is required in the makefiles for
modules exporting symbols.

--- 3.5 Library file goals - lib-y
3.5 Library file goals - lib-y
------------------------------

Objects listed with obj-* are used for modules, or
combined in a built-in.a for that specific directory.
@@ -247,18 +263,21 @@ more details, with real examples.
and to be part of a library. Therefore the same directory
may contain both a built-in.a and a lib.a file.

Example:
Example::

#arch/x86/lib/Makefile
lib-y := delay.o

This will create a library lib.a based on delay.o. For kbuild to
actually recognize that there is a lib.a being built, the directory
shall be listed in libs-y.

See also "6.4 List directories to visit when descending".

Use of lib-y is normally restricted to lib/ and arch/*/lib.
Use of lib-y is normally restricted to `lib/` and `arch/*/lib`.

--- 3.6 Descending down in directories
3.6 Descending down in directories
----------------------------------

A Makefile is only responsible for building objects in its own
directory. Files in subdirectories should be taken care of by
@@ -270,7 +289,8 @@ more details, with real examples.
ext2 lives in a separate directory, and the Makefile present in fs/
tells kbuild to descend down using the following assignment.

Example:
Example::

#fs/Makefile
obj-$(CONFIG_EXT2_FS) += ext2/

@@ -281,11 +301,12 @@ more details, with real examples.
the directory, it is the Makefile in the subdirectory that
specifies what is modular and what is built-in.

It is good practice to use a CONFIG_ variable when assigning directory
It is good practice to use a `CONFIG_` variable when assigning directory
names. This allows kbuild to totally skip the directory if the
corresponding CONFIG_ option is neither 'y' nor 'm'.
corresponding `CONFIG_` option is neither 'y' nor 'm'.

--- 3.7 Compilation flags
3.7 Compilation flags
---------------------

ccflags-y, asflags-y and ldflags-y
These three flags apply only to the kbuild makefile in which they
@@ -297,7 +318,8 @@ more details, with real examples.

ccflags-y specifies options for compiling with $(CC).

Example:
Example::

# drivers/acpi/acpica/Makefile
ccflags-y := -Os -D_LINUX -DBUILDING_ACPICA
ccflags-$(CONFIG_ACPI_DEBUG) += -DACPI_DEBUG_OUTPUT
@@ -308,13 +330,15 @@ more details, with real examples.

asflags-y specifies options for assembling with $(AS).

Example:
Example::

#arch/sparc/kernel/Makefile
asflags-y := -ansi

ldflags-y specifies options for linking with $(LD).

Example:
Example::

#arch/cris/boot/compressed/Makefile
ldflags-y += -T $(srctree)/$(src)/decompress_$(arch-y).lds

@@ -325,18 +349,19 @@ more details, with real examples.
Options specified using subdir-* are added to the commandline before
the options specified using the non-subdir variants.

Example:
Example::

subdir-ccflags-y := -Werror

CFLAGS_$@, AFLAGS_$@

CFLAGS_$@ and AFLAGS_$@ only apply to commands in current
kbuild makefile.

$(CFLAGS_$@) specifies per-file options for $(CC). The $@
part has a literal value which specifies the file that it is for.

Example:
Example::

# drivers/scsi/Makefile
CFLAGS_aha152x.o = -DAHA152X_STAT -DAUTOCONF
CFLAGS_gdth.o = # -DDEBUG_GDTH=2 -D__SERIAL__ -D__COM2__ \
@@ -347,24 +372,27 @@ more details, with real examples.
$(AFLAGS_$@) is a similar feature for source files in assembly
languages.

Example:
Example::

# arch/arm/kernel/Makefile
AFLAGS_head.o := -DTEXT_OFFSET=$(TEXT_OFFSET)
AFLAGS_crunch-bits.o := -Wa,-mcpu=ep9312
AFLAGS_iwmmxt.o := -Wa,-mcpu=iwmmxt


--- 3.9 Dependency tracking
3.9 Dependency tracking
-----------------------

Kbuild tracks dependencies on the following:
1) All prerequisite files (both *.c and *.h)
2) CONFIG_ options used in all prerequisite files
1) All prerequisite files (both `*.c` and `*.h`)
2) `CONFIG_` options used in all prerequisite files
3) Command-line used to compile target

Thus, if you change an option to $(CC) all affected files will
be re-compiled.

--- 3.10 Special Rules
3.10 Special Rules
------------------

Special rules are used when the kbuild infrastructure does
not provide the required support. A typical example is
@@ -379,43 +407,47 @@ more details, with real examples.

Two variables are used when defining special rules:

$(src)
$(src) is a relative path which points to the directory
where the Makefile is located. Always use $(src) when
referring to files located in the src tree.
$(src)
$(src) is a relative path which points to the directory
where the Makefile is located. Always use $(src) when
referring to files located in the src tree.

$(obj)
$(obj) is a relative path which points to the directory
where the target is saved. Always use $(obj) when
referring to generated files.

$(obj)
$(obj) is a relative path which points to the directory
where the target is saved. Always use $(obj) when
referring to generated files.
Example::

Example:
#drivers/scsi/Makefile
$(obj)/53c8xx_d.h: $(src)/53c7,8xx.scr $(src)/script_asm.pl
$(CPP) -DCHIP=810 - < $< | ... $(src)/script_asm.pl

This is a special rule, following the normal syntax
required by make.
The target file depends on two prerequisite files. References
to the target file are prefixed with $(obj), references
to prerequisites are referenced with $(src) (because they are not
generated files).

$(kecho)
echoing information to user in a rule is often a good practice
but when execution "make -s" one does not expect to see any output
except for warnings/errors.
To support this kbuild defines $(kecho) which will echo out the
text following $(kecho) to stdout except if "make -s" is used.

Example:
This is a special rule, following the normal syntax
required by make.

The target file depends on two prerequisite files. References
to the target file are prefixed with $(obj), references
to prerequisites are referenced with $(src) (because they are not
generated files).

$(kecho)
echoing information to user in a rule is often a good practice
but when execution "make -s" one does not expect to see any output
except for warnings/errors.
To support this kbuild defines $(kecho) which will echo out the
text following $(kecho) to stdout except if "make -s" is used.

Example::

#arch/blackfin/boot/Makefile
$(obj)/vmImage: $(obj)/vmlinux.gz
$(call if_changed,uimage)
@$(kecho) 'Kernel: $@ is ready'


--- 3.11 $(CC) support functions
3.11 $(CC) support functions
----------------------------

The kernel may be built with several different versions of
$(CC), each supporting a unique set of features and options.
@@ -425,10 +457,11 @@ more details, with real examples.

as-option
as-option is used to check if $(CC) -- when used to compile
assembler (*.S) files -- supports the given option. An optional
assembler (`*.S`) files -- supports the given option. An optional
second option may be specified if the first option is not supported.

Example:
Example::

#arch/sh/Makefile
cflags-y += $(call as-option,-Wa$(comma)-isa=$(isa-y),)

@@ -437,6 +470,21 @@ more details, with real examples.
The second argument is optional, and if supplied will be used
if first argument is not supported.

cc-ldoption
cc-ldoption is used to check if $(CC) when used to link object files
supports the given option. An optional second option may be
specified if first option are not supported.

Example::

#arch/x86/kernel/Makefile
vsyscall-flags += $(call cc-ldoption, -Wl$(comma)--hash-style=sysv)

In the above example, vsyscall-flags will be assigned the option
-Wl$(comma)--hash-style=sysv if it is supported by $(CC).
The second argument is optional, and if supplied will be used
if first argument is not supported.

as-instr
as-instr checks if the assembler reports a specific instruction
and then outputs either option1 or option2
@@ -447,7 +495,8 @@ more details, with real examples.
cc-option is used to check if $(CC) supports a given option, and if
not supported to use an optional second option.

Example:
Example::

#arch/x86/Makefile
cflags-y += $(call cc-option,-march=pentium-mmx,-march=i586)

@@ -461,7 +510,8 @@ more details, with real examples.
cc-option-yn is used to check if gcc supports a given option
and return 'y' if supported, otherwise 'n'.

Example:
Example::

#arch/ppc/Makefile
biarch := $(call cc-option-yn, -m32)
aflags-$(biarch) += -a32
@@ -479,7 +529,8 @@ more details, with real examples.
because gcc 4.4 and later accept any unknown -Wno-* option and only
warn about it if there is another warning in the source file.

Example:
Example::

KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)

In the above example, -Wno-unused-but-set-variable will be added to
@@ -490,7 +541,8 @@ more details, with real examples.
if version expression is true, or the fifth (if given) if the version
expression is false.

Example:
Example::

#fs/reiserfs/Makefile
ccflags-y := $(call cc-ifversion, -lt, 0402, -O1)

@@ -515,7 +567,8 @@ more details, with real examples.
build (host arch is different from target arch). And if CROSS_COMPILE
is already set then leave it with the old value.

Example:
Example::

#arch/m68k/Makefile
ifneq ($(SUBARCH),$(ARCH))
ifeq ($(CROSS_COMPILE),)
@@ -523,7 +576,8 @@ more details, with real examples.
endif
endif

--- 3.12 $(LD) support functions
3.12 $(LD) support functions
----------------------------

ld-option
ld-option is used to check if $(LD) supports the supplied option.
@@ -531,12 +585,14 @@ more details, with real examples.
The second argument is an optional option that can be used if the
first option is not supported by $(LD).

Example:
Example::

#Makefile
LDFLAGS_vmlinux += $(call ld-option, -X)


=== 4 Host Program support
4 Host Program support
======================

Kbuild supports building executables on the host for use during the
compilation stage.
@@ -550,21 +606,24 @@ This can be done in two ways. Either add the dependency in a rule,
or utilise the variable $(always).
Both possibilities are described in the following.

--- 4.1 Simple Host Program
4.1 Simple Host Program
-----------------------

In some cases there is a need to compile and run a program on the
computer where the build is running.
The following line tells kbuild that the program bin2hex shall be
built on the build host.

Example:
Example::

hostprogs-y := bin2hex

Kbuild assumes in the above example that bin2hex is made from a single
c-source file named bin2hex.c located in the same directory as
the Makefile.

--- 4.2 Composite Host Programs
4.2 Composite Host Programs
---------------------------

Host programs can be made up based on composite objects.
The syntax used to define composite objects for host programs is
@@ -572,7 +631,8 @@ Both possibilities are described in the following.
$(<executable>-objs) lists all objects used to link the final
executable.

Example:
Example::

#scripts/lxdialog/Makefile
hostprogs-y := lxdialog
lxdialog-objs := checklist.o lxdialog.o
@@ -580,16 +640,19 @@ Both possibilities are described in the following.
Objects with extension .o are compiled from the corresponding .c
files. In the above example, checklist.c is compiled to checklist.o
and lxdialog.c is compiled to lxdialog.o.

Finally, the two .o files are linked to the executable, lxdialog.
Note: The syntax <executable>-y is not permitted for host-programs.

--- 4.3 Using C++ for host programs
4.3 Using C++ for host programs
-------------------------------

kbuild offers support for host programs written in C++. This was
introduced solely to support kconfig, and is not recommended
for general use.

Example:
Example::

#scripts/kconfig/Makefile
hostprogs-y := qconf
qconf-cxxobjs := qconf.o
@@ -600,13 +663,15 @@ Both possibilities are described in the following.
If qconf is composed of a mixture of .c and .cc files, then an
additional line can be used to identify this.

Example:
Example::

#scripts/kconfig/Makefile
hostprogs-y := qconf
qconf-cxxobjs := qconf.o
qconf-objs := check.o

--- 4.4 Controlling compiler options for host programs
4.4 Controlling compiler options for host programs
--------------------------------------------------

When compiling host programs, it is possible to set specific flags.
The programs will always be compiled utilising $(HOSTCC) passed
@@ -614,27 +679,31 @@ Both possibilities are described in the following.
To set flags that will take effect for all host programs created
in that Makefile, use the variable HOST_EXTRACFLAGS.

Example:
Example::

#scripts/lxdialog/Makefile
HOST_EXTRACFLAGS += -I/usr/include/ncurses

To set specific flags for a single file the following construction
is used:

Example:
Example::

#arch/ppc64/boot/Makefile
HOSTCFLAGS_piggyback.o := -DKERNELBASE=$(KERNELBASE)

It is also possible to specify additional options to the linker.

Example:
Example::

#scripts/kconfig/Makefile
HOSTLDLIBS_qconf := -L$(QTDIR)/lib

When linking qconf, it will be passed the extra option
"-L$(QTDIR)/lib".

--- 4.5 When host programs are actually built
4.5 When host programs are actually built
-----------------------------------------

Kbuild will only build host-programs when they are referenced
as a prerequisite.
@@ -642,7 +711,8 @@ Both possibilities are described in the following.

(1) List the prerequisite explicitly in a special rule.

Example:
Example::

#drivers/pci/Makefile
hostprogs-y := gen-devlist
$(obj)/devlist.h: $(src)/pci.ids $(obj)/gen-devlist
@@ -653,11 +723,13 @@ Both possibilities are described in the following.
the host programs in special rules must be prefixed with $(obj).

(2) Use $(always)

When there is no suitable special rule, and the host program
shall be built when a makefile is entered, the $(always)
variable shall be used.

Example:
Example::

#scripts/lxdialog/Makefile
hostprogs-y := lxdialog
always := $(hostprogs-y)
@@ -665,11 +737,13 @@ Both possibilities are described in the following.
This will tell kbuild to build lxdialog even if not referenced in
any rule.

--- 4.6 Using hostprogs-$(CONFIG_FOO)
4.6 Using hostprogs-$(CONFIG_FOO)
---------------------------------

A typical pattern in a Kbuild file looks like this:

Example:
Example::

#scripts/Makefile
hostprogs-$(CONFIG_KALLSYMS) += kallsyms

@@ -679,7 +753,8 @@ Both possibilities are described in the following.
like hostprogs-y. But only hostprogs-y is recommended to be used
when no CONFIG symbols are involved.

=== 5 Kbuild clean infrastructure
5 Kbuild clean infrastructure
=============================

"make clean" deletes most generated files in the obj tree where the kernel
is compiled. This includes generated files such as host programs.
@@ -691,7 +766,8 @@ generated by kbuild are deleted all over the kernel src tree when

Additional files can be specified in kbuild makefiles by use of $(clean-files).

Example:
Example::

#lib/Makefile
clean-files := crc32table.h

@@ -701,7 +777,8 @@ Makefile, except if prefixed with $(objtree).

To delete a directory hierarchy use:

Example:
Example::

#scripts/package/Makefile
clean-dirs := $(objtree)/debian/

@@ -711,7 +788,8 @@ subdirectories.
To exclude certain files from make clean, use the $(no-clean-files) variable.
This is only a special case used in the top level Kbuild file:

Example:
Example::

#Kbuild
no-clean-files := $(bounds-file) $(offsets-file)

@@ -719,7 +797,8 @@ Usually kbuild descends down in subdirectories due to "obj-* := dir/",