logo       
Google Custom Search
    AddThis Social Bookmark Button

Patches for building Wget with Mingw32: msg#00082

Subject: Patches for building Wget with Mingw32
I have built Wget on Mingw32 using MSYS to run configure.
I had to manually edit the Makefiles and (since I have Emacs) am using the 
Info documentation.
The changes to the Makefile consisted of changing DEFS to "-DWINDOWS 
-DHAVE_CONFIG_H" and adding "-lwsock32" to LIBS.
Below is a unified diff of my changes to the code (I hope AOL doesn't mangle 
this.):

--- src/ftp.c.orig  2002-05-17 22:05:16.000000000 -0500
+++ src/ftp.c   2003-07-28 13:55:50.000000000 -0500
@@ -837,9 +837,15 @@
      /* This will silently fail for streams that don't correspond
         to regular files, but that's OK.  */
      rewind (fp);
+#if !defined(WINDOWS) || !defined(__GNUC__)
      /* ftruncate is needed because opt.dfp is opened in append
         mode if opt.always_rest is set.  */
      ftruncate (fileno (fp), 0);
+#else /* GCC on Windows (Mingw32) */
+     /* SetEndOfFile is like ftruncate, but the second
+        argument to ftruncate is taken from the file pointer.  */
+     SetEndOfFile ((HANDLE) _get_osfhandle (_fileno (fp)));
+#endif
      clearerr (fp);
    }
     }
--- src/http.c.orig 2002-05-18 22:04:54.000000000 -0500
+++ src/http.c  2003-07-28 13:56:16.000000000 -0500
@@ -1356,9 +1356,15 @@
      /* This will silently fail for streams that don't correspond
         to regular files, but that's OK.  */
      rewind (fp);
+#if !defined(WINDOWS) || !defined(__GNUC__)
      /* ftruncate is needed because opt.dfp is opened in append
         mode if opt.always_rest is set.  */
      ftruncate (fileno (fp), 0);
+#else /* GCC on Windows (Mingw32) */
+     /* SetEndOfFile is like ftruncate, but the second
+        argument to ftruncate is taken from the file pointer.  */
+     SetEndOfFile ((HANDLE) _get_osfhandle (_fileno (fp)));
+#endif
      clearerr (fp);
    }
     }
--- src/init.c.orig 2002-05-17 22:05:20.000000000 -0500
+++ src/init.c  2003-07-25 18:29:54.000000000 -0500
@@ -192,7 +192,9 @@
   { "sslcertkey",  &opt.sslcertkey,    cmd_file },
   { "egdfile",     &opt.sslegdsock,    cmd_file },
 #endif /* HAVE_SSL */
+#ifdef HAVE_SELECT
   { "timeout",     &opt.timeout,       cmd_time },
+#endif /* HAVE_SELECT */
   { "timestamping",    &opt.timestamping,  cmd_boolean },
   { "tries",       &opt.ntry,      cmd_number_inf },
   { "useproxy",        &opt.use_proxy,     cmd_boolean },
--- src/main.c.orig 2002-05-17 22:05:20.000000000 -0500
+++ src/main.c  2003-07-25 19:19:12.000000000 -0500
@@ -87,7 +87,9 @@
 void log_close PARAMS ((void));
 void log_request_redirect_output PARAMS ((const char *));
 
+#ifdef HAVE_SIGNAL
 static RETSIGTYPE redirect_output_signal PARAMS ((int));
+#endif /* HAVE_SIGNAL */
 
 const char *exec_name;
 
--- src/mswindows.c.orig    2002-05-17 22:05:20.000000000 -0500
+++ src/mswindows.c 2003-07-25 20:16:32.000000000 -0500
@@ -81,7 +81,7 @@
   HKEY result;
   DWORD size = *len;
   DWORD type = REG_SZ;
-  if (RegOpenKeyEx (hkey, subkey, NULL, KEY_READ, &result) != ERROR_SUCCESS)
+  if (RegOpenKeyEx (hkey, subkey, 0L, KEY_READ, &result) != ERROR_SUCCESS)
     return NULL;
   if (RegQueryValueEx (result, valuename, NULL, &type, buf, &size) != 
ERROR_SUCCESS)
     buf = NULL;
@@ -123,7 +123,7 @@
   int changedp = 0;
 
   if (!opt.lfilename)
-    {
+    {/* GCC 2.95.2 warns about this but I don't know why */
       opt.lfilename = unique_name (DEFAULT_LOGFILE);
       changedp = 1;
     }
@@ -210,7 +210,7 @@
       if (stat (buf, &sbuf) == 0) 
    {
           printf (_("Starting WinHelp %s\n"), buf);
-          WinHelp (NULL, buf, HELP_INDEX, NULL);
+          WinHelp (NULL, buf, HELP_INDEX, (DWORD) NULL);
         }
       else
         {
--- src/sysdep.h.orig   2002-05-17 22:05:22.000000000 -0500
+++ src/sysdep.h    2003-07-28 13:44:54.000000000 -0500
@@ -53,6 +53,10 @@
    their declarations, as well as some additional declarations and
    macros.  This must come first, so it can set things up.  */
 #include <mswindows.h>
+/* This should never hurt on Windows, and is needed with Mingw32
+   for http.c and ftp.c.  Putting it here just seems more
+   appropriate.  */
+#include <io.h>
 #endif /* WINDOWS */
 
 /* Watcom-specific stuff.  In practice this is probably specific to
--- src/utils.c.orig    2002-05-17 22:05:22.000000000 -0500
+++ src/utils.c 2003-07-25 20:00:48.000000000 -0500
@@ -1504,8 +1504,13 @@
   SYSTEMTIME st;
   GetSystemTime (&st);
   SystemTimeToFileTime (&st, &ft);
+#ifndef __GNUC__
   wt->wintime.HighPart = ft.dwHighDateTime;
   wt->wintime.LowPart  = ft.dwLowDateTime;
+#else
+  wt->wintime.u.HighPart = ft.dwHighDateTime;
+  wt->wintime.u.LowPart  = ft.dwLowDateTime;
+#endif
 #endif
 }
 
@@ -1527,14 +1532,19 @@
   return 1000 * (now - wt->secs);
 #endif
 
-#ifdef WINDOWS
+#ifdef TIMER_WINDOWS
   FILETIME ft;
   SYSTEMTIME st;
   ULARGE_INTEGER uli;
   GetSystemTime (&st);
   SystemTimeToFileTime (&st, &ft);
+#ifndef __GNUC__
   uli.HighPart = ft.dwHighDateTime;
   uli.LowPart = ft.dwLowDateTime;
+#else
+  uli.u.HighPart = ft.dwHighDateTime;
+  uli.u.LowPart = ft.dwLowDateTime;
+#endif
   return (long)((uli.QuadPart - wt->wintime.QuadPart) / 10000);
 #endif
 }




Try Searching:
servers, voip, java, networking, microsoft ...
<Prev in Thread] Current Thread [Next in Thread>