Fix MS-Windows MinGW build

* src/w32/subproc/sub_proc.c (process_wait_for_multiple_objects):
Fix format specifier for GetLastError's value.

* src/job.c (reap_children): Define the 'remote_status_lose' label
only for Posix platforms, to avoid compiler warning.

* build_w32.bat (LNKOUT): New variable, using forward slashes.
Use forward slashes in calls to :Compile, so that linking with GNU
ld works.

* src/makeint.h [!HAVE_UMASK]: Prototype for 'umask'.
(UMASK, MODE_T): Don't define.

* src/misc.c (get_tmpfile): Don't call UMASK, call umask, to
avoid compilation warning on !HAVE_UMASK platforms.
* src/output.c (output_tmpfd): Likewise.

* src/misc.c (umask) [!HAVE_UMASK]: New no-op function.

* src/config.h.W32.template (__USE_MINGW_ANSI_STDIO)
[__MINGW32__]: Define to 1, to force Make use ANSI-compatible
stdio functions, which also support the non-standard 'Id' and 'Ix'
specifiers.
(HAVE_UMASK) [__MINGW32__]: Define to 1.

* src/arscan.c (ar_member_touch): Type-cast argument of strlen to
avoid compiler warnings.
This commit is contained in:
Eli Zaretskii 2019-08-28 17:45:49 +03:00
parent e304a03b6d
commit 715c787dc6
8 changed files with 76 additions and 54 deletions

View File

@ -154,9 +154,11 @@ exit 1
:FoundMSVC :FoundMSVC
set OUTDIR=.\WinRel set OUTDIR=.\WinRel
set LNKOUT=./WinRel
set "OPTS=/O2 /D NDEBUG" set "OPTS=/O2 /D NDEBUG"
set LINKOPTS= set LINKOPTS=
if "%DEBUG%" == "Y" set OUTDIR=.\WinDebug if "%DEBUG%" == "Y" set OUTDIR=.\WinDebug
if "%DEBUG%" == "Y" set LNKOUT=./WinDebug
if "%DEBUG%" == "Y" set "OPTS=/Zi /Od /D _DEBUG" if "%DEBUG%" == "Y" set "OPTS=/Zi /Od /D _DEBUG"
if "%DEBUG%" == "Y" set LINKOPTS=/DEBUG if "%DEBUG%" == "Y" set LINKOPTS=/DEBUG
if "%MAINT%" == "Y" set "OPTS=%OPTS% /D MAKE_MAINTAINER_MODE" if "%MAINT%" == "Y" set "OPTS=%OPTS% /D MAKE_MAINTAINER_MODE"
@ -168,9 +170,11 @@ goto Build
:FindGcc :FindGcc
set OUTDIR=.\GccRel set OUTDIR=.\GccRel
set LNKOUT=./GccRel
set OPTS=-O2 set OPTS=-O2
if "%DEBUG%" == "Y" set OPTS=-O0 if "%DEBUG%" == "Y" set OPTS=-O0
if "%DEBUG%" == "Y" set OUTDIR=.\GccDebug if "%DEBUG%" == "Y" set OUTDIR=.\GccDebug
if "%DEBUG%" == "Y" set LNKOUT=./GccDebug
if "%MAINT%" == "Y" set "OPTS=%OPTS% -DMAKE_MAINTAINER_MODE" if "%MAINT%" == "Y" set "OPTS=%OPTS% -DMAKE_MAINTAINER_MODE"
:: Show the compiler version that we found :: Show the compiler version that we found
echo. echo.
@ -204,43 +208,43 @@ copy lib\fnmatch.in.h %OUTDIR%\lib\fnmatch.h
if exist %OUTDIR%\link.sc del %OUTDIR%\link.sc if exist %OUTDIR%\link.sc del %OUTDIR%\link.sc
call :Compile src\ar call :Compile src/ar
call :Compile src\arscan call :Compile src/arscan
call :Compile src\commands call :Compile src/commands
call :Compile src\default call :Compile src/default
call :Compile src\dir call :Compile src/dir
call :Compile src\expand call :Compile src/expand
call :Compile src\file call :Compile src/file
call :Compile src\function call :Compile src/function
call :Compile src\getopt call :Compile src/getopt
call :Compile src\getopt1 call :Compile src/getopt1
call :Compile src\guile GUILE call :Compile src/guile GUILE
call :Compile src\hash call :Compile src/hash
call :Compile src\implicit call :Compile src/implicit
call :Compile src\job call :Compile src/job
call :Compile src\load call :Compile src/load
call :Compile src\loadapi call :Compile src/loadapi
call :Compile src\main GUILE call :Compile src/main GUILE
call :Compile src\misc call :Compile src/misc
call :Compile src\output call :Compile src/output
call :Compile src\read call :Compile src/read
call :Compile src\remake call :Compile src/remake
call :Compile src\remote-stub call :Compile src/remote-stub
call :Compile src\rule call :Compile src/rule
call :Compile src\signame call :Compile src/signame
call :Compile src\strcache call :Compile src/strcache
call :Compile src\variable call :Compile src/variable
call :Compile src\version call :Compile src/version
call :Compile src\vpath call :Compile src/vpath
call :Compile src\w32\pathstuff call :Compile src/w32/pathstuff
call :Compile src\w32\w32os call :Compile src/w32/w32os
call :Compile src\w32\compat\posixfcn call :Compile src/w32/compat/posixfcn
call :Compile src\w32\subproc\misc call :Compile src/w32/subproc/misc
call :Compile src\w32\subproc\sub_proc call :Compile src/w32/subproc/sub_proc
call :Compile src\w32\subproc\w32err call :Compile src/w32/subproc/w32err
call :Compile lib\fnmatch call :Compile lib/fnmatch
call :Compile lib\glob call :Compile lib/glob
call :Compile lib\getloadavg call :Compile lib/getloadavg
if not "%COMPILER%" == "gcc" call :Compile src\w32\compat\dirent if not "%COMPILER%" == "gcc" call :Compile src\w32\compat\dirent
@ -262,7 +266,7 @@ goto :EOF
:: ::
:Compile :Compile
echo %OUTDIR%\%1.%O% >>%OUTDIR%\link.sc echo %LNKOUT%/%1.%O% >>%OUTDIR%\link.sc
set EXTRAS= set EXTRAS=
if "%2" == "GUILE" set "EXTRAS=%GUILECFLAGS%" if "%2" == "GUILE" set "EXTRAS=%GUILECFLAGS%"
if exist "%OUTDIR%\%1.%O%" del "%OUTDIR%\%1.%O%" if exist "%OUTDIR%\%1.%O%" del "%OUTDIR%\%1.%O%"
@ -277,7 +281,7 @@ goto CompileDone
:GccCompile :GccCompile
:: GCC Compile :: GCC Compile
echo on echo on
%COMPILER% -mthreads -Wall -std=gnu99 -gdwarf-2 -g3 %OPTS% -I%OUTDIR%/src -I./src -I%OUTDIR%/lib -I./lib -I./src/w32/include -DWINDOWS32 -DHAVE_CONFIG_H %EXTRAS% -o %OUTDIR%\%1.%O% -c %1.c %COMPILER% -mthreads -Wall -std=gnu99 -gdwarf-2 -g3 %OPTS% -I%OUTDIR%/src -I./src -I%OUTDIR%/lib -I./lib -I./src/w32/include -DWINDOWS32 -DHAVE_CONFIG_H %EXTRAS% -o %OUTDIR%/%1.%O% -c %1.c
@echo off @echo off
:CompileDone :CompileDone
@ -285,13 +289,14 @@ if not exist "%OUTDIR%\%1.%O%" exit 1
goto :EOF goto :EOF
:Link :Link
echo Linking %OUTDIR%/%MAKE%.exe echo.
echo Linking %LNKOUT%/%MAKE%.exe
if "%COMPILER%" == "gcc" goto GccLink if "%COMPILER%" == "gcc" goto GccLink
:: MSVC Link :: MSVC Link
echo %GUILELIBS% kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib >>%OUTDIR%\link.sc echo %GUILELIBS% kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib >>%OUTDIR%\link.sc
echo on echo on
link.exe /NOLOGO /SUBSYSTEM:console /PDB:%OUTDIR%\%MAKE%.pdb %LINKOPTS% /OUT:%OUTDIR%\%MAKE%.exe @%OUTDIR%\link.sc link.exe /NOLOGO /SUBSYSTEM:console /PDB:%LNKOUT%\%MAKE%.pdb %LINKOPTS% /OUT:%LNKOUT%\%MAKE%.exe @%LNKOUT%\link.sc
@echo off @echo off
goto :EOF goto :EOF
@ -299,7 +304,7 @@ goto :EOF
:: GCC Link :: GCC Link
echo on echo on
echo %GUILELIBS% -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 >>%OUTDIR%\link.sc echo %GUILELIBS% -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 >>%OUTDIR%\link.sc
%COMPILER% -mthreads -gdwarf-2 -g3 %OPTS% -o %OUTDIR%\%MAKE%.exe @%OUTDIR%\link.sc -Wl,--out-implib=%OUTDIR%\libgnumake-1.dll.a %COMPILER% -mthreads -gdwarf-2 -g3 %OPTS% -o %LNKOUT%/%MAKE%.exe @%LNKOUT%/link.sc -Wl,--out-implib=%LNKOUT%/libgnumake-1.dll.a
@echo off @echo off
goto :EOF goto :EOF
@ -390,6 +395,7 @@ set NOGUILE=
set O= set O=
set OPTS= set OPTS=
set OUTDIR= set OUTDIR=
set LNKOUT=
set PKGMSC= set PKGMSC=
set VSVARS= set VSVARS=
goto :EOF goto :EOF

View File

@ -909,7 +909,7 @@ ar_member_touch (const char *arname, const char *memname)
for (ui = 0; ui < sizeof ar_hdr.ar_date; ui++) for (ui = 0; ui < sizeof ar_hdr.ar_date; ui++)
ar_hdr.ar_date[ui] = ' '; ar_hdr.ar_date[ui] = ' ';
sprintf (TOCHAR (ar_hdr.ar_date), "%lu", (long unsigned) statbuf.st_mtime); sprintf (TOCHAR (ar_hdr.ar_date), "%lu", (long unsigned) statbuf.st_mtime);
ar_hdr.ar_date[strlen (ar_hdr.ar_date)] = ' '; ar_hdr.ar_date[strlen ((char *) ar_hdr.ar_date)] = ' ';
#else #else
ar_hdr.ar_date = statbuf.st_mtime; ar_hdr.ar_date = statbuf.st_mtime;
#endif #endif

View File

@ -298,6 +298,11 @@ this program. If not, see <http://www.gnu.org/licenses/>. */
#define HAVE_TTYNAME 1 #define HAVE_TTYNAME 1
char *ttyname (int); char *ttyname (int);
/* Define to 1 if you have the `umask' function. */
#ifdef __MINGW32__
# define HAVE_UMASK 1
#endif
/* Define to 1 if 'n_un.n_name' is a member of 'struct nlist'. */ /* Define to 1 if 'n_un.n_name' is a member of 'struct nlist'. */
/* #undef HAVE_STRUCT_NLIST_N_UN_N_NAME */ /* #undef HAVE_STRUCT_NLIST_N_UN_N_NAME */
@ -470,6 +475,11 @@ char *ttyname (int);
/* Define to empty if 'const' does not conform to ANSI C. */ /* Define to empty if 'const' does not conform to ANSI C. */
/* #undef const */ /* #undef const */
#ifdef __MINGW32__
# undef __USE_MINGW_ANSI_STDIO
# define __USE_MINGW_ANSI_STDIO 1
#endif
#include <sys/types.h> #include <sys/types.h>
/* Define to 'int' if <sys/types.h> doesn't define. */ /* Define to 'int' if <sys/types.h> doesn't define. */

View File

@ -724,7 +724,9 @@ reap_children (int block, int err)
else if (pid < 0) else if (pid < 0)
{ {
/* A remote status command failed miserably. Punt. */ /* A remote status command failed miserably. Punt. */
#if !defined(__MSDOS__) && !defined(_AMIGA) && !defined(WINDOWS32)
remote_status_lose: remote_status_lose:
#endif
pfatal_with_name ("remote_status"); pfatal_with_name ("remote_status");
} }
else else

View File

@ -292,12 +292,8 @@ char *strerror (int errnum);
char *strsignal (int signum); char *strsignal (int signum);
#endif #endif
#if defined(HAVE_UMASK) #if !defined(HAVE_UMASK)
# define UMASK(_m) umask (_m) extern mode_t umask (mode_t);
# define MODE_T mode_t
#else
# define UMASK(_m) 0
# define MODE_T int
#endif #endif
/* ISDIGIT offers the following features: /* ISDIGIT offers the following features:

View File

@ -437,6 +437,14 @@ char *mktemp (char *template);
# endif # endif
#endif #endif
#ifndef HAVE_UMASK
mode_t
umask (mode_t mask)
{
return 0;
}
#endif
FILE * FILE *
get_tmpfile (char **name, const char *template) get_tmpfile (char **name, const char *template)
{ {
@ -446,7 +454,7 @@ get_tmpfile (char **name, const char *template)
#endif #endif
/* Preserve the current umask, and set a restrictive one for temp files. */ /* Preserve the current umask, and set a restrictive one for temp files. */
MODE_T mask = UMASK (0077); mode_t mask = umask (0077);
#if defined(HAVE_MKSTEMP) || defined(HAVE_MKTEMP) #if defined(HAVE_MKSTEMP) || defined(HAVE_MKTEMP)
# define TEMPLATE_LEN strlen (template) # define TEMPLATE_LEN strlen (template)
@ -482,7 +490,7 @@ get_tmpfile (char **name, const char *template)
# endif # endif
#endif #endif
UMASK (mask); umask (mask);
return file; return file;
} }

View File

@ -281,7 +281,7 @@ release_semaphore (void *sem)
int int
output_tmpfd (void) output_tmpfd (void)
{ {
MODE_T mask = UMASK (0077); mode_t mask = umask (0077);
int fd = -1; int fd = -1;
FILE *tfile = tmpfile (); FILE *tfile = tmpfile ();
@ -297,7 +297,7 @@ output_tmpfd (void)
set_append_mode (fd); set_append_mode (fd);
UMASK (mask); umask (mask);
return fd; return fd;
} }

View File

@ -108,7 +108,7 @@ DWORD process_wait_for_multiple_objects(
continue; continue;
break; break;
case WAIT_FAILED: case WAIT_FAILED:
fprintf(stderr,"WaitForMultipleOjbects failed waiting with error %d\n", GetLastError()); fprintf(stderr,"WaitForMultipleOjbects failed waiting with error %lu\n", GetLastError());
break; break;
default: default:
if (retVal >= WAIT_ABANDONED_0) { if (retVal >= WAIT_ABANDONED_0) {