From: Grant Likely Date: Wed, 05 Sep 2007 08:00:16 -0600 Subject: [U-Boot-Users] [PATCH 1/2] Import config.h values into include/config.mk In-Reply-To: <20070905134927.29345.73588.stgit@trillian.cg.shawcable.net> References: <20070905134927.29345.73588.stgit@trillian.cg.shawcable.net> Message-ID: <20070905140015.29345.70726.stgit@trillian.cg.shawcable.net> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de From: Grant Likely 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 Signed-off-by: Grant Likely --- Makefile | 4 ++++ mkconfig | 7 +++++++ tools/scripts/define2mk.sed | 24 ++++++++++++++++++++++++ 3 files changed, 35 insertions(+), 0 deletions(-) diff --git a/Makefile b/Makefile index 0477cd3..75fc4d7 100644 --- a/Makefile +++ b/Makefile @@ -362,6 +362,10 @@ unconfig: @rm -f $(obj)include/config.h $(obj)include/config.mk \ $(obj)board/*/config.tmp $(obj)board/*/*/config.tmp +# Helper target for populating include/config.mk +.populate.config.mk: + @${CPP} ${CFLAGS} -dM include/common.h | sed -n -f tools/scripts/define2mk.sed >> $(obj)include/config.mk + #======================================================================== # PowerPC #======================================================================== diff --git a/mkconfig b/mkconfig index c3e4cea..eff7d2a 100755 --- a/mkconfig +++ b/mkconfig @@ -84,4 +84,11 @@ fi echo "/* Automatically generated - do not edit */" >>config.h echo "#include " >>config.h +# +# Import the board config into config.mk +# + +cd .. +make .populate.config.mk + exit 0 diff --git a/tools/scripts/define2mk.sed b/tools/scripts/define2mk.sed new file mode 100644 index 0000000..0a74e2e --- /dev/null +++ b/tools/scripts/define2mk.sed @@ -0,0 +1,24 @@ +# +# Sed script to parse CPP macros and generate output usable by make +# + +# Only process values prefixed with #define CONFIG_ or CFG_ +/^#define \(CONFIG_\|CFG_\)[A-Za-z0-9_]\+/ { + # Strip the #define prefix + s/#define *//; + # Change to form CONFIG_*=VALUE + s/ \+/=/; + # Drop trailing spaces + s/ *$//; + # drop quoted string values + s/="\(.*\)"$/=\1/; + # Concatenate string values + s/" *"//g; + # Wrap unknown with quotes + s/=\(.*\?[^0-9].*\)$/=\"\1\"/; + # Change empty properties and '1' properties to "y" + s/=$/=y/; + s/=1$/=y/; + # print the line + p +}