winegcc: Correctly manage the -V option (gcc expects to be among the first ones, with -b).

This commit is contained in:
Eric Pouech 2011-03-15 21:17:48 +01:00 committed by Alexandre Julliard
parent acac3cced4
commit 34acd88a2e
1 changed files with 39 additions and 10 deletions

View File

@ -185,6 +185,7 @@ struct options
enum target_cpu target_cpu;
enum target_platform target_platform;
const char *target;
const char *version;
int shared;
int use_msvcrt;
int nostdinc;
@ -283,30 +284,49 @@ static char* get_temp_file(const char* prefix, const char* suffix)
return tmp;
}
static char* build_tool_name(struct options *opts, const char* base, const char* deflt)
{
char* str;
if (opts->target && opts->version)
{
str = strmake("%s-%s-%s", opts->target, base, opts->version);
}
else if (opts->target)
{
str = strmake("%s-%s", opts->target, base);
}
else if (opts->version)
{
str = strmake("%s-%s", base, opts->version);
}
else
str = xstrdup(deflt);
return str;
}
static const strarray* get_translator(struct options *opts)
{
const char *str = NULL;
char *str = NULL;
strarray *ret;
switch(opts->processor)
{
case proc_cpp:
if (opts->target) str = strmake( "%s-cpp", opts->target );
else str = CPP;
str = build_tool_name(opts, "cpp", CPP);
break;
case proc_cc:
case proc_as:
if (opts->target) str = strmake( "%s-gcc", opts->target );
else str = CC;
str = build_tool_name(opts, "gcc", CC);
break;
case proc_cxx:
if (opts->target) str = strmake( "%s-g++", opts->target );
else str = CXX;
str = build_tool_name(opts, "g++", CXX);
break;
default:
assert(0);
}
ret = strarray_fromstring( str, " " );
free(str);
if (opts->force_pointer_size)
strarray_add( ret, strmake("-m%u", 8 * opts->force_pointer_size ));
return ret;
@ -379,6 +399,8 @@ static void compile(struct options* opts, const char* lang)
strarray* comp_args = strarray_alloc();
unsigned int j;
int gcc_defs = 0;
char* gcc;
char* gpp;
strarray_addall(comp_args, get_translator(opts));
switch(opts->processor)
@ -389,12 +411,16 @@ static void compile(struct options* opts, const char* lang)
/* mixing different C and C++ compilers isn't supported in configure anyway */
case proc_cc:
case proc_cxx:
gcc = build_tool_name(opts, "gcc", CC);
gpp = build_tool_name(opts, "g++", CXX);
for ( j = 0; !gcc_defs && j < comp_args->size; j++ )
{
const char *cc = comp_args->base[j];
gcc_defs = strendswith(cc, "gcc") || strendswith(cc, "g++");
gcc_defs = strendswith(cc, gcc) || strendswith(cc, gpp);
}
free(gcc);
free(gpp);
break;
}
@ -1114,7 +1140,7 @@ static int is_linker_arg(const char* arg)
*/
static int is_target_arg(const char* arg)
{
return arg[1] == 'b' || arg[2] == 'V';
return arg[1] == 'b' || arg[1] == 'V';
}
@ -1291,7 +1317,7 @@ int main(int argc, char **argv)
raw_linker_arg = 0;
if (argv[i][1] == 'c' || argv[i][1] == 'L')
raw_compiler_arg = 0;
if (argv[i][1] == 'o' || argv[i][1] == 'b')
if (argv[i][1] == 'o' || argv[i][1] == 'b' || argv[i][1] == 'V')
raw_compiler_arg = raw_linker_arg = 0;
/* do a bit of semantic analysis */
@ -1314,6 +1340,9 @@ int main(int argc, char **argv)
case 'b':
parse_target_option( &opts, option_arg );
break;
case 'V':
opts.version = xstrdup( option_arg );
break;
case 'c': /* compile or assemble */
if (argv[i][2] == 0) opts.compile_only = 1;
/* fall through */