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, ...) ...@@ -41,7 +41,7 @@ void error(const char* s, ...)
va_list ap; va_list ap;
va_start(ap, s); va_start(ap, s);
fprintf(stderr, "Error: "); fprintf(stderr, "winegcc: ");
vfprintf(stderr, s, ap); vfprintf(stderr, s, ap);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
va_end(ap); va_end(ap);
...@@ -273,7 +273,7 @@ file_type get_lib_type(strarray* path, const char* library, char** file) ...@@ -273,7 +273,7 @@ file_type get_lib_type(strarray* path, const char* library, char** file)
return file_na; return file_na;
} }
void spawn(const char* prefix, const strarray* args) void spawn(const strarray* prefix, const strarray* args)
{ {
int i, status; int i, status;
strarray* arr = strarray_dup(args); strarray* arr = strarray_dup(args);
...@@ -285,15 +285,22 @@ void spawn(const char* prefix, const strarray* args) ...@@ -285,15 +285,22 @@ void spawn(const char* prefix, const strarray* args)
if (prefix) if (prefix)
{ {
for (i = 0; i < prefix->size; i++)
{
const char* p; const char* p;
struct stat st; struct stat st;
if (!(p = strrchr(argv[0], '/'))) p = argv[0]; if (!(p = strrchr(argv[0], '/'))) p = argv[0];
prog = strmake("%s/%s", prefix, p); free( prog );
prog = strmake("%s/%s", prefix->base[i], p);
if (stat(prog, &st) == 0) if (stat(prog, &st) == 0)
{ {
if ((st.st_mode & S_IFREG) && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) if ((st.st_mode & S_IFREG) && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
{
argv[0] = prog; argv[0] = prog;
break;
}
}
} }
} }
...@@ -306,7 +313,7 @@ void spawn(const char* prefix, const strarray* args) ...@@ -306,7 +313,7 @@ void spawn(const char* prefix, const strarray* args)
if ((status = spawnvp( _P_WAIT, argv[0], argv))) if ((status = spawnvp( _P_WAIT, argv[0], argv)))
{ {
if (status > 0) error("%s failed.", argv[0]); if (status > 0) error("%s failed.", argv[0]);
else perror("Error:"); else perror("winegcc");
exit(3); exit(3);
} }
......
...@@ -62,6 +62,6 @@ char* get_basename(const char* file); ...@@ -62,6 +62,6 @@ char* get_basename(const char* file);
void create_file(const char* name, int mode, const char* fmt, ...); void create_file(const char* name, int mode, const char* fmt, ...);
file_type get_file_type(const char* filename); file_type get_file_type(const char* filename);
file_type get_lib_type(strarray* path, const char* library, char** file); 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; extern int verbose;
...@@ -161,8 +161,8 @@ struct options ...@@ -161,8 +161,8 @@ struct options
int gui_app; int gui_app;
int compile_only; int compile_only;
int wine_mode; int wine_mode;
const char* prefix;
const char* output_name; const char* output_name;
strarray* prefix;
strarray* lib_dirs; strarray* lib_dirs;
strarray* linker_args; strarray* linker_args;
strarray* compiler_args; strarray* compiler_args;
...@@ -342,7 +342,7 @@ static const char* compile_to_object(struct options* opts, const char* file) ...@@ -342,7 +342,7 @@ static const char* compile_to_object(struct options* opts, const char* file)
static void build(struct options* opts) 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 *lib_dirs, *files;
strarray *spec_args, *comp_args, *link_args; strarray *spec_args, *comp_args, *link_args;
char *spec_c_name, *spec_o_name, *base_file, *base_name; char *spec_c_name, *spec_o_name, *base_file, *base_name;
...@@ -433,7 +433,9 @@ static void build(struct options* opts) ...@@ -433,7 +433,9 @@ static void build(struct options* opts)
strarray_add(files, strmake("-s%s", file + 2)); strarray_add(files, strmake("-s%s", file + 2));
break; break;
default: 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); free(fullname);
} }
...@@ -527,6 +529,7 @@ static void build(struct options* opts) ...@@ -527,6 +529,7 @@ static void build(struct options* opts)
const char* name = files->base[j] + 2; const char* name = files->base[j] + 2;
switch(files->base[j][1]) switch(files->base[j][1])
{ {
case 'l':
case 's': case 's':
strarray_add(link_args, strmake("-l%s", name)); strarray_add(link_args, strmake("-l%s", name));
break; break;
...@@ -720,28 +723,20 @@ int main(int argc, char **argv) ...@@ -720,28 +723,20 @@ int main(int argc, char **argv)
if (argv[i][1] == 'o') if (argv[i][1] == 'o')
raw_compiler_arg = raw_linker_arg = 0; 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 */ /* do a bit of semantic analysis */
switch (argv[i][1]) switch (argv[i][1])
{ {
case 'B': case 'B':
str = strdup(option_arg); 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; if (strendswith(str, "/")) str[strlen(str) - 1] = 0;
opts.prefix = str; if (!opts.prefix) opts.prefix = strarray_alloc();
strarray_add(opts.prefix, str);
break; break;
case 'c': /* compile or assemble */ case 'c': /* compile or assemble */
if (argv[i][2] == 0) opts.compile_only = 1; if (argv[i][2] == 0) opts.compile_only = 1;
...@@ -810,6 +805,20 @@ int main(int argc, char **argv) ...@@ -810,6 +805,20 @@ int main(int argc, char **argv)
break; 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 */ /* skip the next token if it's an argument */
if (next_is_arg) i++; 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