cross-plat-dev-utils/get_wordsize.pm
author Mike Kinghan <mikek@symbian.org>
Thu, 25 Nov 2010 13:59:07 +0000
changeset 40 68f68128601f
parent 10 b2a53d442fd6
permissions -rwxr-xr-x
1) Add the sbsv1 components from sftools/dev/build to make the linux_build package independent of the obsolete buildtools package. 2) Enhance romnibus.pl so that it generate the symbol file for the built rom when invoked by Raptor 3) Make the maksym.pl tool portable for Linux as well as Windows. 4) Remove the of armasm2as.pl from the e32tools component in favour of the copy now exported from sbsv1/e32util.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
10
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
     1
#!/usr/bin/perl
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
     2
# Copyright (c) 2010 Symbian Foundation Ltd
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
     3
# This component and the accompanying materials are made available
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
     4
# under the terms of the License "Eclipse Public License v1.0"
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
     5
# which accompanies this distribution, and is available
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
     6
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
     7
#
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
     8
# Initial Contributors:
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
     9
# Mike Kinghan, mikek@symbian.org, for Symbian Foundation Ltd - initial contribution.
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    10
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    11
# Subroutine to get the wordsize in bits of the host machine.
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    12
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    13
use strict;
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    14
use File::Path;
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    15
use File::Spec;
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    16
use check_os;
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    17
use places;
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    18
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    19
sub get_host_wordsize()
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    20
{
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    21
	if (os_is_windows()) {
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    22
		print ">>> Only 32bit Windows supported\n";
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    23
		return 32;
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    24
	} 
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    25
	my $source = "get_wordsize.c";
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    26
	unless(-f "$source") {
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    27
		die "*** Error: $source not found ***";
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    28
	}
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    29
	my $compile_cmd = "gcc -o get_wordsize $source";
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    30
	print ">>> Excuting: $compile_cmd\n";
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    31
	system($compile_cmd) >> 8 and die "*** Error: Could not compile $source ***";
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    32
	my $get_wordsize = "\.\/get_wordsize";
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    33
	print ">>> Excuting: $get_wordsize\n";
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    34
	my $wordsize = `$get_wordsize`;
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    35
	chomp $wordsize;
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    36
	die "$!", if ($? >> 8);
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    37
	$wordsize *= 8;
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    38
	print ">>> Host system wordsize is $wordsize bits\n";
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    39
	unlink("get_wordsize") or die $!;
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    40
	return $wordsize;
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    41
}
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    42
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    43
1;
b2a53d442fd6 1) Introducing support for 32/64-bit variants of the patch files
mikek
parents:
diff changeset
    44