sbsv1/abld/e32util/checkgcc.pm
changeset 599 fa7a3cc6effd
equal deleted inserted replaced
596:9f25be3da657 599:fa7a3cc6effd
       
     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 Preprocessor;
       
    21 
       
    22 
       
    23 sub CheckGcc_Default()
       
    24 {
       
    25  	# die if CPP.EXE (or whatever) in a dodgy place in the path
       
    26 	my $pbp = $ENV{PBUILDPID};
       
    27 	my @Paths=split ';', $ENV{Path};
       
    28 	unshift @Paths,'.';	# add the current directory
       
    29 	foreach (@Paths) {
       
    30 		s-/-\\-go;	# for those working with UNIX shells
       
    31 		s-^(.*[^\\])$-$1\\-o;   # ensure path ends with a backslash
       
    32 		if ((-e $_.'CPP.EXE') or (-e $_.'CPP.BAT') or (-e $_.'CPP.CMD')) {
       
    33 			unless (/\\GCC(\w\w)?\\BIN\\$/i) {
       
    34 				unless (lc($1) eq lc($pbp)) {
       
    35 					die
       
    36 						"ERROR: First CPP executable found in path is in $_,\n",
       
    37 						"but the required CPP.EXE was expected to be found in a directory\n",
       
    38 						"with a name ending in \\GCC$pbp\\BIN\\, where the Cygnus tools\n",
       
    39 						"this program depends upon are stored.\n",
       
    40 						"Is your path set up correctly?\n"
       
    41 					;
       
    42 				}
       
    43 			}
       
    44 			return;
       
    45 		}
       
    46 	}
       
    47 	die "ERROR: CPP executable not found in path\n";
       
    48 }
       
    49 
       
    50 sub CheckGcc_Generic()
       
    51 {
       
    52 	# die if CPP.EXE (or whatever pre processor) in a dodgy place in the path
       
    53 
       
    54 	my @Paths=split ';', $ENV{Path};
       
    55 	unshift @Paths,'.';	# add the current directory
       
    56 
       
    57 	my $exe = &PreprocessorToUseExe();
       
    58 	my $path = &PreprocessorToUsePath();
       
    59 	
       
    60 	foreach (@Paths) {
       
    61 		s-/-\\-go;	# for those working with UNIX shells
       
    62 		s-^(.*[^\\])$-$1\\-o;   # ensure path ends with a backslash
       
    63 		s-$-$path-;	# add in the path relative to gcc\bin.
       
    64 		if ((-e $_.$exe.'.EXE') or (-e $_.$exe.'.BAT') or (-e $_.$exe.'.CMD')) {
       
    65 			unless (/\\EPOC32\\TOOLS\\\Q$path\E$/i) {
       
    66 				die
       
    67 					"ERROR: First $exe executable found in path is in $_,\n",
       
    68 					"but the required $exe.EXE was expected to be found in a directory\n",
       
    69 					"with a name ending in \\EPOC32\\TOOLS\\$path, where the tools\n",
       
    70 					"this program depends upon are stored.\n",
       
    71 					"Is your path set up correctly?\n"
       
    72 				;
       
    73 			}
       
    74 			return;
       
    75 		}
       
    76 	}
       
    77 	die "ERROR: $exe executable not found in path\n";
       
    78 
       
    79 }
       
    80 BEGIN {
       
    81 	my $preprocessor_to_use = &PreprocessorToUseId();
       
    82 	
       
    83 	if ( $preprocessor_to_use eq "DEFAULT" )
       
    84 	{
       
    85 		&CheckGcc_Default();	# pre processor & cpp same. 
       
    86 	}
       
    87 	elsif ( $preprocessor_to_use eq "MINGW_NO_CYGWIN" )
       
    88 	{
       
    89 		&CheckGcc_Generic();	# check for preprocessor.
       
    90 	}
       
    91 	else
       
    92 	{
       
    93 		die("CHECKGCC.PM :  error should never happen\n");
       
    94 	}
       
    95 }
       
    96 
       
    97 
       
    98 1;
       
    99