wsphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget1/translations/zh_CN/kbuild/kconfig-macro-languagemodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget1/translations/zh_TW/kbuild/kconfig-macro-languagemodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget1/translations/it_IT/kbuild/kconfig-macro-languagemodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget1/translations/ja_JP/kbuild/kconfig-macro-languagemodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget1/translations/ko_KR/kbuild/kconfig-macro-languagemodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget1/translations/sp_SP/kbuild/kconfig-macro-languagemodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhsection)}(hhh](htitle)}(hKconfig macro languageh]hKconfig macro language}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhK/var/lib/git/docbuild/linux/Documentation/kbuild/kconfig-macro-language.rsthKubh)}(hhh](h)}(hConcepth]hConcept}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh paragraph)}(hThe basic idea was inspired by Make. When we look at Make, we notice sort of two languages in one. One language describes dependency graphs consisting of targets and prerequisites. The other is a macro language for performing textual substitution.h]hThe basic idea was inspired by Make. When we look at Make, we notice sort of two languages in one. One language describes dependency graphs consisting of targets and prerequisites. The other is a macro language for performing textual substitution.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hpThere is clear distinction between the two language stages. For example, you can write a makefile like follows::h]hoThere is clear distinction between the two language stages. For example, you can write a makefile like follows:}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hhhhubh literal_block)}(hPAPP := foo SRC := foo.c CC := gcc $(APP): $(SRC) $(CC) -o $(APP) $(SRC)h]hPAPP := foo SRC := foo.c CC := gcc $(APP): $(SRC) $(CC) -o $(APP) $(SRC)}hhsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1hhhhKhhhhubh)}(hThe macro language replaces the variable references with their expanded form, and handles as if the source file were input like follows::h]hThe macro language replaces the variable references with their expanded form, and handles as if the source file were input like follows:}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(h#foo: foo.c gcc -o foo foo.ch]h#foo: foo.c gcc -o foo foo.c}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhKhhhhubh)}(hRThen, Make analyzes the dependency graph and determines the targets to be updated.h]hRThen, Make analyzes the dependency graph and determines the targets to be updated.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(h\The idea is quite similar in Kconfig - it is possible to describe a Kconfig file like this::h]h[The idea is quite similar in Kconfig - it is possible to describe a Kconfig file like this:}(hj"hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK hhhhubh)}(haCC := gcc config CC_HAS_FOO def_bool $(shell, $(srctree)/scripts/gcc-check-foo.sh $(CC))h]haCC := gcc config CC_HAS_FOO def_bool $(shell, $(srctree)/scripts/gcc-check-foo.sh $(CC))}hj0sbah}(h]h ]h"]h$]h&]hhuh1hhhhK#hhhhubh)}(hYThe macro language in Kconfig processes the source file into the following intermediate::h]hXThe macro language in Kconfig processes the source file into the following intermediate:}(hj>hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK(hhhhubh)}(h$config CC_HAS_FOO def_bool yh]h$config CC_HAS_FOO def_bool y}hjLsbah}(h]h ]h"]h$]h&]hhuh1hhhhK+hhhhubh)}(hvThen, Kconfig moves onto the evaluation stage to resolve inter-symbol dependency as explained in kconfig-language.rst.h]hvThen, Kconfig moves onto the evaluation stage to resolve inter-symbol dependency as explained in kconfig-language.rst.}(hjZhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK.hhhhubeh}(h]conceptah ]h"]conceptah$]h&]uh1hhhhhhhhKubh)}(hhh](h)}(h Variablesh]h Variables}(hjshhhNhNubah}(h]h ]h"]h$]h&]uh1hhjphhhhhK3ubh)}(hXxLike in Make, a variable in Kconfig works as a macro variable. A macro variable is expanded "in place" to yield a text string that may then be expanded further. To get the value of a variable, enclose the variable name in $( ). The parentheses are required even for single-letter variable names; $X is a syntax error. The curly brace form as in ${CC} is not supported either.h]hX|Like in Make, a variable in Kconfig works as a macro variable. A macro variable is expanded “in place” to yield a text string that may then be expanded further. To get the value of a variable, enclose the variable name in $( ). The parentheses are required even for single-letter variable names; $X is a syntax error. The curly brace form as in ${CC} is not supported either.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK5hjphhubh)}(h_There are two types of variables: simply expanded variables and recursively expanded variables.h]h_There are two types of variables: simply expanded variables and recursively expanded variables.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK;hjphhubh)}(hA simply expanded variable is defined using the := assignment operator. Its righthand side is expanded immediately upon reading the line from the Kconfig file.h]hA simply expanded variable is defined using the := assignment operator. Its righthand side is expanded immediately upon reading the line from the Kconfig file.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK>hjphhubh)}(hA recursively expanded variable is defined using the = assignment operator. Its righthand side is simply stored as the value of the variable without expanding it in any way. Instead, the expansion is performed when the variable is used.h]hA recursively expanded variable is defined using the = assignment operator. Its righthand side is simply stored as the value of the variable without expanding it in any way. Instead, the expansion is performed when the variable is used.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKBhjphhubh)}(hThere is another type of assignment operator; += is used to append text to a variable. The righthand side of += is expanded immediately if the lefthand side was originally defined as a simple variable. Otherwise, its evaluation is deferred.h]hThere is another type of assignment operator; += is used to append text to a variable. The righthand side of += is expanded immediately if the lefthand side was originally defined as a simple variable. Otherwise, its evaluation is deferred.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKGhjphhubh)}(hCThe variable reference can take parameters, in the following form::h]hBThe variable reference can take parameters, in the following form:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKLhjphhubh)}(h$(name,arg1,arg2,arg3)h]h$(name,arg1,arg2,arg3)}hjsbah}(h]h ]h"]h$]h&]hhuh1hhhhKNhjphhubh)}(hYou can consider the parameterized reference as a function. (more precisely, "user-defined function" in contrast to "built-in function" listed below).h]hYou can consider the parameterized reference as a function. (more precisely, “user-defined function” in contrast to “built-in function” listed below).}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKPhjphhubh)}(hX"Useful functions must be expanded when they are used since the same function is expanded differently if different parameters are passed. Hence, a user-defined function is defined using the = assignment operator. The parameters are referenced within the body definition with $(1), $(2), etc.h]hX"Useful functions must be expanded when they are used since the same function is expanded differently if different parameters are passed. Hence, a user-defined function is defined using the = assignment operator. The parameters are referenced within the body definition with $(1), $(2), etc.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKShjphhubh)}(hIn fact, recursively expanded variables and user-defined functions are the same internally. (In other words, "variable" is "function with zero argument".) When we say "variable" in a broad sense, it includes "user-defined function".h]hIn fact, recursively expanded variables and user-defined functions are the same internally. (In other words, “variable” is “function with zero argument”.) When we say “variable” in a broad sense, it includes “user-defined function”.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKXhjphhubeh}(h] variablesah ]h"] variablesah$]h&]uh1hhhhhhhhK3ubh)}(hhh](h)}(hBuilt-in functionsh]hBuilt-in functions}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhK^ubh)}(hnLike Make, Kconfig provides several built-in functions. Every function takes a particular number of arguments.h]hnLike Make, Kconfig provides several built-in functions. Every function takes a particular number of arguments.}(hj&hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK`hjhhubh)}(hXIIn Make, every built-in function takes at least one argument. Kconfig allows zero argument for built-in functions, such as $(filename), $(lineno). You could consider those as "built-in variable", but it is just a matter of how we call it after all. Let's say "built-in function" here to refer to natively supported functionality.h]hXSIn Make, every built-in function takes at least one argument. Kconfig allows zero argument for built-in functions, such as $(filename), $(lineno). You could consider those as “built-in variable”, but it is just a matter of how we call it after all. Let’s say “built-in function” here to refer to natively supported functionality.}(hj4hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKchjhhubh)}(h