gen_target_config.pl 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. #!/usr/bin/perl
  2. #
  3. # Copyright (C) 2006 OpenWrt.org
  4. #
  5. # This is free software, licensed under the GNU General Public License v2.
  6. # See /LICENSE for more information.
  7. #
  8. use strict;
  9. my @target;
  10. my $target;
  11. my $profiles;
  12. my $profile;
  13. sub features(@) {
  14. my $ret;
  15. while ($_ = shift @_) {
  16. /broken/ and $ret .= "\tdepends BROKEN\n";
  17. /pci/ and $ret .= "\tselect PCI_SUPPORT\n";
  18. /usb/ and $ret .= "\tselect USB_SUPPORT\n";
  19. /atm/ and $ret .= "\tselect ATM_SUPPORT\n";
  20. /pcmcia/ and $ret .= "\tselect PCMCIA_SUPPORT\n";
  21. /squashfs/ and $ret .= "\tselect USES_SQUASHFS\n";
  22. /jffs2/ and $ret .= "\tselect USES_JFFS2\n";
  23. /ext2/ and $ret .= "\tselect USES_EXT2\n";
  24. }
  25. return $ret;
  26. }
  27. while (<>) {
  28. chomp;
  29. /^Target:\s*((.+)-(\d+\.\d+))\s*$/ and do {
  30. my $conf = uc $3.'_'.$2;
  31. $conf =~ tr/\.-/__/;
  32. $target = {
  33. id => $1,
  34. conf => $conf,
  35. board => $2,
  36. kernel => $3
  37. };
  38. push @target, $target;
  39. };
  40. /^Target-Name:\s*(.+)\s*$/ and $target->{name} = $1;
  41. /^Target-Path:\s*(.+)\s*$/ and $target->{path} = $1;
  42. /^Target-Arch:\s*(.+)\s*$/ and $target->{arch} = $1;
  43. /^Target-Features:\s*(.+)\s*$/ and do {
  44. my $f = [];
  45. $target->{features} = $f;
  46. @$f = split /\s+/, $1;
  47. };
  48. /^Target-Description:/ and do {
  49. my $desc;
  50. while (<>) {
  51. last if /^@@/;
  52. $desc .= $_;
  53. }
  54. $target->{desc} = $desc;
  55. };
  56. /^Linux-Version:\s*(.+)\s*$/ and $target->{version} = $1;
  57. /^Linux-Release:\s*(.+)\s*$/ and $target->{release} = $1;
  58. /^Linux-Kernel-Arch:\s*(.+)\s*$/ and $target->{karch} = $1;
  59. /^Default-Packages:\s*(.+)\s*$/ and do {
  60. my @pkgs = split /\s+/, $1;
  61. $target->{defaultpkgs} = \@pkgs;
  62. };
  63. /^Target-Profile:\s*(.+)\s*$/ and do {
  64. $profiles = $target->{profiles} or $target->{profiles} = $profiles = [];
  65. $profile = {
  66. id => $1
  67. };
  68. push @$profiles, $profile;
  69. };
  70. /^Target-Profile-Name:\s*(.+)\s*$/ and $profile->{name} = $1;
  71. /^Target-Profile-Packages:\s*(.+)\s*$/ and do {
  72. my @pkgs = split /\s+/, $1;
  73. $profile->{pkgs} = \@pkgs;
  74. };
  75. }
  76. @target = sort {
  77. $a->{name} cmp $b->{name}
  78. } @target;
  79. print <<EOF;
  80. choice
  81. prompt "Target System"
  82. default LINUX_2_4_BRCM
  83. EOF
  84. foreach $target (@target) {
  85. my $features = features(@{$target->{features}});
  86. my $help = $target->{desc};
  87. chomp $features;
  88. $features .= "\n";
  89. if ($help =~ /\w+/) {
  90. $help =~ s/^\s*/\t /mg;
  91. $help = "\thelp\n$help";
  92. } else {
  93. undef $help;
  94. }
  95. print <<EOF
  96. config LINUX_$target->{conf}
  97. bool "$target->{name}"
  98. select $target->{arch}
  99. $features$help
  100. EOF
  101. }
  102. print <<EOF;
  103. if DEVEL
  104. config LINUX_2_6_ARM
  105. bool "UNSUPPORTED little-endian arm platform"
  106. depends BROKEN
  107. select LINUX_2_6
  108. select arm
  109. config LINUX_2_6_CRIS
  110. bool "UNSUPPORTED cris platform"
  111. depends BROKEN
  112. select LINUX_2_6
  113. select cris
  114. config LINUX_2_6_M68K
  115. bool "UNSUPPORTED m68k platform"
  116. depends BROKEN
  117. select LINUX_2_6
  118. select m68k
  119. config LINUX_2_6_SH3
  120. bool "UNSUPPORTED little-endian sh3 platform"
  121. depends BROKEN
  122. select LINUX_2_6
  123. select sh3
  124. config LINUX_2_6_SH3EB
  125. bool "UNSUPPORTED big-endian sh3 platform"
  126. depends BROKEN
  127. select LINUX_2_6
  128. select sh3eb
  129. config LINUX_2_6_SH4
  130. bool "UNSUPPORTED little-endian sh4 platform"
  131. depends BROKEN
  132. select LINUX_2_6
  133. select sh4
  134. config LINUX_2_6_SH4EB
  135. bool "UNSUPPORTED big-endian sh4 platform"
  136. depends BROKEN
  137. select LINUX_2_6
  138. select sh4eb
  139. config LINUX_2_6_SPARC
  140. bool "UNSUPPORTED sparc platform"
  141. depends BROKEN
  142. select LINUX_2_6
  143. select sparc
  144. endif
  145. endchoice
  146. choice
  147. prompt "Target Profile"
  148. EOF
  149. foreach $target (@target) {
  150. my $profiles;
  151. $profiles = $target->{profiles} or $profiles = [
  152. {
  153. id => 'Default',
  154. name => 'Default',
  155. pkgs => []
  156. }
  157. ];
  158. foreach my $profile (@$profiles) {
  159. print <<EOF;
  160. config LINUX_$target->{conf}_$profile->{id}
  161. bool "$profile->{name}"
  162. depends LINUX_$target->{conf}
  163. EOF
  164. foreach my $pkg (@{$target->{defaultpkgs}}, @{$profile->{pkgs}}) {
  165. print "\tselect DEFAULT_$pkg\n";
  166. }
  167. print "\n";
  168. }
  169. }
  170. print "endchoice\n";