]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
build: split scripts/metadata.pl into target-metadata.pl and package-metadata.pl
authorFelix Fietkau <nbd@nbd.name>
Sun, 22 May 2016 19:31:37 +0000 (21:31 +0200)
committerFelix Fietkau <nbd@nbd.name>
Tue, 7 Jun 2016 06:58:40 +0000 (08:58 +0200)
Signed-off-by: Felix Fietkau <nbd@nbd.name>
include/kernel-defaults.mk
include/kernel.mk
include/toplevel.mk
scripts/package-metadata.pl [moved from scripts/metadata.pl with 65% similarity]
scripts/target-metadata.pl [new file with mode: 0755]
target/imagebuilder/files/Makefile

index 406fd46343271df27e9e5cc9e9e58f243eb1cee3..3679daeb84c91fe22aa4989a6b695ab87b3637a1 100644 (file)
@@ -111,7 +111,7 @@ define Kernel/Configure/Default
        echo "# CONFIG_KALLSYMS_EXTRA_PASS is not set" >> $(LINUX_DIR)/.config.target
        echo "# CONFIG_KALLSYMS_ALL is not set" >> $(LINUX_DIR)/.config.target
        echo "CONFIG_KALLSYMS_UNCOMPRESSED=y" >> $(LINUX_DIR)/.config.target
-       $(SCRIPT_DIR)/metadata.pl kconfig $(TMP_DIR)/.packageinfo $(TOPDIR)/.config $(KERNEL_PATCHVER) > $(LINUX_DIR)/.config.override
+       $(SCRIPT_DIR)/package-metadata.pl kconfig $(TMP_DIR)/.packageinfo $(TOPDIR)/.config $(KERNEL_PATCHVER) > $(LINUX_DIR)/.config.override
        $(SCRIPT_DIR)/kconfig.pl 'm+' '+' $(LINUX_DIR)/.config.target /dev/null $(LINUX_DIR)/.config.override > $(LINUX_DIR)/.config.set
        $(call Kernel/SetNoInitramfs)
        rm -rf $(KERNEL_BUILD_DIR)/modules
index 2b87aeba337550597564da4336ef2f1e0d9dc03f..8ce4df8f2d50ac66baa330b715e8045306df6344 100644 (file)
@@ -215,7 +215,7 @@ $(call KernelPackage/$(1)/config)
   $$(IPKG_kmod-$(1)): $$(wildcard $$(FILES))
 endef
 
-version_filter=$(if $(findstring @,$(1)),$(shell $(SCRIPT_DIR)/metadata.pl version_filter $(KERNEL_PATCHVER) $(1)),$(1))
+version_filter=$(if $(findstring @,$(1)),$(shell $(SCRIPT_DIR)/package-metadata.pl version_filter $(KERNEL_PATCHVER) $(1)),$(1))
 
 define AutoLoad
   add_module "$(1)" "$(call version_filter,$(2))" "$(3)";
index e00a24ab6ad647aa52760c1d644db194ee455689..581083d912dee3a9acdb9c159bd0613bada91f11 100644 (file)
@@ -81,11 +81,11 @@ prepare-tmpinfo: FORCE
        $(_SINGLE)$(NO_TRACE_MAKE) -j1 -r -s -f include/scan.mk SCAN_TARGET="targetinfo" SCAN_DIR="target/linux" SCAN_NAME="target" SCAN_DEPS="image/Makefile profiles/*.mk $(TOPDIR)/include/kernel*.mk $(TOPDIR)/include/target.mk" SCAN_DEPTH=2 SCAN_EXTRA="" SCAN_MAKEOPTS="TARGET_BUILD=1"
        for type in package target; do \
                f=tmp/.$${type}info; t=tmp/.config-$${type}.in; \
-               [ "$$t" -nt "$$f" ] || ./scripts/metadata.pl $(_ignore) $${type}_config "$$f" > "$$t" || { rm -f "$$t"; echo "Failed to build $$t"; false; break; }; \
+               [ "$$t" -nt "$$f" ] || ./scripts/$${type}-metadata.pl $(_ignore) config "$$f" > "$$t" || { rm -f "$$t"; echo "Failed to build $$t"; false; break; }; \
        done
        [ tmp/.config-feeds.in -nt tmp/.packagesubdirs ] || ./scripts/feeds feed_config > tmp/.config-feeds.in
-       ./scripts/metadata.pl package_mk tmp/.packageinfo > tmp/.packagedeps || { rm -f tmp/.packagedeps; false; }
-       ./scripts/metadata.pl package_subdirs tmp/.packageinfo > tmp/.packagesubdirs || { rm -f tmp/.packagesubdirs; false; }
+       ./scripts/package-metadata.pl mk tmp/.packageinfo > tmp/.packagedeps || { rm -f tmp/.packagedeps; false; }
+       ./scripts/package-metadata.pl subdirs tmp/.packageinfo > tmp/.packagesubdirs || { rm -f tmp/.packagesubdirs; false; }
        touch $(TOPDIR)/tmp/.build
 
 .config: ./scripts/config/conf $(if $(CONFIG_HAVE_DOT_CONFIG),,prepare-tmpinfo)
similarity index 65%
rename from scripts/metadata.pl
rename to scripts/package-metadata.pl
index 822382cd6c865ec2a0407d89f000e867819266e2..92c989d3a292416e548cd3e306471ecb29f3da5e 100755 (executable)
@@ -97,298 +97,6 @@ sub gen_kconfig_overrides() {
        }
 }
 
-sub merge_package_lists($$) {
-       my $list1 = shift;
-       my $list2 = shift;
-       my @l = ();
-       my %pkgs;
-
-       foreach my $pkg (@$list1, @$list2) {
-               $pkgs{$pkg} = 1;
-       }
-       foreach my $pkg (keys %pkgs) {
-               push @l, $pkg unless ($pkg =~ /^-/ or $pkgs{"-$pkg"});
-       }
-       return sort(@l);
-}
-
-sub target_config_features(@) {
-       my $ret;
-
-       while ($_ = shift @_) {
-               /arm_v(\w+)/ and $ret .= "\tselect arm_v$1\n";
-               /broken/ and $ret .= "\tdepends on BROKEN\n";
-               /audio/ and $ret .= "\tselect AUDIO_SUPPORT\n";
-               /display/ and $ret .= "\tselect DISPLAY_SUPPORT\n";
-               /dt/ and $ret .= "\tselect USES_DEVICETREE\n";
-               /gpio/ and $ret .= "\tselect GPIO_SUPPORT\n";
-               /pci/ and $ret .= "\tselect PCI_SUPPORT\n";
-               /pcie/ and $ret .= "\tselect PCIE_SUPPORT\n";
-               /usb/ and $ret .= "\tselect USB_SUPPORT\n";
-               /usbgadget/ and $ret .= "\tselect USB_GADGET_SUPPORT\n";
-               /pcmcia/ and $ret .= "\tselect PCMCIA_SUPPORT\n";
-               /rtc/ and $ret .= "\tselect RTC_SUPPORT\n";
-               /squashfs/ and $ret .= "\tselect USES_SQUASHFS\n";
-               /jffs2$/ and $ret .= "\tselect USES_JFFS2\n";
-               /jffs2_nand/ and $ret .= "\tselect USES_JFFS2_NAND\n";
-               /ext4/ and $ret .= "\tselect USES_EXT4\n";
-               /targz/ and $ret .= "\tselect USES_TARGZ\n";
-               /cpiogz/ and $ret .= "\tselect USES_CPIOGZ\n";
-               /ubifs/ and $ret .= "\tselect USES_UBIFS\n";
-               /fpu/ and $ret .= "\tselect HAS_FPU\n";
-               /spe_fpu/ and $ret .= "\tselect HAS_SPE_FPU\n";
-               /ramdisk/ and $ret .= "\tselect USES_INITRAMFS\n";
-               /powerpc64/ and $ret .= "\tselect powerpc64\n";
-               /nommu/ and $ret .= "\tselect NOMMU\n";
-               /mips16/ and $ret .= "\tselect HAS_MIPS16\n";
-               /rfkill/ and $ret .= "\tselect RFKILL_SUPPORT\n";
-               /low_mem/ and $ret .= "\tselect LOW_MEMORY_FOOTPRINT\n";
-               /nand/ and $ret .= "\tselect NAND_SUPPORT\n";
-       }
-       return $ret;
-}
-
-sub target_name($) {
-       my $target = shift;
-       my $parent = $target->{parent};
-       if ($parent) {
-               return $target->{parent}->{name}." - ".$target->{name};
-       } else {
-               return $target->{name};
-       }
-}
-
-sub kver($) {
-       my $v = shift;
-       $v =~ tr/\./_/;
-       if (substr($v,0,2) eq "2_") {
-               $v =~ /(\d+_\d+_\d+)(_\d+)?/ and $v = $1;
-       } else {
-               $v =~ /(\d+_\d+)(_\d+)?/ and $v = $1;
-       }
-       return $v;
-}
-
-sub print_target($) {
-       my $target = shift;
-       my $features = target_config_features(@{$target->{features}});
-       my $help = $target->{desc};
-       my $confstr;
-
-       chomp $features;
-       $features .= "\n";
-       if ($help =~ /\w+/) {
-               $help =~ s/^\s*/\t  /mg;
-               $help = "\thelp\n$help";
-       } else {
-               undef $help;
-       }
-
-       my $v = kver($target->{version});
-       if (@{$target->{subtargets}} == 0) {
-       $confstr = <<EOF;
-config TARGET_$target->{conf}
-       bool "$target->{name}"
-       select LINUX_$v
-EOF
-       }
-       else {
-               $confstr = <<EOF;
-config TARGET_$target->{conf}
-       bool "$target->{name}"
-EOF
-       }
-       if ($target->{subtarget}) {
-               $confstr .= "\tdepends on TARGET_$target->{boardconf}\n";
-       }
-       if (@{$target->{subtargets}} > 0) {
-               $confstr .= "\tselect HAS_SUBTARGETS\n";
-               grep { /broken/ } @{$target->{features}} and $confstr .= "\tdepends on BROKEN\n";
-       } else {
-               $confstr .= $features;
-               if ($target->{arch} =~ /\w/) {
-                       $confstr .= "\tselect $target->{arch}\n";
-               }
-       }
-
-       foreach my $dep (@{$target->{depends}}) {
-               my $mode = "depends on";
-               my $flags;
-               my $name;
-
-               $dep =~ /^([@\+\-]+)(.+)$/;
-               $flags = $1;
-               $name = $2;
-
-               next if $name =~ /:/;
-               $flags =~ /-/ and $mode = "deselect";
-               $flags =~ /\+/ and $mode = "select";
-               $flags =~ /@/ and $confstr .= "\t$mode $name\n";
-       }
-       $confstr .= "$help\n\n";
-       print $confstr;
-}
-
-sub gen_target_config() {
-       my $file = shift @ARGV;
-       my @target = parse_target_metadata($file);
-       my %defaults;
-
-       my @target_sort = sort {
-               target_name($a) cmp target_name($b);
-       } @target;
-
-
-       print <<EOF;
-choice
-       prompt "Target System"
-       default TARGET_ar71xx
-       reset if !DEVEL
-       
-EOF
-
-       foreach my $target (@target_sort) {
-               next if $target->{subtarget};
-               print_target($target);
-       }
-
-       print <<EOF;
-endchoice
-
-choice
-       prompt "Subtarget" if HAS_SUBTARGETS
-EOF
-       foreach my $target (@target) {
-               next unless $target->{def_subtarget};
-               print <<EOF;
-       default TARGET_$target->{conf}_$target->{def_subtarget} if TARGET_$target->{conf}
-EOF
-       }
-       print <<EOF;
-
-EOF
-       foreach my $target (@target) {
-               next unless $target->{subtarget};
-               print_target($target);
-       }
-
-print <<EOF;
-endchoice
-
-choice
-       prompt "Target Profile"
-
-EOF
-
-       foreach my $target (@target) {
-               my $profiles = $target->{profiles};
-               foreach my $profile (@{$target->{profiles}}) {
-                       print <<EOF;
-config TARGET_$target->{conf}_$profile->{id}
-       bool "$profile->{name}"
-       depends on TARGET_$target->{conf}
-EOF
-                       my @pkglist = merge_package_lists($target->{packages}, $profile->{packages});
-                       foreach my $pkg (@pkglist) {
-                               print "\tselect DEFAULT_$pkg\n";
-                               $defaults{$pkg} = 1;
-                       }
-                       my $help = $profile->{desc};
-                       if ($help =~ /\w+/) {
-                               $help =~ s/^\s*/\t  /mg;
-                               $help = "\thelp\n$help";
-                       } else {
-                               undef $help;
-                       }
-                       print "$help\n";
-               }
-       }
-
-       print <<EOF;
-endchoice
-
-config HAS_SUBTARGETS
-       bool
-
-config TARGET_BOARD
-       string
-
-EOF
-       foreach my $target (@target) {
-               $target->{subtarget} or print "\t\tdefault \"".$target->{board}."\" if TARGET_".$target->{conf}."\n";
-       }
-       print <<EOF;
-config TARGET_SUBTARGET
-       string
-       default "generic" if !HAS_SUBTARGETS
-
-EOF
-
-       foreach my $target (@target) {
-               foreach my $subtarget (@{$target->{subtargets}}) {
-                       print "\t\tdefault \"$subtarget\" if TARGET_".$target->{conf}."_$subtarget\n";
-               }
-       }
-       print <<EOF;
-config TARGET_PROFILE
-       string
-EOF
-       foreach my $target (@target) {
-               my $profiles = $target->{profiles};
-               foreach my $profile (@$profiles) {
-                       print "\tdefault \"$profile->{id}\" if TARGET_$target->{conf}_$profile->{id}\n";
-               }
-       }
-
-       print <<EOF;
-
-config TARGET_ARCH_PACKAGES
-       string
-       
-EOF
-       foreach my $target (@target) {
-               next if @{$target->{subtargets}} > 0;
-               print "\t\tdefault \"".($target->{arch_packages} || $target->{board})."\" if TARGET_".$target->{conf}."\n";
-       }
-       print <<EOF;
-
-config DEFAULT_TARGET_OPTIMIZATION
-       string
-EOF
-       foreach my $target (@target) {
-               next if @{$target->{subtargets}} > 0;
-               print "\tdefault \"".$target->{cflags}."\" if TARGET_".$target->{conf}."\n";
-       }
-       print "\tdefault \"-Os -pipe -funit-at-a-time\"\n";
-       print <<EOF;
-
-config CPU_TYPE
-       string
-EOF
-       foreach my $target (@target) {
-               next if @{$target->{subtargets}} > 0;
-               print "\tdefault \"".$target->{cputype}."\" if TARGET_".$target->{conf}."\n";
-       }
-       print "\tdefault \"\"\n";
-
-       my %kver;
-       foreach my $target (@target) {
-               my $v = kver($target->{version});
-               next if $kver{$v};
-               $kver{$v} = 1;
-               print <<EOF;
-
-config LINUX_$v
-       bool
-
-EOF
-       }
-       foreach my $def (sort keys %defaults) {
-               print "\tconfig DEFAULT_".$def."\n";
-               print "\t\tbool\n\n";
-       }
-}
-
 my %dep_check;
 sub __find_package_dep($$) {
        my $pkg = shift;
@@ -905,46 +613,28 @@ sub gen_version_filtered_list() {
        }
 }
 
-sub gen_profile_mk() {
-       my $file = shift @ARGV;
-       my $target = shift @ARGV;
-       my @targets = parse_target_metadata($file);
-       foreach my $cur (@targets) {
-               next unless $cur->{id} eq $target;
-               print "PROFILE_NAMES = ".join(" ", map { $_->{id} } @{$cur->{profiles}})."\n";
-               foreach my $profile (@{$cur->{profiles}}) {
-                       print $profile->{id}.'_NAME:='.$profile->{name}."\n";
-                       print $profile->{id}.'_PACKAGES:='.join(' ', @{$profile->{packages}})."\n";
-               }
-       }
-}
-
 sub parse_command() {
        GetOptions("ignore=s", \@ignore);
        my $cmd = shift @ARGV;
        for ($cmd) {
-               /^target_config$/ and return gen_target_config();
-               /^profile_mk$/ and return gen_profile_mk();
-               /^package_mk$/ and return gen_package_mk();
-               /^package_config$/ and return gen_package_config();
+               /^mk$/ and return gen_package_mk();
+               /^config$/ and return gen_package_config();
                /^kconfig/ and return gen_kconfig_overrides();
-               /^package_source$/ and return gen_package_source();
-               /^package_subdirs$/ and return gen_package_subdirs();
-               /^package_license$/ and return gen_package_license(0);
-               /^package_licensefull$/ and return gen_package_license(1);
+               /^source$/ and return gen_package_source();
+               /^subdirs$/ and return gen_package_subdirs();
+               /^license$/ and return gen_package_license(0);
+               /^licensefull$/ and return gen_package_license(1);
                /^version_filter$/ and return gen_version_filtered_list();
        }
-       print <<EOF
+       die <<EOF
 Available Commands:
-       $0 target_config [file]                 Target metadata in Kconfig format
-       $0 profile_mk [file] [target]           Profile metadata in makefile format
-       $0 package_mk [file]                    Package metadata in makefile format
-       $0 package_config [file]                Package metadata in Kconfig format
+       $0 mk [file]                            Package metadata in makefile format
+       $0 config [file]                        Package metadata in Kconfig format
        $0 kconfig [file] [config] [patchver]   Kernel config overrides
-       $0 package_source [file]                Package source file information
-       $0 package_subdirs [file]               Package subdir information in makefile format
-       $0 package_license [file]               Package license information
-       $0 package_licensefull [file]           Package license information (full list)
+       $0 source [file]                        Package source file information
+       $0 subdirs [file]                       Package subdir information in makefile format
+       $0 license [file]                       Package license information
+       $0 licensefull [file]                   Package license information (full list)
        $0 version_filter [patchver] [list...]  Filter list of version tagged strings
 
 Options:
diff --git a/scripts/target-metadata.pl b/scripts/target-metadata.pl
new file mode 100755 (executable)
index 0000000..16f8a9f
--- /dev/null
@@ -0,0 +1,329 @@
+#!/usr/bin/env perl
+use FindBin;
+use lib "$FindBin::Bin";
+use strict;
+use metadata;
+use Getopt::Long;
+
+sub target_config_features(@) {
+       my $ret;
+
+       while ($_ = shift @_) {
+               /arm_v(\w+)/ and $ret .= "\tselect arm_v$1\n";
+               /broken/ and $ret .= "\tdepends on BROKEN\n";
+               /audio/ and $ret .= "\tselect AUDIO_SUPPORT\n";
+               /display/ and $ret .= "\tselect DISPLAY_SUPPORT\n";
+               /dt/ and $ret .= "\tselect USES_DEVICETREE\n";
+               /gpio/ and $ret .= "\tselect GPIO_SUPPORT\n";
+               /pci/ and $ret .= "\tselect PCI_SUPPORT\n";
+               /pcie/ and $ret .= "\tselect PCIE_SUPPORT\n";
+               /usb/ and $ret .= "\tselect USB_SUPPORT\n";
+               /usbgadget/ and $ret .= "\tselect USB_GADGET_SUPPORT\n";
+               /pcmcia/ and $ret .= "\tselect PCMCIA_SUPPORT\n";
+               /rtc/ and $ret .= "\tselect RTC_SUPPORT\n";
+               /squashfs/ and $ret .= "\tselect USES_SQUASHFS\n";
+               /jffs2$/ and $ret .= "\tselect USES_JFFS2\n";
+               /jffs2_nand/ and $ret .= "\tselect USES_JFFS2_NAND\n";
+               /ext4/ and $ret .= "\tselect USES_EXT4\n";
+               /targz/ and $ret .= "\tselect USES_TARGZ\n";
+               /cpiogz/ and $ret .= "\tselect USES_CPIOGZ\n";
+               /ubifs/ and $ret .= "\tselect USES_UBIFS\n";
+               /fpu/ and $ret .= "\tselect HAS_FPU\n";
+               /spe_fpu/ and $ret .= "\tselect HAS_SPE_FPU\n";
+               /ramdisk/ and $ret .= "\tselect USES_INITRAMFS\n";
+               /powerpc64/ and $ret .= "\tselect powerpc64\n";
+               /nommu/ and $ret .= "\tselect NOMMU\n";
+               /mips16/ and $ret .= "\tselect HAS_MIPS16\n";
+               /rfkill/ and $ret .= "\tselect RFKILL_SUPPORT\n";
+               /low_mem/ and $ret .= "\tselect LOW_MEMORY_FOOTPRINT\n";
+               /nand/ and $ret .= "\tselect NAND_SUPPORT\n";
+       }
+       return $ret;
+}
+
+sub target_name($) {
+       my $target = shift;
+       my $parent = $target->{parent};
+       if ($parent) {
+               return $target->{parent}->{name}." - ".$target->{name};
+       } else {
+               return $target->{name};
+       }
+}
+
+sub kver($) {
+       my $v = shift;
+       $v =~ tr/\./_/;
+       if (substr($v,0,2) eq "2_") {
+               $v =~ /(\d+_\d+_\d+)(_\d+)?/ and $v = $1;
+       } else {
+               $v =~ /(\d+_\d+)(_\d+)?/ and $v = $1;
+       }
+       return $v;
+}
+
+sub print_target($) {
+       my $target = shift;
+       my $features = target_config_features(@{$target->{features}});
+       my $help = $target->{desc};
+       my $confstr;
+
+       chomp $features;
+       $features .= "\n";
+       if ($help =~ /\w+/) {
+               $help =~ s/^\s*/\t  /mg;
+               $help = "\thelp\n$help";
+       } else {
+               undef $help;
+       }
+
+       my $v = kver($target->{version});
+       if (@{$target->{subtargets}} == 0) {
+       $confstr = <<EOF;
+config TARGET_$target->{conf}
+       bool "$target->{name}"
+       select LINUX_$v
+EOF
+       }
+       else {
+               $confstr = <<EOF;
+config TARGET_$target->{conf}
+       bool "$target->{name}"
+EOF
+       }
+       if ($target->{subtarget}) {
+               $confstr .= "\tdepends on TARGET_$target->{boardconf}\n";
+       }
+       if (@{$target->{subtargets}} > 0) {
+               $confstr .= "\tselect HAS_SUBTARGETS\n";
+               grep { /broken/ } @{$target->{features}} and $confstr .= "\tdepends on BROKEN\n";
+       } else {
+               $confstr .= $features;
+               if ($target->{arch} =~ /\w/) {
+                       $confstr .= "\tselect $target->{arch}\n";
+               }
+       }
+
+       foreach my $dep (@{$target->{depends}}) {
+               my $mode = "depends on";
+               my $flags;
+               my $name;
+
+               $dep =~ /^([@\+\-]+)(.+)$/;
+               $flags = $1;
+               $name = $2;
+
+               next if $name =~ /:/;
+               $flags =~ /-/ and $mode = "deselect";
+               $flags =~ /\+/ and $mode = "select";
+               $flags =~ /@/ and $confstr .= "\t$mode $name\n";
+       }
+       $confstr .= "$help\n\n";
+       print $confstr;
+}
+
+sub merge_package_lists($$) {
+       my $list1 = shift;
+       my $list2 = shift;
+       my @l = ();
+       my %pkgs;
+
+       foreach my $pkg (@$list1, @$list2) {
+               $pkgs{$pkg} = 1;
+       }
+       foreach my $pkg (keys %pkgs) {
+               push @l, $pkg unless ($pkg =~ /^-/ or $pkgs{"-$pkg"});
+       }
+       return sort(@l);
+}
+
+sub gen_target_config() {
+       my $file = shift @ARGV;
+       my @target = parse_target_metadata($file);
+       my %defaults;
+
+       my @target_sort = sort {
+               target_name($a) cmp target_name($b);
+       } @target;
+
+
+       print <<EOF;
+choice
+       prompt "Target System"
+       default TARGET_ar71xx
+       reset if !DEVEL
+       
+EOF
+
+       foreach my $target (@target_sort) {
+               next if $target->{subtarget};
+               print_target($target);
+       }
+
+       print <<EOF;
+endchoice
+
+choice
+       prompt "Subtarget" if HAS_SUBTARGETS
+EOF
+       foreach my $target (@target) {
+               next unless $target->{def_subtarget};
+               print <<EOF;
+       default TARGET_$target->{conf}_$target->{def_subtarget} if TARGET_$target->{conf}
+EOF
+       }
+       print <<EOF;
+
+EOF
+       foreach my $target (@target) {
+               next unless $target->{subtarget};
+               print_target($target);
+       }
+
+print <<EOF;
+endchoice
+
+choice
+       prompt "Target Profile"
+
+EOF
+
+       foreach my $target (@target) {
+               my $profiles = $target->{profiles};
+               foreach my $profile (@{$target->{profiles}}) {
+                       print <<EOF;
+config TARGET_$target->{conf}_$profile->{id}
+       bool "$profile->{name}"
+       depends on TARGET_$target->{conf}
+EOF
+                       my @pkglist = merge_package_lists($target->{packages}, $profile->{packages});
+                       foreach my $pkg (@pkglist) {
+                               print "\tselect DEFAULT_$pkg\n";
+                               $defaults{$pkg} = 1;
+                       }
+                       my $help = $profile->{desc};
+                       if ($help =~ /\w+/) {
+                               $help =~ s/^\s*/\t  /mg;
+                               $help = "\thelp\n$help";
+                       } else {
+                               undef $help;
+                       }
+                       print "$help\n";
+               }
+       }
+
+       print <<EOF;
+endchoice
+
+config HAS_SUBTARGETS
+       bool
+
+config TARGET_BOARD
+       string
+
+EOF
+       foreach my $target (@target) {
+               $target->{subtarget} or print "\t\tdefault \"".$target->{board}."\" if TARGET_".$target->{conf}."\n";
+       }
+       print <<EOF;
+config TARGET_SUBTARGET
+       string
+       default "generic" if !HAS_SUBTARGETS
+
+EOF
+
+       foreach my $target (@target) {
+               foreach my $subtarget (@{$target->{subtargets}}) {
+                       print "\t\tdefault \"$subtarget\" if TARGET_".$target->{conf}."_$subtarget\n";
+               }
+       }
+       print <<EOF;
+config TARGET_PROFILE
+       string
+EOF
+       foreach my $target (@target) {
+               my $profiles = $target->{profiles};
+               foreach my $profile (@$profiles) {
+                       print "\tdefault \"$profile->{id}\" if TARGET_$target->{conf}_$profile->{id}\n";
+               }
+       }
+
+       print <<EOF;
+
+config TARGET_ARCH_PACKAGES
+       string
+       
+EOF
+       foreach my $target (@target) {
+               next if @{$target->{subtargets}} > 0;
+               print "\t\tdefault \"".($target->{arch_packages} || $target->{board})."\" if TARGET_".$target->{conf}."\n";
+       }
+       print <<EOF;
+
+config DEFAULT_TARGET_OPTIMIZATION
+       string
+EOF
+       foreach my $target (@target) {
+               next if @{$target->{subtargets}} > 0;
+               print "\tdefault \"".$target->{cflags}."\" if TARGET_".$target->{conf}."\n";
+       }
+       print "\tdefault \"-Os -pipe -funit-at-a-time\"\n";
+       print <<EOF;
+
+config CPU_TYPE
+       string
+EOF
+       foreach my $target (@target) {
+               next if @{$target->{subtargets}} > 0;
+               print "\tdefault \"".$target->{cputype}."\" if TARGET_".$target->{conf}."\n";
+       }
+       print "\tdefault \"\"\n";
+
+       my %kver;
+       foreach my $target (@target) {
+               my $v = kver($target->{version});
+               next if $kver{$v};
+               $kver{$v} = 1;
+               print <<EOF;
+
+config LINUX_$v
+       bool
+
+EOF
+       }
+       foreach my $def (sort keys %defaults) {
+               print "\tconfig DEFAULT_".$def."\n";
+               print "\t\tbool\n\n";
+       }
+}
+
+sub gen_profile_mk() {
+       my $file = shift @ARGV;
+       my $target = shift @ARGV;
+       my @targets = parse_target_metadata($file);
+       foreach my $cur (@targets) {
+               next unless $cur->{id} eq $target;
+               print "PROFILE_NAMES = ".join(" ", map { $_->{id} } @{$cur->{profiles}})."\n";
+               foreach my $profile (@{$cur->{profiles}}) {
+                       print $profile->{id}.'_NAME:='.$profile->{name}."\n";
+                       print $profile->{id}.'_PACKAGES:='.join(' ', @{$profile->{packages}})."\n";
+               }
+       }
+}
+
+sub parse_command() {
+       GetOptions("ignore=s", \@ignore);
+       my $cmd = shift @ARGV;
+       for ($cmd) {
+               /^config$/ and return gen_target_config();
+               /^profile_mk$/ and return gen_profile_mk();
+       }
+       die <<EOF
+Available Commands:
+       $0 config [file]                        Target metadata in Kconfig format
+       $0 profile_mk [file] [target]           Profile metadata in makefile format
+
+EOF
+}
+
+parse_command();
index c5f8bd7681e2cb2d0d499008cdfd055291f370f3..64f21b887108ea95d2ef9743148705828172f893 100644 (file)
@@ -81,7 +81,7 @@ PROFILE_LIST = $(foreach p,$(PROFILE_NAMES), \
 )
 
 .profiles.mk: .targetinfo
-       $(SCRIPT_DIR)/metadata.pl profile_mk $< '$(BOARD)$(if $(SUBTARGET),/$(SUBTARGET))' > $@
+       $(SCRIPT_DIR)/target-metadata.pl profile_mk $< '$(BOARD)$(if $(SUBTARGET),/$(SUBTARGET))' > $@
 
 staging_dir/host/.prereq-build: include/prereq-build.mk
        mkdir -p tmp