
In message 20070905140015.29345.70726.stgit@trillian.cg.shawcable.net you wrote:
Use cpp and sed to postprocess config.h and import the defined values into include/config.mk. This is to support conditional compile of modules
Just a few comments....
+# +# Sed script to parse CPP macros and generate output usable by make
This will NOT work!
+# Only process values prefixed with #define CONFIG_ or CFG_ +/^#define (CONFIG_|CFG_)[A-Za-z0-9_]+/ {
Optional white space between ^ and # and between # and define. White space after define may be any sequence of space and TAB chars.
- # Strip the #define prefix
- s/#define *//;
Ditto.
- # Change to form CONFIG_*=VALUE
- s/ +/=/;
One or more spaces or tabs...
- # Drop trailing spaces
- s/ *$//;
or tabs...
- # drop quoted string values
- s/="(.*)"$/=\1/;
What about embedded escaped " chars?
- # Concatenate string values
- s/" *"//g;
- # Wrap unknown with quotes
Ditto.
- s/=(.*?[^0-9].*)$/="\1"/;
- # Change empty properties and '1' properties to "y"
- s/=$/=y/;
- s/=1$/=y/;
- # print the line
What about #defines between #if 0 / #endif pairs? Or
/* #define CONFIG_FOO */
etc.
Parsing C preprocessor code is not that simple, I guess...
Best regards,
Wolfgang Denk