Alexandre Julliard : winegcc: Fix the lib dir detection.
Alexandre Julliard
julliard at winehq.org
Thu Dec 2 16:30:52 CST 2010
Module: wine
Branch: stable
Commit: 8fdb4620bdeae112a349bf37387744c566b39417
URL: http://source.winehq.org/git/wine.git/?a=commit;h=8fdb4620bdeae112a349bf37387744c566b39417
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Oct 28 11:45:05 2010 +0200
winegcc: Fix the lib dir detection.
Spotted by André Hentschel.
(cherry picked from commit 62f9966fdc8e37720d9ad60a87592b0a593a03a9)
---
tools/winegcc/winegcc.c | 22 +++++++++++++++-------
1 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/tools/winegcc/winegcc.c b/tools/winegcc/winegcc.c
index c5b8537..dbf66c8 100644
--- a/tools/winegcc/winegcc.c
+++ b/tools/winegcc/winegcc.c
@@ -339,28 +339,36 @@ static int check_platform( struct options *opts, const char *file )
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";
unsigned int i;
for (i = 0; i < sizeof(stdlibpath)/sizeof(stdlibpath[0]); i++)
{
- char *p, *buffer = xmalloc( strlen(stdlibpath[i]) + sizeof("32/libwine.so") );
+ char *p, *buffer = xmalloc( strlen(stdlibpath[i]) + strlen(libwine) + 3 );
strcpy( buffer, stdlibpath[i] );
p = buffer + strlen(buffer);
while (p > buffer && p[-1] == '/') p--;
- strcpy( p, "/libwine.so" );
- if (check_platform( opts, buffer )) return buffer;
+ strcpy( p, libwine );
+ if (check_platform( opts, buffer )) goto found;
if (p > buffer + 2 && (!memcmp( p - 2, "32", 2 ) || !memcmp( p - 2, "64", 2 ))) p -= 2;
if (opts->force_pointer_size == 4 || (!opts->force_pointer_size && opts->target_cpu != CPU_x86_64))
{
- strcpy( p, "32/libwine.so" );
- if (check_platform( opts, buffer )) return buffer;
+ strcpy( p, "32" );
+ strcat( p, libwine );
+ if (check_platform( opts, buffer )) goto found;
}
if (opts->force_pointer_size == 8 || (!opts->force_pointer_size && opts->target_cpu == CPU_x86_64))
{
- strcpy( p, "64/libwine.so" );
- if (check_platform( opts, buffer )) return buffer;
+ strcpy( p, "64" );
+ strcat( p, libwine );
+ if (check_platform( opts, buffer )) goto found;
}
free( buffer );
+ continue;
+
+ found:
+ buffer[strlen(buffer) - strlen(libwine)] = 0;
+ return buffer;
}
return xstrdup( LIBDIR );
}
More information about the wine-cvs
mailing list