]> git.ipfire.org Git - thirdparty/make.git/commitdiff
Fix MS-Windows MinGW build
authorEli Zaretskii <eliz@gnu.org>
Wed, 28 Aug 2019 14:45:49 +0000 (17:45 +0300)
committerEli Zaretskii <eliz@gnu.org>
Wed, 28 Aug 2019 14:45:49 +0000 (17:45 +0300)
* 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.

build_w32.bat
src/arscan.c
src/config.h.W32.template
src/job.c
src/makeint.h
src/misc.c
src/output.c
src/w32/subproc/sub_proc.c

index 16aa9a44944b38f04b30701b5f551940fd10c780..9fbfb4bb44eca2b26fc7a53f6941793830ba6460 100755 (executable)
@@ -154,9 +154,11 @@ exit 1
 \r
 :FoundMSVC\r
 set OUTDIR=.\WinRel\r
+set LNKOUT=./WinRel\r
 set "OPTS=/O2 /D NDEBUG"\r
 set LINKOPTS=\r
 if "%DEBUG%" == "Y" set OUTDIR=.\WinDebug\r
+if "%DEBUG%" == "Y" set LNKOUT=./WinDebug\r
 if "%DEBUG%" == "Y" set "OPTS=/Zi /Od /D _DEBUG"\r
 if "%DEBUG%" == "Y" set LINKOPTS=/DEBUG\r
 if "%MAINT%" == "Y" set "OPTS=%OPTS% /D MAKE_MAINTAINER_MODE"\r
@@ -168,9 +170,11 @@ goto Build
 \r
 :FindGcc\r
 set OUTDIR=.\GccRel\r
+set LNKOUT=./GccRel\r
 set OPTS=-O2\r
 if "%DEBUG%" == "Y" set OPTS=-O0\r
 if "%DEBUG%" == "Y" set OUTDIR=.\GccDebug\r
+if "%DEBUG%" == "Y" set LNKOUT=./GccDebug\r
 if "%MAINT%" == "Y" set "OPTS=%OPTS% -DMAKE_MAINTAINER_MODE"\r
 :: Show the compiler version that we found\r
 echo.\r
@@ -204,43 +208,43 @@ copy lib\fnmatch.in.h %OUTDIR%\lib\fnmatch.h
 \r
 if exist %OUTDIR%\link.sc del %OUTDIR%\link.sc\r
 \r
-call :Compile src\ar\r
-call :Compile src\arscan\r
-call :Compile src\commands\r
-call :Compile src\default\r
-call :Compile src\dir\r
-call :Compile src\expand\r
-call :Compile src\file\r
-call :Compile src\function\r
-call :Compile src\getopt\r
-call :Compile src\getopt1\r
-call :Compile src\guile GUILE\r
-call :Compile src\hash\r
-call :Compile src\implicit\r
-call :Compile src\job\r
-call :Compile src\load\r
-call :Compile src\loadapi\r
-call :Compile src\main GUILE\r
-call :Compile src\misc\r
-call :Compile src\output\r
-call :Compile src\read\r
-call :Compile src\remake\r
-call :Compile src\remote-stub\r
-call :Compile src\rule\r
-call :Compile src\signame\r
-call :Compile src\strcache\r
-call :Compile src\variable\r
-call :Compile src\version\r
-call :Compile src\vpath\r
-call :Compile src\w32\pathstuff\r
-call :Compile src\w32\w32os\r
-call :Compile src\w32\compat\posixfcn\r
-call :Compile src\w32\subproc\misc\r
-call :Compile src\w32\subproc\sub_proc\r
-call :Compile src\w32\subproc\w32err\r
-call :Compile lib\fnmatch\r
-call :Compile lib\glob\r
-call :Compile lib\getloadavg\r
+call :Compile src/ar\r
+call :Compile src/arscan\r
+call :Compile src/commands\r
+call :Compile src/default\r
+call :Compile src/dir\r
+call :Compile src/expand\r
+call :Compile src/file\r
+call :Compile src/function\r
+call :Compile src/getopt\r
+call :Compile src/getopt1\r
+call :Compile src/guile GUILE\r
+call :Compile src/hash\r
+call :Compile src/implicit\r
+call :Compile src/job\r
+call :Compile src/load\r
+call :Compile src/loadapi\r
+call :Compile src/main GUILE\r
+call :Compile src/misc\r
+call :Compile src/output\r
+call :Compile src/read\r
+call :Compile src/remake\r
+call :Compile src/remote-stub\r
+call :Compile src/rule\r
+call :Compile src/signame\r
+call :Compile src/strcache\r
+call :Compile src/variable\r
+call :Compile src/version\r
+call :Compile src/vpath\r
+call :Compile src/w32/pathstuff\r
+call :Compile src/w32/w32os\r
+call :Compile src/w32/compat/posixfcn\r
+call :Compile src/w32/subproc/misc\r
+call :Compile src/w32/subproc/sub_proc\r
+call :Compile src/w32/subproc/w32err\r
+call :Compile lib/fnmatch\r
+call :Compile lib/glob\r
+call :Compile lib/getloadavg\r
 \r
 if not "%COMPILER%" == "gcc" call :Compile src\w32\compat\dirent\r
 \r
@@ -262,7 +266,7 @@ goto :EOF
 ::\r
 \r
 :Compile\r
-echo %OUTDIR%\%1.%O% >>%OUTDIR%\link.sc\r
+echo %LNKOUT%/%1.%O% >>%OUTDIR%\link.sc\r
 set EXTRAS=\r
 if "%2" == "GUILE" set "EXTRAS=%GUILECFLAGS%"\r
 if exist "%OUTDIR%\%1.%O%" del "%OUTDIR%\%1.%O%"\r
@@ -277,7 +281,7 @@ goto CompileDone
 :GccCompile\r
 :: GCC Compile\r
 echo on\r
-%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\r
+%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\r
 @echo off\r
 \r
 :CompileDone\r
@@ -285,13 +289,14 @@ if not exist "%OUTDIR%\%1.%O%" exit 1
 goto :EOF\r
 \r
 :Link\r
-echo Linking %OUTDIR%/%MAKE%.exe\r
+echo.\r
+echo Linking %LNKOUT%/%MAKE%.exe\r
 if "%COMPILER%" == "gcc" goto GccLink\r
 \r
 :: MSVC Link\r
 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\r
 echo on\r
-link.exe /NOLOGO /SUBSYSTEM:console /PDB:%OUTDIR%\%MAKE%.pdb %LINKOPTS% /OUT:%OUTDIR%\%MAKE%.exe @%OUTDIR%\link.sc\r
+link.exe /NOLOGO /SUBSYSTEM:console /PDB:%LNKOUT%\%MAKE%.pdb %LINKOPTS% /OUT:%LNKOUT%\%MAKE%.exe @%LNKOUT%\link.sc\r
 @echo off\r
 goto :EOF\r
 \r
@@ -299,7 +304,7 @@ goto :EOF
 :: GCC Link\r
 echo on\r
 echo %GUILELIBS% -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 >>%OUTDIR%\link.sc\r
-%COMPILER% -mthreads -gdwarf-2 -g3 %OPTS% -o %OUTDIR%\%MAKE%.exe @%OUTDIR%\link.sc -Wl,--out-implib=%OUTDIR%\libgnumake-1.dll.a\r
+%COMPILER% -mthreads -gdwarf-2 -g3 %OPTS% -o %LNKOUT%/%MAKE%.exe @%LNKOUT%/link.sc -Wl,--out-implib=%LNKOUT%/libgnumake-1.dll.a\r
 @echo off\r
 goto :EOF\r
 \r
@@ -390,6 +395,7 @@ set NOGUILE=
 set O=\r
 set OPTS=\r
 set OUTDIR=\r
+set LNKOUT=\r
 set PKGMSC=\r
 set VSVARS=\r
 goto :EOF\r
index f90194643980ff5556eaddde7db843218c5b82b9..fb6264129c571dac78ac003864cfdc8b99a50df8 100644 (file)
@@ -909,7 +909,7 @@ ar_member_touch (const char *arname, const char *memname)
   for (ui = 0; ui < sizeof ar_hdr.ar_date; ui++)
     ar_hdr.ar_date[ui] = ' ';
   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
   ar_hdr.ar_date = statbuf.st_mtime;
 #endif
index b6463b20b44e2ecba257641225f02b1655d8dff0..d69e6b73695b9a2c7f02ac2dc6f119149773bb8b 100644 (file)
@@ -298,6 +298,11 @@ this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #define HAVE_TTYNAME 1
 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'. */
 /* #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. */
 /* #undef const */
 
+#ifdef __MINGW32__
+# undef __USE_MINGW_ANSI_STDIO
+# define __USE_MINGW_ANSI_STDIO 1
+#endif
+
 #include <sys/types.h>
 
 /* Define to 'int' if <sys/types.h> doesn't define. */
index e0b21c1337780f72577c1aba6a4f4e6c4bd399dd..f4f2113f405242601f451af28dc903f7f6aa15ad 100644 (file)
--- a/src/job.c
+++ b/src/job.c
@@ -724,7 +724,9 @@ reap_children (int block, int err)
       else if (pid < 0)
         {
           /* A remote status command failed miserably.  Punt.  */
+#if !defined(__MSDOS__) && !defined(_AMIGA) && !defined(WINDOWS32)
         remote_status_lose:
+#endif
           pfatal_with_name ("remote_status");
         }
       else
index 3b0f1f192d055d957c8d1f54bed89406c4b16cbe..d13c3135a22eb27dc6f59a0b01e1ffad14734636 100644 (file)
@@ -292,12 +292,8 @@ char *strerror (int errnum);
 char *strsignal (int signum);
 #endif
 
-#if defined(HAVE_UMASK)
-# define UMASK(_m)  umask (_m)
-# define MODE_T     mode_t
-#else
-# define UMASK(_m)  0
-# define MODE_T     int
+#if !defined(HAVE_UMASK)
+extern mode_t umask (mode_t);
 #endif
 
 /* ISDIGIT offers the following features:
index a0f889804dc8c2063a49f6f5ea11180274827dca..567c86f947b83da610dc42bfd5b408bdf9f6a9cd 100644 (file)
@@ -437,6 +437,14 @@ char *mktemp (char *template);
 # endif
 #endif
 
+#ifndef HAVE_UMASK
+mode_t
+umask (mode_t mask)
+{
+  return 0;
+}
+#endif
+
 FILE *
 get_tmpfile (char **name, const char *template)
 {
@@ -446,7 +454,7 @@ get_tmpfile (char **name, const char *template)
 #endif
 
   /* 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)
 # define TEMPLATE_LEN   strlen (template)
@@ -482,7 +490,7 @@ get_tmpfile (char **name, const char *template)
 # endif
 #endif
 
-  UMASK (mask);
+  umask (mask);
 
   return file;
 }
index 6178c72441c7f70ff97064b79222cc56de99fafb..ccb44143dba2b8567b743f58dec0b46ba8c65c47 100644 (file)
@@ -281,7 +281,7 @@ release_semaphore (void *sem)
 int
 output_tmpfd (void)
 {
-  MODE_T mask = UMASK (0077);
+  mode_t mask = umask (0077);
   int fd = -1;
   FILE *tfile = tmpfile ();
 
@@ -297,7 +297,7 @@ output_tmpfd (void)
 
   set_append_mode (fd);
 
-  UMASK (mask);
+  umask (mask);
 
   return fd;
 }
index 58064650d513bde653b20528b583668593c176ad..f502cda23105d2c83ec60d0f5364a6956e46853b 100644 (file)
@@ -108,7 +108,7 @@ DWORD process_wait_for_multiple_objects(
             continue;
             break;
           case WAIT_FAILED:
-            fprintf(stderr,"WaitForMultipleOjbects failed waiting with error %d\n", GetLastError());
+            fprintf(stderr,"WaitForMultipleOjbects failed waiting with error %lu\n", GetLastError());
             break;
           default:
             if (retVal >= WAIT_ABANDONED_0) {