Commit 69ef7374 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

winegcc: Link unix libs directly to native libraries.

parent 388c9104
...@@ -271,39 +271,39 @@ static char* try_lib_path(const char* dir, const char* pre, ...@@ -271,39 +271,39 @@ static char* try_lib_path(const char* dir, const char* pre,
} }
static file_type guess_lib_type(enum target_platform platform, const char* dir, static file_type guess_lib_type(enum target_platform platform, const char* dir,
const char* library, const char *suffix, char** file) const char* library, const char *prefix, const char *suffix, char** file)
{ {
if (platform != PLATFORM_WINDOWS && platform != PLATFORM_MINGW && platform != PLATFORM_CYGWIN) if (platform != PLATFORM_WINDOWS && platform != PLATFORM_MINGW && platform != PLATFORM_CYGWIN)
{ {
/* Unix shared object */ /* Unix shared object */
if ((*file = try_lib_path(dir, "lib", library, ".so", file_so))) if ((*file = try_lib_path(dir, prefix, library, ".so", file_so)))
return file_so; return file_so;
/* Mach-O (Darwin/Mac OS X) Dynamic Library behaves mostly like .so */ /* Mach-O (Darwin/Mac OS X) Dynamic Library behaves mostly like .so */
if ((*file = try_lib_path(dir, "lib", library, ".dylib", file_so))) if ((*file = try_lib_path(dir, prefix, library, ".dylib", file_so)))
return file_so; return file_so;
/* Windows DLL */ /* Windows DLL */
if ((*file = try_lib_path(dir, "lib", library, ".def", file_def))) if ((*file = try_lib_path(dir, prefix, library, ".def", file_def)))
return file_dll; return file_dll;
} }
/* static archives */ /* static archives */
if ((*file = try_lib_path(dir, "lib", library, suffix, file_arh))) if ((*file = try_lib_path(dir, prefix, library, suffix, file_arh)))
return file_arh; return file_arh;
return file_na; return file_na;
} }
file_type get_lib_type(enum target_platform platform, strarray* path, const char *library, file_type get_lib_type(enum target_platform platform, strarray* path, const char *library,
const char *suffix, char** file) const char *prefix, const char *suffix, char** file)
{ {
unsigned int i; unsigned int i;
if (!suffix) suffix = ".a"; if (!suffix) suffix = ".a";
for (i = 0; i < path->size; i++) for (i = 0; i < path->size; i++)
{ {
file_type type = guess_lib_type(platform, path->base[i], library, suffix, file); file_type type = guess_lib_type(platform, path->base[i], library, prefix, suffix, file);
if (type != file_na) return type; if (type != file_na) return type;
} }
return file_na; return file_na;
......
...@@ -85,7 +85,7 @@ char* get_basename(const char* file); ...@@ -85,7 +85,7 @@ 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(enum target_platform platform, strarray* path, const char *library, file_type get_lib_type(enum target_platform platform, strarray* path, const char *library,
const char *suffix, char** file); const char *prefix, const char *suffix, char** file);
const char *find_binary( const strarray* prefix, const char *name ); const char *find_binary( const strarray* prefix, const char *name );
int spawn(const strarray* prefix, const strarray* arr, int ignore_errors); int spawn(const strarray* prefix, const strarray* arr, int ignore_errors);
......
...@@ -1083,14 +1083,27 @@ static const char *find_libgcc(const strarray *prefix, const strarray *link_tool ...@@ -1083,14 +1083,27 @@ static const char *find_libgcc(const strarray *prefix, const strarray *link_tool
/* add specified library to the list of files */ /* add specified library to the list of files */
static void add_library( struct options *opts, strarray *lib_dirs, strarray *files, const char *library ) static void add_library( struct options *opts, strarray *lib_dirs, strarray *files, const char *library )
{ {
char *static_lib, *fullname = 0; char *static_lib, *fullname = 0, *unixlib;
switch(get_lib_type(opts->target_platform, lib_dirs, library, opts->lib_suffix, &fullname)) switch(get_lib_type(opts->target_platform, lib_dirs, library, "lib", opts->lib_suffix, &fullname))
{ {
case file_arh: case file_arh:
strarray_add(files, strmake("-a%s", fullname)); strarray_add(files, strmake("-a%s", fullname));
break; break;
case file_dll: case file_dll:
if (opts->unix_lib && opts->subsystem && !strcmp(opts->subsystem, "native"))
{
if (get_lib_type(opts->target_platform, lib_dirs, library, "", ".so", &unixlib) == file_so)
{
strarray_add(files, strmake("-s%s", unixlib));
free(unixlib);
}
else
{
strarray_add(files, strmake("-l%s", library));
}
break;
}
strarray_add(files, strmake("-d%s", fullname)); strarray_add(files, strmake("-d%s", fullname));
if ((static_lib = find_static_lib(fullname))) if ((static_lib = find_static_lib(fullname)))
{ {
...@@ -1266,7 +1279,7 @@ static void build(struct options* opts) ...@@ -1266,7 +1279,7 @@ static void build(struct options* opts)
/* set default entry point, if needed */ /* set default entry point, if needed */
if (!opts->entry_point) if (!opts->entry_point)
{ {
if (opts->subsystem && !strcmp( opts->subsystem, "native" )) if (opts->subsystem && !opts->unix_lib && !strcmp( opts->subsystem, "native" ))
entry_point = (is_pe && opts->target_cpu == CPU_x86) ? "DriverEntry@8" : "DriverEntry"; entry_point = (is_pe && opts->target_cpu == CPU_x86) ? "DriverEntry@8" : "DriverEntry";
else if (opts->use_msvcrt && !opts->shared && !opts->win16_app) else if (opts->use_msvcrt && !opts->shared && !opts->win16_app)
entry_point = opts->unicode_app ? "wmainCRTStartup" : "mainCRTStartup"; entry_point = opts->unicode_app ? "wmainCRTStartup" : "mainCRTStartup";
......
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