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 /^separate_ramdisk$/ and $ret .= "\tselect USES_INITRAMFS\n\tselect USES_SEPARATE_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";
48 /^dt-overlay$/ and $ret .= "\tselect HAS_DT_OVERLAY_SUPPORT\n";
55 my $parent = $target->{parent
};
57 return $target->{parent
}->{name
}." - ".$target->{name
};
59 return $target->{name
};
66 if (substr($v,0,2) eq "2_") {
67 $v =~ /(\d+_\d+_\d+)(_\d+)?/ and $v = $1;
69 $v =~ /(\d+_\d+)(_\d+)?/ and $v = $1;
76 my $features = target_config_features
(@
{$target->{features
}});
77 my $help = $target->{desc
};
83 $help =~ s/^\s*/\t /mg;
84 $help = "\thelp\n$help";
89 my $v = kver
($target->{version
});
90 my $tv = kver
($target->{testing_version
});
92 if (@
{$target->{subtargets
}} == 0) {
94 config TARGET_$target->{conf}
95 bool "$target->{name}"
96 select LINUX_$v if !TESTING_KERNEL
97 select LINUX_$tv if TESTING_KERNEL
102 config TARGET_$target->{conf}
103 bool "$target->{name}"
106 if ($target->{subtarget
}) {
107 $confstr .= "\tdepends on TARGET_$target->{boardconf}\n";
109 if (@
{$target->{subtargets
}} > 0) {
110 $confstr .= "\tselect HAS_SUBTARGETS\n";
111 grep { /broken/ } @
{$target->{features
}} and $confstr .= "\tdepends on BROKEN\n";
113 $confstr .= $features;
114 if ($target->{arch
} =~ /\w/) {
115 $confstr .= "\tselect $target->{arch}\n";
117 if ($target->{has_devices
}) {
118 $confstr .= "\tselect HAS_DEVICES\n";
122 foreach my $dep (@
{$target->{depends
}}) {
123 my $mode = "depends on";
127 $dep =~ /^([@\+\-]+)(.+)$/;
131 next if $name =~ /:/;
132 $flags =~ /-/ and $mode = "deselect";
133 $flags =~ /\+/ and $mode = "select";
134 $flags =~ /@/ and $confstr .= "\t$mode $name\n";
136 $confstr .= "$help\n\n";
140 sub merge_package_lists
($$) {
146 foreach my $pkg (@
$list1, @
$list2) {
149 foreach my $pkg (keys %pkgs) {
150 push @l, $pkg unless ($pkg =~ /^-/ or $pkgs{"-$pkg"});
155 sub gen_target_config
() {
156 my $file = shift @ARGV;
157 my @target = parse_target_metadata
($file);
160 my @target_sort = sort {
161 target_name
($a) cmp target_name
($b);
164 foreach my $target (@target_sort) {
165 next if @
{$target->{subtargets
}} > 0;
167 config DEFAULT_TARGET_$target->{conf}
169 depends on TARGET_PER_DEVICE_ROOTFS
170 default y if TARGET_$target->{conf}
172 foreach my $pkg (@
{$target->{packages
}}) {
173 print "\tselect DEFAULT_$pkg if TARGET_PER_DEVICE_ROOTFS\n";
179 prompt "Target System"
185 foreach my $target (@target_sort) {
186 next if $target->{subtarget
};
187 print_target
($target);
194 prompt "Subtarget" if HAS_SUBTARGETS
196 foreach my $target (@target) {
197 next unless $target->{def_subtarget
};
199 default TARGET_$target->{conf}_$target->{def_subtarget} if TARGET_$target->{conf}
205 foreach my $target (@target) {
206 next unless $target->{subtarget
};
207 print_target
($target);
214 prompt "Target Profile"
215 default TARGET_MULTI_PROFILE if BUILDBOT
218 foreach my $target (@target) {
219 my $profile = $target->{profiles
}->[0];
222 default TARGET_$target->{conf}_$profile->{id} if TARGET_$target->{conf} && !BUILDBOT
228 config TARGET_MULTI_PROFILE
229 bool "Multiple devices"
230 depends on HAS_DEVICES
232 Instead of only building a single image, or all images, this allows you
233 to select images to be built for multiple devices in one build.
237 foreach my $target (@target) {
238 my $profiles = $target->{profiles
};
239 foreach my $profile (@
{$target->{profiles
}}) {
241 config TARGET_$target->{conf}_$profile->{id}
242 bool "$profile->{name}"
243 depends on TARGET_$target->{conf}
245 $profile->{broken
} and print "\tdepends on BROKEN\n";
246 my @pkglist = merge_package_lists
($target->{packages
}, $profile->{packages
});
247 foreach my $pkg (@pkglist) {
248 print "\tselect DEFAULT_$pkg\n";
251 my $help = $profile->{desc
};
252 if ($help =~ /\w+/) {
253 $help =~ s/^\s*/\t /mg;
254 $help = "\thelp\n$help";
265 menu "Target Devices"
266 depends on TARGET_MULTI_PROFILE
268 config TARGET_ALL_PROFILES
269 bool "Enable all profiles by default"
272 config TARGET_PER_DEVICE_ROOTFS
273 bool "Use a per-device root filesystem that adds profile packages"
276 When disabled, all device packages from all selected devices
277 will be included in all images by default. (Marked as <*>) You will
278 still be able to manually deselect any/all packages.
279 When enabled, each device builds it's own image, including only the
280 profile packages for that device. (Marked as {M}) You will be able
281 to change a package to included in all images by marking as {*}, but
282 will not be able to disable a profile package completely.
284 To get the most use of this setting, you must set in a .config stub
285 before calling "make defconfig". Selecting TARGET_MULTI_PROFILE and
286 then manually selecting (via menuconfig for instance) this option
287 will have pre-defaulted all profile packages to included, making this
288 option appear to have had no effect.
291 foreach my $target (@target) {
292 my @profiles = sort {
296 } @
{$target->{profiles
}};
297 foreach my $profile (@profiles) {
298 next unless $profile->{id
} =~ /^DEVICE_/;
300 menuconfig TARGET_DEVICE_$target->{conf}_$profile->{id}
301 bool "$profile->{name}"
302 depends on TARGET_$target->{conf}
303 default $profile->{default}
305 $profile->{broken
} and print "\tdepends on BROKEN\n";
306 my @pkglist = merge_package_lists
($target->{packages
}, $profile->{packages
});
307 foreach my $pkg (@pkglist) {
308 print "\tselect DEFAULT_$pkg if !TARGET_PER_DEVICE_ROOTFS\n";
309 print "\tselect MODULE_DEFAULT_$pkg if TARGET_PER_DEVICE_ROOTFS\n";
316 config TARGET_DEVICE_PACKAGES_$target->{conf}_$profile->{id}
317 string "$profile->{name} additional packages"
319 depends on TARGET_PER_DEVICE_ROOTFS
320 depends on TARGET_DEVICE_$target->{conf}_$profile->{id}
330 config HAS_SUBTARGETS
340 foreach my $target (@target) {
341 $target->{subtarget
} or print "\t\tdefault \"".$target->{board
}."\" if TARGET_".$target->{conf
}."\n";
344 config TARGET_SUBTARGET
346 default "generic" if !HAS_SUBTARGETS
350 foreach my $target (@target) {
351 foreach my $subtarget (@
{$target->{subtargets
}}) {
352 print "\t\tdefault \"$subtarget\" if TARGET_".$target->{conf
}."_$subtarget\n";
356 config TARGET_PROFILE
359 foreach my $target (@target) {
360 my $profiles = $target->{profiles
};
361 foreach my $profile (@
$profiles) {
362 print "\tdefault \"$profile->{id}\" if TARGET_$target->{conf}_$profile->{id}\n";
368 config TARGET_ARCH_PACKAGES
372 foreach my $target (@target) {
373 next if @
{$target->{subtargets
}} > 0;
374 print "\t\tdefault \"".($target->{arch_packages
} || $target->{board
})."\" if TARGET_".$target->{conf
}."\n";
378 config DEFAULT_TARGET_OPTIMIZATION
381 foreach my $target (@target) {
382 next if @
{$target->{subtargets
}} > 0;
383 print "\tdefault \"".$target->{cflags
}."\" if TARGET_".$target->{conf
}."\n";
385 print "\tdefault \"-Os -pipe -funit-at-a-time\"\n";
391 foreach my $target (@target) {
392 next if @
{$target->{subtargets
}} > 0;
393 print "\tdefault \"".$target->{cputype
}."\" if TARGET_".$target->{conf
}."\n";
395 print "\tdefault \"\"\n";
398 foreach my $target (@target) {
399 foreach my $tv ($target->{version
}, $target->{testing_version
}) {
412 foreach my $def (sort keys %defaults) {
417 config MODULE_DEFAULT_$def
419 depends on TARGET_PER_DEVICE_ROOTFS
421 default m if DEFAULT_$def
428 sub gen_profile_mk
() {
429 my $file = shift @ARGV;
430 my $target = shift @ARGV;
431 my @targets = parse_target_metadata
($file);
432 foreach my $cur (@targets) {
433 next unless $cur->{id
} eq $target;
434 my @profile_ids_unique = do { my %seen; grep { !$seen{$_}++} map { $_->{id
} } @
{$cur->{profiles
}}};
435 print "PROFILE_NAMES = ".join(" ", @profile_ids_unique)."\n";
436 foreach my $profile (@
{$cur->{profiles
}}) {
437 print $profile->{id
}.'_NAME:='.$profile->{name
}."\n";
438 print $profile->{id
}.'_HAS_IMAGE_METADATA:='.$profile->{has_image_metadata
}."\n";
439 if (defined($profile->{supported_devices
}) and @
{$profile->{supported_devices
}} > 0) {
440 print $profile->{id
}.'_SUPPORTED_DEVICES:='.join(' ', @
{$profile->{supported_devices
}})."\n";
442 print $profile->{id
}.'_PACKAGES:='.join(' ', @
{$profile->{packages
}})."\n";
447 sub parse_command
() {
448 GetOptions
("ignore=s", \
@ignore);
449 my $cmd = shift @ARGV;
451 /^config$/ and return gen_target_config
();
452 /^profile_mk$/ and return gen_profile_mk
();
456 $0 config [file] Target metadata in Kconfig format
457 $0 profile_mk [file] [target] Profile metadata in makefile format