Base code merged to SPIN 2.4
[platform/upstream/curl.git] / tests / testcurl.pl
index 2a2a2c7..8c804e4 100755 (executable)
@@ -6,7 +6,7 @@
 #                            | (__| |_| |  _ <| |___
 #                             \___|\___/|_| \_\_____|
 #
-# Copyright (C) 1998 - 2005, Daniel Stenberg, <daniel@haxx.se>, et al.
+# Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
 #
 # This software is licensed as described in the file COPYING, which
 # you should have received as part of this distribution. The terms
 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
 # KIND, either express or implied.
 #
-# $Id$
 ###########################################################################
 
 ###########################
 #  What is This Script?
 ###########################
 
-# testcurl.pl is the master script to use for automatic testing of CVS-curl.
+# testcurl.pl is the master script to use for automatic testing of curl
+# directly off its source repository.
 # This is written for the purpose of being run from a crontab job or similar
 # at a regular interval. The output is suitable to be mailed to
 # curl-autocompile@haxx.se to be dealt with automatically (make sure the
 # --crosscompile           This is a crosscompile
 # --desc=[desc]            Description of your test system
 # --email=[email]          Set email address to report as
+# --extvercmd=[command]    Command to use for displaying version with cross compiles.
 # --mktarball=[command]    Command to run after completed test
 # --name=[name]            Set name to report as
-# --nocvsup                Don't update from CVS even though it is a CVS tree
+# --nocvsup                Don't pull from git even though it is a git tree
+# --nogitpull              Don't pull from git even though it is a git tree
 # --nobuildconf            Don't run buildconf
+# --noconfigure            Don't run configure
 # --runtestopts=[options]  Options to pass to runtests.pl
 # --setup=[file name]      File name to read setup from (deprecated)
 # --target=[your os]       Specify your target environment.
 #
-# if [curl-daily-name] is omitted, a 'curl' CVS directory is assumed.
+# if [curl-daily-name] is omitted, a 'curl' git directory is assumed.
 #
 
 use strict;
@@ -61,21 +64,28 @@ use Cwd;
 # Turn on warnings (equivalent to -w, which can't be used with /usr/bin/env)
 #BEGIN { $^W = 1; }
 
-use vars qw($version $fixed $infixed $CURLDIR $CVS $pwd $build $buildlog
-            $buildlogname $configurebuild $targetos $confsuffix $binext
+use vars qw($version $fixed $infixed $CURLDIR $git $pwd $build $buildlog
+            $buildlogname $configurebuild $targetos $confheader $binext
             $libext);
+
 use vars qw($name $email $desc $confopts $runtestopts $setupfile $mktarball
-            $nocvsup $nobuildconf $crosscompile);
+            $extvercmd $nogitpull $nobuildconf $crosscompile
+            $timestamp $notes);
 
 # version of this script
-$version='$Revision$';
+$version='2014-11-25';
 $fixed=0;
 
-# Determine if we're running from CVS or a canned copy of curl,
+# Determine if we're running from git or a canned copy of curl,
 # or if we got a specific target option or setup file option.
 $CURLDIR="curl";
-$CVS=1;
+if (-f ".git/config") {
+  $CURLDIR = "./";
+}
+
+$git=1;
 $setupfile = 'setup';
+$configurebuild = 1;
 while ($ARGV[0]) {
   if ($ARGV[0] =~ /--target=/) {
     $targetos = (split(/=/, shift @ARGV))[1];
@@ -83,6 +93,9 @@ while ($ARGV[0]) {
   elsif ($ARGV[0] =~ /--setup=/) {
     $setupfile = (split(/=/, shift @ARGV))[1];
   }
+  elsif ($ARGV[0] =~ /--extvercmd=/) {
+    $extvercmd = (split(/=/, shift @ARGV))[1];
+  }
   elsif ($ARGV[0] =~ /--mktarball=/) {
     $mktarball = (split(/=/, shift @ARGV))[1];
   }
@@ -95,17 +108,22 @@ while ($ARGV[0]) {
   elsif ($ARGV[0] =~ /--desc=/) {
     $desc = (split(/=/, shift @ARGV))[1];
   }
-  elsif ($ARGV[0] =~ /--configure=/) {
-    $confopts = (split(/=/, shift @ARGV))[1];
+  elsif ($ARGV[0] =~ /--configure=(.*)/) {
+    $confopts = $1;
+    shift @ARGV;
   }
-  elsif ($ARGV[0] =~ /--nocvsup/) {
-    $nocvsup=1;
+  elsif (($ARGV[0] eq "--nocvsup") || ($ARGV[0] eq "--nogitpull")) {
+    $nogitpull=1;
     shift @ARGV;
   }
   elsif ($ARGV[0] =~ /--nobuildconf/) {
     $nobuildconf=1;
     shift @ARGV;
   }
+  elsif ($ARGV[0] =~ /--noconfigure/) {
+    $configurebuild=0;
+    shift @ARGV;
+  }
   elsif ($ARGV[0] =~ /--crosscompile/) {
     $crosscompile=1;
     shift @ARGV;
@@ -115,13 +133,12 @@ while ($ARGV[0]) {
   }
   else {
     $CURLDIR=shift @ARGV;
-    $CVS=0;
+    $git=0; # a given dir, assume not using git
   }
 }
 
 # Do the platform-specific stuff here
-$configurebuild = 1;
-$confsuffix = '';
+$confheader = 'curl_config.h';
 $binext = '';
 $libext = '.la'; # .la since both libcurl and libcares are made with libtool
 if ($^O eq 'MSWin32' || $targetos) {
@@ -129,29 +146,42 @@ if ($^O eq 'MSWin32' || $targetos) {
     # If no target defined on Win32 lets assume vc
     $targetos = 'vc';
   }
-  if ($targetos =~ /vc/ || $targetos =~ /mingw32/ || $targetos =~ /borland/) {
+  if ($targetos =~ /vc/ || $targetos =~ /borland/ || $targetos =~ /watcom/) {
     $binext = '.exe';
-    $libext = '.lib' if ($targetos =~ /vc/ || $targetos =~ /borland/);
-    $libext = '.a' if ($targetos =~ /mingw32/);
+    $libext = '.lib';
+  }
+  elsif ($targetos =~ /mingw/) {
+    $binext = '.exe';
+    if ($^O eq 'MSWin32') {
+      $libext = '.a';
+    }
   }
   elsif ($targetos =~ /netware/) {
     $configurebuild = 0;
     $binext = '.nlm';
-    $libext = '.lib';
+    if ($^O eq 'MSWin32') {
+      $libext = '.lib';
+    }
+    else {
+      $libext = '.a';
+    }
   }
 }
 
-if (($^O eq 'MSWin32') && ($targetos =~ /vc/ || $targetos =~ /mingw32/ || $targetos =~ /borland/)) {
+if (($^O eq 'MSWin32' || $^O eq 'msys') &&
+    ($targetos =~ /vc/ || $targetos =~ /mingw32/ ||
+     $targetos =~ /borland/ || $targetos =~ /watcom/)) {
 
   # Set these things only when building ON Windows and for Win32 platform.
   # FOR Windows since we might be cross-compiling on another system. Non-
-  # Windows builds still default to configure-style builds with no confsuffix.
+  # Windows builds still default to configure-style builds with curl_config.h.
 
   $configurebuild = 0;
-  $confsuffix = '-win32';
+  $confheader = 'config-win32.h';
 }
 
-
+$ENV{LC_ALL}="C" if (($ENV{LC_ALL}) && ($ENV{LC_ALL} !~ /^C$/));
+$ENV{LC_CTYPE}="C" if (($ENV{LC_CTYPE}) && ($ENV{LC_CTYPE} !~ /^C$/));
 $ENV{LANG}="C";
 
 sub rmtree($) {
@@ -186,6 +216,13 @@ sub logit($) {
     }
 }
 
+sub logit_spaced($) {
+    my $text=$_[0];
+    if ($text) {
+      print "\ntestcurl: $text\n\n";
+    }
+}
+
 sub mydie($){
     my $text=$_[0];
     logit "$text";
@@ -205,7 +242,29 @@ sub mydie($){
     exit 1;
 }
 
-if (open(F, "$setupfile")) {
+sub get_host_triplet {
+  my $triplet;
+  my $configfile = "$pwd/$build/lib/curl_config.h";
+
+  if(-f $configfile && -s $configfile && open(LIBCONFIGH, "<$configfile")) {
+    while(<LIBCONFIGH>) {
+      if($_ =~ /^\#define\s+OS\s+"*([^"][^"]*)"*\s*/) {
+        $triplet = $1;
+        last;
+      }
+    }
+    close(LIBCONFIGH);
+  }
+  return $triplet;
+}
+
+if($name && $email && $desc) {
+  # having these fields set are enough to continue, skip reading the setup
+  # file
+  $infixed=4;
+  $fixed=4;
+}
+elsif (open(F, "$setupfile")) {
   while (<F>) {
     if (/(\w+)=(.*)/) {
       eval "\$$1=$2;";
@@ -213,7 +272,8 @@ if (open(F, "$setupfile")) {
   }
   close(F);
   $infixed=$fixed;
-} else {
+}
+else {
   $infixed=0;    # so that "additional args to configure" works properly first time...
 }
 
@@ -255,36 +315,72 @@ if ($fixed < 4) {
     print F "email='$email'\n";
     print F "desc='$desc'\n";
     print F "confopts='$confopts'\n";
+    print F "notes='$notes'\n";
     print F "fixed='$fixed'\n";
     close(F);
 }
 
+# Enable picky compiler warnings unless explicitly disabled
+if (($confopts !~ /--enable-debug/) &&
+    ($confopts !~ /--enable-warnings/) &&
+    ($confopts !~ /--disable-warnings/)) {
+  $confopts .= " --enable-warnings";
+}
+
+my $str1066os = 'o' x 1066;
+
+# Set timestamp to the UTC this script is running. Its value might
+# be changed later in the script to the value present in curlver.h
+$timestamp = scalar(gmtime)." UTC";
+
 logit "STARTING HERE"; # first line logged, for scripts to trigger on
+logit 'TRANSFER CONTROL ==== 1120 CHAR LINE' . $str1066os . 'LINE_END';
 logit "NAME = $name";
 logit "EMAIL = $email";
 logit "DESC = $desc";
+logit "NOTES = $notes";
 logit "CONFOPTS = $confopts";
+logit "RUNTESTOPTS = ".$runtestopts;
+logit "CPPFLAGS = ".$ENV{CPPFLAGS};
 logit "CFLAGS = ".$ENV{CFLAGS};
 logit "LDFLAGS = ".$ENV{LDFLAGS};
+logit "LIBS = ".$ENV{LIBS};
 logit "CC = ".$ENV{CC};
+logit "TMPDIR = ".$ENV{TMPDIR};
+logit "MAKEFLAGS = ".$ENV{MAKEFLAGS};
+logit "ACLOCAL_FLAGS = ".$ENV{ACLOCAL_FLAGS};
+logit "PKG_CONFIG_PATH = ".$ENV{PKG_CONFIG_PATH};
+logit "DYLD_LIBRARY_PATH = ".$ENV{DYLD_LIBRARY_PATH};
+logit "LD_LIBRARY_PATH = ".$ENV{LD_LIBRARY_PATH};
+logit "LIBRARY_PATH = ".$ENV{LIBRARY_PATH};
+logit "SHLIB_PATH = ".$ENV{SHLIB_PATH};
+logit "LIBPATH = ".$ENV{LIBPATH};
 logit "target = ".$targetos;
 logit "version = $version"; # script version
-logit "date = ".(scalar gmtime)." UTC";
+logit "date = $timestamp";  # When the test build starts
+
+$str1066os = undef;
 
 # Make $pwd to become the path without newline. We'll use that in order to cut
 # off that path from all possible logs and error messages etc.
-$pwd = cwd();
+$pwd = getcwd();
+
+my $have_embedded_ares = 0;
 
 if (-d $CURLDIR) {
-  if ($CVS && -d "$CURLDIR/CVS") {
-    logit "$CURLDIR is verified to be a fine source dir";
+  if ($git && -d "$CURLDIR/.git") {
+    logit "$CURLDIR is verified to be a fine git source dir";
     # remove the generated sources to force them to be re-generated each
     # time we run this test
-    unlink "$CURLDIR/src/hugehelp.c";
-  } elsif (!$CVS && -f "$CURLDIR/tests/testcurl.pl") {
-    logit "$CURLDIR is verified to be a fine daily source dir"
+    unlink "$CURLDIR/src/tool_hugehelp.c";
+    # find out if curl source dir has an in-tree c-ares repo
+    $have_embedded_ares = 1 if (-f "$CURLDIR/ares/GIT-INFO");
+  } elsif (!$git && -f "$CURLDIR/tests/testcurl.pl") {
+    logit "$CURLDIR is verified to be a fine daily source dir";
+    # find out if curl source dir has an in-tree c-ares extracted tarball
+    $have_embedded_ares = 1 if (-f "$CURLDIR/ares/ares_build.h");
   } else {
-    mydie "$CURLDIR is not a daily source dir or checked out from CVS!"
+    mydie "$CURLDIR is not a daily source dir or checked out from git!"
   }
 }
 $build="build-$$";
@@ -310,51 +406,60 @@ if (-d $build) {
 # get in the curl source tree root
 chdir $CURLDIR;
 
-# Do the CVS thing, or not...
-if ($CVS) {
+# Do the git thing, or not...
+if ($git) {
+  my $gitstat = 0;
+  my @commits;
 
-  # this is a temporary fix to make things work again, remove later
-  logit "remove ares/aclocal.m4";
-  unlink "ares/aclocal.m4";
+  # update quietly to the latest git
+  if($nogitpull) {
+    logit "skipping git pull (--nogitpull)";
+  } else {
+    logit "run git pull in curl";
+    system("git pull 2>&1");
+    $gitstat += $?;
+    logit "failed to update from curl git ($?), continue anyway" if ($?);
 
-  logit "update from CVS";
-  my $cvsstat;
+    # Set timestamp to the UTC the git update took place.
+    $timestamp = scalar(gmtime)." UTC" if (!$gitstat);
+  }
 
-  sub cvsup() {
-    # update quietly to the latest CVS
-    logit "run cvs up";
-    if($nocvsup) {
-        logit "Skipping CVS update (--nocvsup)";
-        return 1;
-    }
-    else {
-        system("cvs -Q up -dP 2>&1");
-    }
+  # get the last 5 commits for show (even if no pull was made)
+  @commits=`git log --pretty=oneline --abbrev-commit -5`;
+  logit "The most recent curl git commits:";
+  for (@commits) {
+    chomp ($_);
+    logit "  $_";
+  }
 
-    $cvsstat=$?;
+  if (-d "ares/.git") {
+    chdir "ares";
 
-    # return !RETURNVALUE so that errors return 0 while goodness
-    # returns 1
-    return !$cvsstat;
-  }
+    if($nogitpull) {
+      logit "skipping git pull (--nogitpull) in ares";
+    } else {
+      logit "run git pull in ares";
+      system("git pull 2>&1");
+      $gitstat += $?;
+      logit "failed to update from ares git ($?), continue anyway" if ($?);
 
-  my $att=0;
-  while (!cvsup()) {
-    $att++;
-    logit "failed CVS update attempt number $att.";
-    if ($att > 10) {
-      $cvsstat=111;
-      last; # get out of the loop
+      # Set timestamp to the UTC the git update took place.
+      $timestamp = scalar(gmtime)." UTC" if (!$gitstat);
     }
-    sleep 5;
-  }
 
-  if ($cvsstat != 0) {
-    mydie "failed to update from CVS ($cvsstat), exiting";
+    # get the last 5 commits for show (even if no pull was made)
+    @commits=`git log --pretty=oneline --abbrev-commit -5`;
+    logit "The most recent ares git commits:";
+    for (@commits) {
+      chomp ($_);
+      logit "  $_";
+    }
+
+    chdir "$pwd/$CURLDIR";
   }
 
   if($nobuildconf) {
-      logit "told to not run buildconf";
+    logit "told to not run buildconf";
   }
   elsif ($configurebuild) {
     # remove possible left-overs from the past
@@ -362,13 +467,16 @@ if ($CVS) {
     unlink "autom4te.cache";
 
     # generate the build files
-    logit "invoke buildconf, but filter off the silly aclocal warnings";
+    logit "invoke buildconf";
     open(F, "./buildconf 2>&1 |") or die;
     open(LOG, ">$buildlog") or die;
     while (<F>) {
-      next if /warning: underquoted definition of/;
-      print;
-      print LOG;
+      my $ll = $_;
+      # ignore messages pertaining to third party m4 files we don't care
+      next if ($ll =~ /aclocal\/gtk\.m4/);
+      next if ($ll =~ /aclocal\/gtkextra\.m4/);
+      print $ll;
+      print LOG $ll;
     }
     close(F);
     close(LOG);
@@ -379,28 +487,32 @@ if ($CVS) {
     else {
       mydie "buildconf was NOT successful";
     }
-
-    if($confopts =~ /--enable-ares/) {
-        logit "run buildconf for ares";
-        chdir "ares";
-        open(F, "./buildconf 2>&1 |") or die;
-        open(LOG, ">$buildlog") or die;
-        while (<F>) {
-            next if /warning: underquoted definition of/;
-            print;
-            print LOG;
-        }
-        close(F);
-        close(LOG);
-        chdir "..";
-    }
-
   }
   else {
     logit "buildconf was successful (dummy message)";
   }
 }
 
+# Set timestamp to the one in curlver.h if this isn't a git test build.
+if ((-f "include/curl/curlver.h") &&
+    (open(F, "<include/curl/curlver.h"))) {
+  while (<F>) {
+    chomp;
+    if ($_ =~ /^\#define\s+LIBCURL_TIMESTAMP\s+\"(.+)\".*$/) {
+      my $stampstring = $1;
+      if ($stampstring !~ /DEV/) {
+          $stampstring =~ s/\s+UTC//;
+          $timestamp = $stampstring." UTC";
+      }
+      last;
+    }
+  }
+  close(F);
+}
+
+# Show timestamp we are using for this test build.
+logit "timestamp = $timestamp";
+
 if ($configurebuild) {
   if (-f "configure") {
     logit "configure created (at least it exists)";
@@ -412,24 +524,29 @@ if ($configurebuild) {
 }
 
 sub findinpath {
-    my $c;
-    my $e;
-    my $p=$ENV{'PATH'};
-    my @pa = split(":", $p);
-    for $c (@_) {
-        for $e (@pa) {
-            if( -x "$e/$c") {
-                return $c;
-            }
-        }
+  my $c;
+  my $e;
+  my $x = ($^O eq 'MSWin32') ? '.exe' : '';
+  my $s = ($^O eq 'MSWin32') ? ';' : ':';
+  my $p=$ENV{'PATH'};
+  my @pa = split($s, $p);
+  for $c (@_) {
+    for $e (@pa) {
+      if( -x "$e/$c$x") {
+        return $c;
+      }
     }
+  }
 }
 
-
 my $make = findinpath("gmake", "make", "nmake");
 if(!$make) {
     mydie "Couldn't find make in the PATH";
 }
+# force to 'nmake' for VC builds
+$make = "nmake" if ($targetos =~ /vc/);
+# force to 'wmake' for Watcom builds
+$make = "wmake" if ($targetos =~ /watcom/);
 logit "going with $make as make";
 
 # change to build dir
@@ -445,36 +562,105 @@ if ($configurebuild) {
     mydie "configure didn't work";
   }
 } else {
+  logit "copying files to build dir ...";
   if (($^O eq 'MSWin32') && ($targetos !~ /netware/)) {
     system("xcopy /s /q ..\\$CURLDIR .");
     system("buildconf.bat");
   }
-  elsif (($^O eq 'linux') || ($targetos =~ /netware/)) {
-    system("cp -afr ../$CURLDIR/* ."); 
-    system("cp -af ../$CURLDIR/Makefile.dist Makefile"); 
+  elsif ($targetos =~ /netware/) {
+    system("cp -afr ../$CURLDIR/* .");
+    system("cp -af ../$CURLDIR/Makefile.dist Makefile");
+    system("$make -i -C lib -f Makefile.netware prebuild");
+    system("$make -i -C src -f Makefile.netware prebuild");
+    if (-d "../$CURLDIR/ares") {
+      system("$make -i -C ares -f Makefile.netware prebuild");
+    }
+  }
+  elsif ($^O eq 'linux') {
+    system("cp -afr ../$CURLDIR/* .");
+    system("cp -af ../$CURLDIR/Makefile.dist Makefile");
+    system("cp -af ../$CURLDIR/include/curl/curlbuild.h.dist ./include/curl/curlbuild.h");
     system("$make -i -C lib -f Makefile.$targetos prebuild");
     system("$make -i -C src -f Makefile.$targetos prebuild");
+    if (-d "../$CURLDIR/ares") {
+      system("cp -af ../$CURLDIR/ares/ares_build.h.dist ./ares/ares_build.h");
+      system("$make -i -C ares -f Makefile.$targetos prebuild");
+    }
+  }
+}
+
+if(-f "./libcurl.pc") {
+  logit_spaced "display libcurl.pc";
+  if(open(F, "<./libcurl.pc")) {
+    while(<F>) {
+      my $ll = $_;
+      print $ll if(($ll !~ /^ *#/) && ($ll !~ /^ *$/));
+    }
+    close(F);
+  }
+}
+
+if(-f "./include/curl/curlbuild.h") {
+  logit_spaced "display include/curl/curlbuild.h";
+  if(open(F, "<./include/curl/curlbuild.h")) {
+    while(<F>) {
+      my $ll = $_;
+      print $ll if(($ll =~ /^ *# *define *CURL_/) && ($ll !~ /__CURL_CURLBUILD_H/));
+    }
+    close(F);
   }
 }
+else {
+  mydie "no curlbuild.h created/found";
+}
 
-logit "display lib/config$confsuffix.h";
-open(F, "lib/config$confsuffix.h") or die "lib/config$confsuffix.h: $!";
+logit_spaced "display lib/$confheader";
+open(F, "lib/$confheader") or die "lib/$confheader: $!";
 while (<F>) {
   print if /^ *#/;
 }
 close(F);
 
-if (grepfile("define USE_ARES", "lib/config$confsuffix.h")) {
+if (($have_embedded_ares) &&
+    (grepfile("^#define USE_ARES", "lib/$confheader"))) {
+  print "\n";
   logit "setup to build ares";
 
-  logit "display ares/config$confsuffix.h";
-  if(open(F, "ares/config$confsuffix.h")) {
+  if(-f "./ares/libcares.pc") {
+    logit_spaced  "display ares/libcares.pc";
+    if(open(F, "<./ares/libcares.pc")) {
+      while(<F>) {
+        my $ll = $_;
+        print $ll if(($ll !~ /^ *#/) && ($ll !~ /^ *$/));
+      }
+      close(F);
+    }
+  }
+
+  if(-f "./ares/ares_build.h") {
+    logit_spaced "display ares/ares_build.h";
+    if(open(F, "<./ares/ares_build.h")) {
+      while(<F>) {
+        my $ll = $_;
+        print $ll if(($ll =~ /^ *# *define *CARES_/) && ($ll !~ /__CARES_BUILD_H/));
+      }
+      close(F);
+    }
+  }
+  else {
+    mydie "no ares_build.h created/found";
+  }
+
+  $confheader =~ s/curl/ares/;
+  logit_spaced "display ares/$confheader";
+  if(open(F, "ares/$confheader")) {
       while (<F>) {
           print if /^ *#/;
       }
       close(F);
   }
 
+  print "\n";
   logit "build ares";
   chdir "ares";
 
@@ -495,78 +681,75 @@ if (grepfile("define USE_ARES", "lib/config$confsuffix.h")) {
   if (-f "libcares$libext") {
     logit "ares is now built successfully (libcares$libext)";
   } else {
-    logit "ares build failed (libares$libext)";
+    mydie "ares build failed (libcares$libext)";
   }
 
   # cd back to the curl build dir
   chdir "$pwd/$build";
 }
 
-if ($configurebuild) {
-  logit "$make -i";
-  open(F, "$make -i 2>&1 |") or die;
-  while (<F>) {
-    s/$pwd//g;
-    print;
-  }
-  close(F);
-}
-else {
-  logit "$make -i $targetos";
-  if ($^O eq 'MSWin32') {
-    if ($targetos =~ /vc/) {
-      open(F, "nmake -i $targetos|") or die;
-    }
-    else {
-      open(F, "$make -i $targetos |") or die;
-    }
-  }
-  else {
-    open(F, "$make -i $targetos 2>&1 |") or die;
-  }
-  while (<F>) {
-    s/$pwd//g;
-    print;
-  }
-  close(F);
+my $mkcmd = "$make -i" . ($targetos && !$configurebuild ? " $targetos" : "");
+logit "$mkcmd";
+open(F, "$mkcmd 2>&1 |") or die;
+while (<F>) {
+  s/$pwd//g;
+  print;
 }
+close(F);
 
 if (-f "lib/libcurl$libext") {
-  logit "lib/libcurl was created fine (libcurl$libext)";
+  logit "libcurl was created fine (libcurl$libext)";
 }
 else {
-  logit "lib/libcurl was not created (libcurl$libext)";
+  mydie "libcurl was not created (libcurl$libext)";
 }
 
 if (-f "src/curl$binext") {
-  logit "src/curl was created fine (curl$binext)";
+  logit "curl was created fine (curl$binext)";
 }
 else {
-  mydie "src/curl was not created (curl$binext)";
+  mydie "curl was not created (curl$binext)";
 }
 
-if ($targetos =~ /netware/) {
-  if (-f '../../curlver') {
-    system('../../curlver');
-  }
-}
-elsif(!$crosscompile) {
-  logit "display curl$binext --version output";
-  open(F, "./src/curl$binext --version|");
+if (!$crosscompile || (($extvercmd ne '') && (-x $extvercmd))) {
+  logit "display curl${binext} --version output";
+  my $cmd = ($extvercmd ne '' ? $extvercmd.' ' : '')."./src/curl${binext} --version|";
+  open(F, $cmd);
   while(<F>) {
-      print;
-      print LOG;
+    # strip CR from output on non-win32 platforms (wine on Linux)
+    s/\r// if ($^O ne 'MSWin32');
+    print;
   }
   close(F);
 }
 
 if ($configurebuild && !$crosscompile) {
+  my $host_triplet = get_host_triplet();
+  # build example programs for selected build targets
+  if(($host_triplet =~ /([^-]+)-([^-]+)-irix(.*)/) ||
+     ($host_triplet =~ /([^-]+)-([^-]+)-aix(.*)/) ||
+     ($host_triplet =~ /([^-]+)-([^-]+)-osf(.*)/) ||
+     ($host_triplet =~ /([^-]+)-([^-]+)-solaris2(.*)/)) {
+    chdir "$pwd/$build/docs/examples";
+    logit_spaced "build examples";
+    open(F, "$make -i 2>&1 |") or die;
+    open(LOG, ">$buildlog") or die;
+    while (<F>) {
+      s/$pwd//g;
+      print;
+      print LOG;
+    }
+    close(F);
+    close(LOG);
+    chdir "$pwd/$build";
+  }
+  # build and run full test suite
   my $o;
   if($runtestopts) {
       $o = "TEST_F=\"$runtestopts\" ";
   }
-  logit "$make ${o}test-full";
-  open(F, "$make ${o}test-full 2>&1 |") or die;
+  logit "$make -k ${o}test-full";
+  open(F, "$make -k ${o}test-full 2>&1 |") or die;
   open(LOG, ">$buildlog") or die;
   while (<F>) {
     s/$pwd//g;
@@ -587,16 +770,49 @@ if ($configurebuild && !$crosscompile) {
   } else {
     logit "the tests were successful!";
   }
-} else {
-  # dummy message to feign success
+}
+else {
   if($crosscompile) {
-    logit "cross-compiling, can't run tests";
+    my $host_triplet = get_host_triplet();
+    # build example programs for selected cross-compiles
+    if(($host_triplet =~ /([^-]+)-([^-]+)-mingw(.*)/) ||
+       ($host_triplet =~ /([^-]+)-([^-]+)-android(.*)/)) {
+      chdir "$pwd/$build/docs/examples";
+      logit_spaced "build examples";
+      open(F, "$make -i 2>&1 |") or die;
+      open(LOG, ">$buildlog") or die;
+      while (<F>) {
+        s/$pwd//g;
+        print;
+        print LOG;
+      }
+      close(F);
+      close(LOG);
+      chdir "$pwd/$build";
+    }
+    # build test harness programs for selected cross-compiles
+    if($host_triplet =~ /([^-]+)-([^-]+)-mingw(.*)/) {
+      chdir "$pwd/$build/tests";
+      logit_spaced "build test harness";
+      open(F, "$make -i 2>&1 |") or die;
+      open(LOG, ">$buildlog") or die;
+      while (<F>) {
+        s/$pwd//g;
+        print;
+        print LOG;
+      }
+      close(F);
+      close(LOG);
+      chdir "$pwd/$build";
+    }
+    logit_spaced "cross-compiling, can't run tests";
   }
+  # dummy message to feign success
   print "TESTDONE: 1 tests out of 0 (dummy message)\n";
 }
 
 # create a tarball if we got that option.
-if (($mktarball ne '') && (-f $mktarball)) {
+if (($mktarball ne '') && (-x $mktarball)) {
   system($mktarball);
 }