sbsv1_os/e32toolp/e32util/checkgcc.pm
changeset 0 83f4b4db085c
child 1 d4b442d23379
equal deleted inserted replaced
-1:000000000000 0:83f4b4db085c
       
     1 # Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 # All rights reserved.
       
     3 # This component and the accompanying materials are made available
       
     4 # under the terms of "Eclipse Public License v1.0"
       
     5 # which accompanies this distribution, and is available
       
     6 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 #
       
     8 # Initial Contributors:
       
     9 # Nokia Corporation - initial contribution.
       
    10 #
       
    11 # Contributors:
       
    12 #
       
    13 # Description:
       
    14 # module for checking gcc is set up correctly
       
    15 # 
       
    16 #
       
    17 
       
    18 package CheckGcc;
       
    19 
       
    20 use strict;
       
    21 use Preprocessor;
       
    22 
       
    23 
       
    24 sub CheckGcc_Default()
       
    25 {
       
    26  	# die if CPP.EXE (or whatever) in a dodgy place in the path
       
    27 	my $pbp = $ENV{PBUILDPID};
       
    28 	my @Paths=split ';', $ENV{Path};
       
    29 	unshift @Paths,'.';	# add the current directory
       
    30 	foreach (@Paths) {
       
    31 		s-/-\\-go;	# for those working with UNIX shells
       
    32 		s-^(.*[^\\])$-$1\\-o;   # ensure path ends with a backslash
       
    33 		if ((-e $_.'CPP.EXE') or (-e $_.'CPP.BAT') or (-e $_.'CPP.CMD')) {
       
    34 			unless (/\\GCC(\w\w)?\\BIN\\$/i) {
       
    35 				unless (lc($1) eq lc($pbp)) {
       
    36 					die
       
    37 						"ERROR: First CPP executable found in path is in $_,\n",
       
    38 						"but the required CPP.EXE was expected to be found in a directory\n",
       
    39 						"with a name ending in \\GCC$pbp\\BIN\\, where the Cygnus tools\n",
       
    40 						"this program depends upon are stored.\n",
       
    41 						"Is your path set up correctly?\n"
       
    42 					;
       
    43 				}
       
    44 			}
       
    45 			return;
       
    46 		}
       
    47 	}
       
    48 	die "ERROR: CPP executable not found in path\n";
       
    49 }
       
    50 
       
    51 sub CheckGcc_Generic()
       
    52 {
       
    53 	# die if CPP.EXE (or whatever pre processor) in a dodgy place in the path
       
    54 
       
    55 	my @Paths=split ';', $ENV{Path};
       
    56 	unshift @Paths,'.';	# add the current directory
       
    57 
       
    58 	my $exe = &PreprocessorToUseExe();
       
    59 	my $path = &PreprocessorToUsePath();
       
    60 	
       
    61 	foreach (@Paths) {
       
    62 		s-/-\\-go;	# for those working with UNIX shells
       
    63 		s-^(.*[^\\])$-$1\\-o;   # ensure path ends with a backslash
       
    64 		s-$-$path-;	# add in the path relative to gcc\bin.
       
    65 		if ((-e $_.$exe.'.EXE') or (-e $_.$exe.'.BAT') or (-e $_.$exe.'.CMD')) {
       
    66 			unless (/\\EPOC32\\TOOLS\\\Q$path\E$/i) {
       
    67 				die
       
    68 					"ERROR: First $exe executable found in path is in $_,\n",
       
    69 					"but the required $exe.EXE was expected to be found in a directory\n",
       
    70 					"with a name ending in \\EPOC32\\TOOLS\\$path, where the tools\n",
       
    71 					"this program depends upon are stored.\n",
       
    72 					"Is your path set up correctly?\n"
       
    73 				;
       
    74 			}
       
    75 			return;
       
    76 		}
       
    77 	}
       
    78 	die "ERROR: $exe executable not found in path\n";
       
    79 
       
    80 }
       
    81 BEGIN {
       
    82 	my $preprocessor_to_use = &PreprocessorToUseId();
       
    83 	
       
    84 	if ( $preprocessor_to_use eq "DEFAULT" )
       
    85 	{
       
    86 		&CheckGcc_Default();	# pre processor & cpp same. 
       
    87 	}
       
    88 	elsif ( $preprocessor_to_use eq "MINGW_NO_CYGWIN" )
       
    89 	{
       
    90 		&CheckGcc_Generic();	# check for preprocessor.
       
    91 	}
       
    92 	else
       
    93 	{
       
    94 		die("CHECKGCC.PM :  error should never happen\n");
       
    95 	}
       
    96 }
       
    97 
       
    98 
       
    99 1;
       
   100