bug-wget
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-wget] Re: Compilation in Visual Studio 8 (and against msvcrt.dl


From: Keisial
Subject: Re: [Bug-wget] Re: Compilation in Visual Studio 8 (and against msvcrt.dll)
Date: Tue, 08 Sep 2009 16:59:44 +0200
User-agent: Thunderbird 2.0.0.21 (Windows/20090302)

Keisial wrote:
> Note that mainline doesn't build on mingw either.
> Mainly due to gnulibzation.
>
> I have local modifications that fix some of the issues, but aren't complete.
>   
I have finished the missing bits.

Short fix: The attached patch.

Long story: See below for the list of errors and decisions taken.
> configure --mingw
Type mingw32-make to start compiling.

> mingw32-make
"test" not recognised as an internal or external command, program or
executable batch file.
System cannot find specified path.
process_begin: CreateProcess((null), cat ./.prev-version, ...) failed.
sed: cannot read ./cfg.mk: No such file or directory
 avoid_if_before_free
Unexpected -f
mingw32-make: *** [sc_avoid_if_before_free] Error 255

Since mingw32-make is a GNU make, it is reading GNUmakefile, which is
tailored to Unix systems.
The text should be upgraded.

> mingw32-make -f Makefile
-----------------------------------------------------------
= If you would like to build WGET.EXE without SSL support,
= please issue the following commands.
=  [1] cd src
=  [2] mingw32-make
=  [3] cd ..
= --------------------
= If you would like to build WGET.EXE with SSL support,
= please follow the instructions below.
=  [1] cd src
=  [2] Check the value of OPENSSL_PATH in Makefile and
=      correct it if it is not the OpenSSL installed directory.
=  [3] mingw32-make SSL=1
=  [4] cd ..
-----------------------------------------------------------
-----------------------------------------------------------
= Please issue the following commands to obtain WGET.HLP.
=  [1] cd doc
=  [2] mingw32-make
=  [3] cd ..
-----------------------------------------------------------

> cd src
> mingw32-make
mingw32-make: *** No rule to make target `config-post.h', needed by
`cmpt.o'.
top.

This was a dead end, but then I found at the top of windows\ChangeLog
2008-09-09  Gisle Vanem  <address@hidden>
        * config.h: config-post.h is gone. SIZEOF_LONG_LONG is 8.

So it wasn't needed, although config-post.h is still referred in
windows\Makefile.src*
After I removed such references, the problem moved to getopt.

> mingw32-make
mingw32-make: *** No rule to make target `getopt.h', needed by
`cmpt.o'.  Stop.

On 1.11 getopt was present on src. However, on mainline it has been
moved to lib, with changeset
http://hg.addictivecode.org/wget/mainline/rev/a026a5d46fa0 again,
without changing the generated makefiles.

Then, it was time for gnu-md5, safe-ctype, and xmalloc to be missing,
per http://hg.addictivecode.org/wget/mainline/rev/f72e8fd5abb5 and
http://hg.addictivecode.org/wget/mainline/rev/6db0ca5800c0

In order to create getopt.h and alloca.h, which are (needlessly?) in the
form of .in.h I added them as prerequisites to $(OBJS) and added the
following rule:
../lib/%.h: ../lib/%.in.h
    cd ..\lib && type "$^" > $@

type and shell redirection was used instead of copy because copy doesn't
like paths using the forward slash. Even type works badly trying to
access the file on current dir instead of using the full path, which is
workarounded with the directory change on the subshell.

The next error was:
gcc -DWINDOWS -DHAVE_CONFIG_H -O3 -Wall -I. -I../lib   -c -o host.o host.c
host.c:67: error: conflicting types for 'WSAGetLastError'
 ../lib/gcc/mingw32/3.4.5/../../../../include/winsock.h:461: error:
previous declaration of 'WSAGetLastError' was here
host.c:67: error: conflicting types for 'WSAGetLastError'
 ../lib/gcc/mingw32/3.4.5/../../../../include/winsock.h:461: error:
previous declaration of 'WSAGetLastError' was here

This is due to the fact that my winsock.h header from mingw w32api contain
#define h_errno WSAGetLastError()
and host.c contains:
#if !HAVE_DECL_H_ERRNO
extern int h_errno;
#endif

I have several winsock.h versions from Microsoft and they also define
h_errno to WSAGetLastError(). So I defined HAVE_DECL_H_ERRNO in
windows/config.h



Then it was time for getpass() and LOCALEDIR.
main.c: In function `prompt_for_password':
main.c:731: warning: implicit declaration of function `getpass'
main.c:731: warning: return makes pointer from integer without a cast
main.c: In function `print_version':
main.c:829: error: `LOCALEDIR' undeclared (first use in this function)
main.c:829: error: (Each undeclared identifier is reported only once
main.c:829: error: for each function it appears in.)
main.c:784: warning: unused variable `line'

Windows doesn't have getpass(), but it is provided by gnulib.
However, getpass.h only gives the prototype if HAVE_DECL_GETPASS is defined
to 0. It's a bit strange that it isn't produced it if it isn't defined.
I fixed the LOCALEDIR error by #ifdefing ENABLE_NLS that line, where it
was used
just for printing the locale with --version

Finally, the object paths for getopt.o, c-ctype.o and xmalloc.o needed
to be adjusted.

And last, version.c was missing (Makefile.am use to generate it, see
http://hg.addictivecode.org/wget/mainline/rev/3a93eeabc77f) so I added a
target for it too.
I added the actual version as a static string, to avoid a dependacy on
m4. Would be nice if there was an easy way to extract it from
configure.ac, though.

Finally, there were the linking errors.
*Remove getopt.c because it was already defined on libmingwex.a
*Add to the object lists from lib folder xalloc-die.c, quote.c,
exitfail.c, quotearg.c, error.c
*Add from src folder css-url.c and exits.c
*Generate a dummy build_info.c to fix the undefined reference to
`compiled_features'
*Add flex rule for css.l

diff -r 4935b01fc20d src/main.c
--- a/src/main.c        Tue Sep 08 01:16:08 2009 -0700
+++ b/src/main.c        Tue Sep 08 16:24:54 2009 +0200
@@ -815,6 +815,7 @@
       printf (_("    %s (env)\n"), env_wgetrc);
       xfree (env_wgetrc);
     }
+
   user_wgetrc = wgetrc_user_file_name ();
   if (user_wgetrc) 
     {
@@ -825,17 +826,25 @@
   printf (_("    %s (system)\n"), SYSTEM_WGETRC);
 #endif
 
+#ifdef ENABLE_NLS
   format_and_print_line (locale_title,
                         LOCALEDIR, 
                         MAX_CHARS_PER_LINE);
+#endif                  
   
-  format_and_print_line (compile_title,
-                        compilation_string,
-                        MAX_CHARS_PER_LINE);
+  if (compilation_string)
+    {        
+      format_and_print_line (compile_title,
+                        compilation_string,
+                        MAX_CHARS_PER_LINE);
+    }
 
-  format_and_print_line (link_title,
+  if (link_string)
+    {
+      format_and_print_line (link_title,
                         link_string,
                         MAX_CHARS_PER_LINE);
+    }
 
   printf ("\n");
   /* TRANSLATORS: When available, an actual copyright character
diff -r 4935b01fc20d windows/Makefile.src
--- a/windows/Makefile.src      Tue Sep 08 01:16:08 2009 -0700
+++ b/windows/Makefile.src      Tue Sep 08 16:24:54 2009 +0200
@@ -84,7 +84,7 @@
        $(LD) @<< $(LDFLAGS) /out:$@ $(OBJ) $(LIBS)
 <<
 
-$(OBJ): config-post.h config.h connect.h convert.h cookies.h ftp.h \
+$(OBJ): config.h connect.h convert.h cookies.h ftp.h \
         gen-md5.h getopt.h gnu-md5.h hash.h host.h html-parse.h    \
         http-ntlm.h init.h log.h mswindows.h netrc.h options.h     \
         progress.h ptimer.h recur.h res.h retr.h safe-ctype.h      \
diff -r 4935b01fc20d windows/Makefile.src.bor
--- a/windows/Makefile.src.bor  Tue Sep 08 01:16:08 2009 -0700
+++ b/windows/Makefile.src.bor  Tue Sep 08 16:24:54 2009 +0200
@@ -61,7 +61,7 @@
 
 |
 
-$(OBJS): config-post.h config.h connect.h convert.h cookies.h ftp.h \
+$(OBJS): config.h connect.h convert.h cookies.h ftp.h \
         gen-md5.h getopt.h gnu-md5.h hash.h host.h html-parse.h    \
         http-ntlm.h init.h log.h mswindows.h netrc.h options.h     \
         progress.h ptimer.h recur.h res.h retr.h safe-ctype.h      \
diff -r 4935b01fc20d windows/Makefile.src.mingw
--- a/windows/Makefile.src.mingw        Tue Sep 08 01:16:08 2009 -0700
+++ b/windows/Makefile.src.mingw        Tue Sep 08 16:24:54 2009 +0200
@@ -16,17 +16,19 @@
 
 CC=gcc
 LDFLAGS= -s
-CFLAGS= -DWINDOWS -DHAVE_CONFIG_H -O3 -Wall -I.
+CFLAGS= -DWINDOWS -DHAVE_CONFIG_H -O3 -Wall -I. -I../lib -I../md5
 
 ## variables
 LIBS= -lwsock32
 OBJ_EXT=.o
 OBJS=cmpt${OBJ_EXT} convert${OBJ_EXT} connect${OBJ_EXT} ftp${OBJ_EXT} 
ftp-basic${OBJ_EXT} \
-     ftp-ls${OBJ_EXT} ftp-opie${OBJ_EXT} getopt${OBJ_EXT} host${OBJ_EXT} 
html-parse${OBJ_EXT} html-url${OBJ_EXT} \
-     http${OBJ_EXT} init${OBJ_EXT} log${OBJ_EXT} main${OBJ_EXT} 
gnu-md5${OBJ_EXT} netrc${OBJ_EXT} \
-     safe-ctype${OBJ_EXT} hash${OBJ_EXT} progress${OBJ_EXT} gen-md5${OBJ_EXT} 
cookies${OBJ_EXT} \
+     ftp-ls${OBJ_EXT} ftp-opie${OBJ_EXT} host${OBJ_EXT} html-parse${OBJ_EXT} 
html-url${OBJ_EXT} \
+     http${OBJ_EXT} init${OBJ_EXT} log${OBJ_EXT} main${OBJ_EXT} 
../md5/md5${OBJ_EXT} netrc${OBJ_EXT} \
+     ../lib/c-ctype${OBJ_EXT} hash${OBJ_EXT} progress${OBJ_EXT} 
gen-md5${OBJ_EXT} cookies${OBJ_EXT} \
      ptimer${OBJ_EXT} recur${OBJ_EXT} res${OBJ_EXT} retr${OBJ_EXT} 
url${OBJ_EXT} utils${OBJ_EXT} \
-     version${OBJ_EXT} xmalloc${OBJ_EXT} mswindows${OBJ_EXT} spider${OBJ_EXT}
+     version${OBJ_EXT} ../lib/xmalloc${OBJ_EXT} ../lib/xalloc-die${OBJ_EXT} 
../lib/quote${OBJ_EXT} \
+     ../lib/exitfail${OBJ_EXT} ../lib/quotearg${OBJ_EXT} 
../lib/error${OBJ_EXT} ../lib/getpass${OBJ_EXT} \
+     mswindows${OBJ_EXT} spider${OBJ_EXT} css-url${OBJ_EXT} exits${OBJ_EXT} 
build_info${OBJ_EXT} css${OBJ_EXT}
 
 ifdef SSL
     ## OPENSSL_PATH is the OpenSSL installed directory
@@ -41,10 +43,31 @@
 wget.exe: $(OBJS)
        ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS}
 
-$(OBJS): config-post.h config.h connect.h convert.h cookies.h ftp.h \
-        gen-md5.h getopt.h gnu-md5.h hash.h host.h html-parse.h    \
+$(OBJS): config.h connect.h convert.h cookies.h ftp.h \
+        gen-md5.h hash.h host.h html-parse.h    \
         http-ntlm.h init.h log.h mswindows.h netrc.h options.h     \
-        progress.h ptimer.h recur.h res.h retr.h safe-ctype.h      \
-        spider.h ssl.h sysdep.h url.h utils.h wget.h xmalloc.h
+        progress.h ptimer.h recur.h res.h retr.h       \
+        spider.h ssl.h sysdep.h url.h utils.h wget.h \
+        ../lib/getopt.h ../lib/alloca.h 
+
+../lib/%.h: ../lib/%.in.h 
+       cd ..\lib && type "$^" > $@
+
+version.c:
+       echo /* version.c */ > $@
+       echo /* Autogenerated by Makefile - DO NOT EDIT */ >> $@
+       echo #include ^<stdio.h^> >> $@ 
+       echo const char *version_string = "1.12-devel" >> $@
+       -hg log -r . --template=" ({node|short})"\n
+       echo ; >> $@
+       echo const char *compilation_string = NULL; >> $@
+       echo const char *link_string = NULL; >> $@
+
+build_info.c:
+       echo #include ^<stdio.h^> > $@
+       echo const char* compiled_features[] = { NULL }; >> $@
+
+%.c: %.l
+       flex -8 -o$@ $^
 
 o = ${OBJ_EXT}
diff -r 4935b01fc20d windows/config.h
--- a/windows/config.h  Tue Sep 08 01:16:08 2009 -0700
+++ b/windows/config.h  Tue Sep 08 16:24:54 2009 +0200
@@ -192,6 +192,12 @@
 /* Define for large files, on AIX-style hosts. */
 /* #undef _LARGE_FILES */
 
+/* winsock defines h_errno to WSAGetLastError() */
+#define HAVE_DECL_H_ERRNO 1
+
+/* getpass.h need this */
+#define HAVE_DECL_GETPASS 0
+
 /* Define to empty if `const' does not conform to ANSI C. */
 /* #undef const */
 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]