xref: /rk3399_rockchip-uboot/tools/scripts/define2mk.sed (revision 02409f8cf54c7cd91981f0dfec135dbf3858090c)
12f155f6cSGrant Likely#
22f155f6cSGrant Likely# Sed script to parse CPP macros and generate output usable by make
32f155f6cSGrant Likely#
42f155f6cSGrant Likely# It is expected that this script is fed the output of 'gpp -dM'
52f155f6cSGrant Likely# which preprocesses the common.h header files and outputs the final
62f155f6cSGrant Likely# list of CPP macros (and whitespace is sanitized)
72f155f6cSGrant Likely#
82f155f6cSGrant Likely
92f155f6cSGrant Likely# Only process values prefixed with #define CONFIG_
10*02409f8cSMarcel Moolenaar/^#define CONFIG_[A-Za-z0-9_][A-Za-z0-9_]*/ {
112f155f6cSGrant Likely	# Strip the #define prefix
122f155f6cSGrant Likely	s/#define *//;
132f155f6cSGrant Likely	# Change to form CONFIG_*=VALUE
14*02409f8cSMarcel Moolenaar	s/  */=/;
152f155f6cSGrant Likely	# Drop trailing spaces
162f155f6cSGrant Likely	s/ *$//;
172f155f6cSGrant Likely	# drop quotes around string values
182f155f6cSGrant Likely	s/="\(.*\)"$/=\1/;
192f155f6cSGrant Likely	# Concatenate string values
202f155f6cSGrant Likely	s/" *"//g;
212f155f6cSGrant Likely	# Wrap non-numeral values with quotes
222f155f6cSGrant Likely	s/=\(.*\?[^0-9].*\)$/=\"\1\"/;
232f155f6cSGrant Likely	# Change '1' and empty values to "y" (not perfect, but
242f155f6cSGrant Likely	# supports conditional compilation in the makefiles
252f155f6cSGrant Likely	s/=$/=y/;
262f155f6cSGrant Likely	s/=1$/=y/;
272f155f6cSGrant Likely	# print the line
282f155f6cSGrant Likely	p
292f155f6cSGrant Likely}
30