Tommy 碎碎念

Tommy Wu's blog

« 上一篇 | 下一篇 »

wget 1.12 的 win32/win64 版本
post by tommy @ 09 四月, 2011 10:57

雖然 wget 的 source tarball 裡頭, 有包含 windows 的支援, 不過... 似乎不能正常的編譯. 所以做了一些修正, 讓 mingw32/mingw64 可以正常的編譯.

首先是 mingw32 的部份, patch 如下:

diff --strip-trailing-cr -Nur wget-1.12.orig//configure wget-1.12/configure
--- wget-1.12.orig//configure 2009-09-23 00:40:13 +0800
+++ wget-1.12/configure 2011-04-09 10:38:36 +0800
@@ -25630,7 +25630,7 @@
 
 
cat >>confdefs.h <<\_ACEOF
-#define HAVE_SYMLINK 1
+//#define HAVE_SYMLINK 1
_ACEOF
 
 
@@ -27912,7 +27912,7 @@
else
 
ac_save_LIBS="$LIBS"
- LIBS="$LIBS $LIBSSL"
+ LIBS="$LIBS $LIBSSL -lws2_32 -lgdi32"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
diff --strip-trailing-cr -Nur wget-1.12.orig//src/Makefile.in wget-1.12/src/Makefile.in
--- wget-1.12.orig//src/Makefile.in 2009-09-23 00:40:11 +0800
+++ wget-1.12/src/Makefile.in 2011-04-09 10:38:36 +0800
@@ -170,7 +170,7 @@
ptimer.$(OBJEXT) recur.$(OBJEXT) res.$(OBJEXT) retr.$(OBJEXT) \
snprintf.$(OBJEXT) spider.$(OBJEXT) url.$(OBJEXT) \
utils.$(OBJEXT) exits.$(OBJEXT) build_info.$(OBJEXT) \
- $(am__objects_3)
+ $(am__objects_3) mswindows.$(OBJEXT)
nodist_wget_OBJECTS = version.$(OBJEXT)
wget_OBJECTS = $(am_wget_OBJECTS) $(nodist_wget_OBJECTS)
wget_LDADD = $(LDADD)
@@ -214,7 +214,7 @@
CYGPATH_W = @CYGPATH_W@
 
# The following line is losing on some versions of make!
-DEFS = @DEFS@ -DSYSTEM_WGETRC=\"$(sysconfdir)/wgetrc\" -DLOCALEDIR=\"$(localedir)\"
+DEFS = @DEFS@ -DSYSTEM_WGETRC=\"C:\\\\Windows\\\\wgetrc\" -DLOCALEDIR=\"$(localedir)\"
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
@@ -476,7 +476,7 @@
LIBMD5_LIBDEPS = @LIBMD5_LIBDEPS@
LIBMD5_LTLIBDEPS = @LIBMD5_LTLIBDEPS@
LIBOBJS = @LIBOBJS@
-LIBS = @LIBSSL@ @LIBGNUTLS@ @LIBICONV@ @LIBINTL@ @LIBS@
+LIBS = @LIBSSL@ @LIBGNUTLS@ @LIBICONV@ @LIBINTL@ @LIBS@ -lws2_32 -lgdi32
LIBSSL = @LIBSSL@
LIBSSL_PREFIX = @LIBSSL_PREFIX@
LOCALCHARSET_TESTS_ENVIRONMENT = @LOCALCHARSET_TESTS_ENVIRONMENT@
diff --strip-trailing-cr -Nur wget-1.12.orig//src/config.h.in wget-1.12/src/config.h.in
--- wget-1.12.orig//src/config.h.in 2009-09-23 00:40:33 +0800
+++ wget-1.12/src/config.h.in 2011-04-09 10:38:36 +0800
@@ -1,5 +1,7 @@
/* src/config.h.in. Generated from configure.ac by autoheader. */
 
+#define WINDOWS 1
+
/* Define if the compiler is building for multiple architectures of Apple
platforms at once. */
#undef AA_APPLE_UNIVERSAL_BUILD
diff --strip-trailing-cr -Nur wget-1.12.orig//src/ftp.c wget-1.12/src/ftp.c
--- wget-1.12.orig//src/ftp.c 2009-09-22 10:59:21 +0800
+++ wget-1.12/src/ftp.c 2011-04-09 10:38:36 +0800
@@ -63,6 +63,11 @@
#define LIST_FILENAME ".listing"
#endif
 
+/* windows is not support symlink */
+#ifdef WINDOWS
+#undef HAVE_SYMLINK
+#endif
+
typedef struct
{
int st; /* connection status */
diff --strip-trailing-cr -Nur wget-1.12.orig//src/host.c wget-1.12/src/host.c
--- wget-1.12.orig//src/host.c 2009-09-22 11:00:05 +0800
+++ wget-1.12/src/host.c 2011-04-09 10:38:36 +0800
@@ -64,7 +64,7 @@
#endif
 
#if !HAVE_DECL_H_ERRNO
-extern int h_errno;
+//extern int h_errno;
#endif
 
 
diff --strip-trailing-cr -Nur wget-1.12.orig//src/mswindows.c wget-1.12/src/mswindows.c
--- wget-1.12.orig//src/mswindows.c 2009-09-22 09:26:23 +0800
+++ wget-1.12/src/mswindows.c 2011-04-09 10:39:17 +0800
@@ -50,6 +50,10 @@
#define ES_CONTINUOUS 0x80000000
#endif
 
+// no usleep in mingw32
+#ifdef HAVE_USLEEP
+#undef HAVE_USLEEP
+#endif
 
/* Defined in log.c. */
void log_request_redirect_output (const char *);
diff --strip-trailing-cr -Nur wget-1.12.orig//src/mswindows.h wget-1.12/src/mswindows.h
--- wget-1.12.orig//src/mswindows.h 2009-09-05 00:31:54 +0800
+++ wget-1.12/src/mswindows.h 2011-04-09 10:38:36 +0800
@@ -163,6 +163,9 @@
/* Finally, provide a private version of strerror that does the
right thing with Winsock errors. */
#ifndef INHIBIT_WRAP
+# ifdef strerror
+# undef strerror
+# endif
# define strerror windows_strerror
#endif
const char *windows_strerror (int);

然後是 mingw64 的 patch 如下:

diff --strip-trailing-cr -Nur wget-1.12.orig//configure wget-1.12/configure
--- wget-1.12.orig//configure 2009-09-23 00:40:13 +0800
+++ wget-1.12/configure 2011-04-09 10:09:20 +0800
@@ -25630,7 +25630,7 @@
 
 
cat >>confdefs.h <<\_ACEOF
-#define HAVE_SYMLINK 1
+//#define HAVE_SYMLINK 1
_ACEOF
 
 
@@ -27912,7 +27912,7 @@
else
 
ac_save_LIBS="$LIBS"
- LIBS="$LIBS $LIBSSL"
+ LIBS="$LIBS $LIBSSL -lws2_32 -lgdi32"
cat >conftest.$ac_ext <<_ACEOF
/* confdefs.h. */
_ACEOF
diff --strip-trailing-cr -Nur wget-1.12.orig//src/Makefile.in wget-1.12/src/Makefile.in
--- wget-1.12.orig//src/Makefile.in 2009-09-23 00:40:11 +0800
+++ wget-1.12/src/Makefile.in 2011-04-09 10:09:46 +0800
@@ -170,7 +170,7 @@
ptimer.$(OBJEXT) recur.$(OBJEXT) res.$(OBJEXT) retr.$(OBJEXT) \
snprintf.$(OBJEXT) spider.$(OBJEXT) url.$(OBJEXT) \
utils.$(OBJEXT) exits.$(OBJEXT) build_info.$(OBJEXT) \
- $(am__objects_3)
+ $(am__objects_3) mswindows.$(OBJEXT)
nodist_wget_OBJECTS = version.$(OBJEXT)
wget_OBJECTS = $(am_wget_OBJECTS) $(nodist_wget_OBJECTS)
wget_LDADD = $(LDADD)
@@ -214,7 +214,7 @@
CYGPATH_W = @CYGPATH_W@
 
# The following line is losing on some versions of make!
-DEFS = @DEFS@ -DSYSTEM_WGETRC=\"$(sysconfdir)/wgetrc\" -DLOCALEDIR=\"$(localedir)\"
+DEFS = @DEFS@ -DSYSTEM_WGETRC=\"C:\\\\Windows\\\\wgetrc\" -DLOCALEDIR=\"$(localedir)\"
DEPDIR = @DEPDIR@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
@@ -476,7 +476,7 @@
LIBMD5_LIBDEPS = @LIBMD5_LIBDEPS@
LIBMD5_LTLIBDEPS = @LIBMD5_LTLIBDEPS@
LIBOBJS = @LIBOBJS@
-LIBS = @LIBSSL@ @LIBGNUTLS@ @LIBICONV@ @LIBINTL@ @LIBS@
+LIBS = @LIBSSL@ @LIBGNUTLS@ @LIBICONV@ @LIBINTL@ @LIBS@ -lws2_32 -lgdi32
LIBSSL = @LIBSSL@
LIBSSL_PREFIX = @LIBSSL_PREFIX@
LOCALCHARSET_TESTS_ENVIRONMENT = @LOCALCHARSET_TESTS_ENVIRONMENT@
diff --strip-trailing-cr -Nur wget-1.12.orig//src/config.h.in wget-1.12/src/config.h.in
--- wget-1.12.orig//src/config.h.in 2009-09-23 00:40:33 +0800
+++ wget-1.12/src/config.h.in 2011-04-09 10:09:20 +0800
@@ -1,5 +1,7 @@
/* src/config.h.in. Generated from configure.ac by autoheader. */
 
+#define WINDOWS 1
+
/* Define if the compiler is building for multiple architectures of Apple
platforms at once. */
#undef AA_APPLE_UNIVERSAL_BUILD
diff --strip-trailing-cr -Nur wget-1.12.orig//src/ftp.c wget-1.12/src/ftp.c
--- wget-1.12.orig//src/ftp.c 2009-09-22 10:59:21 +0800
+++ wget-1.12/src/ftp.c 2011-04-09 10:09:20 +0800
@@ -63,6 +63,11 @@
#define LIST_FILENAME ".listing"
#endif
 
+/* windows is not support symlink */
+#ifdef WINDOWS
+#undef HAVE_SYMLINK
+#endif
+
typedef struct
{
int st; /* connection status */
diff --strip-trailing-cr -Nur wget-1.12.orig//src/mswindows.h wget-1.12/src/mswindows.h
--- wget-1.12.orig//src/mswindows.h 2009-09-05 00:31:54 +0800
+++ wget-1.12/src/mswindows.h 2011-04-09 10:08:58 +0800
@@ -163,6 +163,9 @@
/* Finally, provide a private version of strerror that does the
right thing with Winsock errors. */
#ifndef INHIBIT_WRAP
+# ifdef strerror
+# undef strerror
+# endif
# define strerror windows_strerror
#endif
const char *windows_strerror (int);

所使用的 ssl 是 openssl, 如果是用 gnutls 的話, 也許也可以用吧.

如果你只要執行檔的部份, 可以抓下面這個檔案 (包含 win32 與 win64  的版本, 也包含上頭兩個 patch):
http://www.teatime.com.tw/~tommy/files/wget-1.12-windows.7z

在我的機器上, 我常用的幾個功能跑起來都正常, 不過... 我沒有測所有的功能, 所以... 不保證你也能正常使用.
Del.icio.us Furl HEMiDEMi Technorati MyShare
迴響
暱稱:
標題:
個人網頁:
電子郵件:
authimage

迴響

  

Bad Behavior 已經阻擋了 60 個過去 7 天試圖闖關的垃圾迴響與引用。
Power by LifeType. Template design by JamesHuang. Valid XHTML and CSS