[I wrote]
> I've come up with syntax I think I'm happy with.

Thank you one and all for all the discussion and suggestions for
improvement on my proposals.  I've incorporated a lot of feedback.

I know I promised to try and come up with a working prototype
including some Config.in files, but some of the Menuconfig bits were
harder than they looked, and I ran out of time tonight - I'm about to
leave town for a couple of days.  My Menuconfig currently doesn't
work, and I haven't converted any Config.in files yet.  Meanwhile,
here is the documentation portion.  Critiques are more than welcome,
both for the proposal and for its documentation..

Peter

--- 2.5.31/Documentation/kbuild/config-language.txt     2002-06-09 00:29:17.000000000 
-0500
+++ 2.5.31w/Documentation/kbuild/config-language.txt    2002-08-16 21:18:16.000000000 
+-0500
@@ -84,8 +84,10 @@
     to generate dependencies on individual CONFIG_* symbols instead of
     making one massive dependency on include/linux/autoconf.h.
 
-    A /dep/ is a dependency.  Syntactically, it is a /word/.  At run
-    time, a /dep/ must evaluate to "y", "m", "n", or "".
+    A /dep/ is a dependency list.  Syntactically, it is zero or more
+    /word/s separated by whitespace.  When evaluated, a /dep/ is
+    reduced to a single character "y", "m" or "n".  See the following
+    section for details.
 
     An /expr/ is a bash-like expression using the operators
     '=', '!=', '-a', '-o', and '!'.
@@ -116,12 +118,12 @@
 
     Dependent statements:
 
-        dep_bool        /prompt/ /symbol/ /dep/ ...
-        dep_mbool       /prompt/ /symbol/ /dep/ ...
-        dep_hex         /prompt/ /symbol/ /word/ /dep/ ...
-        dep_int         /prompt/ /symbol/ /word/ /dep/ ...
-        dep_string      /prompt/ /symbol/ /word/ /dep/ ...
-        dep_tristate    /prompt/ /symbol/ /dep/ ...
+        dep_bool        /prompt/ /symbol/ /dep/
+        dep_mbool       /prompt/ /symbol/ /dep/
+        dep_hex         /prompt/ /symbol/ /word/ /dep/
+        dep_int         /prompt/ /symbol/ /word/ /dep/
+        dep_string      /prompt/ /symbol/ /word/ /dep/
+        dep_tristate    /prompt/ /symbol/ /dep/
 
     Unset statement:
 
@@ -132,7 +134,22 @@
         choice          /prompt/ /word/ /word/
         nchoice         /prompt/ /symbol/ /prompt/ /symbol/ ...
 
-    If statements:
+    New-style if blocks:
+
+        if_dep /dep/
+          /statement/
+          ...
+        fi_dep
+
+        if_dep /dep/
+          /statement/
+          ...
+        else_dep
+          /statement/
+          ...
+        fi_dep
+
+    Old-style if blocks (deprecated):
 
         if [ /expr/ ] ; then
          /statement/
@@ -161,6 +178,69 @@
 
 
 
+=== Dependency lists
+
+A dependency list evaluates to a single character "y", "m" or "n".
+Individual words in the list can include:
+
+    The word "or" divides a list into two sub-lists, one on either
+    side of the "or".  The sub-lists are evaluated independently and
+    then combined, as described below.
+
+    A /symbol/ is expanded to the current value of the symbol, or the
+    empty string if the symbol is unset.  In the latter case, if
+    /symbol/ appears in a word by itself, the word is ignored.  This
+    is for backward compatibility and may change in the future.
+
+    If a /symbol/ has a "$" prefix, that prefix is ignored, for
+    backward compatibility.  This may become a syntax error in the
+    future.
+
+    A word with a suffix of "=X", where X is a quoted or unquoted
+    string, expands to "y" if the rest of the word evaluates to X, or
+    "n" otherwise.
+
+    A word prefixed by "!" expands to a transformation of the word:
+    "!y" becomes "n"; "!n" or "!" become "y"; "!m" becomes "m".  The
+    "!" prefix is expanded only after expansion of /symbol/s and the
+    "=" suffix.
+
+Once each word is expanded as described above, it should have a value
+of "y", "m" or "n", or the empty value "", which is discarded.  If the
+dependency list has multiple words, the words are reduced to a single
+word as follows:
+
+    If any word is "n", the value of the list becomes "n".
+
+    Otherwise, if any word is "m", the value of the list becomes "m".
+
+    Otherwise, the value of the list becomes "y".
+
+If there are multiple sub-lists separated by "or" words, each sub-list
+is reduced to a single word as described above, then they are combined
+as follows:
+
+   If any sub-list is "y", the final result is "y".
+
+   Otherwise, if any sub-list is "m", the final result is "m".
+
+   Otherwise, if all sub-lists are "n", the final result is "n".
+
+Finally, an empty /dep/ evaluates to "y".
+
+If you think in terms of Boolean algebra, most of the above rules make
+sense if you think of each primitive value ("y", "m" and "n") as two
+bits: "y"=11, "m"=01, "n"=00.  Adjacent words are implicitly ANDed
+together, and the "or" statement, with lower precedence, performs an
+OR between lists of words.  The "!" operator does not quite fit this
+explanation, because "!m" = "m", but that was specified for practical
+reasons, to cover a common case in kernel configuration.
+
+For examples, look at the statements which use dependency lists
+(dep_bool, dep_mbool, dep_tristate, if_dep).
+
+
+
 === mainmenu_name /prompt/
 
 This verb is a lot less important than it looks.  It specifies the top-level
@@ -436,15 +516,15 @@
 
 
 
-=== dep_bool /prompt/ /symbol/ /dep/ ...
+=== dep_bool /prompt/ /symbol/ /dep/
 
 This verb evaluates all of the dependencies in the dependency list.
-Any dependency which has a value of "y" does not restrict the input
-range.  Any dependency which has an empty value is ignored.
-Any dependency which has a value of "n", or which has some other value,
-(like "m") restricts the input range to "n".  Quoting dependencies is not
-allowed. Using dependencies with an empty value possible is not
-recommended.  See also dep_mbool below.
+Any dependency which expands to "y" (including "!n" and "!"; see
+above) does not restrict the input range.  Any dependency which
+expands to an empty value is ignored.  Any dependency which expands to
+"n", or any other value (like "m"), restricts the input range to "n".
+Quoting dependencies is not allowed. Using dependencies with an empty
+value possible is not recommended.  See also dep_mbool below.
 
 If the input range is restricted to the single choice "n", dep_bool
 silently assigns "n" to /symbol/.  If the input range has more than
@@ -469,11 +549,12 @@
 === dep_mbool /prompt/ /symbol/ /dep/ ...
 
 This verb evaluates all of the dependencies in the dependency list.
-Any dependency which has a value of "y" or "m" does not restrict the
-input range.  Any dependency which has an empty value is ignored.
-Any dependency which has a value of "n", or which has some other value,
-restricts the input range to "n".  Quoting dependencies is not allowed.
-Using dependencies with an empty value possible is not recommended.
+Any dependency which expands to "y" or "m" (including "!n" and "!";
+see above) does not restrict the input range.  Any dependency which
+expands to an empty value is ignored.  Any dependency which expands to
+"n", or any other value, restricts the input range to "n".  Quoting
+dependencies is not allowed.  Using dependencies with an empty value
+possible is not recommended.
 
 If the input range is restricted to the single choice "n", dep_bool
 silently assigns "n" to /symbol/.  If the input range has more than
@@ -514,12 +595,13 @@
 === dep_tristate /prompt/ /symbol/ /dep/ ...
 
 This verb evaluates all of the dependencies in the dependency list.
-Any dependency which has a value of "y" does not restrict the input range.
-Any dependency which has a value of "m" restricts the input range to
-"m" or "n".  Any dependency which has an empty value is ignored.
-Any dependency which has a value of "n", or which has some other value,
-restricts the input range to "n".  Quoting dependencies is not allowed.
-Using dependencies with an empty value possible is not recommended.
+Any dependency which expands to "y" (including "!n" or "!"; see above)
+does not restrict the input range.  Any dependency which expands to
+"m" restricts the input range to "m" or "n".  Any dependency which
+expands to an empty value is ignored.  Any dependency which expands to
+"n", or any other value, restricts the input range to "n".  Quoting
+dependencies is not allowed.  Using dependencies with an empty value
+possible is not recommended.
 
 If the input range is restricted to the single choice "n", dep_tristate
 silently assigns "n" to /symbol/.  If the input range has more than
@@ -619,6 +701,68 @@
 
 
 
+=== if_dep /dep/, else_dep, fi_dep
+
+"if_dep" begins a set of one or two blocks ending with the "fi_dep"
+statement and separated by the "else_dep" statement.  The "else_dep"
+and following block are optional.
+
+First, the dependency line for the if_dep is evaluated.  If it yields
+is "y", the following block is executed, and the block after the
+"else_dep", if present, is skipped.  If it yields "n", the opposite
+happens: the first block is skipped and the second (if present) is
+executed.
+
+If the dependency yields "m", the first block is executed and the
+second skipped, just as with "y", but with one crucial difference: the
+output for certain verbs is restricted.  "bool" and "dep_bool"
+statements are suppressed entirely; "tristate" and "dep_tristate" are
+restricted to the two values "m" and "n".  The valid values for other
+verbs such as "define_bool", "dep_mbool" and "hex" are not restricted.
+
+"if_dep" statements can be nested arbitrarily.  Each level of nesting
+further restricts whether and how the block within is interpreted.
+
+                |        Value of the if_dep dependency line
+  Statements in |        (nested restrictions are cumulative)
+  the blocks    |      y       |      n       |        m
+  --------------+--------------+--------------+-----------------------
+  bool,         |              |              | suppressed in
+  dep_bool      |              |              | both blocks
+                | unrestricted | suppressed   |
+  --------------+ in if_dep    | in if_dep    +-----------------------
+  tristate,     | block,       | block,       | restricted to {m,n} in
+  dep_tristate  | suppressed   | unrestricted | if_dep block, suppressed
+                | in else_dep  | in else_dep  | in else_dep block
+  --------------+ block        | block        +-----------------------
+  all other     |              |              | unrestricted in if_dep
+  verbs         |              |              | block, suppressed in
+                |              |              | else_dep block
+
+Note that "bool" and "dep_bool" are restricted by the "if_dep" in
+exactly the same way as "dep_bool" is by its own dependency line.
+Likewise, "tristate" and "dep_tristate" are restricted in exactly the
+same way as "dep_tristate" is by its dependency line.
+
+Example:
+
+    # FIXME: replace this example and add more, as soon as people
+    # FIXME: start actually using if_dep.
+    if_dep CONFIG_FOO !CONFIG_BAR
+        ...statements which execute if CONFIG_FOO is set to "y" or
+        "m", and CONFIG_BAR is unset or set to "n"
+    else_dep
+        ...statements which execute if the above conditions are not
+        both true
+    fi_dep
+
+Configure:  not implemented
+Menuconfig: implemented
+XConfig:    not implemented
+mconfig:    not implemented
+
+
+
 === if [ /expr/ ] ; then
 
 This is a conditional statement, with an optional 'else' clause.  You may


-------------------------------------------------------
This sf.net email is sponsored by: OSDN - Tired of that same old
cell phone?  Get a new here for FREE!
https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390
_______________________________________________
kbuild-devel mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/kbuild-devel

Reply via email to