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 /^audio$/ and $ret .= "\tselect AUDIO_SUPPORT\n";
14 /^boot-part$/ and $ret .= "\tselect USES_BOOT_PART\n";
15 /^broken$/ and $ret .= "\tdepends on BROKEN\n";
16 /^cpiogz$/ and $ret .= "\tselect USES_CPIOGZ\n";
17 /^display$/ and $ret .= "\tselect DISPLAY_SUPPORT\n";
18 /^dt$/ and $ret .= "\tselect USES_DEVICETREE\n";
19 /^dt-overlay$/ and $ret .= "\tselect HAS_DT_OVERLAY_SUPPORT\n";
20 /^emmc$/ and $ret .= "\tselect EMMC_SUPPORT\n";
21 /^ext4$/ and $ret .= "\tselect USES_EXT4\n";
22 /^fpu$/ and $ret .= "\tselect HAS_FPU\n";
23 /^gpio$/ and $ret .= "\tselect GPIO_SUPPORT\n";
24 /^jffs2$/ and $ret .= "\tselect USES_JFFS2\n";
25 /^jffs2_nand$/ and $ret .= "\tselect USES_JFFS2_NAND\n";
26 /^legacy-sdcard$/ and $ret .= "\tselect LEGACY_SDCARD_SUPPORT\n";
27 /^low_mem$/ and $ret .= "\tselect LOW_MEMORY_FOOTPRINT\n";
28 /^minor$/ and $ret .= "\tselect USES_MINOR\n";
29 /^mips16$/ and $ret .= "\tselect HAS_MIPS16\n";
30 /^nand$/ and $ret .= "\tselect NAND_SUPPORT\n";
31 /^nommu$/ and $ret .= "\tselect NOMMU\n";
32 /^pci$/ and $ret .= "\tselect PCI_SUPPORT\n";
33 /^pcie$/ and $ret .= "\tselect PCIE_SUPPORT\n";
34 /^pcmcia$/ and $ret .= "\tselect PCMCIA_SUPPORT\n";
35 /^powerpc64$/ and $ret .= "\tselect powerpc64\n";
36 /^pwm$/ and $ret .= "\select PWM_SUPPORT\n";
37 /^ramdisk$/ and $ret .= "\tselect USES_INITRAMFS\n";
38 /^rfkill$/ and $ret .= "\tselect RFKILL_SUPPORT\n";
39 /^rootfs-part$/ and $ret .= "\tselect USES_ROOTFS_PART\n";
40 /^rtc$/ and $ret .= "\tselect RTC_SUPPORT\n";
41 /^separate_ramdisk$/ and $ret .= "\tselect USES_INITRAMFS\n\tselect USES_SEPARATE_INITRAMFS\n";
42 /^small_flash$/ and $ret .= "\tselect SMALL_FLASH\n";
43 /^spe_fpu$/ and $ret .= "\tselect HAS_SPE_FPU\n";
44 /^squashfs$/ and $ret .= "\tselect USES_SQUASHFS\n";
45 /^targz$/ and $ret .= "\tselect USES_TARGZ\n";
46 /^testing-kernel$/ and $ret .= "\tselect HAS_TESTING_KERNEL\n";
47 /^ubifs$/ and $ret .= "\tselect USES_UBIFS\n";
48 /^usb$/ and $ret .= "\tselect USB_SUPPORT\n";
49 /^usbgadget$/ and $ret .= "\tselect USB_GADGET_SUPPORT\n";
50 /^virtio$/ and $ret .= "\tselect VIRTIO_SUPPORT\n";
57 my $parent = $target->{parent
};
59 return $target->{parent
}->{name
}." - ".$target->{name
};
61 return $target->{name
};
68 if (substr($v,0,2) eq "2_") {
69 $v =~ /(\d+_\d+_\d+)(_\d+)?/ and $v = $1;
71 $v =~ /(\d+_\d+)(_\d+)?/ and $v = $1;
78 my $features = target_config_features
(@
{$target->{features
}});
79 my $help = $target->{desc
};
85 $help =~ s/^\s*/\t /mg;
86 $help = "\thelp\n$help";
91 my $v = kver
($target->{version
});
92 my $tv = kver
($target->{testing_version
});
94 if (@
{$target->{subtargets
}} == 0) {
96 config TARGET_$target->{conf}
97 bool "$target->{name}"
98 select LINUX_$v if !TESTING_KERNEL
99 select LINUX_$tv if TESTING_KERNEL
104 config TARGET_$target->{conf}
105 bool "$target->{name}"
108 if ($target->{subtarget
}) {
109 $confstr .= "\tdepends on TARGET_$target->{boardconf}\n";
111 if (@
{$target->{subtargets
}} > 0) {
112 $confstr .= "\tselect HAS_SUBTARGETS\n";
113 grep { /broken/ } @
{$target->{features
}} and $confstr .= "\tdepends on BROKEN\n";
115 $confstr .= $features;
116 if ($target->{arch
} =~ /\w/) {
117 $confstr .= "\tselect $target->{arch}\n";
119 if ($target->{has_devices
}) {
120 $confstr .= "\tselect HAS_DEVICES\n";
124 foreach my $dep (@
{$target->{depends
}}) {
125 my $mode = "depends on";
129 $dep =~ /^([@\+\-]+)(.+)$/;
133 next if $name =~ /:/;
134 $flags =~ /-/ and $mode = "deselect";
135 $flags =~ /\+/ and $mode = "select";
136 $flags =~ /@/ and $confstr .= "\t$mode $name\n";
138 $confstr .= "$help\n\n";
142 sub merge_package_lists
($$) {
148 foreach my $pkg (@
$list1, @
$list2) {
151 foreach my $pkg (keys %pkgs) {
152 push @l, $pkg unless ($pkg =~ /^-/ or $pkgs{"-$pkg"});
157 sub gen_target_config
() {
158 my $file = shift @ARGV;
159 my @target = parse_target_metadata
($file);
162 my @target_sort = sort {
163 target_name
($a) cmp target_name
($b);
166 foreach my $target (@target_sort) {
167 next if @
{$target->{subtargets
}} > 0;
169 config DEFAULT_TARGET_$target->{conf}
171 depends on TARGET_PER_DEVICE_ROOTFS
172 default y if TARGET_$target->{conf}
174 foreach my $pkg (@
{$target->{packages
}}) {
175 print "\tselect DEFAULT_$pkg if TARGET_PER_DEVICE_ROOTFS\n";
181 prompt "Target System"
187 foreach my $target (@target_sort) {
188 next if $target->{subtarget
};
189 print_target
($target);
196 prompt "Subtarget" if HAS_SUBTARGETS
198 foreach my $target (@target) {
199 next unless $target->{def_subtarget
};
201 default TARGET_$target->{conf}_$target->{def_subtarget} if TARGET_$target->{conf}
207 foreach my $target (@target) {
208 next unless $target->{subtarget
};
209 print_target
($target);
216 prompt "Target Profile"
217 default TARGET_MULTI_PROFILE if BUILDBOT
220 foreach my $target (@target) {
221 my $profile = $target->{profiles
}->[0];
224 default TARGET_$target->{conf}_$profile->{id} if TARGET_$target->{conf} && !BUILDBOT
230 config TARGET_MULTI_PROFILE
231 bool "Multiple devices"
232 depends on HAS_DEVICES
234 Instead of only building a single image, or all images, this allows you
235 to select images to be built for multiple devices in one build.
239 foreach my $target (@target) {
240 my $profiles = $target->{profiles
};
241 foreach my $profile (@
{$target->{profiles
}}) {
243 config TARGET_$target->{conf}_$profile->{id}
244 bool "$profile->{name}"
245 depends on TARGET_$target->{conf}
247 $profile->{broken
} and print "\tdepends on BROKEN\n";
248 my @pkglist = merge_package_lists
($target->{packages
}, $profile->{packages
});
249 foreach my $pkg (@pkglist) {
250 print "\tselect DEFAULT_$pkg\n";
253 my $help = $profile->{desc
};
254 if ($help =~ /\w+/) {
255 $help =~ s/^\s*/\t /mg;
256 $help = "\thelp\n$help";
267 menu "Target Devices"
268 depends on TARGET_MULTI_PROFILE
270 config TARGET_ALL_PROFILES
271 bool "Enable all profiles by default"
274 config TARGET_PER_DEVICE_ROOTFS
275 bool "Use a per-device root filesystem that adds profile packages"
278 When disabled, all device packages from all selected devices
279 will be included in all images by default. (Marked as <*>) You will
280 still be able to manually deselect any/all packages.
281 When enabled, each device builds it's own image, including only the
282 profile packages for that device. (Marked as {M}) You will be able
283 to change a package to included in all images by marking as {*}, but
284 will not be able to disable a profile package completely.
286 To get the most use of this setting, you must set in a .config stub
287 before calling "make defconfig". Selecting TARGET_MULTI_PROFILE and
288 then manually selecting (via menuconfig for instance) this option
289 will have pre-defaulted all profile packages to included, making this
290 option appear to have had no effect.
293 foreach my $target (@target) {
294 my @profiles = sort {
298 } @
{$target->{profiles
}};
299 foreach my $profile (@profiles) {
300 next unless $profile->{id
} =~ /^DEVICE_/;
302 menuconfig TARGET_DEVICE_$target->{conf}_$profile->{id}
303 bool "$profile->{name}"
304 depends on TARGET_$target->{conf}
305 default $profile->{default}
307 $profile->{broken
} and print "\tdepends on BROKEN\n";
308 my @pkglist = merge_package_lists
($target->{packages
}, $profile->{packages
});
309 foreach my $pkg (@pkglist) {
310 print "\tselect DEFAULT_$pkg if !TARGET_PER_DEVICE_ROOTFS\n";
311 print "\tselect MODULE_DEFAULT_$pkg if TARGET_PER_DEVICE_ROOTFS\n";
318 config TARGET_DEVICE_PACKAGES_$target->{conf}_$profile->{id}
319 string "$profile->{name} additional packages"
321 depends on TARGET_PER_DEVICE_ROOTFS
322 depends on TARGET_DEVICE_$target->{conf}_$profile->{id}
332 config HAS_SUBTARGETS
342 foreach my $target (@target) {
343 $target->{subtarget
} or print "\t\tdefault \"".$target->{board
}."\" if TARGET_".$target->{conf
}."\n";
346 config TARGET_SUBTARGET
348 default "generic" if !HAS_SUBTARGETS
352 foreach my $target (@target) {
353 foreach my $subtarget (@
{$target->{subtargets
}}) {
354 print "\t\tdefault \"$subtarget\" if TARGET_".$target->{conf
}."_$subtarget\n";
358 config TARGET_PROFILE
361 foreach my $target (@target) {
362 my $profiles = $target->{profiles
};
363 foreach my $profile (@
$profiles) {
364 print "\tdefault \"$profile->{id}\" if TARGET_$target->{conf}_$profile->{id}\n";
370 config TARGET_ARCH_PACKAGES
374 foreach my $target (@target) {
375 next if @
{$target->{subtargets
}} > 0;
376 print "\t\tdefault \"".($target->{arch_packages
} || $target->{board
})."\" if TARGET_".$target->{conf
}."\n";
380 config DEFAULT_TARGET_OPTIMIZATION
383 foreach my $target (@target) {
384 next if @
{$target->{subtargets
}} > 0;
385 print "\tdefault \"".$target->{cflags
}."\" if TARGET_".$target->{conf
}."\n";
387 print "\tdefault \"-Os -pipe -funit-at-a-time\"\n";
393 foreach my $target (@target) {
394 next if @
{$target->{subtargets
}} > 0;
395 print "\tdefault \"".$target->{cputype
}."\" if TARGET_".$target->{conf
}."\n";
397 print "\tdefault \"\"\n";
400 foreach my $target (@target) {
401 foreach my $tv ($target->{version
}, $target->{testing_version
}) {
414 foreach my $def (sort keys %defaults) {
419 config MODULE_DEFAULT_$def
421 depends on TARGET_PER_DEVICE_ROOTFS
423 default m if DEFAULT_$def
430 sub gen_profile_mk
() {
431 my $file = shift @ARGV;
432 my $target = shift @ARGV;
433 my @targets = parse_target_metadata
($file);
434 foreach my $cur (@targets) {
435 next unless $cur->{id
} eq $target;
436 my @profile_ids_unique = do { my %seen; grep { !$seen{$_}++} map { $_->{id
} } @
{$cur->{profiles
}}};
437 print "PROFILE_NAMES = ".join(" ", @profile_ids_unique)."\n";
438 foreach my $profile (@
{$cur->{profiles
}}) {
439 print $profile->{id
}.'_NAME:='.$profile->{name
}."\n";
440 print $profile->{id
}.'_HAS_IMAGE_METADATA:='.$profile->{has_image_metadata
}."\n";
441 if (defined($profile->{supported_devices
}) and @
{$profile->{supported_devices
}} > 0) {
442 print $profile->{id
}.'_SUPPORTED_DEVICES:='.join(' ', @
{$profile->{supported_devices
}})."\n";
444 print $profile->{id
}.'_PACKAGES:='.join(' ', @
{$profile->{packages
}})."\n";
449 sub parse_command
() {
450 GetOptions
("ignore=s", \
@ignore);
451 my $cmd = shift @ARGV;
453 /^config$/ and return gen_target_config
();
454 /^profile_mk$/ and return gen_profile_mk
();
458 $0 config [file] Target metadata in Kconfig format
459 $0 profile_mk [file] [target] Profile metadata in makefile format