makefiles: Link with the full library name for Unix library imports.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2021-09-20 15:30:27 +02:00
parent 0f62381f67
commit eda25a58c5
1 changed files with 24 additions and 15 deletions

View File

@ -2111,6 +2111,18 @@ static const char *get_static_lib( const struct makefile *make, const char *name
}
/*******************************************************************
* get_native_unix_lib
*/
static const char *get_native_unix_lib( const struct makefile *make, const char *name )
{
if (!make->unixlib) return NULL;
if (strncmp( make->unixlib, name, strlen(name) )) return NULL;
if (make->unixlib[strlen(name)] != '.') return NULL;
return obj_dir_path( make, make->unixlib );
}
/*******************************************************************
* get_parent_makefile
*/
@ -2162,13 +2174,15 @@ static int needs_implib_symlink( const struct makefile *make )
/*******************************************************************
* add_unix_libraries
*/
static struct strarray add_unix_libraries( const struct makefile *make, struct strarray *deps )
static struct strarray add_unix_libraries( const struct makefile *make, struct strarray *deps,
int native_unix )
{
struct strarray ret = empty_strarray;
struct strarray all_libs = empty_strarray;
unsigned int i, j;
strarray_add( &all_libs, "-lwine_port" );
if (native_unix && strcmp( make->module, "ntdll.dll" )) strarray_add( &all_libs, "-lntdll" );
strarray_addall( &all_libs, get_expanded_make_var_array( make, "EXTRALIBS" ));
strarray_addall( &all_libs, libs );
@ -2182,6 +2196,9 @@ static struct strarray add_unix_libraries( const struct makefile *make, struct s
for (j = 0; j < subdirs.count; j++)
if ((lib = get_static_lib( submakes[j], name ))) break;
if (!lib && native_unix)
for (j = 0; j < subdirs.count; j++)
if ((lib = get_native_unix_lib( submakes[j], name ))) break;
}
if (lib)
@ -3325,7 +3342,7 @@ static void output_module( struct makefile *make )
}
else if (*dll_ext)
{
if (!make->use_msvcrt) strarray_addall( &all_libs, add_unix_libraries( make, &dep_libs ));
if (!make->use_msvcrt) strarray_addall( &all_libs, add_unix_libraries( make, &dep_libs, 0 ));
for (i = 0; i < make->delayimports.count; i++)
strarray_add( &all_libs, strmake( "-Wl,-delayload,%s%s", make->delayimports.str[i],
strchr( make->delayimports.str[i], '.' ) ? "" : ".dll" ));
@ -3339,7 +3356,7 @@ static void output_module( struct makefile *make )
}
else
{
strarray_addall( &all_libs, add_unix_libraries( make, &dep_libs ));
strarray_addall( &all_libs, add_unix_libraries( make, &dep_libs, 0 ));
strarray_add( &make->all_targets, make->module );
add_install_rule( make, make->module, make->module,
strmake( "p$(%s)/%s", spec_file ? "dlldir" : "bindir", make->module ));
@ -3376,15 +3393,7 @@ static void output_module( struct makefile *make )
struct strarray extra_libs = get_expanded_make_var_array( make, "EXTRALIBS" );
int native_unix_lib = strarray_exists( &extra_libs, "-Wl,--subsystem,unixlib" );
if (native_unix_lib)
{
if (strcmp( make->module, "ntdll.dll" ))
{
strarray_add( &unix_libs, "-lntdll" );
strarray_add( &unix_deps, obj_dir_path( top_makefile, "dlls/ntdll/ntdll.so" ));
}
}
else
if (!native_unix_lib)
{
struct strarray unix_imports = empty_strarray;
@ -3399,7 +3408,7 @@ static void output_module( struct makefile *make )
strarray_addall( &unix_libs, add_import_libs( make, &unix_deps, unix_imports, 0, 1 ));
}
strarray_addall( &unix_libs, add_unix_libraries( make, &unix_deps ));
strarray_addall( &unix_libs, add_unix_libraries( make, &unix_deps, native_unix_lib ));
strarray_add( &make->all_targets, make->unixlib );
add_install_rule( make, make->module, make->unixlib, strmake( "p%s/%s", so_dir, make->unixlib ));
@ -3546,7 +3555,7 @@ static void output_shared_lib( struct makefile *make )
strarray_addall( &dep_libs, get_local_dependencies( make, basename, make->in_files ));
strarray_addall( &all_libs, get_expanded_file_local_var( make, basename, "LDFLAGS" ));
strarray_addall( &all_libs, add_unix_libraries( make, &dep_libs ));
strarray_addall( &all_libs, add_unix_libraries( make, &dep_libs, 0 ));
output( "%s:", obj_dir_path( make, make->sharedlib ));
output_filenames_obj_dir( make, make->object_files );
@ -3660,7 +3669,7 @@ static void output_programs( struct makefile *make )
if (!objs.count) objs = make->object_files;
if (!strarray_exists( &all_libs, "-nodefaultlibs" ))
strarray_addall( &all_libs, add_unix_libraries( make, &deps ));
strarray_addall( &all_libs, add_unix_libraries( make, &deps, 0 ));
output( "%s:", obj_dir_path( make, program ) );
output_filenames_obj_dir( make, objs );