Jacek Caban : winegcc: Improve heuristics for -m32/ -m64 options in get_lib_dir.
Alexandre Julliard
julliard at winehq.org
Fri Aug 17 12:33:09 CDT 2018
Module: wine
Branch: master
Commit: ce4dde3e9af31f896d34251ec2f47a08363893db
URL: https://source.winehq.org/git/wine.git/?a=commit;h=ce4dde3e9af31f896d34251ec2f47a08363893db
Author: Jacek Caban <jacek at codeweavers.com>
Date: Fri Aug 17 16:58:15 2018 +0200
winegcc: Improve heuristics for -m32/-m64 options in get_lib_dir.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
tools/winegcc/winegcc.c | 47 +++++++++++++++++++++++++++++++++++------------
1 file changed, 35 insertions(+), 12 deletions(-)
diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c
index 931ac53..b586c04 100644
--- a/tools/winegcc/winegcc.c
+++ b/tools/winegcc/winegcc.c
@@ -448,8 +448,12 @@ static char *get_lib_dir( struct options *opts )
{
static const char *stdlibpath[] = { LIBDIR, "/usr/lib", "/usr/local/lib", "/lib" };
static const char libwine[] = "/libwine.so";
+ const char *bit_suffix, *other_bit_suffix;
unsigned int i;
+ bit_suffix = opts->target_cpu == CPU_x86_64 || opts->target_cpu == CPU_ARM64 ? "64" : "32";
+ other_bit_suffix = opts->target_cpu == CPU_x86_64 || opts->target_cpu == CPU_ARM64 ? "32" : "64";
+
for (i = 0; i < sizeof(stdlibpath)/sizeof(stdlibpath[0]); i++)
{
char *p, *buffer = xmalloc( strlen(stdlibpath[i]) + strlen("/arm-linux-gnueabi") + strlen(libwine) + 1 );
@@ -464,18 +468,9 @@ static char *get_lib_dir( struct options *opts )
strcpy( p, libwine );
if (check_platform( opts, buffer )) goto found;
}
- if (opts->target_cpu != CPU_x86_64 && opts->target_cpu != CPU_ARM64)
- {
- strcpy( p, "32" );
- strcat( p, libwine );
- if (check_platform( opts, buffer )) goto found;
- }
- if (opts->target_cpu == CPU_x86_64 || opts->target_cpu == CPU_ARM64)
- {
- strcpy( p, "64" );
- strcat( p, libwine );
- if (check_platform( opts, buffer )) goto found;
- }
+ strcpy( p, bit_suffix );
+ strcat( p, libwine );
+ if (check_platform( opts, buffer )) goto found;
switch(opts->target_cpu)
{
case CPU_x86: strcpy( p, "/i386-linux-gnu" ); break;
@@ -488,6 +483,34 @@ static char *get_lib_dir( struct options *opts )
}
strcat( p, libwine );
if (check_platform( opts, buffer )) goto found;
+
+ strcpy( buffer, stdlibpath[i] );
+ p = buffer + strlen(buffer);
+ while (p > buffer && p[-1] == '/') p--;
+ strcpy( p, libwine );
+
+ /* try to fixup each parent dirs named lib, lib32 or lib64 with target bitness suffix */
+ while (p > buffer)
+ {
+ p--;
+ while (p > buffer && *p != '/') p--;
+ if (*p != '/') break;
+ if (memcmp( p + 1, "lib", 3 )) continue;
+ if (p[4] == '/')
+ {
+ memmove( p + 6, p + 4, strlen( p + 4 ) + 1 );
+ memcpy( p + 4, bit_suffix, 2 );
+ if (check_platform( opts, buffer )) goto found;
+ memmove( p + 4, p + 6, strlen( p + 6 ) + 1 );
+ }
+ else if (!memcmp( p + 4, other_bit_suffix, 2 ) && p[6] == '/')
+ {
+ memcpy( p + 4, bit_suffix, 2 );
+ if (check_platform( opts, buffer )) goto found;
+ memcpy( p + 4, other_bit_suffix, 2 );
+ }
+ }
+
free( buffer );
continue;
More information about the wine-cvs
mailing list