make target/linux/* directories self-contained, use the selected kernel version for...
[openwrt/svn-archive/archive.git] / scripts / gen_target_config.pl
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
9 use strict;
10
11 my @target;
12 my $target;
13
14 sub features(@) {
15 my $ret;
16
17 while ($_ = shift @_) {
18 /broken/ and $ret .= "\tdepends BROKEN\n";
19 /pci/ and $ret .= "\tselect PCI_SUPPORT\n";
20 /usb/ and $ret .= "\tselect USB_SUPPORT\n";
21 /atm/ and $ret .= "\tselect ATM_SUPPORT\n";
22 /pcmcia/ and $ret .= "\tselect PCMCIA_SUPPORT\n";
23 /squashfs/ and $ret .= "\tselect USES_SQUASHFS\n";
24 /jffs2/ and $ret .= "\tselect USES_JFFS2\n";
25 /ext2/ and $ret .= "\tselect USES_EXT2\n";
26 }
27 return $ret;
28 }
29
30 while (<>) {
31 chomp;
32 /^Target:\s*((.+)-(\d+\.\d+))\s*$/ and do {
33 $target = {
34 id => $1,
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 }
60
61 @target = sort {
62 $a->{name} cmp $b->{name}
63 } @target;
64
65
66 foreach $target (@target) {
67 my $conf = uc $target->{kernel}.'_'.$target->{board};
68 my $features = features(@{$target->{features}});
69 my $help = $target->{desc};
70 chomp $features;
71 $features .= "\n";
72 $conf =~ tr/\.-/__/;
73 if ($help =~ /\w+/) {
74 $help =~ s/^\s*/\t /mg;
75 $help = "\thelp\n$help";
76 } else {
77 undef $help;
78 }
79
80 print <<EOF
81 config LINUX_$conf
82 bool "$target->{name}"
83 select $target->{arch}
84 $features$help
85
86 EOF
87 }
88