blob: e7ba3e20f27f81bf78a944fc85b6bc7607b468c3 [file] [log] [blame]
Jonathan Gordon4c385e62010-09-28 13:44:56 +00001#!/usr/bin/perl
2# __________ __ ___.
3# Open \______ \ ____ ____ | | _\_ |__ _______ ___
4# Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5# Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6# Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7# \/ \/ \/ \/ \/
8# $Id$
9#
10
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.
19
20# This script must be placed in the same directory as configure and builds.pm
21#
22
23use File::Basename;
24my $srcdir = dirname $0;
25require "$srcdir/builds.pm";
26
27my $builddir = `pwd`;
28my @dirs = split(/\//, $builddir);
29
30my $test = pop(@dirs);
31
32sub doconfigure {
Thomas Martitz0d5883d2013-03-16 22:30:46 +010033 my ($target, $type, $width, $height) = @_;
Jonathan Gordon4c385e62010-09-28 13:44:56 +000034 if (!exists($builds{$target})) {
35 for $key (keys(%builds)) {
36 if ($key =~ $target) {
37 $target = $key;
38 last;
39 }
40 }
41 }
42 $command = "${srcdir}/configure --type=${type} --target=${target}";
Thomas Martitz0d5883d2013-03-16 22:30:46 +010043 if (defined $width) {
44 $command .= " --lcdwidth=${width}";
45 }
46 if (defined $height) {
47 $command .= " --lcdheight=${height}";
48 }
Jonathan Gordon4c385e62010-09-28 13:44:56 +000049 %typenames = ("n" => "Normal", "s" => "Simulator", "b" => "Bootloader" );
Thomas Martitzeb027782012-05-28 11:32:10 +020050 unless (@ARGV[0] eq "-y") {
Thomas Martitz0d5883d2013-03-16 22:30:46 +010051 $prompt = "Rockbox autoconf: \n\tTarget: $target \n\tType: $typenames{$type} \n";
52 if (defined $width) {
53 $prompt .= "\tLCD width: $width\n";
54 }
55 if (defined $height) {
56 $prompt .= "\tLCD height: $height\n";
57 }
58 print $prompt . "Correct? [Y/n] ";
59
Thomas Martitzeb027782012-05-28 11:32:10 +020060 chomp($response = <>);
61 if ($response eq "") {
62 $response = "y";
63 }
64 if ($response ne "y" && $response ne "Y") {
65 print "autoconf: Aborting\n";
66 exit(0);
67 }
68 }
Jonathan Gordon4c385e62010-09-28 13:44:56 +000069 system($command);
70}
71
72sub buildtype {
73 my ($text) = @_;
74 if ($text eq "sim") {
75 $build = "s";
76 } elsif ($text eq "boot") {
77 $build = "b";
Thomas Martitzeb027782012-05-28 11:32:10 +020078 } elsif ($text eq "build") {
Jonathan Gordon4c385e62010-09-28 13:44:56 +000079 $build = "n";
Thomas Martitzeb027782012-05-28 11:32:10 +020080 } else {
81 $build = "";
82 }
Jonathan Gordon4c385e62010-09-28 13:44:56 +000083 return $build;
84}
85
Thomas Martitz0d5883d2013-03-16 22:30:46 +010086if ($test =~ /(.*)-(.*)-([0-9]+)x([0-9]+)/)
87{
88 if (buildtype($2)) {
89 doconfigure($1, buildtype($2), $3, $4);
90 } elsif (buildtype($1)) {
91 doconfigure($2, buildtype($1), $3, $4);
92 }
93}
94elsif ($test =~ /(.*)-(.*)/)
Jonathan Gordon4c385e62010-09-28 13:44:56 +000095{
Thomas Martitzeb027782012-05-28 11:32:10 +020096 if (buildtype($2)) {
97 doconfigure($1, buildtype($2));
98 } elsif (buildtype($1)) {
99 doconfigure($2, buildtype($1));
100 }
101}
Jonathan Gordon4c385e62010-09-28 13:44:56 +0000102elsif ($test =~ /(.*)/)
103{
104 $target = $1;
105 $build = buildtype(pop(@dirs));
106 doconfigure($target, $build);
107}