summaryrefslogtreecommitdiffstats
path: root/scripts/gen_target_config.pl
blob: 4d0d6b13ef45e0f959a469ff40c2ef9b5391298d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#!/usr/bin/perl
# 
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

use strict;

my @target;
my $target;
my $profiles;
my $profile;

sub features(@) {
	my $ret;

	while ($_ = shift @_) {
		/broken/ and $ret .= "\tdepends BROKEN\n";
		/pci/ and $ret .= "\tselect PCI_SUPPORT\n";
		/usb/ and $ret .= "\tselect USB_SUPPORT\n";
		/atm/ and $ret .= "\tselect ATM_SUPPORT\n";
		/pcmcia/ and $ret .= "\tselect PCMCIA_SUPPORT\n";
		/squashfs/ and $ret .= "\tselect USES_SQUASHFS\n";
		/jffs2/ and $ret .= "\tselect USES_JFFS2\n";
		/ext2/ and $ret .= "\tselect USES_EXT2\n";
	}
	return $ret;
}

while (<>) {
	chomp;
	/^Target:\s*((.+)-(\d+\.\d+))\s*$/ and do {
		my $conf = uc $3.'_'.$2;
		$conf =~ tr/\.-/__/;
		$target = {
			id => $1,
			conf => $conf,
			board => $2,
			kernel => $3
		};
		push @target, $target;
	};
	/^Target-Name:\s*(.+)\s*$/ and $target->{name} = $1;
	/^Target-Path:\s*(.+)\s*$/ and $target->{path} = $1;
	/^Target-Arch:\s*(.+)\s*$/ and $target->{arch} = $1;
	/^Target-Features:\s*(.+)\s*$/ and do {
		my $f = [];
		$target->{features} = $f;
		@$f = split /\s+/, $1;
	};
	/^Target-Description:/ and do {
		my $desc;
		while (<>) {
			last if /^@@/;
			$desc .= $_;
		}
		$target->{desc} = $desc;
	};
	/^Linux-Version:\s*(.+)\s*$/ and $target->{version} = $1;
	/^Linux-Release:\s*(.+)\s*$/ and $target->{release} = $1;
	/^Linux-Kernel-Arch:\s*(.+)\s*$/ and $target->{karch} = $1;
	/^Default-Packages:\s*(.+)\s*$/ and do {
		my @pkgs = split /\s+/, $1;
		$target->{defaultpkgs} = \@pkgs;
	};
	/^Target-Profile:\s*(.+)\s*$/ and do {
		$profiles = $target->{profiles} or $target->{profiles} = $profiles = [];
		$profile = {
			id => $1
		};
		push @$profiles, $profile;
	};
	/^Target-Profile-Name:\s*(.+)\s*$/ and $profile->{name} = $1;
	/^Target-Profile-Packages:\s*(.+)\s*$/ and do {
		my @pkgs = split /\s+/, $1;
		$profile->{pkgs} = \@pkgs;
	};
}

@target = sort {
	$a->{name} cmp $b->{name}
} @target;


print <<EOF;
choice
	prompt "Target System"
	default LINUX_2_4_BRCM
	
EOF

foreach $target (@target) {
	my $features = features(@{$target->{features}});
	my $help = $target->{desc};
	chomp $features;
	$features .= "\n";
	if ($help =~ /\w+/) {
		$help =~ s/^\s*/\t  /mg;
		$help = "\thelp\n$help";
	} else {
		undef $help;
	}

	print <<EOF
config LINUX_$target->{conf}
	bool "$target->{name}"
	select $target->{arch}
$features$help

EOF
}

print <<EOF;
if DEVEL

config LINUX_2_6_ARM
	bool "UNSUPPORTED little-endian arm platform"
	depends BROKEN
	select LINUX_2_6
	select arm

config LINUX_2_6_CRIS
	bool "UNSUPPORTED cris platform"
	depends BROKEN
	select LINUX_2_6
	select cris

config LINUX_2_6_M68K
	bool "UNSUPPORTED m68k platform"
	depends BROKEN
	select LINUX_2_6
	select m68k

config LINUX_2_6_SH3
	bool "UNSUPPORTED little-endian sh3 platform"
	depends BROKEN
	select LINUX_2_6
	select sh3

config LINUX_2_6_SH3EB
	bool "UNSUPPORTED big-endian sh3 platform"
	depends BROKEN
	select LINUX_2_6
	select sh3eb

config LINUX_2_6_SH4
	bool "UNSUPPORTED little-endian sh4 platform"
	depends BROKEN
	select LINUX_2_6
	select sh4

config LINUX_2_6_SH4EB
	bool "UNSUPPORTED big-endian sh4 platform"
	depends BROKEN
	select LINUX_2_6
	select sh4eb

config LINUX_2_6_SPARC
	bool "UNSUPPORTED sparc platform"
	depends BROKEN
	select LINUX_2_6
	select sparc

endif

endchoice

choice
	prompt "Target Profile"

EOF

foreach $target (@target) {
	my $profiles;
	
	$profiles = $target->{profiles} or $profiles = [
		{
			id => 'Default',
			name => 'Default',
			pkgs => []
		}
	];
	foreach my $profile (@$profiles) {
		print <<EOF;
config LINUX_$target->{conf}_$profile->{id}
	bool "$profile->{name}"
	depends LINUX_$target->{conf}
EOF
		foreach my $pkg (@{$target->{defaultpkgs}}, @{$profile->{pkgs}}) {
			print "\tselect DEFAULT_$pkg\n";
		}
		print "\n";
	}
}

print "endchoice\n";