fix rt61 build on 2.4
[openwrt/staging/mkresin.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
14 while (<>) {
15 chomp;
16 /^Target:\s*((.+)-(\d+\.\d+))\s*$/ and do {
17 $target = {
18 id => $1,
19 board => $2,
20 kernel => $3
21 };
22 push @target, $target;
23 };
24 /^Target-Name:\s*(.+)\s*$/ and $target->{name} = $1;
25 /^Target-Path:\s*(.+)\s*$/ and $target->{path} = $1;
26 /^Target-Arch:\s*(.+)\s*$/ and $target->{arch} = $1;
27 /^Target-Features:\s*(.+)\s*$/ and do {
28 my $f = [];
29 $target->{features} = $f;
30 @$f = split /\s+/, $1;
31 };
32 /^Target-Description:/ and do {
33 my $desc;
34 while (<>) {
35 last if /^@@/;
36 $desc .= $_;
37 }
38 $target->{desc} = $desc;
39 };
40 /^Linux-Version:\s*(.+)\s*$/ and $target->{version} = $1;
41 /^Linux-Release:\s*(.+)\s*$/ and $target->{release} = $1;
42 /^Linux-Kernel-Arch:\s*(.+)\s*$/ and $target->{karch} = $1;
43 }
44
45 @target = sort {
46 $a->{id} cmp $b->{id}
47 } @target;
48
49 foreach $target (@target) {
50 my $conf = uc $target->{kernel}.'_'.$target->{board};
51 $conf =~ tr/\.-/__/;
52 print <<EOF
53 ifeq (\$(CONFIG_LINUX_$conf),y)
54 define Target
55 KERNEL:=$target->{kernel}
56 BOARD:=$target->{board}
57 LINUX_VERSION:=$target->{version}
58 LINUX_RELEASE:=$target->{release}
59 LINUX_KARCH:=$target->{karch}
60 endef
61 endif
62
63 EOF
64 }
65 print "\$(eval \$(call Target))\n";