convert-config.pl 527 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/usr/bin/env perl
  2. use strict;
  3. print <<EOF;
  4. config ALL
  5. bool
  6. default y
  7. EOF
  8. while (<>) {
  9. chomp;
  10. next unless /^CONFIG_([^=]+)=(.*)$/;
  11. my $var = $1;
  12. my $val = $2;
  13. my $type;
  14. next if $var eq 'ALL';
  15. if ($val eq 'y') {
  16. $type = "bool";
  17. } elsif ($val eq 'm') {
  18. $type = "tristate";
  19. } elsif ($val =~ /^".*"$/) {
  20. $type = "string";
  21. } elsif ($val =~ /^\d+$/) {
  22. $type = "int";
  23. } else {
  24. warn "WARNING: no type found for symbol CONFIG_$var=$val\n";
  25. next;
  26. }
  27. print <<EOF;
  28. config $var
  29. $type
  30. default $val
  31. EOF
  32. }