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

Grant Likely grant.likely at secretlab.ca
Wed Sep 5 16:00:16 CEST 2007


From: Grant Likely <grant.likely at secretlab.ca>

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 <grant.likely at secretlab.ca>
---

 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 <configs/$1.h>" >>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
+}





More information about the U-Boot mailing list