From 1aea4efd7999a19265c44c8be85cee7064bec97b Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 27 Aug 2009 13:35:46 +0200 Subject: [PATCH] tools: Take into account the executable extension when looking for tools in the path. --- configure | 5 +++++ configure.ac | 1 + include/config.h.in | 3 +++ tools/winebuild/utils.c | 5 +++-- tools/winegcc/utils.c | 8 +++++--- 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/configure b/configure index 1c42c9eaa3..bcf67cfde6 100755 --- a/configure +++ b/configure @@ -3960,6 +3960,11 @@ else fi +cat >>confdefs.h <<_ACEOF +#define EXEEXT "$ac_exeext" +_ACEOF + + case $host in *-darwin*) if test "x$enable_win64" = "xyes" diff --git a/configure.ac b/configure.ac index 39eea850bd..c880ad381b 100644 --- a/configure.ac +++ b/configure.ac @@ -105,6 +105,7 @@ AC_PROG_CC AC_PROG_CXX dnl We can't use AC_PROG_CPP for winegcc, it uses by default $(CC) -E AC_CHECK_TOOL(CPPBIN,cpp,cpp) +AC_DEFINE_UNQUOTED(EXEEXT,["$ac_exeext"],[Define to the file extension for executables.]) case $host in *-darwin*) diff --git a/include/config.h.in b/include/config.h.in index 5eb84c3683..6956963b99 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -2,6 +2,9 @@ #define __WINE_CONFIG_H +/* Define to the file extension for executables. */ +#undef EXEEXT + /* Define to 1 if you have the header file. */ #undef HAVE_ALIAS_H diff --git a/tools/winebuild/utils.c b/tools/winebuild/utils.c index d11bd328b2..e0cd8bcb9d 100644 --- a/tools/winebuild/utils.c +++ b/tools/winebuild/utils.c @@ -198,7 +198,7 @@ int output( const char *format, ... ) } /* find a build tool in the path, trying the various names */ -char *find_tool( const char * const *names ) +static char *find_tool( const char * const *names ) { static char **dirs; static unsigned int count, maxlen; @@ -231,7 +231,7 @@ char *find_tool( const char * const *names ) while (*names) { - len = strlen(*names) + 1; + len = strlen(*names) + sizeof(EXEEXT) + 1; file = xmalloc( maxlen + len ); for (i = 0; i < count; i++) @@ -241,6 +241,7 @@ char *find_tool( const char * const *names ) if (p == file) *p++ = '.'; if (p[-1] != '/') *p++ = '/'; strcpy( p, *names ); + strcat( p, EXEEXT ); if (!stat( file, &st ) && S_ISREG(st.st_mode) && (st.st_mode & 0111)) return file; } diff --git a/tools/winegcc/utils.c b/tools/winegcc/utils.c index 611ec42f4a..66c7e4171d 100644 --- a/tools/winegcc/utils.c +++ b/tools/winegcc/utils.c @@ -308,14 +308,16 @@ void spawn(const strarray* prefix, const strarray* args, int ignore_errors) if (prefix) { + const char *p = strrchr(argv[0], '/'); + if (!p) p = argv[0]; + else p++; + for (i = 0; i < prefix->size; i++) { - const char* p; struct stat st; - if (!(p = strrchr(argv[0], '/'))) p = argv[0]; free( prog ); - prog = strmake("%s/%s", prefix->base[i], p); + prog = strmake("%s/%s%s", prefix->base[i], p, EXEEXT); if (stat(prog, &st) == 0 && S_ISREG(st.st_mode) && (st.st_mode & 0111)) { argv[0] = prog;