convert-config.pl 563 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 if /^CONFIG_SIGNED_PACKAGES/;
  11. next unless /^CONFIG_([^=]+)=(.*)$/;
  12. my $var = $1;
  13. my $val = $2;
  14. my $type;
  15. next if $var eq 'ALL';
  16. if ($val eq 'y') {
  17. $type = "bool";
  18. } elsif ($val eq 'm') {
  19. $type = "tristate";
  20. } elsif ($val =~ /^".*"$/) {
  21. $type = "string";
  22. } elsif ($val =~ /^\d+$/) {
  23. $type = "int";
  24. } else {
  25. warn "WARNING: no type found for symbol CONFIG_$var=$val\n";
  26. next;
  27. }
  28. print <<EOF;
  29. config $var
  30. $type
  31. default $val
  32. EOF
  33. }