diff --git a/doc/ChangeLog b/doc/ChangeLog
index 7da9595e..e028ad40 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,10 @@
+2008-06-13  Micah Cowan  <micah@cowan.name>
+
+	* wget.texi (Mailing List): The wget-notify mailing list no longer
+	receives commit notifications from the source repository.
+	(Internet Relay Chat): Activity isn't quite so low any more,
+	remove notice to that effect.
+
 2008-05-17  Steven Schubiger  <stsc@members.fsf.org>
 
 	* wget.texi (Download Options): Change documentation to reflect
diff --git a/doc/wget.texi b/doc/wget.texi
index 3e661a6f..83f97a37 100644
--- a/doc/wget.texi
+++ b/doc/wget.texi
@@ -3405,11 +3405,9 @@ The mailing list is archived at
 @url{http://news.gmane.org/gmane.comp.web.wget.patches}.
 
 Finally, there is the @email{wget-notify@@addictivecode.org} mailing
-list. This is a non-discussion list that receives commit notifications
-from the source repository, and also bug report-change notifications.
-This is the highest-traffic list for Wget, and is recommended only for
-people who are seriously interested in ongoing Wget development.
-Subscription is through the @code{mailman} interface at
+list. This is a non-discussion list that receives bug report-change
+notifications from the bug-tracker.  Unlike for the other mailing lists,
+subscription is through the @code{mailman} interface at
 @url{http://addictivecode.org/mailman/listinfo/wget-notify}.
 
 @node Internet Relay Chat
@@ -3418,9 +3416,8 @@ Subscription is through the @code{mailman} interface at
 @cindex IRC
 @cindex #wget
 
-While, at the time of this writing, there is very low activity, we do
-have a support channel set up via IRC at @code{irc.freenode.org},
-@code{#wget}. Come check it out!
+In addition to the mailinglists, we also have a support channel set up
+via IRC at @code{irc.freenode.org}, @code{#wget}. Come check it out!
 
 @node Reporting Bugs
 @section Reporting Bugs
diff --git a/src/ChangeLog b/src/ChangeLog
index 49c8506c..9af9267b 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,13 @@
+2008-06-13  Micah Cowan  <micah@cowan.name>
+
+	* build_info.c: ENABLE_NTLM, not HAVE_NTLM.
+
+2008-06-13  Madhusudan Hosaagrahara <com.gmail.hrmadhu>
+
+	* Makefile.am, main.c, init.c, init.h, build_info.c: Adds build
+	information to the --version command line option. Fixes bug
+	#20636.
+
 2008-06-01  Micah Cowan  <micah@cowan.name>
 
 	* main.c [WINDOWS]: Reopen stdout in binary mode, when -O - is
diff --git a/src/Makefile.am b/src/Makefile.am
index 45175491..c8485cfd 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -35,25 +35,32 @@ DEFS     = @DEFS@ -DSYSTEM_WGETRC=\"$(sysconfdir)/wgetrc\" -DLOCALEDIR=\"$(local
 LIBS     = @LIBSSL@ @LIBGNUTLS@ @LIBINTL@ @LIBS@
 
 bin_PROGRAMS = wget
-wget_SOURCES = cmpt.c connect.c convert.c cookies.c ftp.c ftp-basic.c	\
-	       ftp-ls.c hash.c host.c html-parse.c html-url.c http.c	\
-	       init.c log.c main.c netrc.c progress.c ptimer.c recur.c	\
-	       res.c retr.c snprintf.c spider.c url.c	\
-	       utils.c 				\
-	       connect.h convert.h cookies.h 		\
-	       ftp.h gen-md5.h hash.h host.h html-parse.h \
-	       http.h http-ntlm.h init.h log.h mswindows.h netrc.h \
-	       options.h progress.h ptimer.h recur.h res.h retr.h \
+wget_SOURCES = build_info.c cmpt.c connect.c convert.c cookies.c ftp.c    \
+	       ftp-basic.c ftp-ls.c hash.c host.c html-parse.c html-url.c \
+	       http.c init.c log.c main.c netrc.c progress.c ptimer.c     \
+	       recur.c res.c retr.c snprintf.c spider.c url.c	          \
+	       utils.c				          \
+	       connect.h convert.h cookies.h 		                  \
+	       ftp.h gen-md5.h hash.h host.h html-parse.h                 \
+	       http.h http-ntlm.h init.h log.h mswindows.h netrc.h        \
+	       options.h progress.h ptimer.h recur.h res.h retr.h         \
 	       spider.h ssl.h sysdep.h url.h utils.h wget.h
 nodist_wget_SOURCES = version.c
 EXTRA_wget_SOURCES = mswindows.c
 LDADD = $(LIBOBJS) ../lib/libgnu.a @MD5_LDADD@
 AM_CPPFLAGS = -I$(top_srcdir)/lib @MD5_CPPFLAGS@
 
+ESCAPEQUOTE = sed -e 's/[\\"]/\\&/g' -e 's/\\"/"/' -e 's/\\";$$/";/'
 version.c:  $(wget_SOURCES) $(LDADD) $(srcdir)/Makefile.am
-	echo 'const char *version_string = "@VERSION@"' > $@
-	-hg log -r . --template='" ({node|short})"\n' 2>/dev/null >> $@
+	echo '/* version.c */' > $@
+	echo '/* Autogenerated by Makefile - DO NOT EDIT */' >> $@
+	echo '' >> $@
+	echo -n 'char* version_string = "@VERSION@ ' >> $@
+	-hg log -r . --template=' ({node|short})"\n' 2>/dev/null >> $@
 	echo ';' >> $@
+	echo 'char* compilation_string = "'$(COMPILE)'";' | $(ESCAPEQUOTE) >> $@
+	echo 'char* link_string = "'$(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) $(LIBS) $(wget_LDADD)'";' | $(ESCAPEQUOTE) >> $@
 
 check_LIBRARIES = libunittest.a
 libunittest_a_SOURCES = $(wget_SOURCES) test.c test.h
diff --git a/src/build_info.c b/src/build_info.c
new file mode 100644
index 00000000..1ac682a7
--- /dev/null
+++ b/src/build_info.c
@@ -0,0 +1,107 @@
+/* This stores global variables that are initialized with 
+   preprocessor declarations for output with the --version flag.
+
+   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003,
+   2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+
+This file is part of GNU Wget.
+
+GNU Wget is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 3 of the License, or
+(at your option) any later version.
+
+GNU Wget is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with Wget.  If not, see <http://www.gnu.org/licenses/>.
+
+Additional permission under GNU GPL version 3 section 7
+
+If you modify this program, or any covered work, by linking or
+combining it with the OpenSSL project's OpenSSL library (or a
+modified version of that library), containing parts covered by the
+terms of the OpenSSL or SSLeay licenses, the Free Software Foundation
+grants you additional permission to convey the resulting work.
+Corresponding Source for a non-source form of such a combination
+shall include the source code for the parts of OpenSSL used as well
+as that of the covered work.  */
+
+#include "config.h"
+#include <stdio.h>
+
+char *system_wgetrc = SYSTEM_WGETRC;
+char *locale_dir = LOCALEDIR;
+
+const char* (compiled_features[]) =
+{
+
+#ifdef ENABLE_DIGEST
+  "+digest",
+#else
+  "-digest",
+#endif
+
+#ifdef ENABLE_IPV6
+  "+ipv6",
+#else
+  "-ipv6",
+#endif
+
+#ifdef ENABLE_NLS
+  "+nls",
+#else
+  "-nls",
+#endif
+
+#ifdef ENABLE_NTLM
+  "+ntlm",
+#else
+  "-ntlm",
+#endif
+
+#ifdef ENABLE_OPIE
+  "+opie",
+#else
+  "-opie",
+#endif
+
+#ifdef HAVE_MD5
+#ifdef HAVE_BUILTIN_MD5
+  "+md5/builtin", 
+#elif HAVE_OPENSSL_MD5
+  "+md5/openssl",
+#elif HAVE_SOLARIS_MD5
+  "+md5/solaris",
+#else
+#error "md5 set, but no library found!",
+#endif
+#else
+  "-md5",
+#endif
+
+#ifdef HAVE_LIBGNUTLS
+  "+gnutls",
+#else
+  "-gnutls",
+#endif
+
+#ifdef HAVE_LIBSSL
+  "+ssl",
+#else
+  "-ssl",
+#endif
+
+#ifdef HAVE_GETTEXT
+  "+gettext",
+#else
+  "-gettext",
+#endif
+  /* sentinel value */
+  NULL
+};
+
+
diff --git a/src/init.c b/src/init.c
index 2aa8e133..167c84fe 100644
--- a/src/init.c
+++ b/src/init.c
@@ -380,19 +380,14 @@ home_dir (void)
   return home ? xstrdup (home) : NULL;
 }
 
-/* Return the path to the user's .wgetrc.  This is either the value of
-   `WGETRC' environment variable, or `$HOME/.wgetrc'.
-
+/* Check the 'WGETRC' environment variable and return the file name 
+   if  'WGETRC' is set and is a valid file.  
    If the `WGETRC' variable exists but the file does not exist, the
    function will exit().  */
-static char *
-wgetrc_file_name (void)
+char *
+wgetrc_env_file_name (void) 
 {
-  char *env, *home;
-  char *file = NULL;
-
-  /* Try the environment.  */
-  env = getenv ("WGETRC");
+  char *env = getenv ("WGETRC");
   if (env && *env)
     {
       if (!file_exists_p (env))
@@ -403,12 +398,40 @@ wgetrc_file_name (void)
         }
       return xstrdup (env);
     }
-
-  /* If that failed, try $HOME/.wgetrc.  */
-  home = home_dir ();
+  return NULL;
+}
+/* Check for the existance of '$HOME/.wgetrc' and return it's path
+   if it exists and is set.  */
+char *
+wgetrc_user_file_name (void) 
+{
+  char *home = home_dir();
+  char *file = NULL;
   if (home)
     file = aprintf ("%s/.wgetrc", home);
   xfree_null (home);
+  if (!file)
+    return NULL;
+  if (!file_exists_p (file))
+    {
+      xfree (file);
+      return NULL;
+    }
+  return file;
+}
+/* Return the path to the user's .wgetrc.  This is either the value of
+   `WGETRC' environment variable, or `$HOME/.wgetrc'.
+
+   Additionally, for windows, look in the directory where wget.exe 
+   resides.  */
+char *
+wgetrc_file_name (void)
+{
+  char *file = wgetrc_env_file_name ();
+  if (file && *file)
+    return file;
+
+  file = wgetrc_user_file_name ();
 
 #ifdef WINDOWS
   /* Under Windows, if we still haven't found .wgetrc, look for the file
@@ -549,7 +572,7 @@ initialize (void)
   xfree (file);
   return;
 }
-
+
 /* Remove dashes and underscores from S, modifying S in the
    process. */
 
diff --git a/src/init.h b/src/init.h
index 923d988b..545f3405 100644
--- a/src/init.h
+++ b/src/init.h
@@ -31,6 +31,9 @@ as that of the covered work.  */
 #ifndef INIT_H
 #define INIT_H
 
+char *wgetrc_env_file_name (void);
+char *wgetrc_user_file_name (void);
+char *wgetrc_file_name (void);
 void initialize (void);
 void run_command (const char *);
 void setoptval (const char *, const char *, const char *);
diff --git a/src/main.c b/src/main.c
index 0727b1db..9b449438 100644
--- a/src/main.c
+++ b/src/main.c
@@ -68,7 +68,17 @@ as that of the covered work.  */
 
 struct options opt;
 
+/* defined in version.c */
 extern char *version_string;
+extern char *compilation_string;
+extern char *system_getrc;
+extern char *link_string;
+/* defined in build_info.c */
+extern char *compiled_features[];
+extern char *system_wgetrc;
+extern char *locale_dir;
+/* Used for --version output in print_version */
+static const int max_chars_per_line = 72;
 
 #if defined(SIGHUP) || defined(SIGUSR1)
 static void redirect_output_signal (int);
@@ -700,10 +710,111 @@ prompt_for_password (void)
   return getpass("");
 }
 
+/* Function that prints the line argument while limiting it
+   to at most line_length. prefix is printed on the first line
+   and an appropriate number of spaces are added on subsequent
+   lines.*/
+static void
+format_and_print_line (char* prefix, char* line,
+		       int line_length) 
+{
+  assert (prefix != NULL);
+  assert (line != NULL);
+
+  if (line_length <= 0)
+    line_length = max_chars_per_line;
+
+  const int leading_spaces = strlen (prefix);
+  printf ("%s", prefix);
+  int remaining_chars = line_length - leading_spaces;
+  /* We break on spaces. */
+  char* token = strtok (line, " ");
+  while (token != NULL) 
+    {
+      /* If however a token is much larger than the maximum
+         line length, all bets are off and we simply print the
+         token on the next line. */
+      if (remaining_chars <= strlen (token)) 
+        {
+          printf ("\n");
+          int j = 0;
+          for (j = 0; j < leading_spaces; j++) 
+            {
+              printf (" ");
+            }
+          remaining_chars = line_length - leading_spaces;
+        }
+      printf ("%s ", token);
+      remaining_chars -= strlen (token) + 1;  // account for " "
+      token = strtok (NULL, " ");
+    }
+
+  printf ("\n");
+  xfree (prefix);
+  xfree (line);
+}
+
 static void
 print_version (void)
 {
-  printf ("GNU Wget %s\n\n", version_string);
+  const char *options_title = "Options    : ";
+  const char *wgetrc_title  = "Wgetrc     : ";
+  const char *locale_title  = "Locale     : ";
+  const char *compile_title = "Compile    : ";
+  const char *link_title    = "Link       : ";
+  const char *prefix_spaces = "             ";
+  const int prefix_space_length = strlen (prefix_spaces);
+
+  printf ("GNU Wget %s\n", version_string);
+  printf (options_title);
+  /* compiled_features is a char*[]. We limit the characters per
+     line to max_chars_per_line and prefix each line with a constant
+     number of spaces for proper alignment. */
+  int i =0;
+  for (i = 0; compiled_features[i] != NULL; ) 
+    {
+      int line_length = max_chars_per_line - prefix_space_length;
+      while ((line_length > 0) && (compiled_features[i] != NULL)) 
+        {
+          printf ("%s ", compiled_features[i]);
+          line_length -= strlen (compiled_features[i]) + 2;
+          i++;
+        }
+      printf ("\n");
+      if (compiled_features[i] != NULL) 
+        {
+	  printf (prefix_spaces);
+        }
+    }
+  /* Handle the case when $WGETRC is unset and $HOME/.wgetrc is 
+     absent. */
+  printf (wgetrc_title);
+  char *env_wgetrc = wgetrc_env_file_name ();
+  if (env_wgetrc && *env_wgetrc) 
+    {
+      printf ("%s (env)\n%s", env_wgetrc, prefix_spaces);
+      xfree (env_wgetrc);
+    }
+  char *user_wgetrc = wgetrc_user_file_name ();
+  if (user_wgetrc) 
+    {
+      printf ("%s (user)\n%s", user_wgetrc, prefix_spaces);
+      xfree (user_wgetrc);
+    }
+  printf ("%s (system)\n", system_wgetrc);
+
+  format_and_print_line (strdup (locale_title),
+			 strdup (locale_dir), 
+			 max_chars_per_line);
+  
+  format_and_print_line (strdup (compile_title),
+			 strdup (compilation_string),
+			 max_chars_per_line);
+
+  format_and_print_line (strdup (link_title),
+			 strdup (link_string),
+			 max_chars_per_line);
+  printf ("\n");
   /* TRANSLATORS: When available, an actual copyright character
      (cirle-c) should be used in preference to "(C)". */
   fputs (_("\
@@ -721,7 +832,6 @@ There is NO WARRANTY, to the extent permitted by law.\n"), stdout);
          stdout);
   exit (0);
 }
-
 
 int
 main (int argc, char **argv)
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 73d93a2f..3efa37bf 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,41 @@
+2008-06-12  Micah Cowan  <micah@cowan.name>
+
+	* FTPServer.pm, FTPTest.pm, HTTPServer.pm, HTTPTest.pm,
+	Test--no-content-disposition-trivial.px,
+	Test--no-content-disposition.px, Test--spider-fail.px,
+	Test--spider-r--no-content-disposition-trivial.px,
+	Test--spider-r--no-content-disposition.px,
+	Test--spider-r-HTTP-Content-Disposition.px, Test--spider-r.px,
+	Test--spider.px, Test-E-k-K.px, Test-E-k.px,
+	Test-HTTP-Content-Disposition-1.px,
+	Test-HTTP-Content-Disposition-2.px,
+	Test-HTTP-Content-Disposition.px,
+	Test-N--no-content-disposition-trivial.px,
+	Test-N--no-content-disposition.px,
+	Test-N-HTTP-Content-Disposition.px, Test-N-current.px,
+	Test-N-no-info.px, Test-N-old.px, Test-N-smaller.px, Test-N.px,
+	Test-O--no-content-disposition-trivial.px,
+	Test-O--no-content-disposition.px,
+	Test-O-HTTP-Content-Disposition.px, Test-O-nonexisting.px,
+	Test-O.px, Test-Restrict-Lowercase.px,
+	Test-Restrict-Uppercase.px, Test-auth-basic.px, Test-c-full.px,
+	Test-c-partial.px, Test-c.px, Test-ftp.px,
+	Test-nonexisting-quiet.px, Test-noop.px, Test-np.px,
+	Test-proxied-https-auth.px, Test-proxy-auth-basic.px,
+	WgetTest.pm.in: Use whatever ports are available, rather than
+	hard-coded ones.
+
+	* run-px: More summary info, explicit exit code.
+
+	* Makefile.am: Reinstate "run-px-tests" as a dependency for the
+	"check" target.
+
+	* WgetTest.pm.in: Draw more attention to the fact that
+	WgetTest.pm is a generated file.
+
+	* Test-proxied-https-auth.px: Better cleanup, so next test can
+	open the port.
+
 2008-05-31  Micah Cowan  <micah@cowan.name>
 
 	* Test-N-current.px: Ensure we catch failures.
diff --git a/tests/FTPServer.pm b/tests/FTPServer.pm
index d8ad8b0c..8c7cada7 100644
--- a/tests/FTPServer.pm
+++ b/tests/FTPServer.pm
@@ -748,7 +748,7 @@ sub __wildcard_to_regex
 {
     my %_attr_data = ( # DEFAULT
         _localAddr  => 'localhost',
-        _localPort  => 8021,
+        _localPort  => undef,
         _reuseAddr  => 1,
         _rootDir    => Cwd::getcwd(),
     );
@@ -781,6 +781,16 @@ sub new {
             $self->{$attrname} = $self->_default_for($attrname);
         }
     }
+    # create server socket
+    "0" =~ /(0)/; # Perl 5.7 / IO::Socket::INET bug workaround.
+    $self->{_server_sock}
+                    = IO::Socket::INET->new (LocalHost => $self->{_localAddr},
+                                             LocalPort => $self->{_localPort},
+                                             Listen => 1,
+                                             Reuse => $self->{_reuseAddr},
+                                             Proto => 'tcp',
+                                             Type => SOCK_STREAM)
+                                        or die "bind: $!";
     return $self;
 }
 
@@ -803,21 +813,13 @@ sub run
     my $old_ils = $/;
     $/ = "\r\n";
 
-    # create server socket
-    "0" =~ /(0)/; # Perl 5.7 / IO::Socket::INET bug workaround.
-    my $server_sock = IO::Socket::INET->new (LocalHost => $self->{_localAddr},
-                                             LocalPort => $self->{_localPort},
-                                             Listen => 1,
-                                             Reuse => $self->{_reuseAddr},
-                                             Proto => 'tcp',
-                                             Type => SOCK_STREAM) or die "bind: $!";
-
     if (!$initialized) {
         $synch_callback->();
         $initialized = 1;
     }
 
     $SIG{CHLD} = sub { wait };
+    my $server_sock = $self->{_server_sock};
 
     # the accept loop
     while (my $client_addr = accept (my $socket, $server_sock))
@@ -929,6 +931,11 @@ sub run
     $/ = $old_ils;
 }
 
+sub sockport {
+    my $self = shift;
+    return $self->{_server_sock}->sockport;
+}
+
 1;
 
 # vim: et ts=4 sw=4
diff --git a/tests/FTPTest.pm b/tests/FTPTest.pm
index 0e9e0715..eed2eb89 100644
--- a/tests/FTPTest.pm
+++ b/tests/FTPTest.pm
@@ -44,18 +44,24 @@ sub _setup_server {
 
         close (FILE);
     }
+
+    $self->{_server} = FTPServer->new (LocalAddr => 'localhost',
+                                       ReuseAddr => 1,
+                                       rootDir => "$self->{_workdir}/$self->{_name}/input") or die "Cannot create server!!!";
 }
 
 
 sub _launch_server {
     my $self = shift;
     my $synch_func = shift;
+    $self->{_server}->run ($synch_func);
+}
 
-    my $server = FTPServer->new (LocalAddr => 'localhost',
-                                 LocalPort => '8021',
-                                 ReuseAddr => 1,
-                                 rootDir => "$self->{_workdir}/$self->{_name}/input") or die "Cannot create server!!!";
-    $server->run ($synch_func);
+sub _substitute_port {
+    my $self = shift;
+    my $ret = shift;
+    $ret =~ s/{{port}}/$self->{_server}->sockport/eg;
+    return $ret;
 }
 
 1;
diff --git a/tests/HTTPServer.pm b/tests/HTTPServer.pm
index a307b737..dbfa3ef1 100644
--- a/tests/HTTPServer.pm
+++ b/tests/HTTPServer.pm
@@ -120,6 +120,7 @@ sub send_response {
             next;
         }
         # fill in content
+        $content = $self->_substitute_port($content);
         $resp->content($content);
         print STDERR "HTTP::Response with content: \n", $resp->as_string if $log;
     }
@@ -207,6 +208,13 @@ sub verify_auth_basic {
     }
 }
 
+sub _substitute_port {
+    my $self = shift;
+    my $ret = shift;
+    $ret =~ s/{{port}}/$self->sockport/eg;
+    return $ret;
+}
+
 1;
 
 # vim: et ts=4 sw=4
diff --git a/tests/HTTPTest.pm b/tests/HTTPTest.pm
index cd4fb2e2..0fdcb8f0 100644
--- a/tests/HTTPTest.pm
+++ b/tests/HTTPTest.pm
@@ -30,17 +30,26 @@ my $VERSION = 0.01;
 }
     
 
-sub _setup_server {}
+sub _setup_server {
+    my $self = shift;
+    $self->{_server} = HTTPServer->new (LocalAddr => 'localhost',
+                                        ReuseAddr => 1)
+                                    or die "Cannot create server!!!";
+}
 
 
 sub _launch_server {
     my $self = shift;
     my $synch_func = shift;
 
-    my $server = HTTPServer->new (LocalAddr => 'localhost',
-                                  LocalPort => '8080',
-                                  ReuseAddr => 1) or die "Cannot create server!!!";
-    $server->run ($self->{_input}, $synch_func);
+    $self->{_server}->run ($self->{_input}, $synch_func);
+}
+
+sub _substitute_port {
+    my $self = shift;
+    my $ret = shift;
+    $ret =~ s/{{port}}/$self->{_server}->sockport/eg;
+    return $ret;
 }
 
 1;
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 85369828..27f9adaa 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -37,7 +37,7 @@ PERLRUN = $(PERL) -I$(srcdir)
 
 check-local: test
 
-test: ../src/wget$(EXEEXT) run-unit-tests #run-px-tests
+test: ../src/wget$(EXEEXT) run-unit-tests run-px-tests
 
 ../src/wget$(EXEEXT):
 	cd ../src && $(MAKE) $(AM_MAKEFLAGS)
diff --git a/tests/Test--no-content-disposition-trivial.px b/tests/Test--no-content-disposition-trivial.px
index 1d64125a..6a5b1def 100755
--- a/tests/Test--no-content-disposition-trivial.px
+++ b/tests/Test--no-content-disposition-trivial.px
@@ -32,7 +32,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " --no-content-disposition http://localhost:8080/dummy.html";
+my $cmdline = $WgetTest::WGETPATH . " --no-content-disposition http://localhost:{{port}}/dummy.html";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test--no-content-disposition.px b/tests/Test--no-content-disposition.px
index d5433f00..4975913b 100755
--- a/tests/Test--no-content-disposition.px
+++ b/tests/Test--no-content-disposition.px
@@ -33,7 +33,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " --no-content-disposition http://localhost:8080/dummy.html";
+my $cmdline = $WgetTest::WGETPATH . " --no-content-disposition http://localhost:{{port}}/dummy.html";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test--spider-fail.px b/tests/Test--spider-fail.px
index c5a299d1..b30ef755 100755
--- a/tests/Test--spider-fail.px
+++ b/tests/Test--spider-fail.px
@@ -32,7 +32,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " --spider http://localhost:8080/nonexistent";
+my $cmdline = $WgetTest::WGETPATH . " --spider http://localhost:{{port}}/nonexistent";
 
 my $expected_error_code = 256;
 
diff --git a/tests/Test--spider-r--no-content-disposition-trivial.px b/tests/Test--spider-r--no-content-disposition-trivial.px
index 0e290c28..1e850d40 100755
--- a/tests/Test--spider-r--no-content-disposition-trivial.px
+++ b/tests/Test--spider-r--no-content-disposition-trivial.px
@@ -14,8 +14,8 @@ my $mainpage = <<EOF;
 </head>
 <body>
   <p>
-    Some text and a link to a <a href="http://localhost:8080/secondpage.html">second page</a>.
-    Also, a <a href="http://localhost:8080/nonexistent">broken link</a>.
+    Some text and a link to a <a href="http://localhost:{{port}}/secondpage.html">second page</a>.
+    Also, a <a href="http://localhost:{{port}}/nonexistent">broken link</a>.
   </p>
 </body>
 </html>
@@ -28,8 +28,8 @@ my $secondpage = <<EOF;
 </head>
 <body>
   <p>
-    Some text and a link to a <a href="http://localhost:8080/thirdpage.html">third page</a>.
-    Also, a <a href="http://localhost:8080/nonexistent">broken link</a>.
+    Some text and a link to a <a href="http://localhost:{{port}}/thirdpage.html">third page</a>.
+    Also, a <a href="http://localhost:{{port}}/nonexistent">broken link</a>.
   </p>
 </body>
 </html>
@@ -42,8 +42,8 @@ my $thirdpage = <<EOF;
 </head>
 <body>
   <p>
-    Some text and a link to a <a href="http://localhost:8080/dummy.txt">text file</a>.
-    Also, another <a href="http://localhost:8080/againnonexistent">broken link</a>.
+    Some text and a link to a <a href="http://localhost:{{port}}/dummy.txt">text file</a>.
+    Also, another <a href="http://localhost:{{port}}/againnonexistent">broken link</a>.
   </p>
 </body>
 </html>
@@ -89,7 +89,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " --spider -r --no-content-disposition http://localhost:8080/";
+my $cmdline = $WgetTest::WGETPATH . " --spider -r --no-content-disposition http://localhost:{{port}}/";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test--spider-r--no-content-disposition.px b/tests/Test--spider-r--no-content-disposition.px
index 0e3c00ed..4eba8579 100755
--- a/tests/Test--spider-r--no-content-disposition.px
+++ b/tests/Test--spider-r--no-content-disposition.px
@@ -14,8 +14,8 @@ my $mainpage = <<EOF;
 </head>
 <body>
   <p>
-    Some text and a link to a <a href="http://localhost:8080/secondpage.html">second page</a>.
-    Also, a <a href="http://localhost:8080/nonexistent">broken link</a>.
+    Some text and a link to a <a href="http://localhost:{{port}}/secondpage.html">second page</a>.
+    Also, a <a href="http://localhost:{{port}}/nonexistent">broken link</a>.
   </p>
 </body>
 </html>
@@ -28,8 +28,8 @@ my $secondpage = <<EOF;
 </head>
 <body>
   <p>
-    Some text and a link to a <a href="http://localhost:8080/thirdpage.html">third page</a>.
-    Also, a <a href="http://localhost:8080/nonexistent">broken link</a>.
+    Some text and a link to a <a href="http://localhost:{{port}}/thirdpage.html">third page</a>.
+    Also, a <a href="http://localhost:{{port}}/nonexistent">broken link</a>.
   </p>
 </body>
 </html>
@@ -42,8 +42,8 @@ my $thirdpage = <<EOF;
 </head>
 <body>
   <p>
-    Some text and a link to a <a href="http://localhost:8080/dummy.txt">text file</a>.
-    Also, another <a href="http://localhost:8080/againnonexistent">broken link</a>.
+    Some text and a link to a <a href="http://localhost:{{port}}/dummy.txt">text file</a>.
+    Also, another <a href="http://localhost:{{port}}/againnonexistent">broken link</a>.
   </p>
 </body>
 </html>
@@ -90,7 +90,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " --spider -r --no-content-disposition http://localhost:8080/";
+my $cmdline = $WgetTest::WGETPATH . " --spider -r --no-content-disposition http://localhost:{{port}}/";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test--spider-r-HTTP-Content-Disposition.px b/tests/Test--spider-r-HTTP-Content-Disposition.px
index e70f6b40..09f93fa3 100755
--- a/tests/Test--spider-r-HTTP-Content-Disposition.px
+++ b/tests/Test--spider-r-HTTP-Content-Disposition.px
@@ -14,8 +14,8 @@ my $mainpage = <<EOF;
 </head>
 <body>
   <p>
-    Some text and a link to a <a href="http://localhost:8080/secondpage.html">second page</a>.
-    Also, a <a href="http://localhost:8080/nonexistent">broken link</a>.
+    Some text and a link to a <a href="http://localhost:{{port}}/secondpage.html">second page</a>.
+    Also, a <a href="http://localhost:{{port}}/nonexistent">broken link</a>.
   </p>
 </body>
 </html>
@@ -28,8 +28,8 @@ my $secondpage = <<EOF;
 </head>
 <body>
   <p>
-    Some text and a link to a <a href="http://localhost:8080/thirdpage.html">third page</a>.
-    Also, a <a href="http://localhost:8080/nonexistent">broken link</a>.
+    Some text and a link to a <a href="http://localhost:{{port}}/thirdpage.html">third page</a>.
+    Also, a <a href="http://localhost:{{port}}/nonexistent">broken link</a>.
   </p>
 </body>
 </html>
@@ -42,8 +42,8 @@ my $thirdpage = <<EOF;
 </head>
 <body>
   <p>
-    Some text and a link to a <a href="http://localhost:8080/dummy.txt">text file</a>.
-    Also, another <a href="http://localhost:8080/againnonexistent">broken link</a>.
+    Some text and a link to a <a href="http://localhost:{{port}}/dummy.txt">text file</a>.
+    Also, another <a href="http://localhost:{{port}}/againnonexistent">broken link</a>.
   </p>
 </body>
 </html>
@@ -90,7 +90,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " --spider -r http://localhost:8080/";
+my $cmdline = $WgetTest::WGETPATH . " --spider -r http://localhost:{{port}}/";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test--spider-r.px b/tests/Test--spider-r.px
index 7b8d460f..a315d974 100755
--- a/tests/Test--spider-r.px
+++ b/tests/Test--spider-r.px
@@ -14,8 +14,8 @@ my $mainpage = <<EOF;
 </head>
 <body>
   <p>
-    Some text and a link to a <a href="http://localhost:8080/secondpage.html">second page</a>.
-    Also, a <a href="http://localhost:8080/nonexistent">broken link</a>.
+    Some text and a link to a <a href="http://localhost:{{port}}/secondpage.html">second page</a>.
+    Also, a <a href="http://localhost:{{port}}/nonexistent">broken link</a>.
   </p>
 </body>
 </html>
@@ -28,8 +28,8 @@ my $secondpage = <<EOF;
 </head>
 <body>
   <p>
-    Some text and a link to a <a href="http://localhost:8080/thirdpage.html">third page</a>.
-    Also, a <a href="http://localhost:8080/nonexistent">broken link</a>.
+    Some text and a link to a <a href="http://localhost:{{port}}/thirdpage.html">third page</a>.
+    Also, a <a href="http://localhost:{{port}}/nonexistent">broken link</a>.
   </p>
 </body>
 </html>
@@ -42,8 +42,8 @@ my $thirdpage = <<EOF;
 </head>
 <body>
   <p>
-    Some text and a link to a <a href="http://localhost:8080/dummy.txt">text file</a>.
-    Also, another <a href="http://localhost:8080/againnonexistent">broken link</a>.
+    Some text and a link to a <a href="http://localhost:{{port}}/dummy.txt">text file</a>.
+    Also, another <a href="http://localhost:{{port}}/againnonexistent">broken link</a>.
   </p>
 </body>
 </html>
@@ -89,7 +89,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " --spider -r http://localhost:8080/";
+my $cmdline = $WgetTest::WGETPATH . " --spider -r http://localhost:{{port}}/";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test--spider.px b/tests/Test--spider.px
index f412c762..dbc97135 100755
--- a/tests/Test--spider.px
+++ b/tests/Test--spider.px
@@ -32,7 +32,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " --spider http://localhost:8080/index.html";
+my $cmdline = $WgetTest::WGETPATH . " --spider http://localhost:{{port}}/index.html";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test-E-k-K.px b/tests/Test-E-k-K.px
index 71d51ea1..d71c39e5 100755
--- a/tests/Test-E-k-K.px
+++ b/tests/Test-E-k-K.px
@@ -13,7 +13,7 @@ my $mainpage = <<EOF;
   <title>Main Page Title</title>
 </head>
 <body>
-  <a href="http://localhost:8080/subpage.php">Secondary Page</a>
+  <a href="http://localhost:{{port}}/subpage.php">Secondary Page</a>
 </body>
 </html>
 EOF
@@ -60,7 +60,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " -d -r -nd -E -k -K http://localhost:8080/index.php";
+my $cmdline = $WgetTest::WGETPATH . " -d -r -nd -E -k -K http://localhost:{{port}}/index.php";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test-E-k.px b/tests/Test-E-k.px
index 3bf441df..4581ed71 100755
--- a/tests/Test-E-k.px
+++ b/tests/Test-E-k.px
@@ -13,7 +13,7 @@ my $mainpage = <<EOF;
   <title>Main Page Title</title>
 </head>
 <body>
-  <a href="http://localhost:8080/subpage.php">Secondary Page</a>
+  <a href="http://localhost:{{port}}/subpage.php">Secondary Page</a>
 </body>
 </html>
 EOF
@@ -60,7 +60,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " -r -nd -E -k http://localhost:8080/index.php";
+my $cmdline = $WgetTest::WGETPATH . " -r -nd -E -k http://localhost:{{port}}/index.php";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test-HTTP-Content-Disposition-1.px b/tests/Test-HTTP-Content-Disposition-1.px
index ffc9eb25..01fb0901 100755
--- a/tests/Test-HTTP-Content-Disposition-1.px
+++ b/tests/Test-HTTP-Content-Disposition-1.px
@@ -37,7 +37,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " -e contentdisposition=on http://localhost:8080/dummy.html";
+my $cmdline = $WgetTest::WGETPATH . " -e contentdisposition=on http://localhost:{{port}}/dummy.html";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test-HTTP-Content-Disposition-2.px b/tests/Test-HTTP-Content-Disposition-2.px
index 03eb2bee..46c16a17 100755
--- a/tests/Test-HTTP-Content-Disposition-2.px
+++ b/tests/Test-HTTP-Content-Disposition-2.px
@@ -37,7 +37,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " --no-content-disposition http://localhost:8080/dummy.html";
+my $cmdline = $WgetTest::WGETPATH . " --no-content-disposition http://localhost:{{port}}/dummy.html";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test-HTTP-Content-Disposition.px b/tests/Test-HTTP-Content-Disposition.px
index 0f4b285b..3b6eb2c9 100755
--- a/tests/Test-HTTP-Content-Disposition.px
+++ b/tests/Test-HTTP-Content-Disposition.px
@@ -33,7 +33,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " -e contentdisposition=on http://localhost:8080/dummy.html";
+my $cmdline = $WgetTest::WGETPATH . " -e contentdisposition=on http://localhost:{{port}}/dummy.html";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test-N--no-content-disposition-trivial.px b/tests/Test-N--no-content-disposition-trivial.px
index 390d369b..c58f451a 100755
--- a/tests/Test-N--no-content-disposition-trivial.px
+++ b/tests/Test-N--no-content-disposition-trivial.px
@@ -24,7 +24,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " -N --no-content-disposition http://localhost:8080/dummy.txt";
+my $cmdline = $WgetTest::WGETPATH . " -N --no-content-disposition http://localhost:{{port}}/dummy.txt";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test-N--no-content-disposition.px b/tests/Test-N--no-content-disposition.px
index dbec7c67..78fe522f 100755
--- a/tests/Test-N--no-content-disposition.px
+++ b/tests/Test-N--no-content-disposition.px
@@ -25,7 +25,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " -N --no-content-disposition http://localhost:8080/dummy.txt";
+my $cmdline = $WgetTest::WGETPATH . " -N --no-content-disposition http://localhost:{{port}}/dummy.txt";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test-N-HTTP-Content-Disposition.px b/tests/Test-N-HTTP-Content-Disposition.px
index 42aa39ad..32f87710 100755
--- a/tests/Test-N-HTTP-Content-Disposition.px
+++ b/tests/Test-N-HTTP-Content-Disposition.px
@@ -26,7 +26,7 @@ my %urls = (
 );
 
 my $cmdline = $WgetTest::WGETPATH . " -N --content-disposition "
-              . "http://localhost:8080/dummy.txt";
+              . "http://localhost:{{port}}/dummy.txt";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test-N-current.px b/tests/Test-N-current.px
index 16086ae8..b8e05a94 100755
--- a/tests/Test-N-current.px
+++ b/tests/Test-N-current.px
@@ -33,7 +33,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " -N http://localhost:8080/somefile.txt";
+my $cmdline = $WgetTest::WGETPATH . " -N http://localhost:{{port}}/somefile.txt";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test-N-no-info.px b/tests/Test-N-no-info.px
index bd83f644..301a9101 100755
--- a/tests/Test-N-no-info.px
+++ b/tests/Test-N-no-info.px
@@ -32,7 +32,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " -N http://localhost:8080/somefile.txt";
+my $cmdline = $WgetTest::WGETPATH . " -N http://localhost:{{port}}/somefile.txt";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test-N-old.px b/tests/Test-N-old.px
index ee9a84e0..6ae116e5 100755
--- a/tests/Test-N-old.px
+++ b/tests/Test-N-old.px
@@ -31,7 +31,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " -N http://localhost:8080/somefile.txt";
+my $cmdline = $WgetTest::WGETPATH . " -N http://localhost:{{port}}/somefile.txt";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test-N-smaller.px b/tests/Test-N-smaller.px
index 9ad44c29..71e34d96 100755
--- a/tests/Test-N-smaller.px
+++ b/tests/Test-N-smaller.px
@@ -34,7 +34,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " -N http://localhost:8080/somefile.txt";
+my $cmdline = $WgetTest::WGETPATH . " -N http://localhost:{{port}}/somefile.txt";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test-N.px b/tests/Test-N.px
index 61069875..2e235e08 100755
--- a/tests/Test-N.px
+++ b/tests/Test-N.px
@@ -24,7 +24,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " -N http://localhost:8080/dummy.txt";
+my $cmdline = $WgetTest::WGETPATH . " -N http://localhost:{{port}}/dummy.txt";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test-O--no-content-disposition-trivial.px b/tests/Test-O--no-content-disposition-trivial.px
index be25960c..501fd44d 100755
--- a/tests/Test-O--no-content-disposition-trivial.px
+++ b/tests/Test-O--no-content-disposition-trivial.px
@@ -23,7 +23,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " -O out --no-content-disposition http://localhost:8080/dummy.txt";
+my $cmdline = $WgetTest::WGETPATH . " -O out --no-content-disposition http://localhost:{{port}}/dummy.txt";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test-O--no-content-disposition.px b/tests/Test-O--no-content-disposition.px
index 47cab071..592f0fec 100755
--- a/tests/Test-O--no-content-disposition.px
+++ b/tests/Test-O--no-content-disposition.px
@@ -24,7 +24,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " -O out --no-content-disposition http://localhost:8080/dummy.txt";
+my $cmdline = $WgetTest::WGETPATH . " -O out --no-content-disposition http://localhost:{{port}}/dummy.txt";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test-O-HTTP-Content-Disposition.px b/tests/Test-O-HTTP-Content-Disposition.px
index b0a5aa40..934f54aa 100755
--- a/tests/Test-O-HTTP-Content-Disposition.px
+++ b/tests/Test-O-HTTP-Content-Disposition.px
@@ -24,7 +24,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " -O out http://localhost:8080/dummy.txt";
+my $cmdline = $WgetTest::WGETPATH . " -O out http://localhost:{{port}}/dummy.txt";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test-O-nonexisting.px b/tests/Test-O-nonexisting.px
index 347dc38e..89744fc8 100755
--- a/tests/Test-O-nonexisting.px
+++ b/tests/Test-O-nonexisting.px
@@ -23,7 +23,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " --quiet -O out http://localhost:8080/nonexistent";
+my $cmdline = $WgetTest::WGETPATH . " --quiet -O out http://localhost:{{port}}/nonexistent";
 
 my $expected_error_code = 256;
 
diff --git a/tests/Test-O.px b/tests/Test-O.px
index e584d060..1f4e8efe 100755
--- a/tests/Test-O.px
+++ b/tests/Test-O.px
@@ -23,7 +23,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " -O out http://localhost:8080/dummy.txt";
+my $cmdline = $WgetTest::WGETPATH . " -O out http://localhost:{{port}}/dummy.txt";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test-Restrict-Lowercase.px b/tests/Test-Restrict-Lowercase.px
index fab08d43..2b35f1e4 100755
--- a/tests/Test-Restrict-Lowercase.px
+++ b/tests/Test-Restrict-Lowercase.px
@@ -32,7 +32,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " --restrict-file-names=lowercase http://localhost:8080/SomePage.html";
+my $cmdline = $WgetTest::WGETPATH . " --restrict-file-names=lowercase http://localhost:{{port}}/SomePage.html";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test-Restrict-Uppercase.px b/tests/Test-Restrict-Uppercase.px
index cefa1722..14fa81f4 100755
--- a/tests/Test-Restrict-Uppercase.px
+++ b/tests/Test-Restrict-Uppercase.px
@@ -32,7 +32,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " --restrict-file-names=uppercase http://localhost:8080/SomePage.html";
+my $cmdline = $WgetTest::WGETPATH . " --restrict-file-names=uppercase http://localhost:{{port}}/SomePage.html";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test-auth-basic.px b/tests/Test-auth-basic.px
index 527d4200..75013609 100755
--- a/tests/Test-auth-basic.px
+++ b/tests/Test-auth-basic.px
@@ -25,7 +25,7 @@ my %urls = (
 );
 
 my $cmdline = $WgetTest::WGETPATH . " --user=fiddle-dee-dee --password=Dodgson"
-    . " http://localhost:8080/needs-auth.txt";
+    . " http://localhost:{{port}}/needs-auth.txt";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test-c-full.px b/tests/Test-c-full.px
index bb9304b9..f277a023 100755
--- a/tests/Test-c-full.px
+++ b/tests/Test-c-full.px
@@ -27,7 +27,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " -c http://localhost:8080/somefile.txt";
+my $cmdline = $WgetTest::WGETPATH . " -c http://localhost:{{port}}/somefile.txt";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test-c-partial.px b/tests/Test-c-partial.px
index ddf1d4be..02234242 100755
--- a/tests/Test-c-partial.px
+++ b/tests/Test-c-partial.px
@@ -37,7 +37,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " -c http://localhost:8080/somefile.txt";
+my $cmdline = $WgetTest::WGETPATH . " -c http://localhost:{{port}}/somefile.txt";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test-c.px b/tests/Test-c.px
index 58b45f72..8c61eb06 100755
--- a/tests/Test-c.px
+++ b/tests/Test-c.px
@@ -27,7 +27,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " -c http://localhost:8080/somefile.txt";
+my $cmdline = $WgetTest::WGETPATH . " -c http://localhost:{{port}}/somefile.txt";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test-ftp.px b/tests/Test-ftp.px
index 5925e38b..8cef5a55 100755
--- a/tests/Test-ftp.px
+++ b/tests/Test-ftp.px
@@ -21,7 +21,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " -S ftp://localhost:8021/afile.txt";
+my $cmdline = $WgetTest::WGETPATH . " -S ftp://localhost:{{port}}/afile.txt";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test-nonexisting-quiet.px b/tests/Test-nonexisting-quiet.px
index 45f24390..2766b5c5 100755
--- a/tests/Test-nonexisting-quiet.px
+++ b/tests/Test-nonexisting-quiet.px
@@ -23,7 +23,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " --quiet http://localhost:8080/nonexistent";
+my $cmdline = $WgetTest::WGETPATH . " --quiet http://localhost:{{port}}/nonexistent";
 
 my $expected_error_code = 256;
 
diff --git a/tests/Test-noop.px b/tests/Test-noop.px
index e45c8af3..14bd851c 100755
--- a/tests/Test-noop.px
+++ b/tests/Test-noop.px
@@ -33,7 +33,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " http://localhost:8080/";
+my $cmdline = $WgetTest::WGETPATH . " http://localhost:{{port}}/";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test-np.px b/tests/Test-np.px
index 8a14b32d..28d13eec 100755
--- a/tests/Test-np.px
+++ b/tests/Test-np.px
@@ -14,7 +14,7 @@ my $mainpage = <<EOF;
 </head>
 <body>
   <p>
-    Some text and a link to a <a href="http://localhost:8080/firstlevel/secondpage.html">second page</a>.
+    Some text and a link to a <a href="http://localhost:{{port}}/firstlevel/secondpage.html">second page</a>.
   </p>
 </body>
 </html>
@@ -27,7 +27,7 @@ my $secondpage = <<EOF;
 </head>
 <body>
   <p>
-    Some text and a link to a <a href="http://localhost:8080/firstlevel/lowerlevel/thirdpage.html">third page</a>.
+    Some text and a link to a <a href="http://localhost:{{port}}/firstlevel/lowerlevel/thirdpage.html">third page</a>.
   </p>
 </body>
 </html>
@@ -40,7 +40,7 @@ my $thirdpage = <<EOF;
 </head>
 <body>
   <p>
-    Some text and a link to a <a href="http://localhost:8080/higherlevelpage.html">higher level page</a>.
+    Some text and a link to a <a href="http://localhost:{{port}}/higherlevelpage.html">higher level page</a>.
   </p>
 </body>
 </html>
@@ -69,7 +69,7 @@ my $higherlevelpage = <<EOF;
   <p>
     This page is on a higher level in the URL path hierarchy. Therefore, it
     should not be downloaded. Wget should not visit the following link to a 
-    <a href="http://localhost:8080/firstlevel/fourthpage.html">fourth page</a>.
+    <a href="http://localhost:{{port}}/firstlevel/fourthpage.html">fourth page</a>.
   </p>
 </body>
 </html>
@@ -119,7 +119,7 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " -np -nH -r http://localhost:8080/firstlevel/";
+my $cmdline = $WgetTest::WGETPATH . " -np -nH -r http://localhost:{{port}}/firstlevel/";
 
 my $expected_error_code = 0;
 
diff --git a/tests/Test-proxied-https-auth.px b/tests/Test-proxied-https-auth.px
index 22606589..b732d553 100755
--- a/tests/Test-proxied-https-auth.px
+++ b/tests/Test-proxied-https-auth.px
@@ -87,15 +87,16 @@ sub fork_server {
 }
 
 system ('rm -f needs-auth.txt');
-&fork_server;
+my $pid = &fork_server;
 
 sleep 1;
 my $cmdline = $WgetTest::WGETPATH . " --user=fiddle-dee-dee"
-    . " --password=Dodgson -e https_proxy=localhost:8080"
+    . " --password=Dodgson -e https_proxy=localhost:{{port}}"
     . " --no-check-certificate"
     . " https://no.such.domain/needs-auth.txt";
 
 my $code = system($cmdline);
 
 warn "Got code: $code\n" if $code;
+kill ('TERM', $pid);
 exit $code;
diff --git a/tests/Test-proxy-auth-basic.px b/tests/Test-proxy-auth-basic.px
index 5566e22f..e440a392 100755
--- a/tests/Test-proxy-auth-basic.px
+++ b/tests/Test-proxy-auth-basic.px
@@ -25,7 +25,7 @@ my %urls = (
 );
 
 my $cmdline = $WgetTest::WGETPATH . " --debug --user=fiddle-dee-dee --password=Dodgson"
-    . " -e http_proxy=localhost:8080 http://no.such.domain/needs-auth.txt";
+    . " -e http_proxy=localhost:{{port}} http://no.such.domain/needs-auth.txt";
 
 my $expected_error_code = 0;
 
diff --git a/tests/WgetTest.pm.in b/tests/WgetTest.pm.in
index 915759df..910ac80d 100644
--- a/tests/WgetTest.pm.in
+++ b/tests/WgetTest.pm.in
@@ -1,5 +1,9 @@
 #!/usr/bin/perl -w
 
+# WARNING!
+# WgetTest.pm is a generated file! Do not edit! Edit WgetTest.pm.in
+# instead.
+
 package WgetTest;
 $VERSION = 0.01;
 
@@ -78,11 +82,13 @@ sub run {
     
     # Call wget
     chdir ("$self->{_workdir}/$self->{_name}/output");
-    # print "Calling $self->{_cmdline}\n";
+    my $cmdline = $self->{_cmdline};
+    $cmdline = $self->_substitute_port($cmdline);
+    print "Calling $cmdline\n";
     my $errcode = 
-        ($self->{_cmdline} =~ m{^/.*}) 
-            ? system ($self->{_cmdline})
-            : system ("$self->{_workdir}/../src/$self->{_cmdline}");
+        ($cmdline =~ m{^/.*}) 
+            ? system ($cmdline)
+            : system ("$self->{_workdir}/../src/$cmdline");
 
     # Shutdown server
     # if we didn't explicitely kill the server, we would have to call 
@@ -166,7 +172,9 @@ sub _verify_download {
             or return "Test failed: file $filename not downloaded\n";
         
         my $content = <FILE>;
-        $content eq $filedata->{'content'} 
+        my $expected_content = $filedata->{'content'};
+        $expected_content = $self->_substitute_port($expected_content);
+        $content eq $expected_content
             or return "Test failed: wrong content for file $filename\n";
 
         if (exists($filedata->{'timestamp'})) {
diff --git a/tests/run-px b/tests/run-px
index febb0de4..37f14324 100755
--- a/tests/run-px
+++ b/tests/run-px
@@ -61,3 +61,10 @@ for (my $i=0; $i != @tests; ++$i) {
     }
     print "$tests[$i]\n";
 }
+
+print "\n";
+print scalar(@results) . " tests were run\n";
+print scalar(grep $_ == 0, @results) . " PASS\n";
+print scalar(grep $_ != 0, @results) . " FAIL\n";
+
+exit scalar (grep $_ != 0, @results);