Module: wine Branch: master Commit: 8c700a4e8316a1c1c2fb23a8ae61178102d5922d URL: https://gitlab.winehq.org/wine/wine/-/commit/8c700a4e8316a1c1c2fb23a8ae61178...
Author: Alexandre Julliard julliard@winehq.org Date: Tue Jun 25 11:58:25 2024 +0200
ntdll: Build relative paths at run-time instead of depending on makedep.
---
dlls/ntdll/Makefile.in | 6 +++--- dlls/ntdll/unix/loader.c | 40 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 41 insertions(+), 5 deletions(-)
diff --git a/dlls/ntdll/Makefile.in b/dlls/ntdll/Makefile.in index e17e3f72b92..37bd6c86e31 100644 --- a/dlls/ntdll/Makefile.in +++ b/dlls/ntdll/Makefile.in @@ -75,6 +75,6 @@ EXTRA_OBJS = unix/version.o
unix_loader_EXTRADEFS = \ -DBINDIR="${bindir}" \ - -DSYSTEMDLLPATH="${system_dllpath}" \ - -DDLL_TO_BINDIR="`${MAKEDEP} -R ${libdir}/wine ${bindir}`" \ - -DBIN_TO_DATADIR="`${MAKEDEP} -R ${bindir} ${datadir}/wine`" + -DLIBDIR="${libdir}" \ + -DDATADIR="${datadir}" \ + -DSYSTEMDLLPATH="${system_dllpath}" diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index f8420dd9e62..19fbfb2b68c 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -302,6 +302,42 @@ static char *build_path( const char *dir, const char *name ) return ret; }
+/* build a path with the relative dir from 'from' to 'dest' appended to base */ +static char *build_relative_path( const char *base, const char *from, const char *dest ) +{ + const char *start; + char *ret; + unsigned int dotdots = 0; + + for (;;) + { + while (*from == '/') from++; + while (*dest == '/') dest++; + start = dest; /* save start of next path element */ + if (!*from) break; + + while (*from && *from != '/' && *from == *dest) { from++; dest++; } + if ((!*from || *from == '/') && (!*dest || *dest == '/')) continue; + + do /* count remaining elements in 'from' */ + { + dotdots++; + while (*from && *from != '/') from++; + while (*from == '/') from++; + } + while (*from); + break; + } + + ret = malloc( strlen(base) + 3 * dotdots + strlen(start) + 2 ); + strcpy( ret, base ); + while (dotdots--) strcat( ret, "/.." ); + + if (!start[0]) return ret; + strcat( ret, "/" ); + strcat( ret, start ); + return ret; +}
/* build a path to a binary and exec it */ static int build_path_and_exec( pid_t *pid, const char *dir, const char *name, char **argv ) @@ -444,8 +480,8 @@ static void init_paths( char *argv[] ) free( path ); } #endif - if (!bin_dir) bin_dir = build_path( dll_dir, DLL_TO_BINDIR ); - data_dir = build_path( bin_dir, BIN_TO_DATADIR ); + if (!bin_dir) bin_dir = build_relative_path( dll_dir, LIBDIR "/wine", BINDIR ); + data_dir = build_relative_path( bin_dir, BINDIR, DATADIR "/wine" ); wineloader = build_path( bin_dir, basename ); } else