gen_target_config.pl 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. $target->{kernel} =~ tr/\./_/;
  39. push @target, $target;
  40. };
  41. /^Target-Name:\s*(.+)\s*$/ and $target->{name} = $1;
  42. /^Target-Path:\s*(.+)\s*$/ and $target->{path} = $1;
  43. /^Target-Arch:\s*(.+)\s*$/ and $target->{arch} = $1;
  44. /^Target-Features:\s*(.+)\s*$/ and do {
  45. my $f = [];
  46. $target->{features} = $f;
  47. @$f = split /\s+/, $1;
  48. };
  49. /^Target-Description:/ and do {
  50. my $desc;
  51. while (<>) {
  52. last if /^@@/;
  53. $desc .= $_;
  54. }
  55. $target->{desc} = $desc;
  56. };
  57. /^Linux-Version:\s*(.+)\s*$/ and $target->{version} = $1;
  58. /^Linux-Release:\s*(.+)\s*$/ and $target->{release} = $1;
  59. /^Linux-Kernel-Arch:\s*(.+)\s*$/ and $target->{karch} = $1;
  60. /^Default-Packages:\s*(.+)\s*$/ and do {
  61. my @pkgs = split /\s+/, $1;
  62. $target->{defaultpkgs} = \@pkgs;
  63. };
  64. /^Target-Profile:\s*(.+)\s*$/ and do {
  65. $profiles = $target->{profiles} or $target->{profiles} = $profiles = [];
  66. $profile = {
  67. id => $1
  68. };
  69. push @$profiles, $profile;
  70. };
  71. /^Target-Profile-Name:\s*(.+)\s*$/ and $profile->{name} = $1;
  72. /^Target-Profile-Packages:\s*(.+)\s*$/ and do {
  73. my @pkgs = split /\s+/, $1;
  74. $profile->{pkgs} = \@pkgs;
  75. };
  76. }
  77. @target = sort {
  78. $a->{name} cmp $b->{name}
  79. } @target;
  80. print <<EOF;
  81. choice
  82. prompt "Target System"
  83. default LINUX_2_4_BRCM
  84. EOF
  85. foreach $target (@target) {
  86. my $features = features(@{$target->{features}});
  87. my $help = $target->{desc};
  88. chomp $features;
  89. $features .= "\n";
  90. if ($help =~ /\w+/) {
  91. $help =~ s/^\s*/\t /mg;
  92. $help = "\thelp\n$help";
  93. } else {
  94. undef $help;
  95. }
  96. print <<EOF
  97. config LINUX_$target->{conf}
  98. bool "$target->{name}"
  99. select $target->{arch}
  100. select LINUX_$target->{kernel}
  101. $features$help
  102. EOF
  103. }
  104. print <<EOF;
  105. if DEVEL
  106. config LINUX_2_6_ARM
  107. bool "UNSUPPORTED little-endian arm platform"
  108. depends BROKEN
  109. select LINUX_2_6
  110. select arm
  111. config LINUX_2_6_CRIS
  112. bool "UNSUPPORTED cris platform"
  113. depends BROKEN
  114. select LINUX_2_6
  115. select cris
  116. config LINUX_2_6_M68K
  117. bool "UNSUPPORTED m68k platform"
  118. depends BROKEN
  119. select LINUX_2_6
  120. select m68k
  121. config LINUX_2_6_SH3
  122. bool "UNSUPPORTED little-endian sh3 platform"
  123. depends BROKEN
  124. select LINUX_2_6
  125. select sh3
  126. config LINUX_2_6_SH3EB
  127. bool "UNSUPPORTED big-endian sh3 platform"
  128. depends BROKEN
  129. select LINUX_2_6
  130. select sh3eb
  131. config LINUX_2_6_SH4
  132. bool "UNSUPPORTED little-endian sh4 platform"
  133. depends BROKEN
  134. select LINUX_2_6
  135. select sh4
  136. config LINUX_2_6_SH4EB
  137. bool "UNSUPPORTED big-endian sh4 platform"
  138. depends BROKEN
  139. select LINUX_2_6
  140. select sh4eb
  141. config LINUX_2_6_SPARC
  142. bool "UNSUPPORTED sparc platform"
  143. depends BROKEN
  144. select LINUX_2_6
  145. select sparc
  146. endif
  147. endchoice
  148. choice
  149. prompt "Target Profile"
  150. EOF
  151. foreach $target (@target) {
  152. my $profiles;
  153. $profiles = $target->{profiles} or $profiles = [
  154. {
  155. id => 'Default',
  156. name => 'Default',
  157. pkgs => []
  158. }
  159. ];
  160. foreach my $profile (@$profiles) {
  161. print <<EOF;
  162. config LINUX_$target->{conf}_$profile->{id}
  163. bool "$profile->{name}"
  164. depends LINUX_$target->{conf}
  165. EOF
  166. foreach my $pkg (@{$target->{defaultpkgs}}, @{$profile->{pkgs}}) {
  167. print "\tselect DEFAULT_$pkg\n";
  168. }
  169. print "\n";
  170. }
  171. }
  172. print "endchoice\n";