From: Rémi Bernon rbernon@codeweavers.com
--- tools/makedep.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-)
diff --git a/tools/makedep.c b/tools/makedep.c index 7045dab9541..527cbd3c058 100644 --- a/tools/makedep.c +++ b/tools/makedep.c @@ -2151,19 +2151,17 @@ static const char *get_crt_define( const struct makefile *make )
/******************************************************************* - * add_default_imports + * get_default_imports */ -static struct strarray add_default_imports( const struct makefile *make, struct strarray imports ) +static struct strarray get_default_imports( const struct makefile *make, struct strarray imports ) { struct strarray ret = empty_strarray; const char *crt_dll = get_default_crt( make ); unsigned int i;
for (i = 0; i < imports.count; i++) - { - if (is_crt_module( imports.str[i] )) crt_dll = imports.str[i]; - else strarray_add( &ret, imports.str[i] ); - } + if (is_crt_module( imports.str[i] )) + crt_dll = imports.str[i];
strarray_add( &ret, "winecrt0" ); if (crt_dll) strarray_add( &ret, crt_dll ); @@ -2180,6 +2178,7 @@ enum import_type { IMPORT_TYPE_DIRECT, IMPORT_TYPE_DELAYED, + IMPORT_TYPE_DEFAULT, };
/******************************************************************* @@ -2196,6 +2195,9 @@ static struct strarray add_import_libs( const struct makefile *make, struct stra const char *name = imports.str[i]; const char *lib = NULL;
+ /* add crt import lib only when adding the default imports libs */ + if (is_crt_module( imports.str[i] ) && type != IMPORT_TYPE_DEFAULT) continue; + if (name[0] == '-') { switch (name[1]) @@ -2964,15 +2966,18 @@ static void output_source_spec( struct makefile *make, struct incl_file *source, { struct strarray imports = get_expanded_file_local_var( make, obj, "IMPORTS" ); struct strarray dll_flags = get_expanded_file_local_var( make, obj, "EXTRADLLFLAGS" ); - struct strarray all_libs, dep_libs = empty_strarray; + struct strarray all_libs = empty_strarray, dep_libs = empty_strarray; + struct strarray default_imports = empty_strarray; char *dll_name, *obj_name, *output_file; const char *debug_file;
if (!imports.count) imports = make->imports; if (!dll_flags.count) dll_flags = make->extradllflags; - if (!strarray_exists( &dll_flags, "-nodefaultlibs" )) imports = add_default_imports( make, imports ); + if (!strarray_exists( &dll_flags, "-nodefaultlibs" )) default_imports = get_default_imports( make, imports ); + + strarray_addall( &all_libs, add_import_libs( make, &dep_libs, imports, IMPORT_TYPE_DIRECT, make->is_cross ) ); + strarray_addall( &all_libs, add_import_libs( make, &dep_libs, default_imports, IMPORT_TYPE_DEFAULT, make->is_cross ) );
- all_libs = add_import_libs( make, &dep_libs, imports, IMPORT_TYPE_DIRECT, make->is_cross ); dll_name = strmake( "%s.dll%s", obj, make->is_cross ? "" : dll_ext ); obj_name = strmake( "%s%s", obj_dir_path( make, obj ), make->is_cross ? ".cross.o" : ".o" ); output_file = obj_dir_path( make, dll_name ); @@ -3152,6 +3157,7 @@ static char *get_unix_lib_name( struct makefile *make ) */ static void output_module( struct makefile *make ) { + struct strarray default_imports = empty_strarray; struct strarray all_libs = empty_strarray; struct strarray dep_libs = empty_strarray; struct strarray imports = make->imports; @@ -3168,11 +3174,11 @@ static void output_module( struct makefile *make ) if (*dll_ext && !make->is_cross && !make->data_only) module_name = strmake( "%s%s", make->module, dll_ext );
- if (!strarray_exists( &make->extradllflags, "-nodefaultlibs" )) - imports = add_default_imports( make, imports ); + if (!strarray_exists( &make->extradllflags, "-nodefaultlibs" )) default_imports = get_default_imports( make, imports );
strarray_addall( &all_libs, add_import_libs( make, &dep_libs, make->delayimports, IMPORT_TYPE_DELAYED, make->is_cross )); strarray_addall( &all_libs, add_import_libs( make, &dep_libs, imports, IMPORT_TYPE_DIRECT, make->is_cross )); + strarray_addall( &all_libs, add_import_libs( make, &dep_libs, default_imports, IMPORT_TYPE_DEFAULT, make->is_cross ) );
if (!make->use_msvcrt) { @@ -3458,14 +3464,16 @@ static void output_test_module( struct makefile *make ) char *testmodule = replace_extension( make->testdll, ".dll", "_test.exe" ); char *stripped = replace_extension( make->testdll, ".dll", "_test-stripped.exe" ); char *testres = replace_extension( make->testdll, ".dll", "_test.res" ); - struct strarray dep_libs = empty_strarray; - struct strarray all_libs = add_import_libs( make, &dep_libs, add_default_imports( make, make->imports ), - IMPORT_TYPE_DIRECT, make->is_cross ); + struct strarray default_imports = get_default_imports( make, make->imports ); + struct strarray dep_libs = empty_strarray, all_libs = empty_strarray; struct makefile *parent = get_parent_makefile( make ); const char *ext = make->is_cross ? "" : dll_ext; const char *debug_file; char *output_file;
+ strarray_addall( &all_libs, add_import_libs( make, &dep_libs, make->imports, IMPORT_TYPE_DIRECT, make->is_cross ) ); + strarray_addall( &all_libs, add_import_libs( make, &dep_libs, default_imports, IMPORT_TYPE_DEFAULT, make->is_cross ) ); + strarray_add( &make->all_targets, strmake( "%s%s", testmodule, ext )); strarray_add( &make->clean_files, strmake( "%s%s", stripped, ext )); output_file = strmake( "%s%s", obj_dir_path( make, testmodule ), ext );