[OpenWrt-Devel] [PATCH 1/3] build: add support for options

Luka Perkov luka at openwrt.org
Mon Aug 11 04:47:40 EDT 2014


This patch adds support for target DEFAULT_OPTIONS and profile OPTIONS
variables. Those are simmilar to existing DEFAULT_PACKAGES and PACKAGES
but one can use them to select other options by default in menuconfig.

Signed-off-by: Luka Perkov <luka at openwrt.org>
---
 include/target.mk   |  4 ++++
 scripts/metadata.pl | 12 ++++++++++--
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/include/target.mk b/include/target.mk
index e36cdd6..20179d1 100644
--- a/include/target.mk
+++ b/include/target.mk
@@ -11,6 +11,7 @@ __target_inc=1
 # default device type
 DEVICE_TYPE?=router
 
+DEFAULT_OPTIONS:=
 # Default packages - the really basic set
 DEFAULT_PACKAGES:=base-files libc libgcc busybox dropbear mtd uci opkg netifd fstools
 # For router targets
@@ -56,6 +57,7 @@ extra_packages = $(if $(filter wpad-mini wpad nas,$(1)),iwinfo)
 
 define Profile/Default
   NAME:=
+  OPTIONS:=
   PACKAGES:=
 endef
 
@@ -68,6 +70,7 @@ define Profile
   DUMPINFO += \
 	echo "Target-Profile: $(1)"; \
 	echo "Target-Profile-Name: $(NAME)"; \
+	echo "Target-Profile-Options: $(OPTIONS)"; \
 	echo "Target-Profile-Packages: $(PACKAGES) $(call extra_packages,$(DEFAULT_PACKAGES) $(PACKAGES))"; \
 	if [ -f ./config/profile-$(1) ]; then \
 		echo "Target-Profile-Kconfig: yes"; \
@@ -276,6 +279,7 @@ define BuildTargets/DumpCurrent
 	 echo 'Target-Description:'; \
 	 $(SH_FUNC) getvar $(call shvar,Target/Description); \
 	 echo '@@'; \
+	 echo 'Default-Options: $(DEFAULT_OPTIONS)'; \
 	 echo 'Default-Packages: $(DEFAULT_PACKAGES) $(call extra_packages,$(DEFAULT_PACKAGES))'; \
 	 $(DUMPINFO)
 	$(if $(SUBTARGET),,@$(foreach SUBTARGET,$(SUBTARGETS),$(SUBMAKE) -s DUMP=1 SUBTARGET=$(SUBTARGET); ))
diff --git a/scripts/metadata.pl b/scripts/metadata.pl
index 79f930c..d7d168d 100755
--- a/scripts/metadata.pl
+++ b/scripts/metadata.pl
@@ -58,16 +58,19 @@ sub parse_target_metadata() {
 		/^Linux-Release:\s*(.+)\s*$/ and $target->{release} = $1;
 		/^Linux-Kernel-Arch:\s*(.+)\s*$/ and $target->{karch} = $1;
 		/^Default-Subtarget:\s*(.+)\s*$/ and $target->{def_subtarget} = $1;
+		/^Default-Options:\s*(.+)\s*$/ and $target->{options} = [ split(/\s+/, $1) ];
 		/^Default-Packages:\s*(.+)\s*$/ and $target->{packages} = [ split(/\s+/, $1) ];
 		/^Target-Profile:\s*(.+)\s*$/ and do {
 			$profile = {
 				id => $1,
 				name => $1,
+				options => [],
 				packages => []
 			};
 			push @{$target->{profiles}}, $profile;
 		};
 		/^Target-Profile-Name:\s*(.+)\s*$/ and $profile->{name} = $1;
+		/^Target-Profile-Options:\s*(.*)\s*$/ and $profile->{options} = [ split(/\s+/, $1) ];
 		/^Target-Profile-Packages:\s*(.*)\s*$/ and $profile->{packages} = [ split(/\s+/, $1) ];
 		/^Target-Profile-Description:\s*(.*)\s*/ and $profile->{desc} = get_multiline(*FILE);
 		/^Target-Profile-Config:/ and $profile->{config} = get_multiline(*FILE, "\t");
@@ -83,6 +86,7 @@ sub parse_target_metadata() {
 			{
 				id => 'Default',
 				name => 'Default',
+				options => [],
 				packages => []
 			}
 		];
@@ -138,7 +142,7 @@ sub gen_kconfig_overrides() {
 	}
 }
 
-sub merge_package_lists($$) {
+sub merge_lists($$) {
 	my $list1 = shift;
 	my $list2 = shift;
 	my @l = ();
@@ -331,7 +335,11 @@ config TARGET_$target->{conf}_$profile->{id}
 $profile->{config}
 EOF
 			$profile->{kconfig} and print "\tselect PROFILE_KCONFIG\n";
-			my @pkglist = merge_package_lists($target->{packages}, $profile->{packages});
+			my @optlist = merge_lists($target->{options}, $profile->{options});
+			foreach my $opt (@optlist) {
+				print "\tselect $opt\n";
+			}
+			my @pkglist = merge_lists($target->{packages}, $profile->{packages});
 			foreach my $pkg (@pkglist) {
 				print "\tselect DEFAULT_$pkg\n";
 				$defaults{$pkg} = 1;
-- 
2.0.3
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list