From: Wolfgang Denk Date: Fri, 07 Sep 2007 00:22:11 +0200 Subject: [U-Boot-Users] [PATCH 1/2] Import config.h values into include/config.mk In-Reply-To: Your message of "Wed, 05 Sep 2007 08:00:16 MDT." <20070905140015.29345.70726.stgit@trillian.cg.shawcable.net> Message-ID: <20070906222211.9E074247B6@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 -- 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.