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 /^seperate_ramdisk$/ and $ret .= "\tselect USES_INITRAMFS\n\tselect USES_SEPERATE_INITRAMFS\n";
37 /^powerpc64$/ and $ret .= "\tselect powerpc64\n";
38 /^nommu$/ and $ret .= "\tselect NOMMU\n";
39 /^mips16$/ and $ret .= "\tselect HAS_MIPS16\n";
40 /^rfkill$/ and $ret .= "\tselect RFKILL_SUPPORT\n";
41 /^low_mem$/ and $ret .= "\tselect LOW_MEMORY_FOOTPRINT\n";
42 /^small_flash$/ and $ret .= "\tselect SMALL_FLASH\n";
43 /^nand$/ and $ret .= "\tselect NAND_SUPPORT\n";
44 /^virtio$/ and $ret .= "\tselect VIRTIO_SUPPORT\n";
45 /^rootfs-part$/ and $ret .= "\tselect USES_ROOTFS_PART\n";
46 /^boot-part$/ and $ret .= "\tselect USES_BOOT_PART\n";
47 /^testing-kernel$/ and $ret .= "\tselect HAS_TESTING_KERNEL\n";
54 my $parent = $target->{parent
};
56 return $target->{parent
}->{name
}." - ".$target->{name
};
58 return $target->{name
};
65 if (substr($v,0,2) eq "2_") {
66 $v =~ /(\d+_\d+_\d+)(_\d+)?/ and $v = $1;
68 $v =~ /(\d+_\d+)(_\d+)?/ and $v = $1;
75 my $features = target_config_features
(@
{$target->{features
}});
76 my $help = $target->{desc
};
82 $help =~ s/^\s*/\t /mg;
83 $help = "\thelp\n$help";
88 my $v = kver
($target->{version
});
89 my $tv = kver
($target->{testing_version
});
91 if (@
{$target->{subtargets
}} == 0) {
93 config TARGET_$target->{conf}
94 bool "$target->{name}"
95 select LINUX_$v if !TESTING_KERNEL
96 select LINUX_$tv if TESTING_KERNEL
101 config TARGET_$target->{conf}
102 bool "$target->{name}"
105 if ($target->{subtarget
}) {
106 $confstr .= "\tdepends on TARGET_$target->{boardconf}\n";
108 if (@
{$target->{subtargets
}} > 0) {
109 $confstr .= "\tselect HAS_SUBTARGETS\n";
110 grep { /broken/ } @
{$target->{features
}} and $confstr .= "\tdepends on BROKEN\n";
112 $confstr .= $features;
113 if ($target->{arch
} =~ /\w/) {
114 $confstr .= "\tselect $target->{arch}\n";
116 if ($target->{has_devices
}) {
117 $confstr .= "\tselect HAS_DEVICES\n";
121 foreach my $dep (@
{$target->{depends
}}) {
122 my $mode = "depends on";
126 $dep =~ /^([@\+\-]+)(.+)$/;
130 next if $name =~ /:/;
131 $flags =~ /-/ and $mode = "deselect";
132 $flags =~ /\+/ and $mode = "select";
133 $flags =~ /@/ and $confstr .= "\t$mode $name\n";
135 $confstr .= "$help\n\n";
139 sub merge_package_lists
($$) {
145 foreach my $pkg (@
$list1, @
$list2) {
148 foreach my $pkg (keys %pkgs) {
149 push @l, $pkg unless ($pkg =~ /^-/ or $pkgs{"-$pkg"});
154 sub gen_target_config
() {
155 my $file = shift @ARGV;
156 my @target = parse_target_metadata
($file);
159 my @target_sort = sort {
160 target_name
($a) cmp target_name
($b);
163 foreach my $target (@target_sort) {
164 next if @
{$target->{subtargets
}} > 0;
166 config DEFAULT_TARGET_$target->{conf}
168 depends on TARGET_PER_DEVICE_ROOTFS
169 default y if TARGET_$target->{conf}
171 foreach my $pkg (@
{$target->{packages
}}) {
172 print "\tselect DEFAULT_$pkg if TARGET_PER_DEVICE_ROOTFS\n";
178 prompt "Target System"
184 foreach my $target (@target_sort) {
185 next if $target->{subtarget
};
186 print_target
($target);
193 prompt "Subtarget" if HAS_SUBTARGETS
195 foreach my $target (@target) {
196 next unless $target->{def_subtarget
};
198 default TARGET_$target->{conf}_$target->{def_subtarget} if TARGET_$target->{conf}
204 foreach my $target (@target) {
205 next unless $target->{subtarget
};
206 print_target
($target);
213 prompt "Target Profile"
214 default TARGET_MULTI_PROFILE if BUILDBOT
217 foreach my $target (@target) {
218 my $profile = $target->{profiles
}->[0];
221 default TARGET_$target->{conf}_$profile->{id} if TARGET_$target->{conf} && !BUILDBOT
227 config TARGET_MULTI_PROFILE
228 bool "Multiple devices"
229 depends on HAS_DEVICES
231 Instead of only building a single image, or all images, this allows you
232 to select images to be built for multiple devices in one build.
236 foreach my $target (@target) {
237 my $profiles = $target->{profiles
};
238 foreach my $profile (@
{$target->{profiles
}}) {
240 config TARGET_$target->{conf}_$profile->{id}
241 bool "$profile->{name}"
242 depends on TARGET_$target->{conf}
244 $profile->{broken
} and print "\tdepends on BROKEN\n";
245 my @pkglist = merge_package_lists
($target->{packages
}, $profile->{packages
});
246 foreach my $pkg (@pkglist) {
247 print "\tselect DEFAULT_$pkg\n";
250 my $help = $profile->{desc
};
251 if ($help =~ /\w+/) {
252 $help =~ s/^\s*/\t /mg;
253 $help = "\thelp\n$help";
264 menu "Target Devices"
265 depends on TARGET_MULTI_PROFILE
267 config TARGET_ALL_PROFILES
268 bool "Enable all profiles by default"
271 config TARGET_PER_DEVICE_ROOTFS
272 bool "Use a per-device root filesystem that adds profile packages"
275 When disabled, all device packages from all selected devices
276 will be included in all images by default. (Marked as <*>) You will
277 still be able to manually deselect any/all packages.
278 When enabled, each device builds it's own image, including only the
279 profile packages for that device. (Marked as {M}) You will be able
280 to change a package to included in all images by marking as {*}, but
281 will not be able to disable a profile package completely.
283 To get the most use of this setting, you must set in a .config stub
284 before calling "make defconfig". Selecting TARGET_MULTI_PROFILE and
285 then manually selecting (via menuconfig for instance) this option
286 will have pre-defaulted all profile packages to included, making this
287 option appear to have had no effect.
290 foreach my $target (@target) {
291 my @profiles = sort {
295 } @
{$target->{profiles
}};
296 foreach my $profile (@profiles) {
297 next unless $profile->{id
} =~ /^DEVICE_/;
299 menuconfig TARGET_DEVICE_$target->{conf}_$profile->{id}
300 bool "$profile->{name}"
301 depends on TARGET_$target->{conf}
302 default $profile->{default}
304 $profile->{broken
} and print "\tdepends on BROKEN\n";
305 my @pkglist = merge_package_lists
($target->{packages
}, $profile->{packages
});
306 foreach my $pkg (@pkglist) {
307 print "\tselect DEFAULT_$pkg if !TARGET_PER_DEVICE_ROOTFS\n";
308 print "\tselect MODULE_DEFAULT_$pkg if TARGET_PER_DEVICE_ROOTFS\n";
315 config TARGET_DEVICE_PACKAGES_$target->{conf}_$profile->{id}
316 string "$profile->{name} additional packages"
318 depends on TARGET_PER_DEVICE_ROOTFS
319 depends on TARGET_DEVICE_$target->{conf}_$profile->{id}
329 config HAS_SUBTARGETS
339 foreach my $target (@target) {
340 $target->{subtarget
} or print "\t\tdefault \"".$target->{board
}."\" if TARGET_".$target->{conf
}."\n";
343 config TARGET_SUBTARGET
345 default "generic" if !HAS_SUBTARGETS
349 foreach my $target (@target) {
350 foreach my $subtarget (@
{$target->{subtargets
}}) {
351 print "\t\tdefault \"$subtarget\" if TARGET_".$target->{conf
}."_$subtarget\n";
355 config TARGET_PROFILE
358 foreach my $target (@target) {
359 my $profiles = $target->{profiles
};
360 foreach my $profile (@
$profiles) {
361 print "\tdefault \"$profile->{id}\" if TARGET_$target->{conf}_$profile->{id}\n";
367 config TARGET_ARCH_PACKAGES
371 foreach my $target (@target) {
372 next if @
{$target->{subtargets
}} > 0;
373 print "\t\tdefault \"".($target->{arch_packages
} || $target->{board
})."\" if TARGET_".$target->{conf
}."\n";
377 config DEFAULT_TARGET_OPTIMIZATION
380 foreach my $target (@target) {
381 next if @
{$target->{subtargets
}} > 0;
382 print "\tdefault \"".$target->{cflags
}."\" if TARGET_".$target->{conf
}."\n";
384 print "\tdefault \"-Os -pipe -funit-at-a-time\"\n";
390 foreach my $target (@target) {
391 next if @
{$target->{subtargets
}} > 0;
392 print "\tdefault \"".$target->{cputype
}."\" if TARGET_".$target->{conf
}."\n";
394 print "\tdefault \"\"\n";
397 foreach my $target (@target) {
398 foreach my $tv ($target->{version
}, $target->{testing_version
}) {
411 foreach my $def (sort keys %defaults) {
416 config MODULE_DEFAULT_$def
418 depends on TARGET_PER_DEVICE_ROOTFS
420 default m if DEFAULT_$def
427 sub gen_profile_mk
() {
428 my $file = shift @ARGV;
429 my $target = shift @ARGV;
430 my @targets = parse_target_metadata
($file);
431 foreach my $cur (@targets) {
432 next unless $cur->{id
} eq $target;
433 my @profile_ids_unique = do { my %seen; grep { !$seen{$_}++} map { $_->{id
} } @
{$cur->{profiles
}}};
434 print "PROFILE_NAMES = ".join(" ", @profile_ids_unique)."\n";
435 foreach my $profile (@
{$cur->{profiles
}}) {
436 print $profile->{id
}.'_NAME:='.$profile->{name
}."\n";
437 print $profile->{id
}.'_HAS_IMAGE_METADATA:='.$profile->{has_image_metadata
}."\n";
438 if (defined($profile->{supported_devices
}) and @
{$profile->{supported_devices
}} > 0) {
439 print $profile->{id
}.'_SUPPORTED_DEVICES:='.join(' ', @
{$profile->{supported_devices
}})."\n";
441 print $profile->{id
}.'_PACKAGES:='.join(' ', @
{$profile->{packages
}})."\n";
446 sub parse_command
() {
447 GetOptions
("ignore=s", \
@ignore);
448 my $cmd = shift @ARGV;
450 /^config$/ and return gen_target_config
();
451 /^profile_mk$/ and return gen_profile_mk
();
455 $0 config [file] Target metadata in Kconfig format
456 $0 profile_mk [file] [target] Profile metadata in makefile format