/******************************************************************* * parse_spec_flags * * Parse the optional flags for an entry point in a .spec file. */ static const char *parse_spec_flags( DLLSPEC *spec, ORDDEF *odp ) { unsigned int i; const char *token; do { if (!(token = GetToken(0))) break; if (!strncmp( token, "arch=", 5)) { char *args = xstrdup( token + 5 ); char *cpu_name = strtok( args, "," ); while (cpu_name) { if (!strcmp( cpu_name, "win32" )) { if (spec->type == SPEC_WIN32) odp->flags |= FLAG_CPU_WIN32; else odp->flags |= FLAG_EXPORT32; } else if (!strcmp( cpu_name, "win64" )) odp->flags |= FLAG_CPU_WIN64; else { enum target_cpu cpu = get_cpu_from_name( cpu_name ); if (cpu == -1) { error( "Unknown architecture '%s'\n", cpu_name ); return NULL; } odp->flags |= FLAG_CPU( cpu ); } cpu_name = strtok( NULL, "," ); } free( args ); } else if (!strcmp( token, "i386" )) /* backwards compatibility */ { odp->flags |= FLAG_CPU(CPU_x86); } else { for (i = 0; FlagNames[i]; i++) if (!strcmp( FlagNames[i], token )) break; if (!FlagNames[i]) { error( "Unknown flag '%s'\n", token ); return NULL; } odp->flags |= 1 << i; } token = GetToken(0); } while (token && *token == '-'); return token; }
/* set the target CPU and platform */ static void set_target( const char *target ) { unsigned int i; char *p, *platform, *spec = xstrdup( target ); /* target specification is in the form CPU-MANUFACTURER-OS or CPU-MANUFACTURER-KERNEL-OS */ target_alias = xstrdup( target ); /* get the CPU part */ if ((p = strchr( spec, '-' ))) { int cpu; *p++ = 0; cpu = get_cpu_from_name( spec ); if (cpu == -1) fatal_error( "Unrecognized CPU '%s'\n", spec ); target_cpu = cpu; platform = p; if ((p = strrchr( p, '-' ))) platform = p + 1; } else if (!strcmp( spec, "mingw32" )) { target_cpu = CPU_x86; platform = spec; } else fatal_error( "Invalid target specification '%s'\n", target ); /* get the OS part */ target_platform = PLATFORM_UNSPECIFIED; /* default value */ for (i = 0; i < sizeof(platform_names)/sizeof(platform_names[0]); i++) { if (!strncmp( platform_names[i].name, platform, strlen(platform_names[i].name) )) { target_platform = platform_names[i].platform; break; } } free( spec ); }