add a hack to allow source package names in Build-Depends: (PKG_BUILDDEP)
[openwrt.git] / scripts / gen_target_mk.pl
1 #!/usr/bin/perl
2 #
3 # Copyright (C) 2006 OpenWrt.org
4 #
5 # This is free software, licensed under the GNU General Public License v2.
6 # See /LICENSE for more information.
7 #
8
9 use strict;
10
11 my @target;
12 my $target;
13 my $profile;
14
15 while (<>) {
16 chomp;
17 /^Target:\s*((.+)-(\d+\.\d+))\s*$/ and do {
18 $target = {
19 id => $1,
20 board => $2,
21 kernel => $3,
22 profiles => []
23 };
24 push @target, $target;
25 };
26 /^Target-Name:\s*(.+)\s*$/ and $target->{name} = $1;
27 /^Target-Path:\s*(.+)\s*$/ and $target->{path} = $1;
28 /^Target-Arch:\s*(.+)\s*$/ and $target->{arch} = $1;
29 /^Target-Features:\s*(.+)\s*$/ and $target->{features} = [ split(/\s+/, $1) ];
30 /^Target-Description:/ and do {
31 my $desc;
32 while (<>) {
33 last if /^@@/;
34 $desc .= $_;
35 }
36 $target->{desc} = $desc;
37 };
38 /^Linux-Version:\s*(.+)\s*$/ and $target->{version} = $1;
39 /^Linux-Release:\s*(.+)\s*$/ and $target->{release} = $1;
40 /^Linux-Kernel-Arch:\s*(.+)\s*$/ and $target->{karch} = $1;
41 /^Default-Packages:\s*(.+)\s*$/ and $target->{packages} = [ split(/\s+/, $1) ];
42 /^Target-Profile:\s*(.+)\s*$/ and do {
43 $profile = {
44 id => $1,
45 name => $1,
46 packages => []
47 };
48 push @{$target->{profiles}}, $profile;
49 };
50 /^Target-Profile-Name:\s*(.+)\s*$/ and $profile->{name} = $1;
51 /^Target-Profile-Packages:\s*(.*)\s*$/ and $profile->{packages} = [ split(/\s+/, $1) ];
52 }
53
54 @target = sort {
55 $a->{id} cmp $b->{id}
56 } @target;
57
58 foreach $target (@target) {
59 my ($profiles_def, $profiles_eval);
60 my $conf = uc $target->{kernel}.'_'.$target->{board};
61 $conf =~ tr/\.-/__/;
62
63 foreach my $profile (@{$target->{profiles}}) {
64 $profiles_def .= "
65 define Profile/$conf\_$profile->{id}
66 ID:=$profile->{id}
67 NAME:=$profile->{name}
68 PACKAGES:=".join(" ", @{$profile->{packages}})."
69 endef";
70 $profiles_eval .= "
71 \$(eval \$(call Profile,$conf\_$profile->{id}))"
72 }
73 print <<EOF
74 ifeq (\$(CONFIG_LINUX_$conf),y)
75 define Target
76 KERNEL:=$target->{kernel}
77 BOARD:=$target->{board}
78 LINUX_VERSION:=$target->{version}
79 LINUX_RELEASE:=$target->{release}
80 LINUX_KARCH:=$target->{karch}
81 endef$profiles_def
82 endif$profiles_eval
83
84 EOF
85 }
86 print "\$(eval \$(call Target))\n";
This page took 0.058637 seconds and 5 git commands to generate.