blob: af40bfaf2e8758607d5e64072063b883301ca40e [file] [log] [blame]
Grant Likely2f155f62007-09-24 09:05:31 -06001#
2# Sed script to parse CPP macros and generate output usable by make
3#
4# It is expected that this script is fed the output of 'gpp -dM'
5# which preprocesses the common.h header files and outputs the final
6# list of CPP macros (and whitespace is sanitized)
7#
8
9# Only process values prefixed with #define CONFIG_
Marcel Moolenaar02409f82008-02-22 10:48:07 -080010/^#define CONFIG_[A-Za-z0-9_][A-Za-z0-9_]*/ {
Grant Likely2f155f62007-09-24 09:05:31 -060011 # Strip the #define prefix
12 s/#define *//;
13 # Change to form CONFIG_*=VALUE
Marcel Moolenaar02409f82008-02-22 10:48:07 -080014 s/ */=/;
Grant Likely2f155f62007-09-24 09:05:31 -060015 # Drop trailing spaces
16 s/ *$//;
17 # drop quotes around string values
18 s/="\(.*\)"$/=\1/;
19 # Concatenate string values
20 s/" *"//g;
21 # Wrap non-numeral values with quotes
22 s/=\(.*\?[^0-9].*\)$/=\"\1\"/;
23 # Change '1' and empty values to "y" (not perfect, but
24 # supports conditional compilation in the makefiles
25 s/=$/=y/;
26 s/=1$/=y/;
27 # print the line
28 p
29}