Prepare new maemo release
[maemo-rb.git] / tools / autoconf.pl
blob24efc5aaf3ddb3c6b366818477d646d44d2ecb45
1 #!/usr/bin/perl
2 # __________ __ ___.
3 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 # \/ \/ \/ \/ \/
8 # $Id$
11 # This program attempts to run configure with the correct build target
12 # and type based on the pwd.
13 # example: ~/rockbox/sansae200 is the build dir, it would run configure
14 # for the sansae200 normal build target.
15 # ~/rockbox/sansae200-sim for the e200 sim build (-boot for bootloader)
16 # ~/rockbox/sim/sansae200 for e200 sim build. (replace sim with boot is also possible)
17 # The full shortname is not required, each target name is checked and the first
18 # possible match is used.
20 # This script must be placed in the same directory as configure and builds.pm
23 use File::Basename;
24 my $srcdir = dirname $0;
25 require "$srcdir/builds.pm";
27 my $builddir = `pwd`;
28 my @dirs = split(/\//, $builddir);
30 my $test = pop(@dirs);
32 sub doconfigure {
33 my ($target, $type) = @_;
34 if (!exists($builds{$target})) {
35 for $key (keys(%builds)) {
36 if ($key =~ $target) {
37 $target = $key;
38 last;
42 $command = "${srcdir}/configure --type=${type} --target=${target}";
43 %typenames = ("n" => "Normal", "s" => "Simulator", "b" => "Bootloader" );
44 unless (@ARGV[0] eq "-y") {
45 print "Rockbox autoconf: \n\tTarget: $target \n\tType: $typenames{$type} \nCorrect? [Y/n] ";
46 chomp($response = <>);
47 if ($response eq "") {
48 $response = "y";
50 if ($response ne "y" && $response ne "Y") {
51 print "autoconf: Aborting\n";
52 exit(0);
55 system($command);
58 sub buildtype {
59 my ($text) = @_;
60 if ($text eq "sim") {
61 $build = "s";
62 } elsif ($text eq "boot") {
63 $build = "b";
64 } elsif ($text eq "build") {
65 $build = "n";
66 } else {
67 $build = "";
69 return $build;
72 if ($test =~ /(.*)-(.*)/)
74 if (buildtype($2)) {
75 doconfigure($1, buildtype($2));
76 } elsif (buildtype($1)) {
77 doconfigure($2, buildtype($1));
80 elsif ($test =~ /(.*)/)
82 $target = $1;
83 $build = buildtype(pop(@dirs));
84 doconfigure($target, $build);