conf2h.awk 503 B

1234567891011121314151617181920212223242526272829
  1. #! /usr/bin/gawk -f
  2. # Trivial little script to convert from a makefile-style configuration
  3. # file to a C header. No copyright claimed.
  4. BEGIN {
  5. print "// autoconf.h generated from " ARGV[1] " at " strftime() "\n" \
  6. "#ifndef AUTOCONF_H\n" \
  7. "#define AUTOCONF_H"
  8. }
  9. /^#/ { sub(/^#/,"//") }
  10. /^CONFIG_.*=/ {
  11. if (/=n$/) {
  12. sub(/^/,"// ");
  13. } else {
  14. sub(/^/,"#define ")
  15. if (/=y$/) {
  16. sub(/=.*$/,"")
  17. } else {
  18. sub(/=/," ")
  19. }
  20. }
  21. }
  22. { print }
  23. END { print "#endif" }