<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl
# 
# Copyright (C) 2006 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#

use strict;

my @target;
my $target;
my $profiles;
my $profile;

sub features(@) {
	my $ret;

	while ($_ = shift @_) {
		/broken/ and $ret .= "\tdepends BROKEN\n";
		/pci/ and $ret .= "\tselect PCI_SUPPORT\n";
		/usb/ and $ret .= "\tselect USB_SUPPORT\n";
		/atm/ and $ret .= "\tselect ATM_SUPPORT\n";
		/pcmcia/ and $ret .= "\tselect PCMCIA_SUPPORT\n";
		/squashfs/ and $ret .= "\tselect USES_SQUASHFS\n";
		/jffs2/ and $ret .= "\tselect USES_JFFS2\n";
		/ext2/ and $ret .= "\tselect USES_EXT2\n";
	}
	return $ret;
}

while (&lt;&gt;) {
	chomp;
	/^Target:\s*((.+)-(\d+\.\d+))\s*$/ and do {
		my $conf = uc $3.'_'.$2;
		$conf =~ tr/\.-/__/;
		$target = {
			id =&gt; $1,
			conf =&gt; $conf,
			board =&gt; $2,
			kernel =&gt; $3
		};
		$target-&gt;{kernel} =~ tr/\./_/;
		push @target, $target;
	};
	/^Target-Name:\s*(.+)\s*$/ and $target-&gt;{name} = $1;
	/^Target-Path:\s*(.+)\s*$/ and $target-&gt;{path} = $1;
	/^Target-Arch:\s*(.+)\s*$/ and $target-&gt;{arch} = $1;
	/^Target-Features:\s*(.+)\s*$/ and do {
		my $f = [];
		$target-&gt;{features} = $f;
		@$f = split /\s+/, $1;
	};
	/^Target-Description:/ and do {
		my $desc;
		while (&lt;&gt;) {
			last if /^@@/;
			$desc .= $_;
		}
		$target-&gt;{desc} = $desc;
	};
	/^Linux-Version:\s*(.+)\s*$/ and $target-&gt;{version} = $1;
	/^Linux-Release:\s*(.+)\s*$/ and $target-&gt;{release} = $1;
	/^Linux-Kernel-Arch:\s*(.+)\s*$/ and $target-&gt;{karch} = $1;
	/^Default-Packages:\s*(.+)\s*$/ and do {
		my @pkgs = split /\s+/, $1;
		$target-&gt;{defaultpkgs} = \@pkgs;
	};
	/^Target-Profile:\s*(.+)\s*$/ and do {
		$profiles = $target-&gt;{profiles} or $target-&gt;{profiles} = $profiles = [];
		$profile = {
			id =&gt; $1
		};
		push @$profiles, $profile;
	};
	/^Target-Profile-Name:\s*(.+)\s*$/ and $profile-&gt;{name} = $1;
	/^Target-Profile-Packages:\s*(.+)\s*$/ and do {
		my @pkgs = split /\s+/, $1;
		$profile-&gt;{pkgs} = \@pkgs;
	};
}

@target = sort {
	$a-&gt;{name} cmp $b-&gt;{name}
} @target;


print &lt;&lt;EOF;
choice
	prompt "Target System"
	default LINUX_2_4_BRCM
	
EOF

foreach $target (@target) {
	my $features = features(@{$target-&gt;{features}});
	my $help = $target-&gt;{desc};
	chomp $features;
	$features .= "\n";
	if ($help =~ /\w+/) {
		$help =~ s/^\s*/\t  /mg;
		$help = "\thelp\n$help";
	} else {
		undef $help;
	}

	print &lt;&lt;EOF
config LINUX_$target-&gt;{conf}
	bool "$target-&gt;{name}"
	select $target-&gt;{arch}
	select LINUX_$target-&gt;{kernel}
$features$help

EOF
}

print &lt;&lt;EOF;
if DEVEL

config LINUX_2_6_ARM
	bool "UNSUPPORTED little-endian arm platform"
	depends BROKEN
	select LINUX_2_6
	select arm

config LINUX_2_6_CRIS
	bool "UNSUPPORTED cris platform"
	depends BROKEN
	select LINUX_2_6
	select cris

config LINUX_2_6_M68K
	bool "UNSUPPORTED m68k platform"
	depends BROKEN
	select LINUX_2_6
	select m68k

config LINUX_2_6_SH3
	bool "UNSUPPORTED little-endian sh3 platform"
	depends BROKEN
	select LINUX_2_6
	select sh3

config LINUX_2_6_SH3EB
	bool "UNSUPPORTED big-endian sh3 platform"
	depends BROKEN
	select LINUX_2_6
	select sh3eb

config LINUX_2_6_SH4
	bool "UNSUPPORTED little-endian sh4 platform"
	depends BROKEN
	select LINUX_2_6
	select sh4

config LINUX_2_6_SH4EB
	bool "UNSUPPORTED big-endian sh4 platform"
	depends BROKEN
	select LINUX_2_6
	select sh4eb

config LINUX_2_6_SPARC
	bool "UNSUPPORTED sparc platform"
	depends BROKEN
	select LINUX_2_6
	select sparc

endif

endchoice

choice
	prompt "Target Profile"

EOF

foreach $target (@target) {
	my $profiles;
	
	$profiles = $target-&gt;{profiles} or $profiles = [
		{
			id =&gt; 'Default',
			name =&gt; 'Default',
			pkgs =&gt; []
		}
	];
	foreach my $profile (@$profiles) {
		print &lt;&lt;EOF;
config LINUX_$target-&gt;{conf}_$profile-&gt;{id}
	bool "$profile-&gt;{name}"
	depends LINUX_$target-&gt;{conf}
EOF
		foreach my $pkg (@{$target-&gt;{defaultpkgs}}, @{$profile-&gt;{pkgs}}) {
			print "\tselect DEFAULT_$pkg\n";
		}
		print "\n";
	}
}

print "endchoice\n";
</pre></body></html>