[U-Boot-Users] [PATCH 1/2] Import config.h values into include/config.mk

Wolfgang Denk wd at denx.de
Fri Sep 7 00:22:11 CEST 2007


In message <20070905140015.29345.70726.stgit at 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

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I have a theory that it's impossible to prove anything, but  I  can't
prove it.




More information about the U-Boot mailing list