* lib/Parrot/Pmc2c/MethodEmitter.pm:
[parrot.git] / config / auto / arch.pm
blobce139b4e8273db02b85a1d4a947c31a85da8d2a6
1 # Copyright (C) 2001-2007, The Perl Foundation.
2 # $Id$
4 =head1 NAME
6 config/auto/arch - Determine CPU architecture and operating system
8 =head1 DESCRIPTION
10 Determines the CPU architecture, the operating system.
12 This code was formerly part of configuration step class auto::jit.
14 =cut
16 package auto::arch;
18 use strict;
19 use warnings;
22 use base qw(Parrot::Configure::Step);
24 sub _init {
25 my $self = shift;
26 my %data;
27 $data{description} = q{Determining CPU architecture and OS};
28 $data{result} = q{};
29 return \%data;
32 sub runstep {
33 my ( $self, $conf ) = @_;
35 if ( $conf->options->get('miniparrot') ) {
36 $self->set_result('skipped');
37 return 1;
40 my $verbose = $conf->options->get('verbose');
41 $verbose and print "\n";
43 my $archname = $conf->data->get('archname');
44 my ( $cpuarch, $osname ) = split( /-/, $archname );
46 if ($verbose) {
47 print "determining operating system and cpu architecture\n";
48 print "archname: <$archname>\n";
51 if ( !defined $osname ) {
52 ( $osname, $cpuarch ) = ( $cpuarch, q{} );
55 # This was added to convert 9000/800 to 9000_800 on HP-UX
56 $cpuarch =~ s|/|_|g;
58 # On OS X if you are using the Perl that shipped with the system
59 # the above split fails because archname is "darwin-thread-multi-2level".
60 if ( $cpuarch =~ /darwin/ ) {
61 $osname = 'darwin';
62 if ( $conf->data->get('byteorder') == 1234 ) {
63 $cpuarch = 'i386';
65 else {
66 $cpuarch = 'ppc';
70 # cpuarch and osname are reversed in archname on windows
71 elsif ( $cpuarch =~ /MSWin32/ ) {
72 $cpuarch = ( $osname =~ /x64/ ) ? 'amd64' : 'i386';
73 $osname = 'MSWin32';
75 elsif ( $osname =~ /cygwin/i || $cpuarch =~ /cygwin/i ) {
76 $cpuarch = 'i386';
77 $osname = 'cygwin';
80 if ( $archname =~ m/powerpc/ ) {
81 $cpuarch = 'ppc';
84 $cpuarch =~ s/armv[34]l?/arm/i;
85 $cpuarch =~ s/i[456]86/i386/i;
86 $cpuarch =~ s/x86_64/amd64/i;
88 print "osname: $osname\ncpuarch: $cpuarch\n" if $verbose;
90 $conf->data->set(
91 cpuarch => $cpuarch,
92 osname => $osname
95 return 1;
100 # Local Variables:
101 # mode: cperl
102 # cperl-indent-level: 4
103 # fill-column: 100
104 # End:
105 # vim: expandtab shiftwidth=4: