6 sub parse_target_metadata
() {
7 my ($target, @target, $profile);
10 /^Target:\s*((.+)-(\d+\.\d+))\s*$/ and do {
11 my $conf = uc $3.'_'.$2;
20 push @target, $target;
22 /^Target-Name:\s*(.+)\s*$/ and $target->{name
} = $1;
23 /^Target-Path:\s*(.+)\s*$/ and $target->{path
} = $1;
24 /^Target-Arch:\s*(.+)\s*$/ and $target->{arch
} = $1;
25 /^Target-Features:\s*(.+)\s*$/ and $target->{features
} = [ split(/\s+/, $1) ];
26 /^Target-Description:/ and do {
32 $target->{desc
} = $desc;
34 /^Linux-Version:\s*(.+)\s*$/ and $target->{version
} = $1;
35 /^Linux-Release:\s*(.+)\s*$/ and $target->{release
} = $1;
36 /^Linux-Kernel-Arch:\s*(.+)\s*$/ and $target->{karch
} = $1;
37 /^Default-Packages:\s*(.+)\s*$/ and $target->{packages
} = [ split(/\s+/, $1) ];
38 /^Target-Profile:\s*(.+)\s*$/ and do {
44 push @
{$target->{profiles
}}, $profile;
46 /^Target-Profile-Name:\s*(.+)\s*$/ and $profile->{name
} = $1;
47 /^Target-Profile-Packages:\s*(.*)\s*$/ and $profile->{packages
} = [ split(/\s+/, $1) ];
48 /^Target-Profile-Description:/ and do {
54 $profile->{desc
} = $desc;
57 foreach my $target (@target) {
58 @
{$target->{profiles
}} > 0 or $target->{profiles
} = [
69 sub parse_package_metadata
() {
75 /^Source-Makefile: \s*(.+\/([^\
/]+)\/Makefile
)\s
*$/ and do {
80 /^Package: \s*(.+)\s*$/ and do {
83 $pkg->{makefile
} = $makefile;
85 $pkg->{default} = "m if ALL";
88 /^Version: \s*(.+)\s*$/ and $pkg->{version
} = $1;
89 /^Title: \s*(.+)\s*$/ and $pkg->{title
} = $1;
90 /^Menu: \s*(.+)\s*$/ and $pkg->{menu
} = $1;
91 /^Submenu: \s*(.+)\s*$/ and $pkg->{submenu
} = $1;
92 /^Submenu-Depends: \s*(.+)\s*$/ and $pkg->{submenudep
} = $1;
93 /^Default: \s*(.+)\s*$/ and $pkg->{default} = $1;
94 /^Provides: \s*(.+)\s*$/ and do {
95 my @vpkg = split /\s+/, $1;
96 foreach my $vpkg (@vpkg) {
97 $package{$vpkg} or $package{$vpkg} = { vdepends
=> [] };
98 push @
{$package{$vpkg}->{vdepends
}}, $pkg->{name
};
101 /^Depends: \s*(.+)\s*$/ and do {
102 my @dep = split /\s+/, $1;
103 $pkg->{depends
} = \
@dep;
105 /^Category: \s*(.+)\s*$/ and do {
106 $pkg->{category
} = $1;
107 defined $category{$1} or $category{$1} = {};
108 defined $category{$1}->{$src} or $category{$1}->{$src} = [];
109 push @
{$category{$1}->{$src}}, $pkg;
111 /^Description: \s*(.*)\s*$/ and do {
112 my $desc = "\t\t$1\n\n";
115 last if $line =~ /^@@/;
116 $desc .= "\t\t$line";
118 $pkg->{description
} = $desc;
120 /^Config: \s*(.*)\s*$/ and do {
124 last if $line =~ /^@@/;
127 $pkg->{config
} = $conf;
134 sub gen_target_mk
() {
135 my @target = parse_target_metadata
();
138 $a->{id
} cmp $b->{id
}
141 foreach my $target (@target) {
142 my ($profiles_def, $profiles_eval);
143 my $conf = uc $target->{kernel
}.'_'.$target->{board
};
146 foreach my $profile (@
{$target->{profiles
}}) {
148 define Profile/$conf\_$profile->{id}
150 NAME:=$profile->{name}
151 PACKAGES:=".join(" ", @
{$profile->{packages
}})."
154 \$(eval \$(call Profile,$conf\_$profile->{id}))"
157 ifeq (\$(CONFIG_LINUX_$conf),y)
159 KERNEL:=$target->{kernel}
160 BOARD:=$target->{board}
161 BOARDNAME:=$target->{name}
162 LINUX_VERSION:=$target->{version}
163 LINUX_RELEASE:=$target->{release}
164 LINUX_KARCH:=$target->{karch}
165 DEFAULT_PACKAGES:=".join(" ", @
{$target->{packages
}})."
171 print "\$(eval \$(call Target))\n";
174 sub target_config_features
(@
) {
177 while ($_ = shift @_) {
178 /broken/ and $ret .= "\tdepends BROKEN\n";
179 /pci/ and $ret .= "\tselect PCI_SUPPORT\n";
180 /usb/ and $ret .= "\tselect USB_SUPPORT\n";
181 /atm/ and $ret .= "\tselect ATM_SUPPORT\n";
182 /pcmcia/ and $ret .= "\tselect PCMCIA_SUPPORT\n";
183 /squashfs/ and $ret .= "\tselect USES_SQUASHFS\n";
184 /jffs2/ and $ret .= "\tselect USES_JFFS2\n";
185 /ext2/ and $ret .= "\tselect USES_EXT2\n";
191 sub gen_target_config
() {
192 my @target = parse_target_metadata
();
195 $a->{name
} cmp $b->{name
}
201 prompt "Target System"
202 default LINUX_2_4_BRCM
206 foreach my $target (@target) {
207 my $features = target_config_features
(@
{$target->{features
}});
208 my $help = $target->{desc
};
209 my $kernel = $target->{kernel
};
214 if ($help =~ /\w+/) {
215 $help =~ s/^\s*/\t /mg;
216 $help = "\thelp\n$help";
222 config LINUX_$target->{conf}
223 bool "$target->{name}"
224 select $target->{arch}
235 bool "UNSUPPORTED little-endian arm platform"
240 config LINUX_2_6_CRIS
241 bool "UNSUPPORTED cris platform"
246 config LINUX_2_6_M68K
247 bool "UNSUPPORTED m68k platform"
253 bool "UNSUPPORTED little-endian sh3 platform"
258 config LINUX_2_6_SH3EB
259 bool "UNSUPPORTED big-endian sh3 platform"
265 bool "UNSUPPORTED little-endian sh4 platform"
270 config LINUX_2_6_SH4EB
271 bool "UNSUPPORTED big-endian sh4 platform"
276 config LINUX_2_6_SPARC
277 bool "UNSUPPORTED sparc platform"
287 prompt "Target Profile"
291 foreach my $target (@target) {
292 my $profiles = $target->{profiles
};
294 foreach my $profile (@
$profiles) {
296 config LINUX_$target->{conf}_$profile->{id}
297 bool "$profile->{name}"
298 depends LINUX_$target->{conf}
300 foreach my $pkg (@
{$target->{packages
}}, @
{$profile->{packages
}}) {
301 print "\tselect DEFAULT_$pkg\n";
310 sub find_package_dep
($$) {
313 my $deps = ($pkg->{vdepends
} or $pkg->{depends
});
315 return 0 unless defined $deps;
316 foreach my $dep (@
{$deps}) {
317 return 1 if $dep eq $name;
318 return 1 if ($package{$dep} and (find_package_dep
($package{$dep},$name) == 1));
323 sub package_depends
($$) {
328 return 0 if ($a->{submenu
} ne $b->{submenu
});
329 if (find_package_dep
($a, $b->{name
}) == 1) {
331 } elsif (find_package_dep
($b, $a->{name
}) == 1) {
339 sub print_package_config_category
($) {
344 return unless $category{$cat};
346 print "menu \"$cat\"\n\n";
347 my %spkg = %{$category{$cat}};
349 foreach my $spkg (sort {uc($a) cmp uc($b)} keys %spkg) {
350 foreach my $pkg (@
{$spkg{$spkg}}) {
351 my $menu = $pkg->{submenu
};
353 $menu_dep{$menu} or $menu_dep{$menu} = $pkg->{submenudep
};
357 $menus{$menu} or $menus{$menu} = [];
358 push @
{$menus{$menu}}, $pkg;
359 print "\tconfig DEFAULT_".$pkg->{name
}."\n";
360 print "\t\tbool\n\n";
364 ($a eq 'undef' ?
1 : 0) or
365 ($b eq 'undef' ?
-1 : 0) or
369 foreach my $menu (@menus) {
371 package_depends
($a, $b) or
372 ($a->{name
} cmp $b->{name
})
374 if ($menu ne 'undef') {
375 $menu_dep{$menu} and print "if $menu_dep{$menu}\n";
376 print "menu \"$menu\"\n";
378 foreach my $pkg (@pkgs) {
379 my $title = $pkg->{name
};
380 my $c = (72 - length($pkg->{name
}) - length($pkg->{title
}));
382 $title .= ("." x
$c). " ". $pkg->{title
};
385 $pkg->{menu
} and print "menu";
386 print "config PACKAGE_".$pkg->{name
}."\n";
387 print "\t\ttristate \"$title\"\n";
388 print "\t\tdefault y if DEFAULT_".$pkg->{name
}."\n";
389 foreach my $default (split /\s*,\s*/, $pkg->{default}) {
390 print "\t\tdefault $default\n";
392 foreach my $depend (@
{$pkg->{depends
}}) {
394 $depend =~ s/^([@\+]+)//;
398 if ($vdep = $package{$depend}->{vdepends
}) {
399 $depend = join("||", map { "PACKAGE_".$_ } @
$vdep);
401 $flags =~ /@/ or $depend = "PACKAGE_$depend";
402 $flags =~ /\+/ and $m = "select";
404 print "\t\t$m $depend\n";
407 print $pkg->{description
};
410 $pkg->{config
} and print $pkg->{config
}."\n";
412 if ($menu ne 'undef') {
414 $menu_dep{$menu} and print "endif\n";
419 undef $category{$cat};
422 sub gen_package_config
() {
423 parse_package_metadata
();
424 print_package_config_category
'Base system';
425 foreach my $cat (keys %category) {
426 print_package_config_category
$cat;
430 sub parse_command
() {
431 my $cmd = shift @ARGV;
433 /^target_mk$/ and return gen_target_mk
();
434 /^target_config$/ and return gen_target_config
();
435 /^package_config$/ and return gen_package_config
();
439 $0 target_mk [file] Target metadata in makefile format
440 $0 target_config [file] Target metadata in Kconfig format
441 $0 package_config [file] Package metadata in Kconfig format