OpenWrt – Diff between revs 2 and 3
?pathlinks?
Rev 2 | Rev 3 | |||
---|---|---|---|---|
1 | #!/usr/bin/env perl |
1 | #!/usr/bin/env perl |
|
2 | use FindBin; |
2 | use FindBin; |
|
3 | use lib "$FindBin::Bin"; |
3 | use lib "$FindBin::Bin"; |
|
4 | use strict; |
4 | use strict; |
|
5 | use metadata; |
5 | use metadata; |
|
6 | use Getopt::Long; |
6 | use Getopt::Long; |
|
7 | |
7 | |
|
8 | sub target_config_features(@) { |
8 | sub target_config_features(@) { |
|
9 | my $ret; |
9 | my $ret; |
|
10 | |
10 | |
|
11 | while ($_ = shift @_) { |
11 | while ($_ = shift @_) { |
|
12 | /^arm_v(\w+)$/ and $ret .= "\tselect arm_v$1\n"; |
12 | /^arm_v(\w+)$/ and $ret .= "\tselect arm_v$1\n"; |
|
13 | /^broken$/ and $ret .= "\tdepends on BROKEN\n"; |
13 | /^broken$/ and $ret .= "\tdepends on BROKEN\n"; |
|
14 | /^audio$/ and $ret .= "\tselect AUDIO_SUPPORT\n"; |
14 | /^audio$/ and $ret .= "\tselect AUDIO_SUPPORT\n"; |
|
15 | /^display$/ and $ret .= "\tselect DISPLAY_SUPPORT\n"; |
15 | /^display$/ and $ret .= "\tselect DISPLAY_SUPPORT\n"; |
|
16 | /^dt$/ and $ret .= "\tselect USES_DEVICETREE\n"; |
16 | /^dt$/ and $ret .= "\tselect USES_DEVICETREE\n"; |
|
17 | /^gpio$/ and $ret .= "\tselect GPIO_SUPPORT\n"; |
17 | /^gpio$/ and $ret .= "\tselect GPIO_SUPPORT\n"; |
|
18 | /^pci$/ and $ret .= "\tselect PCI_SUPPORT\n"; |
18 | /^pci$/ and $ret .= "\tselect PCI_SUPPORT\n"; |
|
19 | /^pcie$/ and $ret .= "\tselect PCIE_SUPPORT\n"; |
19 | /^pcie$/ and $ret .= "\tselect PCIE_SUPPORT\n"; |
|
20 | /^usb$/ and $ret .= "\tselect USB_SUPPORT\n"; |
20 | /^usb$/ and $ret .= "\tselect USB_SUPPORT\n"; |
|
21 | /^usbgadget$/ and $ret .= "\tselect USB_GADGET_SUPPORT\n"; |
21 | /^usbgadget$/ and $ret .= "\tselect USB_GADGET_SUPPORT\n"; |
|
22 | /^pcmcia$/ and $ret .= "\tselect PCMCIA_SUPPORT\n"; |
22 | /^pcmcia$/ and $ret .= "\tselect PCMCIA_SUPPORT\n"; |
|
23 | /^rtc$/ and $ret .= "\tselect RTC_SUPPORT\n"; |
23 | /^rtc$/ and $ret .= "\tselect RTC_SUPPORT\n"; |
|
24 | /^squashfs$/ and $ret .= "\tselect USES_SQUASHFS\n"; |
24 | /^squashfs$/ and $ret .= "\tselect USES_SQUASHFS\n"; |
|
25 | /^jffs2$/ and $ret .= "\tselect USES_JFFS2\n"; |
25 | /^jffs2$/ and $ret .= "\tselect USES_JFFS2\n"; |
|
26 | /^jffs2_nand$/ and $ret .= "\tselect USES_JFFS2_NAND\n"; |
26 | /^jffs2_nand$/ and $ret .= "\tselect USES_JFFS2_NAND\n"; |
|
27 | /^ext4$/ and $ret .= "\tselect USES_EXT4\n"; |
27 | /^ext4$/ and $ret .= "\tselect USES_EXT4\n"; |
|
28 | /^targz$/ and $ret .= "\tselect USES_TARGZ\n"; |
28 | /^targz$/ and $ret .= "\tselect USES_TARGZ\n"; |
|
29 | /^cpiogz$/ and $ret .= "\tselect USES_CPIOGZ\n"; |
29 | /^cpiogz$/ and $ret .= "\tselect USES_CPIOGZ\n"; |
|
30 | /^minor$/ and $ret .= "\tselect USES_MINOR\n"; |
30 | /^minor$/ and $ret .= "\tselect USES_MINOR\n"; |
|
31 | /^ubifs$/ and $ret .= "\tselect USES_UBIFS\n"; |
31 | /^ubifs$/ and $ret .= "\tselect USES_UBIFS\n"; |
|
32 | /^fpu$/ and $ret .= "\tselect HAS_FPU\n"; |
32 | /^fpu$/ and $ret .= "\tselect HAS_FPU\n"; |
|
33 | /^spe_fpu$/ and $ret .= "\tselect HAS_SPE_FPU\n"; |
33 | /^spe_fpu$/ and $ret .= "\tselect HAS_SPE_FPU\n"; |
|
34 | /^ramdisk$/ and $ret .= "\tselect USES_INITRAMFS\n"; |
34 | /^ramdisk$/ and $ret .= "\tselect USES_INITRAMFS\n"; |
|
35 | /^powerpc64$/ and $ret .= "\tselect powerpc64\n"; |
35 | /^powerpc64$/ and $ret .= "\tselect powerpc64\n"; |
|
36 | /^nommu$/ and $ret .= "\tselect NOMMU\n"; |
36 | /^nommu$/ and $ret .= "\tselect NOMMU\n"; |
|
37 | /^mips16$/ and $ret .= "\tselect HAS_MIPS16\n"; |
37 | /^mips16$/ and $ret .= "\tselect HAS_MIPS16\n"; |
|
38 | /^rfkill$/ and $ret .= "\tselect RFKILL_SUPPORT\n"; |
38 | /^rfkill$/ and $ret .= "\tselect RFKILL_SUPPORT\n"; |
|
39 | /^low_mem$/ and $ret .= "\tselect LOW_MEMORY_FOOTPRINT\n"; |
39 | /^low_mem$/ and $ret .= "\tselect LOW_MEMORY_FOOTPRINT\n"; |
|
40 | /^small_flash$/ and $ret .= "\tselect SMALL_FLASH\n"; |
40 | /^small_flash$/ and $ret .= "\tselect SMALL_FLASH\n"; |
|
41 | /^nand$/ and $ret .= "\tselect NAND_SUPPORT\n"; |
41 | /^nand$/ and $ret .= "\tselect NAND_SUPPORT\n"; |
|
42 | /^virtio$/ and $ret .= "\tselect VIRTIO_SUPPORT\n"; |
42 | /^virtio$/ and $ret .= "\tselect VIRTIO_SUPPORT\n"; |
|
43 | /^rootfs-part$/ and $ret .= "\tselect USES_ROOTFS_PART\n"; |
- | ||
44 | /^boot-part$/ and $ret .= "\tselect USES_BOOT_PART\n"; |
- | ||
45 | } |
43 | } |
|
46 | return $ret; |
44 | return $ret; |
|
47 | } |
45 | } |
|
48 | |
46 | |
|
49 | sub target_name($) { |
47 | sub target_name($) { |
|
50 | my $target = shift; |
48 | my $target = shift; |
|
51 | my $parent = $target->{parent}; |
49 | my $parent = $target->{parent}; |
|
52 | if ($parent) { |
50 | if ($parent) { |
|
53 | return $target->{parent}->{name}." - ".$target->{name}; |
51 | return $target->{parent}->{name}." - ".$target->{name}; |
|
54 | } else { |
52 | } else { |
|
55 | return $target->{name}; |
53 | return $target->{name}; |
|
56 | } |
54 | } |
|
57 | } |
55 | } |
|
58 | |
56 | |
|
59 | sub kver($) { |
57 | sub kver($) { |
|
60 | my $v = shift; |
58 | my $v = shift; |
|
61 | $v =~ tr/\./_/; |
59 | $v =~ tr/\./_/; |
|
62 | if (substr($v,0,2) eq "2_") { |
60 | if (substr($v,0,2) eq "2_") { |
|
63 | $v =~ /(\d+_\d+_\d+)(_\d+)?/ and $v = $1; |
61 | $v =~ /(\d+_\d+_\d+)(_\d+)?/ and $v = $1; |
|
64 | } else { |
62 | } else { |
|
65 | $v =~ /(\d+_\d+)(_\d+)?/ and $v = $1; |
63 | $v =~ /(\d+_\d+)(_\d+)?/ and $v = $1; |
|
66 | } |
64 | } |
|
67 | return $v; |
65 | return $v; |
|
68 | } |
66 | } |
|
69 | |
67 | |
|
70 | sub print_target($) { |
68 | sub print_target($) { |
|
71 | my $target = shift; |
69 | my $target = shift; |
|
72 | my $features = target_config_features(@{$target->{features}}); |
70 | my $features = target_config_features(@{$target->{features}}); |
|
73 | my $help = $target->{desc}; |
71 | my $help = $target->{desc}; |
|
74 | my $confstr; |
72 | my $confstr; |
|
75 | |
73 | |
|
76 | chomp $features; |
74 | chomp $features; |
|
77 | $features .= "\n"; |
75 | $features .= "\n"; |
|
78 | if ($help =~ /\w+/) { |
76 | if ($help =~ /\w+/) { |
|
79 | $help =~ s/^\s*/\t /mg; |
77 | $help =~ s/^\s*/\t /mg; |
|
80 | $help = "\thelp\n$help"; |
78 | $help = "\thelp\n$help"; |
|
81 | } else { |
79 | } else { |
|
82 | undef $help; |
80 | undef $help; |
|
83 | } |
81 | } |
|
84 | |
82 | |
|
85 | my $v = kver($target->{version}); |
83 | my $v = kver($target->{version}); |
|
86 | if (@{$target->{subtargets}} == 0) { |
84 | if (@{$target->{subtargets}} == 0) { |
|
87 | $confstr = <<EOF; |
85 | $confstr = <<EOF; |
|
88 | config TARGET_$target->{conf} |
86 | config TARGET_$target->{conf} |
|
89 | bool "$target->{name}" |
87 | bool "$target->{name}" |
|
90 | select LINUX_$v |
88 | select LINUX_$v |
|
91 | EOF |
89 | EOF |
|
92 | } |
90 | } |
|
93 | else { |
91 | else { |
|
94 | $confstr = <<EOF; |
92 | $confstr = <<EOF; |
|
95 | config TARGET_$target->{conf} |
93 | config TARGET_$target->{conf} |
|
96 | bool "$target->{name}" |
94 | bool "$target->{name}" |
|
97 | EOF |
95 | EOF |
|
98 | } |
96 | } |
|
99 | if ($target->{subtarget}) { |
97 | if ($target->{subtarget}) { |
|
100 | $confstr .= "\tdepends on TARGET_$target->{boardconf}\n"; |
98 | $confstr .= "\tdepends on TARGET_$target->{boardconf}\n"; |
|
101 | } |
99 | } |
|
102 | if (@{$target->{subtargets}} > 0) { |
100 | if (@{$target->{subtargets}} > 0) { |
|
103 | $confstr .= "\tselect HAS_SUBTARGETS\n"; |
101 | $confstr .= "\tselect HAS_SUBTARGETS\n"; |
|
104 | grep { /broken/ } @{$target->{features}} and $confstr .= "\tdepends on BROKEN\n"; |
102 | grep { /broken/ } @{$target->{features}} and $confstr .= "\tdepends on BROKEN\n"; |
|
105 | } else { |
103 | } else { |
|
106 | $confstr .= $features; |
104 | $confstr .= $features; |
|
107 | if ($target->{arch} =~ /\w/) { |
105 | if ($target->{arch} =~ /\w/) { |
|
108 | $confstr .= "\tselect $target->{arch}\n"; |
106 | $confstr .= "\tselect $target->{arch}\n"; |
|
109 | } |
107 | } |
|
110 | if ($target->{has_devices}) { |
108 | if ($target->{has_devices}) { |
|
111 | $confstr .= "\tselect HAS_DEVICES\n"; |
109 | $confstr .= "\tselect HAS_DEVICES\n"; |
|
112 | } |
110 | } |
|
113 | } |
111 | } |
|
114 | |
112 | |
|
115 | foreach my $dep (@{$target->{depends}}) { |
113 | foreach my $dep (@{$target->{depends}}) { |
|
116 | my $mode = "depends on"; |
114 | my $mode = "depends on"; |
|
117 | my $flags; |
115 | my $flags; |
|
118 | my $name; |
116 | my $name; |
|
119 | |
117 | |
|
120 | $dep =~ /^([@\+\-]+)(.+)$/; |
118 | $dep =~ /^([@\+\-]+)(.+)$/; |
|
121 | $flags = $1; |
119 | $flags = $1; |
|
122 | $name = $2; |
120 | $name = $2; |
|
123 | |
121 | |
|
124 | next if $name =~ /:/; |
122 | next if $name =~ /:/; |
|
125 | $flags =~ /-/ and $mode = "deselect"; |
123 | $flags =~ /-/ and $mode = "deselect"; |
|
126 | $flags =~ /\+/ and $mode = "select"; |
124 | $flags =~ /\+/ and $mode = "select"; |
|
127 | $flags =~ /@/ and $confstr .= "\t$mode $name\n"; |
125 | $flags =~ /@/ and $confstr .= "\t$mode $name\n"; |
|
128 | } |
126 | } |
|
129 | $confstr .= "$help\n\n"; |
127 | $confstr .= "$help\n\n"; |
|
130 | print $confstr; |
128 | print $confstr; |
|
131 | } |
129 | } |
|
132 | |
130 | |
|
133 | sub merge_package_lists($$) { |
131 | sub merge_package_lists($$) { |
|
134 | my $list1 = shift; |
132 | my $list1 = shift; |
|
135 | my $list2 = shift; |
133 | my $list2 = shift; |
|
136 | my @l = (); |
134 | my @l = (); |
|
137 | my %pkgs; |
135 | my %pkgs; |
|
138 | |
136 | |
|
139 | foreach my $pkg (@$list1, @$list2) { |
137 | foreach my $pkg (@$list1, @$list2) { |
|
140 | $pkgs{$pkg} = 1; |
138 | $pkgs{$pkg} = 1; |
|
141 | } |
139 | } |
|
142 | foreach my $pkg (keys %pkgs) { |
140 | foreach my $pkg (keys %pkgs) { |
|
143 | push @l, $pkg unless ($pkg =~ /^-/ or $pkgs{"-$pkg"}); |
141 | push @l, $pkg unless ($pkg =~ /^-/ or $pkgs{"-$pkg"}); |
|
144 | } |
142 | } |
|
145 | return sort(@l); |
143 | return sort(@l); |
|
146 | } |
144 | } |
|
147 | |
145 | |
|
148 | sub gen_target_config() { |
146 | sub gen_target_config() { |
|
149 | my $file = shift @ARGV; |
147 | my $file = shift @ARGV; |
|
150 | my @target = parse_target_metadata($file); |
148 | my @target = parse_target_metadata($file); |
|
151 | my %defaults; |
149 | my %defaults; |
|
152 | |
150 | |
|
153 | my @target_sort = sort { |
151 | my @target_sort = sort { |
|
154 | target_name($a) cmp target_name($b); |
152 | target_name($a) cmp target_name($b); |
|
155 | } @target; |
153 | } @target; |
|
156 | |
154 | |
|
157 | foreach my $target (@target_sort) { |
155 | foreach my $target (@target_sort) { |
|
158 | next if @{$target->{subtargets}} > 0; |
156 | next if @{$target->{subtargets}} > 0; |
|
159 | print <<EOF; |
157 | print <<EOF; |
|
160 | config DEFAULT_TARGET_$target->{conf} |
158 | config DEFAULT_TARGET_$target->{conf} |
|
161 | bool |
159 | bool |
|
162 | depends on TARGET_PER_DEVICE_ROOTFS |
160 | depends on TARGET_PER_DEVICE_ROOTFS |
|
163 | default y if TARGET_$target->{conf} |
161 | default y if TARGET_$target->{conf} |
|
164 | EOF |
162 | EOF |
|
165 | foreach my $pkg (@{$target->{packages}}) { |
163 | foreach my $pkg (@{$target->{packages}}) { |
|
166 | print "\tselect DEFAULT_$pkg if TARGET_PER_DEVICE_ROOTFS\n"; |
164 | print "\tselect DEFAULT_$pkg if TARGET_PER_DEVICE_ROOTFS\n"; |
|
167 | } |
165 | } |
|
168 | } |
166 | } |
|
169 | |
167 | |
|
170 | print <<EOF; |
168 | print <<EOF; |
|
171 | choice |
169 | choice |
|
172 | prompt "Target System" |
170 | prompt "Target System" |
|
173 | default TARGET_ar71xx |
171 | default TARGET_ar71xx |
|
174 | reset if !DEVEL |
172 | reset if !DEVEL |
|
175 | |
173 | |
|
176 | EOF |
174 | EOF |
|
177 | |
175 | |
|
178 | foreach my $target (@target_sort) { |
176 | foreach my $target (@target_sort) { |
|
179 | next if $target->{subtarget}; |
177 | next if $target->{subtarget}; |
|
180 | print_target($target); |
178 | print_target($target); |
|
181 | } |
179 | } |
|
182 | |
180 | |
|
183 | print <<EOF; |
181 | print <<EOF; |
|
184 | endchoice |
182 | endchoice |
|
185 | |
183 | |
|
186 | choice |
184 | choice |
|
187 | prompt "Subtarget" if HAS_SUBTARGETS |
185 | prompt "Subtarget" if HAS_SUBTARGETS |
|
188 | EOF |
186 | EOF |
|
189 | foreach my $target (@target) { |
187 | foreach my $target (@target) { |
|
190 | next unless $target->{def_subtarget}; |
188 | next unless $target->{def_subtarget}; |
|
191 | print <<EOF; |
189 | print <<EOF; |
|
192 | default TARGET_$target->{conf}_$target->{def_subtarget} if TARGET_$target->{conf} |
190 | default TARGET_$target->{conf}_$target->{def_subtarget} if TARGET_$target->{conf} |
|
193 | EOF |
191 | EOF |
|
194 | } |
192 | } |
|
195 | print <<EOF; |
193 | print <<EOF; |
|
196 | |
194 | |
|
197 | EOF |
195 | EOF |
|
198 | foreach my $target (@target) { |
196 | foreach my $target (@target) { |
|
199 | next unless $target->{subtarget}; |
197 | next unless $target->{subtarget}; |
|
200 | print_target($target); |
198 | print_target($target); |
|
201 | } |
199 | } |
|
202 | |
200 | |
|
203 | print <<EOF; |
201 | print <<EOF; |
|
204 | endchoice |
202 | endchoice |
|
205 | |
203 | |
|
206 | choice |
204 | choice |
|
207 | prompt "Target Profile" |
205 | prompt "Target Profile" |
|
208 | default TARGET_MULTI_PROFILE if BUILDBOT |
206 | default TARGET_MULTI_PROFILE if BUILDBOT |
|
209 | |
207 | |
|
210 | EOF |
208 | EOF |
|
211 | foreach my $target (@target) { |
209 | foreach my $target (@target) { |
|
212 | my $profile = $target->{profiles}->[0]; |
210 | my $profile = $target->{profiles}->[0]; |
|
213 | $profile or next; |
211 | $profile or next; |
|
214 | print <<EOF; |
212 | print <<EOF; |
|
215 | default TARGET_$target->{conf}_$profile->{id} if TARGET_$target->{conf} && !BUILDBOT |
213 | default TARGET_$target->{conf}_$profile->{id} if TARGET_$target->{conf} && !BUILDBOT |
|
216 | EOF |
214 | EOF |
|
217 | } |
215 | } |
|
218 | |
216 | |
|
219 | print <<EOF; |
217 | print <<EOF; |
|
220 | |
218 | |
|
221 | config TARGET_MULTI_PROFILE |
219 | config TARGET_MULTI_PROFILE |
|
222 | bool "Multiple devices" |
220 | bool "Multiple devices" |
|
223 | depends on HAS_DEVICES |
221 | depends on HAS_DEVICES |
|
224 | help |
222 | help |
|
225 | Instead of only building a single image, or all images, this allows you |
223 | Instead of only building a single image, or all images, this allows you |
|
226 | to select images to be built for multiple devices in one build. |
224 | to select images to be built for multiple devices in one build. |
|
227 | |
225 | |
|
228 | EOF |
226 | EOF |
|
229 | |
227 | |
|
230 | foreach my $target (@target) { |
228 | foreach my $target (@target) { |
|
231 | my $profiles = $target->{profiles}; |
229 | my $profiles = $target->{profiles}; |
|
232 | foreach my $profile (@{$target->{profiles}}) { |
230 | foreach my $profile (@{$target->{profiles}}) { |
|
233 | print <<EOF; |
231 | print <<EOF; |
|
234 | config TARGET_$target->{conf}_$profile->{id} |
232 | config TARGET_$target->{conf}_$profile->{id} |
|
235 | bool "$profile->{name}" |
233 | bool "$profile->{name}" |
|
236 | depends on TARGET_$target->{conf} |
234 | depends on TARGET_$target->{conf} |
|
237 | EOF |
235 | EOF |
|
238 | my @pkglist = merge_package_lists($target->{packages}, $profile->{packages}); |
236 | my @pkglist = merge_package_lists($target->{packages}, $profile->{packages}); |
|
239 | foreach my $pkg (@pkglist) { |
237 | foreach my $pkg (@pkglist) { |
|
240 | print "\tselect DEFAULT_$pkg\n"; |
238 | print "\tselect DEFAULT_$pkg\n"; |
|
241 | $defaults{$pkg} = 1; |
239 | $defaults{$pkg} = 1; |
|
242 | } |
240 | } |
|
243 | my $help = $profile->{desc}; |
241 | my $help = $profile->{desc}; |
|
244 | if ($help =~ /\w+/) { |
242 | if ($help =~ /\w+/) { |
|
245 | $help =~ s/^\s*/\t /mg; |
243 | $help =~ s/^\s*/\t /mg; |
|
246 | $help = "\thelp\n$help"; |
244 | $help = "\thelp\n$help"; |
|
247 | } else { |
245 | } else { |
|
248 | undef $help; |
246 | undef $help; |
|
249 | } |
247 | } |
|
250 | print "$help\n"; |
248 | print "$help\n"; |
|
251 | } |
249 | } |
|
252 | } |
250 | } |
|
253 | |
251 | |
|
254 | print <<EOF; |
252 | print <<EOF; |
|
255 | endchoice |
253 | endchoice |
|
256 | |
254 | |
|
257 | menu "Target Devices" |
255 | menu "Target Devices" |
|
258 | depends on TARGET_MULTI_PROFILE |
256 | depends on TARGET_MULTI_PROFILE |
|
259 | |
257 | |
|
260 | config TARGET_ALL_PROFILES |
258 | config TARGET_ALL_PROFILES |
|
261 | bool "Enable all profiles by default" |
259 | bool "Enable all profiles by default" |
|
262 | default BUILDBOT |
260 | default BUILDBOT |
|
263 | |
261 | |
|
264 | config TARGET_PER_DEVICE_ROOTFS |
262 | config TARGET_PER_DEVICE_ROOTFS |
|
265 | bool "Use a per-device root filesystem that adds profile packages" |
263 | bool "Use a per-device root filesystem that adds profile packages" |
|
266 | default BUILDBOT |
264 | default BUILDBOT |
|
267 | help |
265 | help |
|
268 | When disabled, all device packages from all selected devices |
266 | When disabled, all device packages from all selected devices |
|
269 | will be included in all images by default. (Marked as <*>) You will |
267 | will be included in all images by default. (Marked as <*>) You will |
|
270 | still be able to manually deselect any/all packages. |
268 | still be able to manually deselect any/all packages. |
|
271 | When enabled, each device builds it's own image, including only the |
269 | When enabled, each device builds it's own image, including only the |
|
272 | profile packages for that device. (Marked as {M}) You will be able |
270 | profile packages for that device. (Marked as {M}) You will be able |
|
273 | to change a package to included in all images by marking as {*}, but |
271 | to change a package to included in all images by marking as {*}, but |
|
274 | will not be able to disable a profile package completely. |
272 | will not be able to disable a profile package completely. |
|
275 | |
273 | |
|
276 | To get the most use of this setting, you must set in a .config stub |
274 | To get the most use of this setting, you must set in a .config stub |
|
277 | before calling "make defconfig". Selecting TARGET_MULTI_PROFILE and |
275 | before calling "make defconfig". Selecting TARGET_MULTI_PROFILE and |
|
278 | then manually selecting (via menuconfig for instance) this option |
276 | then manually selecting (via menuconfig for instance) this option |
|
279 | will have pre-defaulted all profile packages to included, making this |
277 | will have pre-defaulted all profile packages to included, making this |
|
280 | option appear to have had no effect. |
278 | option appear to have had no effect. |
|
281 | |
279 | |
|
282 | EOF |
280 | EOF |
|
283 | foreach my $target (@target) { |
281 | foreach my $target (@target) { |
|
284 | my @profiles = sort { |
282 | my @profiles = sort { |
|
285 | my $x = $a->{name}; |
283 | my $x = $a->{name}; |
|
286 | my $y = $b->{name}; |
284 | my $y = $b->{name}; |
|
287 | "\L$x" cmp "\L$y"; |
285 | "\L$x" cmp "\L$y"; |
|
288 | } @{$target->{profiles}}; |
286 | } @{$target->{profiles}}; |
|
289 | foreach my $profile (@profiles) { |
287 | foreach my $profile (@profiles) { |
|
290 | next unless $profile->{id} =~ /^DEVICE_/; |
288 | next unless $profile->{id} =~ /^DEVICE_/; |
|
291 | print <<EOF; |
289 | print <<EOF; |
|
292 | menuconfig TARGET_DEVICE_$target->{conf}_$profile->{id} |
290 | menuconfig TARGET_DEVICE_$target->{conf}_$profile->{id} |
|
293 | bool "$profile->{name}" |
291 | bool "$profile->{name}" |
|
294 | depends on TARGET_$target->{conf} |
292 | depends on TARGET_$target->{conf} |
|
295 | default y if TARGET_ALL_PROFILES |
293 | default y if TARGET_ALL_PROFILES |
|
296 | EOF |
294 | EOF |
|
297 | my @pkglist = merge_package_lists($target->{packages}, $profile->{packages}); |
295 | my @pkglist = merge_package_lists($target->{packages}, $profile->{packages}); |
|
298 | foreach my $pkg (@pkglist) { |
296 | foreach my $pkg (@pkglist) { |
|
299 | print "\tselect DEFAULT_$pkg if !TARGET_PER_DEVICE_ROOTFS\n"; |
297 | print "\tselect DEFAULT_$pkg if !TARGET_PER_DEVICE_ROOTFS\n"; |
|
300 | print "\tselect MODULE_DEFAULT_$pkg if TARGET_PER_DEVICE_ROOTFS\n"; |
298 | print "\tselect MODULE_DEFAULT_$pkg if TARGET_PER_DEVICE_ROOTFS\n"; |
|
301 | $defaults{$pkg} = 1; |
299 | $defaults{$pkg} = 1; |
|
302 | } |
300 | } |
|
303 | |
301 | |
|
304 | print <<EOF; |
302 | print <<EOF; |
|
305 | |
303 | |
|
306 | |
304 | |
|
307 | config TARGET_DEVICE_PACKAGES_$target->{conf}_$profile->{id} |
305 | config TARGET_DEVICE_PACKAGES_$target->{conf}_$profile->{id} |
|
308 | string "$profile->{name} additional packages" |
306 | string "$profile->{name} additional packages" |
|
309 | default "" |
307 | default "" |
|
310 | depends on TARGET_PER_DEVICE_ROOTFS |
308 | depends on TARGET_PER_DEVICE_ROOTFS |
|
311 | depends on TARGET_DEVICE_$target->{conf}_$profile->{id} |
309 | depends on TARGET_DEVICE_$target->{conf}_$profile->{id} |
|
312 | |
310 | |
|
313 | EOF |
311 | EOF |
|
314 | } |
312 | } |
|
315 | } |
313 | } |
|
316 | |
314 | |
|
317 | print <<EOF; |
315 | print <<EOF; |
|
318 | |
316 | |
|
319 | endmenu |
317 | endmenu |
|
320 | |
318 | |
|
321 | config HAS_SUBTARGETS |
319 | config HAS_SUBTARGETS |
|
322 | bool |
320 | bool |
|
323 | |
321 | |
|
324 | config HAS_DEVICES |
322 | config HAS_DEVICES |
|
325 | bool |
323 | bool |
|
326 | |
324 | |
|
327 | config TARGET_BOARD |
325 | config TARGET_BOARD |
|
328 | string |
326 | string |
|
329 | |
327 | |
|
330 | EOF |
328 | EOF |
|
331 | foreach my $target (@target) { |
329 | foreach my $target (@target) { |
|
332 | $target->{subtarget} or print "\t\tdefault \"".$target->{board}."\" if TARGET_".$target->{conf}."\n"; |
330 | $target->{subtarget} or print "\t\tdefault \"".$target->{board}."\" if TARGET_".$target->{conf}."\n"; |
|
333 | } |
331 | } |
|
334 | print <<EOF; |
332 | print <<EOF; |
|
335 | config TARGET_SUBTARGET |
333 | config TARGET_SUBTARGET |
|
336 | string |
334 | string |
|
337 | default "generic" if !HAS_SUBTARGETS |
335 | default "generic" if !HAS_SUBTARGETS |
|
338 | |
336 | |
|
339 | EOF |
337 | EOF |
|
340 | |
338 | |
|
341 | foreach my $target (@target) { |
339 | foreach my $target (@target) { |
|
342 | foreach my $subtarget (@{$target->{subtargets}}) { |
340 | foreach my $subtarget (@{$target->{subtargets}}) { |
|
343 | print "\t\tdefault \"$subtarget\" if TARGET_".$target->{conf}."_$subtarget\n"; |
341 | print "\t\tdefault \"$subtarget\" if TARGET_".$target->{conf}."_$subtarget\n"; |
|
344 | } |
342 | } |
|
345 | } |
343 | } |
|
346 | print <<EOF; |
344 | print <<EOF; |
|
347 | config TARGET_PROFILE |
345 | config TARGET_PROFILE |
|
348 | string |
346 | string |
|
349 | EOF |
347 | EOF |
|
350 | foreach my $target (@target) { |
348 | foreach my $target (@target) { |
|
351 | my $profiles = $target->{profiles}; |
349 | my $profiles = $target->{profiles}; |
|
352 | foreach my $profile (@$profiles) { |
350 | foreach my $profile (@$profiles) { |
|
353 | print "\tdefault \"$profile->{id}\" if TARGET_$target->{conf}_$profile->{id}\n"; |
351 | print "\tdefault \"$profile->{id}\" if TARGET_$target->{conf}_$profile->{id}\n"; |
|
354 | } |
352 | } |
|
355 | } |
353 | } |
|
356 | |
354 | |
|
357 | print <<EOF; |
355 | print <<EOF; |
|
358 | |
356 | |
|
359 | config TARGET_ARCH_PACKAGES |
357 | config TARGET_ARCH_PACKAGES |
|
360 | string |
358 | string |
|
361 | |
359 | |
|
362 | EOF |
360 | EOF |
|
363 | foreach my $target (@target) { |
361 | foreach my $target (@target) { |
|
364 | next if @{$target->{subtargets}} > 0; |
362 | next if @{$target->{subtargets}} > 0; |
|
365 | print "\t\tdefault \"".($target->{arch_packages} || $target->{board})."\" if TARGET_".$target->{conf}."\n"; |
363 | print "\t\tdefault \"".($target->{arch_packages} || $target->{board})."\" if TARGET_".$target->{conf}."\n"; |
|
366 | } |
364 | } |
|
367 | print <<EOF; |
365 | print <<EOF; |
|
368 | |
366 | |
|
369 | config DEFAULT_TARGET_OPTIMIZATION |
367 | config DEFAULT_TARGET_OPTIMIZATION |
|
370 | string |
368 | string |
|
371 | EOF |
369 | EOF |
|
372 | foreach my $target (@target) { |
370 | foreach my $target (@target) { |
|
373 | next if @{$target->{subtargets}} > 0; |
371 | next if @{$target->{subtargets}} > 0; |
|
374 | print "\tdefault \"".$target->{cflags}."\" if TARGET_".$target->{conf}."\n"; |
372 | print "\tdefault \"".$target->{cflags}."\" if TARGET_".$target->{conf}."\n"; |
|
375 | } |
373 | } |
|
376 | print "\tdefault \"-Os -pipe -funit-at-a-time\"\n"; |
374 | print "\tdefault \"-Os -pipe -funit-at-a-time\"\n"; |
|
377 | print <<EOF; |
375 | print <<EOF; |
|
378 | |
376 | |
|
379 | config CPU_TYPE |
377 | config CPU_TYPE |
|
380 | string |
378 | string |
|
381 | EOF |
379 | EOF |
|
382 | foreach my $target (@target) { |
380 | foreach my $target (@target) { |
|
383 | next if @{$target->{subtargets}} > 0; |
381 | next if @{$target->{subtargets}} > 0; |
|
384 | print "\tdefault \"".$target->{cputype}."\" if TARGET_".$target->{conf}."\n"; |
382 | print "\tdefault \"".$target->{cputype}."\" if TARGET_".$target->{conf}."\n"; |
|
385 | } |
383 | } |
|
386 | print "\tdefault \"\"\n"; |
384 | print "\tdefault \"\"\n"; |
|
387 | |
385 | |
|
388 | my %kver; |
386 | my %kver; |
|
389 | foreach my $target (@target) { |
387 | foreach my $target (@target) { |
|
390 | my $v = kver($target->{version}); |
388 | my $v = kver($target->{version}); |
|
391 | next if $kver{$v}; |
389 | next if $kver{$v}; |
|
392 | $kver{$v} = 1; |
390 | $kver{$v} = 1; |
|
393 | print <<EOF; |
391 | print <<EOF; |
|
394 | |
392 | |
|
395 | config LINUX_$v |
393 | config LINUX_$v |
|
396 | bool |
394 | bool |
|
397 | |
395 | |
|
398 | EOF |
396 | EOF |
|
399 | } |
397 | } |
|
400 | foreach my $def (sort keys %defaults) { |
398 | foreach my $def (sort keys %defaults) { |
|
401 | print <<EOF; |
399 | print <<EOF; |
|
402 | config DEFAULT_$def |
400 | config DEFAULT_$def |
|
403 | bool |
401 | bool |
|
404 | |
402 | |
|
405 | config MODULE_DEFAULT_$def |
403 | config MODULE_DEFAULT_$def |
|
406 | tristate |
404 | tristate |
|
407 | depends on TARGET_PER_DEVICE_ROOTFS |
405 | depends on TARGET_PER_DEVICE_ROOTFS |
|
408 | depends on m |
406 | depends on m |
|
409 | default m if DEFAULT_$def |
407 | default m if DEFAULT_$def |
|
410 | select PACKAGE_$def |
408 | select PACKAGE_$def |
|
411 | |
409 | |
|
412 | EOF |
410 | EOF |
|
413 | } |
411 | } |
|
414 | } |
412 | } |
|
415 | |
413 | |
|
416 | sub gen_profile_mk() { |
414 | sub gen_profile_mk() { |
|
417 | my $file = shift @ARGV; |
415 | my $file = shift @ARGV; |
|
418 | my $target = shift @ARGV; |
416 | my $target = shift @ARGV; |
|
419 | my @targets = parse_target_metadata($file); |
417 | my @targets = parse_target_metadata($file); |
|
420 | foreach my $cur (@targets) { |
418 | foreach my $cur (@targets) { |
|
421 | next unless $cur->{id} eq $target; |
419 | next unless $cur->{id} eq $target; |
|
422 | print "PROFILE_NAMES = ".join(" ", map { $_->{id} } @{$cur->{profiles}})."\n"; |
420 | print "PROFILE_NAMES = ".join(" ", map { $_->{id} } @{$cur->{profiles}})."\n"; |
|
423 | foreach my $profile (@{$cur->{profiles}}) { |
421 | foreach my $profile (@{$cur->{profiles}}) { |
|
424 | print $profile->{id}.'_NAME:='.$profile->{name}."\n"; |
422 | print $profile->{id}.'_NAME:='.$profile->{name}."\n"; |
|
425 | print $profile->{id}.'_PACKAGES:='.join(' ', @{$profile->{packages}})."\n"; |
423 | print $profile->{id}.'_PACKAGES:='.join(' ', @{$profile->{packages}})."\n"; |
|
426 | } |
424 | } |
|
427 | } |
425 | } |
|
428 | } |
426 | } |
|
429 | |
427 | |
|
430 | sub parse_command() { |
428 | sub parse_command() { |
|
431 | GetOptions("ignore=s", \@ignore); |
429 | GetOptions("ignore=s", \@ignore); |
|
432 | my $cmd = shift @ARGV; |
430 | my $cmd = shift @ARGV; |
|
433 | for ($cmd) { |
431 | for ($cmd) { |
|
434 | /^config$/ and return gen_target_config(); |
432 | /^config$/ and return gen_target_config(); |
|
435 | /^profile_mk$/ and return gen_profile_mk(); |
433 | /^profile_mk$/ and return gen_profile_mk(); |
|
436 | } |
434 | } |
|
437 | die <<EOF |
435 | die <<EOF |
|
438 | Available Commands: |
436 | Available Commands: |
|
439 | $0 config [file] Target metadata in Kconfig format |
437 | $0 config [file] Target metadata in Kconfig format |
|
440 | $0 profile_mk [file] [target] Profile metadata in makefile format |
438 | $0 profile_mk [file] [target] Profile metadata in makefile format |
|
441 | |
439 | |
|
442 | EOF |
440 | EOF |
|
443 | } |
441 | } |
|
444 | |
442 | |
|
445 | parse_command(); |
443 | parse_command(); |
|
446 | |
444 | |
|
447 | |
445 | |
|
448 |
|
446 |
|
|
449 | |
447 | |
|
450 | |
448 | |
|
451 | |
449 | |