3 use lib
"$FindBin::Bin";
8 sub target_config_features
(@
) {
11 while ($_ = shift @_) {
12 /^arm_v(\w+)$/ and $ret .= "\tselect arm_v$1\n";
13 /^broken$/ and $ret .= "\tdepends on BROKEN\n";
14 /^audio$/ and $ret .= "\tselect AUDIO_SUPPORT\n";
15 /^display$/ and $ret .= "\tselect DISPLAY_SUPPORT\n";
16 /^dt$/ and $ret .= "\tselect USES_DEVICETREE\n";
17 /^gpio$/ and $ret .= "\tselect GPIO_SUPPORT\n";
18 /^pci$/ and $ret .= "\tselect PCI_SUPPORT\n";
19 /^pcie$/ and $ret .= "\tselect PCIE_SUPPORT\n";
20 /^usb$/ and $ret .= "\tselect USB_SUPPORT\n";
21 /^usbgadget$/ and $ret .= "\tselect USB_GADGET_SUPPORT\n";
22 /^pcmcia$/ and $ret .= "\tselect PCMCIA_SUPPORT\n";
23 /^pwm$/ and $ret .= "\select PWM_SUPPORT\n";
24 /^rtc$/ and $ret .= "\tselect RTC_SUPPORT\n";
25 /^squashfs$/ and $ret .= "\tselect USES_SQUASHFS\n";
26 /^jffs2$/ and $ret .= "\tselect USES_JFFS2\n";
27 /^jffs2_nand$/ and $ret .= "\tselect USES_JFFS2_NAND\n";
28 /^ext4$/ and $ret .= "\tselect USES_EXT4\n";
29 /^targz$/ and $ret .= "\tselect USES_TARGZ\n";
30 /^cpiogz$/ and $ret .= "\tselect USES_CPIOGZ\n";
31 /^minor$/ and $ret .= "\tselect USES_MINOR\n";
32 /^ubifs$/ and $ret .= "\tselect USES_UBIFS\n";
33 /^fpu$/ and $ret .= "\tselect HAS_FPU\n";
34 /^spe_fpu$/ and $ret .= "\tselect HAS_SPE_FPU\n";
35 /^ramdisk$/ and $ret .= "\tselect USES_INITRAMFS\n";
36 /^powerpc64$/ and $ret .= "\tselect powerpc64\n";
37 /^nommu$/ and $ret .= "\tselect NOMMU\n";
38 /^mips16$/ and $ret .= "\tselect HAS_MIPS16\n";
39 /^rfkill$/ and $ret .= "\tselect RFKILL_SUPPORT\n";
40 /^low_mem$/ and $ret .= "\tselect LOW_MEMORY_FOOTPRINT\n";
41 /^small_flash$/ and $ret .= "\tselect SMALL_FLASH\n";
42 /^nand$/ and $ret .= "\tselect NAND_SUPPORT\n";
43 /^virtio$/ and $ret .= "\tselect VIRTIO_SUPPORT\n";
44 /^rootfs-part$/ and $ret .= "\tselect USES_ROOTFS_PART\n";
45 /^boot-part$/ and $ret .= "\tselect USES_BOOT_PART\n";
46 /^testing-kernel$/ and $ret .= "\tselect HAS_TESTING_KERNEL\n";
53 my $parent = $target->{parent
};
55 return $target->{parent
}->{name
}." - ".$target->{name
};
57 return $target->{name
};
64 if (substr($v,0,2) eq "2_") {
65 $v =~ /(\d+_\d+_\d+)(_\d+)?/ and $v = $1;
67 $v =~ /(\d+_\d+)(_\d+)?/ and $v = $1;
74 my $features = target_config_features
(@
{$target->{features
}});
75 my $help = $target->{desc
};
81 $help =~ s/^\s*/\t /mg;
82 $help = "\thelp\n$help";
87 my $v = kver
($target->{version
});
88 my $tv = kver
($target->{testing_version
});
90 if (@
{$target->{subtargets
}} == 0) {
92 config TARGET_$target->{conf}
93 bool "$target->{name}"
94 select LINUX_$v if !TESTING_KERNEL
95 select LINUX_$tv if TESTING_KERNEL
100 config TARGET_$target->{conf}
101 bool "$target->{name}"
104 if ($target->{subtarget
}) {
105 $confstr .= "\tdepends on TARGET_$target->{boardconf}\n";
107 if (@
{$target->{subtargets
}} > 0) {
108 $confstr .= "\tselect HAS_SUBTARGETS\n";
109 grep { /broken/ } @
{$target->{features
}} and $confstr .= "\tdepends on BROKEN\n";
111 $confstr .= $features;
112 if ($target->{arch
} =~ /\w/) {
113 $confstr .= "\tselect $target->{arch}\n";
115 if ($target->{has_devices
}) {
116 $confstr .= "\tselect HAS_DEVICES\n";
120 foreach my $dep (@
{$target->{depends
}}) {
121 my $mode = "depends on";
125 $dep =~ /^([@\+\-]+)(.+)$/;
129 next if $name =~ /:/;
130 $flags =~ /-/ and $mode = "deselect";
131 $flags =~ /\+/ and $mode = "select";
132 $flags =~ /@/ and $confstr .= "\t$mode $name\n";
134 $confstr .= "$help\n\n";
138 sub merge_package_lists
($$) {
144 foreach my $pkg (@
$list1, @
$list2) {
147 foreach my $pkg (keys %pkgs) {
148 push @l, $pkg unless ($pkg =~ /^-/ or $pkgs{"-$pkg"});
153 sub gen_target_config
() {
154 my $file = shift @ARGV;
155 my @target = parse_target_metadata
($file);
158 my @target_sort = sort {
159 target_name
($a) cmp target_name
($b);
162 foreach my $target (@target_sort) {
163 next if @
{$target->{subtargets
}} > 0;
165 config DEFAULT_TARGET_$target->{conf}
167 depends on TARGET_PER_DEVICE_ROOTFS
168 default y if TARGET_$target->{conf}
170 foreach my $pkg (@
{$target->{packages
}}) {
171 print "\tselect DEFAULT_$pkg if TARGET_PER_DEVICE_ROOTFS\n";
177 prompt "Target System"
183 foreach my $target (@target_sort) {
184 next if $target->{subtarget
};
185 print_target
($target);
192 prompt "Subtarget" if HAS_SUBTARGETS
194 foreach my $target (@target) {
195 next unless $target->{def_subtarget
};
197 default TARGET_$target->{conf}_$target->{def_subtarget} if TARGET_$target->{conf}
203 foreach my $target (@target) {
204 next unless $target->{subtarget
};
205 print_target
($target);
212 prompt "Target Profile"
213 default TARGET_MULTI_PROFILE if BUILDBOT
216 foreach my $target (@target) {
217 my $profile = $target->{profiles
}->[0];
220 default TARGET_$target->{conf}_$profile->{id} if TARGET_$target->{conf} && !BUILDBOT
226 config TARGET_MULTI_PROFILE
227 bool "Multiple devices"
228 depends on HAS_DEVICES
230 Instead of only building a single image, or all images, this allows you
231 to select images to be built for multiple devices in one build.
235 foreach my $target (@target) {
236 my $profiles = $target->{profiles
};
237 foreach my $profile (@
{$target->{profiles
}}) {
239 config TARGET_$target->{conf}_$profile->{id}
240 bool "$profile->{name}"
241 depends on TARGET_$target->{conf}
243 $profile->{broken
} and print "\tdepends on BROKEN\n";
244 my @pkglist = merge_package_lists
($target->{packages
}, $profile->{packages
});
245 foreach my $pkg (@pkglist) {
246 print "\tselect DEFAULT_$pkg\n";
249 my $help = $profile->{desc
};
250 if ($help =~ /\w+/) {
251 $help =~ s/^\s*/\t /mg;
252 $help = "\thelp\n$help";
263 menu "Target Devices"
264 depends on TARGET_MULTI_PROFILE
266 config TARGET_ALL_PROFILES
267 bool "Enable all profiles by default"
270 config TARGET_PER_DEVICE_ROOTFS
271 bool "Use a per-device root filesystem that adds profile packages"
274 When disabled, all device packages from all selected devices
275 will be included in all images by default. (Marked as <*>) You will
276 still be able to manually deselect any/all packages.
277 When enabled, each device builds it's own image, including only the
278 profile packages for that device. (Marked as {M}) You will be able
279 to change a package to included in all images by marking as {*}, but
280 will not be able to disable a profile package completely.
282 To get the most use of this setting, you must set in a .config stub
283 before calling "make defconfig". Selecting TARGET_MULTI_PROFILE and
284 then manually selecting (via menuconfig for instance) this option
285 will have pre-defaulted all profile packages to included, making this
286 option appear to have had no effect.
289 foreach my $target (@target) {
290 my @profiles = sort {
294 } @
{$target->{profiles
}};
295 foreach my $profile (@profiles) {
296 next unless $profile->{id
} =~ /^DEVICE_/;
298 menuconfig TARGET_DEVICE_$target->{conf}_$profile->{id}
299 bool "$profile->{name}"
300 depends on TARGET_$target->{conf}
301 default $profile->{default}
303 $profile->{broken
} and print "\tdepends on BROKEN\n";
304 my @pkglist = merge_package_lists
($target->{packages
}, $profile->{packages
});
305 foreach my $pkg (@pkglist) {
306 print "\tselect DEFAULT_$pkg if !TARGET_PER_DEVICE_ROOTFS\n";
307 print "\tselect MODULE_DEFAULT_$pkg if TARGET_PER_DEVICE_ROOTFS\n";
314 config TARGET_DEVICE_PACKAGES_$target->{conf}_$profile->{id}
315 string "$profile->{name} additional packages"
317 depends on TARGET_PER_DEVICE_ROOTFS
318 depends on TARGET_DEVICE_$target->{conf}_$profile->{id}
328 config HAS_SUBTARGETS
338 foreach my $target (@target) {
339 $target->{subtarget
} or print "\t\tdefault \"".$target->{board
}."\" if TARGET_".$target->{conf
}."\n";
342 config TARGET_SUBTARGET
344 default "generic" if !HAS_SUBTARGETS
348 foreach my $target (@target) {
349 foreach my $subtarget (@
{$target->{subtargets
}}) {
350 print "\t\tdefault \"$subtarget\" if TARGET_".$target->{conf
}."_$subtarget\n";
354 config TARGET_PROFILE
357 foreach my $target (@target) {
358 my $profiles = $target->{profiles
};
359 foreach my $profile (@
$profiles) {
360 print "\tdefault \"$profile->{id}\" if TARGET_$target->{conf}_$profile->{id}\n";
366 config TARGET_ARCH_PACKAGES
370 foreach my $target (@target) {
371 next if @
{$target->{subtargets
}} > 0;
372 print "\t\tdefault \"".($target->{arch_packages
} || $target->{board
})."\" if TARGET_".$target->{conf
}."\n";
376 config DEFAULT_TARGET_OPTIMIZATION
379 foreach my $target (@target) {
380 next if @
{$target->{subtargets
}} > 0;
381 print "\tdefault \"".$target->{cflags
}."\" if TARGET_".$target->{conf
}."\n";
383 print "\tdefault \"-Os -pipe -funit-at-a-time\"\n";
389 foreach my $target (@target) {
390 next if @
{$target->{subtargets
}} > 0;
391 print "\tdefault \"".$target->{cputype
}."\" if TARGET_".$target->{conf
}."\n";
393 print "\tdefault \"\"\n";
396 foreach my $target (@target) {
397 foreach my $tv ($target->{version
}, $target->{testing_version
}) {
410 foreach my $def (sort keys %defaults) {
415 config MODULE_DEFAULT_$def
417 depends on TARGET_PER_DEVICE_ROOTFS
419 default m if DEFAULT_$def
426 sub gen_profile_mk
() {
427 my $file = shift @ARGV;
428 my $target = shift @ARGV;
429 my @targets = parse_target_metadata
($file);
430 foreach my $cur (@targets) {
431 next unless $cur->{id
} eq $target;
432 print "PROFILE_NAMES = ".join(" ", map { $_->{id
} } @
{$cur->{profiles
}})."\n";
433 foreach my $profile (@
{$cur->{profiles
}}) {
434 print $profile->{id
}.'_NAME:='.$profile->{name
}."\n";
435 print $profile->{id
}.'_HAS_IMAGE_METADATA:='.$profile->{has_image_metadata
}."\n";
436 if (defined($profile->{supported_devices
}) and @
{$profile->{supported_devices
}} > 0) {
437 print $profile->{id
}.'_SUPPORTED_DEVICES:='.join(' ', @
{$profile->{supported_devices
}})."\n";
439 print $profile->{id
}.'_PACKAGES:='.join(' ', @
{$profile->{packages
}})."\n";
444 sub parse_command
() {
445 GetOptions
("ignore=s", \
@ignore);
446 my $cmd = shift @ARGV;
448 /^config$/ and return gen_target_config
();
449 /^profile_mk$/ and return gen_profile_mk
();
453 $0 config [file] Target metadata in Kconfig format
454 $0 profile_mk [file] [target] Profile metadata in makefile format