diff --git a/configure b/configure index 1c42c9eaa3f..bcf67cfde69 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 39eea850bde..c880ad381bc 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 5eb84c3683d..6956963b99f 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 d11bd328b2c..e0cd8bcb9df 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 611ec42f4aa..66c7e4171d5 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;