X-Git-Url: https://git.rohieb.name/openwrt.git/blobdiff_plain/7082dce3c68d7ced81caccd694a6a4edf1587c32..7e450a1c869a5b227e3c91c4e71049059f1193e6:/scripts/metadata.pl?ds=sidebyside

diff --git a/scripts/metadata.pl b/scripts/metadata.pl
index 963be3f38..063524a67 100755
--- a/scripts/metadata.pl
+++ b/scripts/metadata.pl
@@ -53,6 +53,7 @@ sub parse_target_metadata() {
 			}
 			$profile->{desc} = $desc;
 		};
+		/^Target-Profile-Kconfig:/ and $profile->{kconfig} = 1;
 	}
 	foreach my $target (@target) {
 		@{$target->{profiles}} > 0 or $target->{profiles} = [
@@ -148,10 +149,11 @@ sub gen_target_mk() {
   define Profile/$conf\_$profile->{id}
     ID:=$profile->{id}
     NAME:=$profile->{name}
-    PACKAGES:=".join(" ", @{$profile->{packages}})."
-  endef";
-  $profiles_eval .= "
-\$(eval \$(call Profile,$conf\_$profile->{id}))"
+    PACKAGES:=".join(" ", @{$profile->{packages}})."\n";
+			$profile->{kconfig} and $profiles_def .= "    KCONFIG:=1\n";
+			$profiles_def .= "  endef";
+			$profiles_eval .= "
+\$(eval \$(call AddProfile,$conf\_$profile->{id}))"
 		}
 		print "
 ifeq (\$(CONFIG_LINUX_$conf),y)
@@ -298,6 +300,7 @@ config LINUX_$target->{conf}_$profile->{id}
 	bool "$profile->{name}"
 	depends LINUX_$target->{conf}
 EOF
+			$profile->{kconfig} and print "\tselect PROFILE_KCONFIG\n";
 			my %pkgs;
 			foreach my $pkg (@{$target->{packages}}, @{$profile->{packages}}) {
 				$pkgs{$pkg} = 1;
@@ -341,6 +344,39 @@ sub package_depends($$) {
 	return $ret;
 }
 
+sub mconf_depends($$) {
+	my $depends = shift;
+	my $only_dep = shift;
+	my $res;
+
+	$depends or return;
+	my @depends = @$depends;
+	foreach my $depend (@depends) {
+		my $m = "depends";
+		$depend =~ s/^([@\+]+)//;
+		my $flags = $1;
+		my $vdep;
+	
+		if ($vdep = $package{$depend}->{vdepends}) {
+			$depend = join("||", map { "PACKAGE_".$_ } @$vdep);
+		} else {
+			$flags =~ /\+/ and do {
+				next if $only_dep;
+				$m = "select";
+
+				# Menuconfig will not treat 'select FOO' as a real dependency
+				# thus if FOO depends on other config options, these dependencies
+				# will not be checked. To fix this, we simply emit all of FOO's
+				# depends here as well.
+				$package{$depend} and $res .= mconf_depends($package{$depend}->{depends}, 1);
+			};
+			$flags =~ /@/ or $depend = "PACKAGE_$depend";
+		}
+		$res .= "\t\t$m $depend\n";
+	}
+	return $res;
+}
+
 sub print_package_config_category($) {
 	my $cat = shift;
 	my %menus;
@@ -394,20 +430,7 @@ sub print_package_config_category($) {
 			foreach my $default (split /\s*,\s*/, $pkg->{default}) {
 				print "\t\tdefault $default\n";
 			}
-			foreach my $depend (@{$pkg->{depends}}) {
-				my $m = "depends";
-				$depend =~ s/^([@\+]+)//;
-				my $flags = $1;
-				my $vdep;
-				
-				if ($vdep = $package{$depend}->{vdepends}) {
-					$depend = join("||", map { "PACKAGE_".$_ } @$vdep);
-				} else {
-					$flags =~ /@/ or $depend = "PACKAGE_$depend";
-					$flags =~ /\+/ and $m = "select";
-				}
-				print "\t\t$m $depend\n";
-			}
+			print mconf_depends($pkg->{depends}, 0);
 			print "\t\thelp\n";
 			print $pkg->{description};
 			print "\n";