define2mk.sed 792 B

1234567891011121314151617181920212223242526272829
  1. #
  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. # Only process values prefixed with #define CONFIG_
  9. /^#define CONFIG_[A-Za-z0-9_]\+/ {
  10. # Strip the #define prefix
  11. s/#define *//;
  12. # Change to form CONFIG_*=VALUE
  13. s/ \+/=/;
  14. # Drop trailing spaces
  15. s/ *$//;
  16. # drop quotes around string values
  17. s/="\(.*\)"$/=\1/;
  18. # Concatenate string values
  19. s/" *"//g;
  20. # Wrap non-numeral values with quotes
  21. s/=\(.*\?[^0-9].*\)$/=\"\1\"/;
  22. # Change '1' and empty values to "y" (not perfect, but
  23. # supports conditional compilation in the makefiles
  24. s/=$/=y/;
  25. s/=1$/=y/;
  26. # print the line
  27. p
  28. }