Here are some patches that I made to get Wget to compile with Mingw:
1: Puts $LIB variable after other libraries, so $LIB can specify
libraries that Open SSL needs.
2: Avoids using symlinks, and conditionally compiles mswindows.c using
a Make flag. I guess there's a better way to do this with Autotools
but I don't know how. (I'm not a huge fan of Autotools.)
3: Set stdout to binary mode.
4: Merge of #3 with 1 and 2 and release 1.11 code.
There are 3 changes in the "mainline" Mercurial repository that are
meant to fix the binary stdout issue, but because they use freopen
they're no good if you actually want to redirect output, etc. So I
think you should use my change instead of these:
5f807d16a269db03a3c451f2933bc1e155984cb5
9112e488960986583af74ad7f0825754a225da5e
da7d4cf3465c8517cd8884f8aea23a0fe3b772cd
I case anyone's interested, these are the commands I used to build
Wget with using mingw/msys:
PREFIX=k:
rm -f autom4te.cache/traces.0 # otherwise things don't get regenerated!
./autogen.sh
# Wget should check the more standard "_WIN32" macro rather than "WINDOWS"?
# Autotools wants to link directly to the static Open SSL library files
# rather than simply specifying the library names (which should automatically
# prefer the DLLs).
./configure \
CPPFLAGS="-D WINDOWS" LIBS="-lws2_32 -lgdi32" \
--disable-nls \
--with-ssl --with-libssl-prefix="$PREFIX"
make WINDOWS=yes
Also, it looks like the wiki page for patches says to send patches to
an old mailing list address:
http://wget.addictivecode.org/PatchGuidelines
The mailing lists page said to use this list instead.
http://wget.addictivecode.org/MailingLists
# HG changeset patch
# User Martin Panter <vadmium `a gmail.com>
# Date 1240738907 0
# Branch trunk
# Node ID dfcf5d9243218fb557cb03e7abafd6d89e858e4d
# Parent 0c1cfe100028421dc5c755d06b26bc292020b461
Put general LIBS at end of list.
diff -r 0c1cfe100028 -r dfcf5d924321 ChangeLog
--- a/ChangeLog Sun Jun 29 19:14:17 2008 -0700
+++ b/ChangeLog Sun Apr 26 09:41:47 2009 +0000
@@ -1,3 +1,7 @@
+2009-04-26 Martin Panter <vadmium `a gmail.com>
+
+ * m4/lib-link.m4, Makefile.in: Put general LIBS at end of list.
+
2008-06-29 Micah Cowan <[email protected]>
* po/*.po: Sync with TP.
diff -r 0c1cfe100028 -r dfcf5d924321 Makefile.in
--- a/Makefile.in Sun Jun 29 19:14:17 2008 -0700
+++ b/Makefile.in Sun Apr 26 09:41:47 2009 +0000
@@ -58,7 +58,7 @@
CFLAGS = @CFLAGS@
CPPFLAGS = @CPPFLAGS@
DEFS = @DEFS@ -DSYSTEM_WGETRC=\"$(sysconfdir)/wgetrc\"
-DLOCALEDIR=\"$(localedir)\"
-LIBS = @LIBS@ @LIBSSL@ @LIBGNUTLS@
+LIBS = @LIBSSL@ @LIBGNUTLS@ @LIBS@
LDFLAGS = @LDFLAGS@
#
diff -r 0c1cfe100028 -r dfcf5d924321 m4/lib-link.m4
--- a/m4/lib-link.m4 Sun Jun 29 19:14:17 2008 -0700
+++ b/m4/lib-link.m4 Sun Apr 26 09:41:47 2009 +0000
@@ -67,7 +67,7 @@
AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
ac_save_LIBS="$LIBS"
- LIBS="$LIBS $LIB[]NAME"
+ LIBS="$LIB[]NAME $LIBS"
AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no])
LIBS="$ac_save_LIBS"
])
# HG changeset patch
# User Martin Panter <vadmium `a gmail.com>
# Date 1240741093 0
# Branch trunk
# Node ID 49dced1d2e1667cfe1f99112a0091ff2db68a366
# Parent dfcf5d9243218fb557cb03e7abafd6d89e858e4d
On Windows, don't use symlinks, and do compile mswindows.c.
diff -r dfcf5d924321 -r 49dced1d2e16 src/ChangeLog
--- a/src/ChangeLog Sun Apr 26 09:41:47 2009 +0000
+++ b/src/ChangeLog Sun Apr 26 10:18:13 2009 +0000
@@ -1,3 +1,9 @@
+2009-04-26 Martin Panter <vadmium `a gmail.com>
+
+ * ftp.c (ftp_retrieve_list): Don't use symlinks on Windows despite
+ what Autotools says.
+ * Makefile.in: Compile mswindows.c when WINDOWS defined.
+
2008-06-29 Micah Cowan <[email protected]>
* version.c: Bumped version to 1.11.4.
diff -r dfcf5d924321 -r 49dced1d2e16 src/Makefile.in
--- a/src/Makefile.in Sun Apr 26 09:41:47 2009 +0000
+++ b/src/Makefile.in Sun Apr 26 10:18:13 2009 +0000
@@ -80,6 +80,10 @@
res.o retr.o safe-ctype.o snprintf.o spider.o $(SSL_OBJ) \
url.o utils.o version.o xmalloc.o
+ifdef WINDOWS
+ OBJ += mswindows.o
+endif
+
.SUFFIXES:
.SUFFIXES: .c .o
diff -r dfcf5d924321 -r 49dced1d2e16 src/ftp.c
--- a/src/ftp.c Sun Apr 26 09:41:47 2009 +0000
+++ b/src/ftp.c Sun Apr 26 10:18:13 2009 +0000
@@ -1468,7 +1468,7 @@
follow them. */
if (!opt.retr_symlinks)
{
-#ifdef HAVE_SYMLINK
+#if defined HAVE_SYMLINK && !defined WINDOWS
if (!f->linkto)
logputs (LOG_NOTQUIET,
_("Invalid name of the symlink, skipping.\n"));
@@ -1504,11 +1504,11 @@
logprintf (LOG_NOTQUIET, "symlink: %s\n", strerror
(errno));
logputs (LOG_VERBOSE, "\n");
} /* have f->linkto */
-#else /* not HAVE_SYMLINK */
+#else /* !HAVE_SYMLINK || WINDOWS */
logprintf (LOG_NOTQUIET,
_("Symlinks not supported, skipping symlink `%s'.\n"),
con->target);
-#endif /* not HAVE_SYMLINK */
+#endif /* HAVE_SYMLINK && !WINDOWS */
}
else /* opt.retr_symlinks */
{
# HG changeset patch
# User Martin Panter <vadmium `a gmail.com>
# Date 1241274234 0
# Branch trunk
# Node ID 9c6d1a4622b21d3298548b14a0aeca3ed8dba4b2
# Parent c7cd37207957c82ab20fc018b9c8e5c5273a0664
Set stdout to binary mode for "-O -" on Windows.
diff -r c7cd37207957 -r 9c6d1a4622b2 src/ChangeLog
--- a/src/ChangeLog Fri Jul 14 06:25:50 2006 -0700
+++ b/src/ChangeLog Sat May 02 14:23:54 2009 +0000
@@ -1,3 +1,7 @@
+2009-05-02 Martin Panter <vadmium `a gmail.com>
+
+ * main.c (main) [_WIN32]: Set stdout to binary mode for "-O -".
+
2006-07-14 Mauro Tortonesi <[email protected]>
* sysdep.h: If intptr_t isn't defined, simply typedef it to long.
diff -r c7cd37207957 -r 9c6d1a4622b2 src/main.c
--- a/src/main.c Fri Jul 14 06:25:50 2006 -0700
+++ b/src/main.c Sat May 02 14:23:54 2009 +0000
@@ -56,6 +56,11 @@
/* On GNU system this will include system-wide getopt.h. */
#include "getopt.h"
+#ifdef _WIN32 /* need to change stdout to binary mode */
+# include <io.h>
+# include <fcntl.h>
+#endif
+
#ifndef PATH_SEPARATOR
# define PATH_SEPARATOR '/'
#endif
@@ -917,7 +922,12 @@
if (opt.output_document)
{
if (HYPHENP (opt.output_document))
- output_stream = stdout;
+ {
+ output_stream = stdout;
+#ifdef _WIN32
+ _setmode (_fileno (output_stream), _O_BINARY);
+#endif
+ }
else
{
struct_fstat st;
# HG changeset patch
# User Martin Panter <vadmium `a gmail.com>
# Date 1241274500 0
# Branch trunk
# Node ID 2e9be192c46ccf635d9a5575ae998ebd6844140d
# Parent 49dced1d2e1667cfe1f99112a0091ff2db68a366
# Parent 9c6d1a4622b21d3298548b14a0aeca3ed8dba4b2
Merge: Binary mode for "-O -" using _setmode.
diff -r 49dced1d2e16 -r 2e9be192c46c src/ChangeLog
--- a/src/ChangeLog Sun Apr 26 10:18:13 2009 +0000
+++ b/src/ChangeLog Sat May 02 14:28:20 2009 +0000
@@ -1,3 +1,7 @@
+2009-05-02 Martin Panter <vadmium `a gmail.com>
+
+ * main.c (main) [_WIN32]: Set stdout to binary mode for "-O -".
+
2009-04-26 Martin Panter <vadmium `a gmail.com>
* ftp.c (ftp_retrieve_list): Don't use symlinks on Windows despite
diff -r 49dced1d2e16 -r 2e9be192c46c src/main.c
--- a/src/main.c Sun Apr 26 10:18:13 2009 +0000
+++ b/src/main.c Sat May 02 14:28:20 2009 +0000
@@ -59,6 +59,11 @@
/* On GNU system this will include system-wide getopt.h. */
#include "getopt.h"
+#ifdef _WIN32 /* need to change stdout to binary mode */
+# include <io.h>
+# include <fcntl.h>
+#endif
+
#ifndef PATH_SEPARATOR
# define PATH_SEPARATOR '/'
#endif
@@ -956,7 +961,12 @@
if (opt.output_document)
{
if (HYPHENP (opt.output_document))
- output_stream = stdout;
+ {
+ output_stream = stdout;
+#ifdef _WIN32
+ _setmode (_fileno (output_stream), _O_BINARY);
+#endif
+ }
else
{
struct_fstat st;