Jonathan Gordon | 4c385e6 | 2010-09-28 13:44:56 +0000 | [diff] [blame] | 1 | #!/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 | |
| 23 | use File::Basename; |
| 24 | my $srcdir = dirname $0; |
| 25 | require "$srcdir/builds.pm"; |
| 26 | |
| 27 | my $builddir = `pwd`; |
| 28 | my @dirs = split(/\//, $builddir); |
| 29 | |
| 30 | my $test = pop(@dirs); |
| 31 | |
| 32 | sub doconfigure { |
Thomas Martitz | 0d5883d | 2013-03-16 22:30:46 +0100 | [diff] [blame] | 33 | my ($target, $type, $width, $height) = @_; |
Jonathan Gordon | 4c385e6 | 2010-09-28 13:44:56 +0000 | [diff] [blame] | 34 | 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 Martitz | 0d5883d | 2013-03-16 22:30:46 +0100 | [diff] [blame] | 43 | if (defined $width) { |
| 44 | $command .= " --lcdwidth=${width}"; |
| 45 | } |
| 46 | if (defined $height) { |
| 47 | $command .= " --lcdheight=${height}"; |
| 48 | } |
Jonathan Gordon | 4c385e6 | 2010-09-28 13:44:56 +0000 | [diff] [blame] | 49 | %typenames = ("n" => "Normal", "s" => "Simulator", "b" => "Bootloader" ); |
Thomas Martitz | eb02778 | 2012-05-28 11:32:10 +0200 | [diff] [blame] | 50 | unless (@ARGV[0] eq "-y") { |
Thomas Martitz | 0d5883d | 2013-03-16 22:30:46 +0100 | [diff] [blame] | 51 | $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 Martitz | eb02778 | 2012-05-28 11:32:10 +0200 | [diff] [blame] | 60 | 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 Gordon | 4c385e6 | 2010-09-28 13:44:56 +0000 | [diff] [blame] | 69 | system($command); |
| 70 | } |
| 71 | |
| 72 | sub buildtype { |
| 73 | my ($text) = @_; |
| 74 | if ($text eq "sim") { |
| 75 | $build = "s"; |
| 76 | } elsif ($text eq "boot") { |
| 77 | $build = "b"; |
Thomas Martitz | eb02778 | 2012-05-28 11:32:10 +0200 | [diff] [blame] | 78 | } elsif ($text eq "build") { |
Jonathan Gordon | 4c385e6 | 2010-09-28 13:44:56 +0000 | [diff] [blame] | 79 | $build = "n"; |
Thomas Martitz | eb02778 | 2012-05-28 11:32:10 +0200 | [diff] [blame] | 80 | } else { |
| 81 | $build = ""; |
| 82 | } |
Jonathan Gordon | 4c385e6 | 2010-09-28 13:44:56 +0000 | [diff] [blame] | 83 | return $build; |
| 84 | } |
| 85 | |
Thomas Martitz | 0d5883d | 2013-03-16 22:30:46 +0100 | [diff] [blame] | 86 | if ($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 | } |
| 94 | elsif ($test =~ /(.*)-(.*)/) |
Jonathan Gordon | 4c385e6 | 2010-09-28 13:44:56 +0000 | [diff] [blame] | 95 | { |
Thomas Martitz | eb02778 | 2012-05-28 11:32:10 +0200 | [diff] [blame] | 96 | if (buildtype($2)) { |
| 97 | doconfigure($1, buildtype($2)); |
| 98 | } elsif (buildtype($1)) { |
| 99 | doconfigure($2, buildtype($1)); |
| 100 | } |
| 101 | } |
Jonathan Gordon | 4c385e6 | 2010-09-28 13:44:56 +0000 | [diff] [blame] | 102 | elsif ($test =~ /(.*)/) |
| 103 | { |
| 104 | $target = $1; |
| 105 | $build = buildtype(pop(@dirs)); |
| 106 | doconfigure($target, $build); |
| 107 | } |