Commit 2d52cfa9 authored by Alexandre Julliard's avatar Alexandre Julliard

Allow multiple -B options.

Do not pass the -Btools/winebuild magic option to the compiler to avoid warnings. Pass to the linker even the libraries we didn't find in the lib search path, in case we are not using the standard paths.
parent ac1bd4d1
......@@ -41,7 +41,7 @@ void error(const char* s, ...)
va_list ap;
va_start(ap, s);
fprintf(stderr, "Error: ");
fprintf(stderr, "winegcc: ");
vfprintf(stderr, s, ap);
fprintf(stderr, "\n");
va_end(ap);
......@@ -273,7 +273,7 @@ file_type get_lib_type(strarray* path, const char* library, char** file)
return file_na;
}
void spawn(const char* prefix, const strarray* args)
void spawn(const strarray* prefix, const strarray* args)
{
int i, status;
strarray* arr = strarray_dup(args);
......@@ -285,16 +285,23 @@ void spawn(const char* prefix, const strarray* args)
if (prefix)
{
const char* p;
struct stat st;
if (!(p = strrchr(argv[0], '/'))) p = argv[0];
prog = strmake("%s/%s", prefix, p);
if (stat(prog, &st) == 0)
{
if ((st.st_mode & S_IFREG) && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
argv[0] = prog;
}
for (i = 0; i < prefix->size; i++)
{
const char* p;
struct stat st;
if (!(p = strrchr(argv[0], '/'))) p = argv[0];
free( prog );
prog = strmake("%s/%s", prefix->base[i], p);
if (stat(prog, &st) == 0)
{
if ((st.st_mode & S_IFREG) && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
{
argv[0] = prog;
break;
}
}
}
}
if (verbose)
......@@ -306,7 +313,7 @@ void spawn(const char* prefix, const strarray* args)
if ((status = spawnvp( _P_WAIT, argv[0], argv)))
{
if (status > 0) error("%s failed.", argv[0]);
else perror("Error:");
else perror("winegcc");
exit(3);
}
......
......@@ -62,6 +62,6 @@ char* get_basename(const char* file);
void create_file(const char* name, int mode, const char* fmt, ...);
file_type get_file_type(const char* filename);
file_type get_lib_type(strarray* path, const char* library, char** file);
void spawn(const char* prefix, const strarray* arr);
void spawn(const strarray* prefix, const strarray* arr);
extern int verbose;
......@@ -161,8 +161,8 @@ struct options
int gui_app;
int compile_only;
int wine_mode;
const char* prefix;
const char* output_name;
strarray* prefix;
strarray* lib_dirs;
strarray* linker_args;
strarray* compiler_args;
......@@ -342,7 +342,7 @@ static const char* compile_to_object(struct options* opts, const char* file)
static void build(struct options* opts)
{
static const char *stdlibpath[] = { DLLDIR, LIBDIR, "/usr/lib", "/usr/local/lib" };
static const char *stdlibpath[] = { DLLDIR, LIBDIR, "/usr/lib", "/usr/local/lib", "/lib" };
strarray *lib_dirs, *files;
strarray *spec_args, *comp_args, *link_args;
char *spec_c_name, *spec_o_name, *base_file, *base_name;
......@@ -433,7 +433,9 @@ static void build(struct options* opts)
strarray_add(files, strmake("-s%s", file + 2));
break;
default:
fprintf(stderr, "Can't find library '%s', ignoring\n", file);
/* keep it anyway, the linker may know what to do with it */
strarray_add(files, file);
break;
}
free(fullname);
}
......@@ -527,6 +529,7 @@ static void build(struct options* opts)
const char* name = files->base[j] + 2;
switch(files->base[j][1])
{
case 'l':
case 's':
strarray_add(link_args, strmake("-l%s", name));
break;
......@@ -720,28 +723,20 @@ int main(int argc, char **argv)
if (argv[i][1] == 'o')
raw_compiler_arg = raw_linker_arg = 0;
/* put the arg into the appropriate bucket */
if (raw_linker_arg)
{
strarray_add(opts.linker_args, argv[i]);
if (next_is_arg && (i + 1 < argc))
strarray_add(opts.linker_args, argv[i + 1]);
}
if (raw_compiler_arg)
{
strarray_add(opts.compiler_args, argv[i]);
if (next_is_arg && (i + 1 < argc))
strarray_add(opts.compiler_args, argv[i + 1]);
}
/* do a bit of semantic analysis */
switch (argv[i][1])
{
case 'B':
str = strdup(option_arg);
if (strendswith(str, "/tools/winebuild")) opts.wine_mode = 1;
if (strendswith(str, "/tools/winebuild"))
{
opts.wine_mode = 1;
/* don't pass it to the compiler, this generates warnings */
raw_compiler_arg = raw_linker_arg = 0;
}
if (strendswith(str, "/")) str[strlen(str) - 1] = 0;
opts.prefix = str;
if (!opts.prefix) opts.prefix = strarray_alloc();
strarray_add(opts.prefix, str);
break;
case 'c': /* compile or assemble */
if (argv[i][2] == 0) opts.compile_only = 1;
......@@ -810,6 +805,20 @@ int main(int argc, char **argv)
break;
}
/* put the arg into the appropriate bucket */
if (raw_linker_arg)
{
strarray_add(opts.linker_args, argv[i]);
if (next_is_arg && (i + 1 < argc))
strarray_add(opts.linker_args, argv[i + 1]);
}
if (raw_compiler_arg)
{
strarray_add(opts.compiler_args, argv[i]);
if (next_is_arg && (i + 1 < argc))
strarray_add(opts.compiler_args, argv[i + 1]);
}
/* skip the next token if it's an argument */
if (next_is_arg) i++;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment