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