~ubuntu-branches/ubuntu/vivid/curl/vivid

1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
1
#!/usr/bin/env perl
2
#***************************************************************************
3
#                                  _   _ ____  _
4
#  Project                     ___| | | |  _ \| |
5
#                             / __| | | | |_) | |
6
#                            | (__| |_| |  _ <| |___
7
#                             \___|\___/|_| \_\_____|
8
#
1.2.17 by Alessandro Ghedini
Import upstream version 7.26.0
9
# Copyright (C) 1998 - 2012, Daniel Stenberg, <daniel@haxx.se>, et al.
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
10
#
11
# This software is licensed as described in the file COPYING, which
12
# you should have received as part of this distribution. The terms
13
# are also available at http://curl.haxx.se/docs/copyright.html.
14
#
15
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
16
# copies of the Software, and permit persons to whom the Software is
17
# furnished to do so, under the terms of the COPYING file.
18
#
19
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
20
# KIND, either express or implied.
21
#
22
###########################################################################
23
24
###########################
25
#  What is This Script?
26
###########################
27
1.2.4 by Ramakrishnan Muthukrishnan
Import upstream version 7.20.1
28
# testcurl.pl is the master script to use for automatic testing of curl
29
# directly off its source repository.
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
30
# This is written for the purpose of being run from a crontab job or similar
1.1.3 by Matthias Klose
Import upstream version 7.14.0
31
# at a regular interval. The output is suitable to be mailed to
32
# curl-autocompile@haxx.se to be dealt with automatically (make sure the
33
# subject includes the word "autobuild" as the mail gets silently discarded
34
# otherwise).  The most current build status (with a resonable backlog) will
35
# be published on the curl site, at http://curl.haxx.se/auto/
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
36
37
# USAGE:
1.1.3 by Matthias Klose
Import upstream version 7.14.0
38
# testcurl.pl [options] [curl-daily-name] > output
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
39
1.1.3 by Matthias Klose
Import upstream version 7.14.0
40
# Options:
41
#
42
# --configure=[options]    Configure options
43
# --crosscompile           This is a crosscompile
44
# --desc=[desc]            Description of your test system
45
# --email=[email]          Set email address to report as
1.1.11 by Michael Vogt
Import upstream version 7.18.2
46
# --extvercmd=[command]    Command to use for displaying version with cross compiles.
1.1.3 by Matthias Klose
Import upstream version 7.14.0
47
# --mktarball=[command]    Command to run after completed test
48
# --name=[name]            Set name to report as
1.2.4 by Ramakrishnan Muthukrishnan
Import upstream version 7.20.1
49
# --nocvsup                Don't pull from git even though it is a git tree
50
# --nogitpull              Don't pull from git even though it is a git tree
1.1.4 by Martin Pitt
Import upstream version 7.15.1
51
# --nobuildconf            Don't run buildconf
1.2.8 by Ramakrishnan Muthukrishnan
Import upstream version 7.21.3
52
# --noconfigure            Don't run configure
1.1.3 by Matthias Klose
Import upstream version 7.14.0
53
# --runtestopts=[options]  Options to pass to runtests.pl
54
# --setup=[file name]      File name to read setup from (deprecated)
55
# --target=[your os]       Specify your target environment.
56
#
1.2.4 by Ramakrishnan Muthukrishnan
Import upstream version 7.20.1
57
# if [curl-daily-name] is omitted, a 'curl' git directory is assumed.
1.1.3 by Matthias Klose
Import upstream version 7.14.0
58
#
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
59
60
use strict;
61
62
use Cwd;
63
64
# Turn on warnings (equivalent to -w, which can't be used with /usr/bin/env)
1.1.3 by Matthias Klose
Import upstream version 7.14.0
65
#BEGIN { $^W = 1; }
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
66
1.2.4 by Ramakrishnan Muthukrishnan
Import upstream version 7.20.1
67
use vars qw($version $fixed $infixed $CURLDIR $git $pwd $build $buildlog
1.2.7 by Ramakrishnan Muthukrishnan
Import upstream version 7.21.2
68
            $buildlogname $configurebuild $targetos $confheader $binext
1.1.3 by Matthias Klose
Import upstream version 7.14.0
69
            $libext);
1.2.4 by Ramakrishnan Muthukrishnan
Import upstream version 7.20.1
70
1.1.3 by Matthias Klose
Import upstream version 7.14.0
71
use vars qw($name $email $desc $confopts $runtestopts $setupfile $mktarball
1.2.4 by Ramakrishnan Muthukrishnan
Import upstream version 7.20.1
72
            $extvercmd $nogitpull $nobuildconf $crosscompile
1.2.13 by Alessandro Ghedini
Import upstream version 7.22.0
73
            $timestamp $notes);
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
74
75
# version of this script
1.3.1 by Alessandro Ghedini
Import upstream version 7.29.0
76
$version='2012-11-30';
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
77
$fixed=0;
78
1.2.4 by Ramakrishnan Muthukrishnan
Import upstream version 7.20.1
79
# Determine if we're running from git or a canned copy of curl,
1.1.2 by LaMont Jones
Import upstream version 7.12.3
80
# or if we got a specific target option or setup file option.
81
$CURLDIR="curl";
1.2.4 by Ramakrishnan Muthukrishnan
Import upstream version 7.20.1
82
if (-f ".git/config") {
83
  $CURLDIR = "./";
84
}
85
86
$git=1;
1.1.2 by LaMont Jones
Import upstream version 7.12.3
87
$setupfile = 'setup';
1.2.8 by Ramakrishnan Muthukrishnan
Import upstream version 7.21.3
88
$configurebuild = 1;
1.1.2 by LaMont Jones
Import upstream version 7.12.3
89
while ($ARGV[0]) {
90
  if ($ARGV[0] =~ /--target=/) {
91
    $targetos = (split(/=/, shift @ARGV))[1];
1.1.3 by Matthias Klose
Import upstream version 7.14.0
92
  }
93
  elsif ($ARGV[0] =~ /--setup=/) {
1.1.2 by LaMont Jones
Import upstream version 7.12.3
94
    $setupfile = (split(/=/, shift @ARGV))[1];
1.1.3 by Matthias Klose
Import upstream version 7.14.0
95
  }
1.1.11 by Michael Vogt
Import upstream version 7.18.2
96
  elsif ($ARGV[0] =~ /--extvercmd=/) {
97
    $extvercmd = (split(/=/, shift @ARGV))[1];
98
  }
1.1.3 by Matthias Klose
Import upstream version 7.14.0
99
  elsif ($ARGV[0] =~ /--mktarball=/) {
1.1.2 by LaMont Jones
Import upstream version 7.12.3
100
    $mktarball = (split(/=/, shift @ARGV))[1];
1.1.3 by Matthias Klose
Import upstream version 7.14.0
101
  }
102
  elsif ($ARGV[0] =~ /--name=/) {
103
    $name = (split(/=/, shift @ARGV))[1];
104
  }
105
  elsif ($ARGV[0] =~ /--email=/) {
106
    $email = (split(/=/, shift @ARGV))[1];
107
  }
108
  elsif ($ARGV[0] =~ /--desc=/) {
109
    $desc = (split(/=/, shift @ARGV))[1];
110
  }
1.2.12 by Ramakrishnan Muthukrishnan
Import upstream version 7.21.7
111
  elsif ($ARGV[0] =~ /--configure=(.*)/) {
112
    $confopts = $1;
113
    shift @ARGV;
1.1.3 by Matthias Klose
Import upstream version 7.14.0
114
  }
1.2.4 by Ramakrishnan Muthukrishnan
Import upstream version 7.20.1
115
  elsif (($ARGV[0] eq "--nocvsup") || ($ARGV[0] eq "--nogitpull")) {
116
    $nogitpull=1;
1.1.3 by Matthias Klose
Import upstream version 7.14.0
117
    shift @ARGV;
118
  }
1.1.4 by Martin Pitt
Import upstream version 7.15.1
119
  elsif ($ARGV[0] =~ /--nobuildconf/) {
120
    $nobuildconf=1;
121
    shift @ARGV;
122
  }
1.2.8 by Ramakrishnan Muthukrishnan
Import upstream version 7.21.3
123
  elsif ($ARGV[0] =~ /--noconfigure/) {
124
    $configurebuild=0;
125
    shift @ARGV;
126
  }
1.1.3 by Matthias Klose
Import upstream version 7.14.0
127
  elsif ($ARGV[0] =~ /--crosscompile/) {
128
    $crosscompile=1;
129
    shift @ARGV;
130
  }
131
  elsif ($ARGV[0] =~ /--runtestopts=/) {
132
    $runtestopts = (split(/=/, shift @ARGV, 2))[1];
133
  }
134
  else {
1.1.2 by LaMont Jones
Import upstream version 7.12.3
135
    $CURLDIR=shift @ARGV;
1.2.4 by Ramakrishnan Muthukrishnan
Import upstream version 7.20.1
136
    $git=0; # a given dir, assume not using git
1.1.2 by LaMont Jones
Import upstream version 7.12.3
137
  }
138
}
139
140
# Do the platform-specific stuff here
1.2.7 by Ramakrishnan Muthukrishnan
Import upstream version 7.21.2
141
$confheader = 'curl_config.h';
1.1.2 by LaMont Jones
Import upstream version 7.12.3
142
$binext = '';
143
$libext = '.la'; # .la since both libcurl and libcares are made with libtool
1.1.3 by Matthias Klose
Import upstream version 7.14.0
144
if ($^O eq 'MSWin32' || $targetos) {
145
  if (!$targetos) {
1.1.2 by LaMont Jones
Import upstream version 7.12.3
146
    # If no target defined on Win32 lets assume vc
147
    $targetos = 'vc';
148
  }
1.2.6 by Ramakrishnan Muthukrishnan
Import upstream version 7.21.1
149
  if ($targetos =~ /vc/ || $targetos =~ /borland/ || $targetos =~ /watcom/) {
1.1.2 by LaMont Jones
Import upstream version 7.12.3
150
    $binext = '.exe';
1.1.5 by Martin Pitt
Import upstream version 7.15.4
151
    $libext = '.lib';
1.1.3 by Matthias Klose
Import upstream version 7.14.0
152
  }
1.2.2 by Domenico Andreoli
Import upstream version 7.19.7
153
  elsif ($targetos =~ /mingw/) {
1.1.7 by Matthias Klose
Import upstream version 7.16.2
154
    $binext = '.exe';
155
    if ($^O eq 'MSWin32') {
156
      $libext = '.a';
157
    }
158
  }
1.1.3 by Matthias Klose
Import upstream version 7.14.0
159
  elsif ($targetos =~ /netware/) {
160
    $configurebuild = 0;
1.1.2 by LaMont Jones
Import upstream version 7.12.3
161
    $binext = '.nlm';
1.1.7 by Matthias Klose
Import upstream version 7.16.2
162
    if ($^O eq 'MSWin32') {
163
      $libext = '.lib';
164
    }
165
    else {
166
      $libext = '.a';
167
    }
1.1.2 by LaMont Jones
Import upstream version 7.12.3
168
  }
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
169
}
170
1.2.6 by Ramakrishnan Muthukrishnan
Import upstream version 7.21.1
171
if (($^O eq 'MSWin32' || $^O eq 'msys') &&
172
    ($targetos =~ /vc/ || $targetos =~ /mingw32/ ||
173
     $targetos =~ /borland/ || $targetos =~ /watcom/)) {
1.1.3 by Matthias Klose
Import upstream version 7.14.0
174
1.1.4 by Martin Pitt
Import upstream version 7.15.1
175
  # Set these things only when building ON Windows and for Win32 platform.
1.1.3 by Matthias Klose
Import upstream version 7.14.0
176
  # FOR Windows since we might be cross-compiling on another system. Non-
1.2.7 by Ramakrishnan Muthukrishnan
Import upstream version 7.21.2
177
  # Windows builds still default to configure-style builds with curl_config.h.
1.1.3 by Matthias Klose
Import upstream version 7.14.0
178
179
  $configurebuild = 0;
1.2.7 by Ramakrishnan Muthukrishnan
Import upstream version 7.21.2
180
  $confheader = 'config-win32.h';
1.1.3 by Matthias Klose
Import upstream version 7.14.0
181
}
182
1.2.1 by Andreas Schuldei
Import upstream version 7.19.5
183
$ENV{LC_ALL}="C" if (($ENV{LC_ALL}) && ($ENV{LC_ALL} !~ /^C$/));
184
$ENV{LC_CTYPE}="C" if (($ENV{LC_CTYPE}) && ($ENV{LC_CTYPE} !~ /^C$/));
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
185
$ENV{LANG}="C";
186
187
sub rmtree($) {
188
    my $target = $_[0];
189
    if ($^O eq 'MSWin32') {
190
      foreach (glob($target)) {
191
        s:/:\\:g;
192
        system("rd /s /q $_");
193
      }
194
    } else {
195
      system("rm -rf $target");
196
    }
197
}
198
199
sub grepfile($$) {
200
    my ($target, $fn) = @_;
201
    open(F, $fn) or die;
202
    while (<F>) {
203
      if (/$target/) {
204
        close(F);
205
        return 1;
206
      }
207
    }
208
    close(F);
209
    return 0;
210
}
211
212
sub logit($) {
213
    my $text=$_[0];
214
    if ($text) {
215
      print "testcurl: $text\n";
216
    }
217
}
218
1.2.1 by Andreas Schuldei
Import upstream version 7.19.5
219
sub logit_spaced($) {
220
    my $text=$_[0];
221
    if ($text) {
222
      print "\ntestcurl: $text\n\n";
223
    }
224
}
225
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
226
sub mydie($){
227
    my $text=$_[0];
228
    logit "$text";
229
    chdir $pwd; # cd back to the original root dir
230
231
    if ($pwd && $build) {
232
      # we have a build directory name, remove the dir
233
      logit "removing the $build dir";
234
      rmtree "$pwd/$build";
235
    }
236
    if (-r $buildlog) {
237
      # we have a build log output file left, remove it
238
      logit "removing the $buildlogname file";
239
      unlink "$buildlog";
240
    }
241
    logit "ENDING HERE"; # last line logged!
242
    exit 1;
243
}
244
1.2.2 by Domenico Andreoli
Import upstream version 7.19.7
245
sub get_host_triplet {
246
  my $triplet;
247
  my $configfile = "$pwd/$build/lib/curl_config.h";
248
249
  if(-f $configfile && -s $configfile && open(LIBCONFIGH, "<$configfile")) {
250
    while(<LIBCONFIGH>) {
251
      if($_ =~ /^\#define\s+OS\s+"*([^"][^"]*)"*\s*/) {
252
        $triplet = $1;
253
        last;
254
      }
255
    }
256
    close(LIBCONFIGH);
257
  }
258
  return $triplet;
259
}
260
1.1.2 by LaMont Jones
Import upstream version 7.12.3
261
if (open(F, "$setupfile")) {
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
262
  while (<F>) {
263
    if (/(\w+)=(.*)/) {
264
      eval "\$$1=$2;";
265
    }
266
  }
267
  close(F);
268
  $infixed=$fixed;
269
} else {
1.1.2 by LaMont Jones
Import upstream version 7.12.3
270
  $infixed=0;    # so that "additional args to configure" works properly first time...
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
271
}
272
273
if (!$name) {
274
  print "please enter your name\n";
275
  $name = <>;
276
  chomp $name;
277
  $fixed=1;
278
}
279
280
if (!$email) {
281
  print "please enter your contact email address\n";
282
  $email = <>;
283
  chomp $email;
284
  $fixed=2;
285
}
286
287
if (!$desc) {
288
  print "please enter a one line system description\n";
289
  $desc = <>;
290
  chomp $desc;
291
  $fixed=3;
292
}
293
294
if (!$confopts) {
295
  if ($infixed < 4) {
296
    print "please enter your additional arguments to configure\n";
297
    print "examples: --with-ssl --enable-debug --enable-ipv6 --with-krb4\n";
298
    $confopts = <>;
299
    chomp $confopts;
1.1.3 by Matthias Klose
Import upstream version 7.14.0
300
  }
301
}
302
303
304
if ($fixed < 4) {
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
305
    $fixed=4;
1.1.3 by Matthias Klose
Import upstream version 7.14.0
306
    open(F, ">$setupfile") or die;
307
    print F "name='$name'\n";
308
    print F "email='$email'\n";
309
    print F "desc='$desc'\n";
310
    print F "confopts='$confopts'\n";
1.2.13 by Alessandro Ghedini
Import upstream version 7.22.0
311
    print F "notes='$notes'\n";
1.1.3 by Matthias Klose
Import upstream version 7.14.0
312
    print F "fixed='$fixed'\n";
313
    close(F);
314
}
315
1.1.12 by Andreas Schuldei
Import upstream version 7.19.4
316
# Enable picky compiler warnings unless explicitly disabled
317
if (($confopts !~ /--enable-debug/) &&
318
    ($confopts !~ /--enable-warnings/) &&
319
    ($confopts !~ /--disable-warnings/)) {
320
  $confopts .= " --enable-warnings";
321
}
322
1.1.7 by Matthias Klose
Import upstream version 7.16.2
323
my $str1066os = 'o' x 1066;
324
325
# Set timestamp to the UTC this script is running. Its value might
326
# be changed later in the script to the value present in curlver.h
327
$timestamp = scalar(gmtime)." UTC";
328
1.1.3 by Matthias Klose
Import upstream version 7.14.0
329
logit "STARTING HERE"; # first line logged, for scripts to trigger on
1.1.7 by Matthias Klose
Import upstream version 7.16.2
330
logit 'TRANSFER CONTROL ==== 1120 CHAR LINE' . $str1066os . 'LINE_END';
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
331
logit "NAME = $name";
332
logit "EMAIL = $email";
333
logit "DESC = $desc";
1.2.13 by Alessandro Ghedini
Import upstream version 7.22.0
334
logit "NOTES = $notes";
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
335
logit "CONFOPTS = $confopts";
1.1.5 by Martin Pitt
Import upstream version 7.15.4
336
logit "CPPFLAGS = ".$ENV{CPPFLAGS};
1.1.3 by Matthias Klose
Import upstream version 7.14.0
337
logit "CFLAGS = ".$ENV{CFLAGS};
338
logit "LDFLAGS = ".$ENV{LDFLAGS};
1.2.17 by Alessandro Ghedini
Import upstream version 7.26.0
339
logit "LIBS = ".$ENV{LIBS};
1.1.3 by Matthias Klose
Import upstream version 7.14.0
340
logit "CC = ".$ENV{CC};
1.2.17 by Alessandro Ghedini
Import upstream version 7.26.0
341
logit "TMPDIR = ".$ENV{TMPDIR};
1.2.1 by Andreas Schuldei
Import upstream version 7.19.5
342
logit "MAKEFLAGS = ".$ENV{MAKEFLAGS};
1.2.15 by Alessandro Ghedini
Import upstream version 7.24.0
343
logit "ACLOCAL_FLAGS = ".$ENV{ACLOCAL_FLAGS};
1.2.2 by Domenico Andreoli
Import upstream version 7.19.7
344
logit "PKG_CONFIG_PATH = ".$ENV{PKG_CONFIG_PATH};
1.2.17 by Alessandro Ghedini
Import upstream version 7.26.0
345
logit "DYLD_LIBRARY_PATH = ".$ENV{DYLD_LIBRARY_PATH};
346
logit "LD_LIBRARY_PATH = ".$ENV{LD_LIBRARY_PATH};
347
logit "LIBRARY_PATH = ".$ENV{LIBRARY_PATH};
348
logit "SHLIB_PATH = ".$ENV{SHLIB_PATH};
349
logit "LIBPATH = ".$ENV{LIBPATH};
1.1.3 by Matthias Klose
Import upstream version 7.14.0
350
logit "target = ".$targetos;
351
logit "version = $version"; # script version
1.1.7 by Matthias Klose
Import upstream version 7.16.2
352
logit "date = $timestamp";  # When the test build starts
353
354
$str1066os = undef;
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
355
356
# Make $pwd to become the path without newline. We'll use that in order to cut
357
# off that path from all possible logs and error messages etc.
1.1.10 by Matthias Klose
Import upstream version 7.18.0
358
$pwd = getcwd();
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
359
1.2.18 by Alessandro Ghedini
Import upstream version 7.27.0
360
my $have_embedded_ares = 0;
361
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
362
if (-d $CURLDIR) {
1.2.4 by Ramakrishnan Muthukrishnan
Import upstream version 7.20.1
363
  if ($git && -d "$CURLDIR/.git") {
364
    logit "$CURLDIR is verified to be a fine git source dir";
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
365
    # remove the generated sources to force them to be re-generated each
366
    # time we run this test
1.3.1 by Alessandro Ghedini
Import upstream version 7.29.0
367
    unlink "$CURLDIR/src/tool_hugehelp.c";
1.2.18 by Alessandro Ghedini
Import upstream version 7.27.0
368
    # find out if curl source dir has an in-tree c-ares repo
369
    $have_embedded_ares = 1 if (-f "$CURLDIR/ares/GIT-INFO");
1.2.4 by Ramakrishnan Muthukrishnan
Import upstream version 7.20.1
370
  } elsif (!$git && -f "$CURLDIR/tests/testcurl.pl") {
1.2.18 by Alessandro Ghedini
Import upstream version 7.27.0
371
    logit "$CURLDIR is verified to be a fine daily source dir";
372
    # find out if curl source dir has an in-tree c-ares extracted tarball
373
    $have_embedded_ares = 1 if (-f "$CURLDIR/ares/ares_build.h");
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
374
  } else {
1.2.4 by Ramakrishnan Muthukrishnan
Import upstream version 7.20.1
375
    mydie "$CURLDIR is not a daily source dir or checked out from git!"
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
376
  }
377
}
378
$build="build-$$";
379
$buildlogname="buildlog-$$";
380
$buildlog="$pwd/$buildlogname";
381
382
# remove any previous left-overs
383
rmtree "build-*";
384
rmtree "buildlog-*";
385
386
# this is to remove old build logs that ended up in the wrong dir
387
foreach (glob("$CURLDIR/buildlog-*")) { unlink $_; }
388
389
# create a dir to build in
390
mkdir $build, 0777;
391
392
if (-d $build) {
393
  logit "build dir $build was created fine";
394
} else {
395
  mydie "failed to create dir $build";
396
}
397
398
# get in the curl source tree root
399
chdir $CURLDIR;
400
1.2.4 by Ramakrishnan Muthukrishnan
Import upstream version 7.20.1
401
# Do the git thing, or not...
402
if ($git) {
403
  # update quietly to the latest git
404
  if($nogitpull) {
405
    logit "skipping git pull (--nogitpull)";
406
  } else {
407
    my $gitstat = 0;
408
    my @commits;
409
    logit "run git pull in curl";
410
    system("git pull 2>&1");
411
    $gitstat += $?;
412
    logit "failed to update from curl git ($?), continue anyway" if ($?);
413
    # get the last 5 commits for show (even if no pull was made)
414
    @commits=`git log --pretty=oneline --abbrev-commit -5`;
415
    logit "The most recent curl git commits:";
416
    for (@commits) {
417
      chomp ($_);
418
      logit "  $_";
419
    }
420
    if (-d "ares/.git") {
421
      chdir "ares";
422
      logit "run git pull in ares";
423
      system("git pull 2>&1");
424
      $gitstat += $?;
425
      logit "failed to update from ares git ($?), continue anyway" if ($?);
426
      # get the last 5 commits for show (even if no pull was made)
427
      @commits=`git log --pretty=oneline --abbrev-commit -5`;
428
      logit "The most recent ares git commits:";
429
      for (@commits) {
430
        chomp ($_);
431
        logit "  $_";
432
      }
433
      chdir "$pwd/$CURLDIR";
434
    }
435
    # Set timestamp to the UTC the git update took place.
436
    $timestamp = scalar(gmtime)." UTC" if (!$gitstat);
1.1.7 by Matthias Klose
Import upstream version 7.16.2
437
  }
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
438
1.1.4 by Martin Pitt
Import upstream version 7.15.1
439
  if($nobuildconf) {
1.2.4 by Ramakrishnan Muthukrishnan
Import upstream version 7.20.1
440
    logit "told to not run buildconf";
1.1.4 by Martin Pitt
Import upstream version 7.15.1
441
  }
442
  elsif ($configurebuild) {
443
    # remove possible left-overs from the past
444
    unlink "configure";
445
    unlink "autom4te.cache";
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
446
447
    # generate the build files
1.2.15 by Alessandro Ghedini
Import upstream version 7.24.0
448
    logit "invoke buildconf";
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
449
    open(F, "./buildconf 2>&1 |") or die;
450
    open(LOG, ">$buildlog") or die;
451
    while (<F>) {
1.2.15 by Alessandro Ghedini
Import upstream version 7.24.0
452
      my $ll = $_;
453
      # ignore messages pertaining to third party m4 files we don't care
454
      next if ($ll =~ /aclocal\/gtk\.m4/);
455
      next if ($ll =~ /aclocal\/gtkextra\.m4/);
456
      print $ll;
457
      print LOG $ll;
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
458
    }
459
    close(F);
460
    close(LOG);
461
462
    if (grepfile("^buildconf: OK", $buildlog)) {
1.1.2 by LaMont Jones
Import upstream version 7.12.3
463
      logit "buildconf was successful";
1.1.3 by Matthias Klose
Import upstream version 7.14.0
464
    }
465
    else {
1.1.2 by LaMont Jones
Import upstream version 7.12.3
466
      mydie "buildconf was NOT successful";
467
    }
1.1.3 by Matthias Klose
Import upstream version 7.14.0
468
  }
469
  else {
470
    logit "buildconf was successful (dummy message)";
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
471
  }
472
}
473
1.2.4 by Ramakrishnan Muthukrishnan
Import upstream version 7.20.1
474
# Set timestamp to the one in curlver.h if this isn't a git test build.
1.1.7 by Matthias Klose
Import upstream version 7.16.2
475
if ((-f "include/curl/curlver.h") &&
476
    (open(F, "<include/curl/curlver.h"))) {
477
  while (<F>) {
478
    chomp;
479
    if ($_ =~ /^\#define\s+LIBCURL_TIMESTAMP\s+\"(.+)\".*$/) {
480
      my $stampstring = $1;
1.2.4 by Ramakrishnan Muthukrishnan
Import upstream version 7.20.1
481
      if ($stampstring !~ /DEV/) {
1.1.7 by Matthias Klose
Import upstream version 7.16.2
482
          $stampstring =~ s/\s+UTC//;
483
          $timestamp = $stampstring." UTC";
484
      }
485
      last;
486
    }
487
  }
488
  close(F);
489
}
490
491
# Show timestamp we are using for this test build.
492
logit "timestamp = $timestamp";
493
1.1.3 by Matthias Klose
Import upstream version 7.14.0
494
if ($configurebuild) {
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
495
  if (-f "configure") {
1.1.4 by Martin Pitt
Import upstream version 7.15.1
496
    logit "configure created (at least it exists)";
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
497
  } else {
1.1.4 by Martin Pitt
Import upstream version 7.15.1
498
    mydie "no configure created/found";
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
499
  }
500
} else {
501
  logit "configure created (dummy message)"; # dummy message to feign success
502
}
503
1.1.4 by Martin Pitt
Import upstream version 7.15.1
504
sub findinpath {
505
  my $c;
506
  my $e;
1.2.2 by Domenico Andreoli
Import upstream version 7.19.7
507
  my $x = ($^O eq 'MSWin32') ? '.exe' : '';
508
  my $s = ($^O eq 'MSWin32') ? ';' : ':';
1.1.4 by Martin Pitt
Import upstream version 7.15.1
509
  my $p=$ENV{'PATH'};
510
  my @pa = split($s, $p);
511
  for $c (@_) {
512
    for $e (@pa) {
513
      if( -x "$e/$c$x") {
514
        return $c;
515
      }
516
    }
517
  }
518
}
519
520
my $make = findinpath("gmake", "make", "nmake");
521
if(!$make) {
522
    mydie "Couldn't find make in the PATH";
523
}
1.2.2 by Domenico Andreoli
Import upstream version 7.19.7
524
# force to 'nmake' for VC builds
525
$make = "nmake" if ($targetos =~ /vc/);
1.2.6 by Ramakrishnan Muthukrishnan
Import upstream version 7.21.1
526
# force to 'wmake' for Watcom builds
527
$make = "wmake" if ($targetos =~ /watcom/);
1.1.4 by Martin Pitt
Import upstream version 7.15.1
528
logit "going with $make as make";
529
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
530
# change to build dir
531
chdir "$pwd/$build";
532
1.1.3 by Matthias Klose
Import upstream version 7.14.0
533
if ($configurebuild) {
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
534
  # run configure script
1.1.2 by LaMont Jones
Import upstream version 7.12.3
535
  print `../$CURLDIR/configure $confopts 2>&1`;
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
536
537
  if (-f "lib/Makefile") {
538
    logit "configure seems to have finished fine";
539
  } else {
540
    mydie "configure didn't work";
541
  }
542
} else {
1.1.8 by Matthias Klose
Import upstream version 7.16.4
543
  logit "copying files to build dir ...";
1.1.2 by LaMont Jones
Import upstream version 7.12.3
544
  if (($^O eq 'MSWin32') && ($targetos !~ /netware/)) {
545
    system("xcopy /s /q ..\\$CURLDIR .");
546
    system("buildconf.bat");
1.1.3 by Matthias Klose
Import upstream version 7.14.0
547
  }
1.1.12 by Andreas Schuldei
Import upstream version 7.19.4
548
  elsif ($targetos =~ /netware/) {
549
    system("cp -afr ../$CURLDIR/* .");
550
    system("cp -af ../$CURLDIR/Makefile.dist Makefile");
551
    system("$make -i -C lib -f Makefile.netware prebuild");
552
    system("$make -i -C src -f Makefile.netware prebuild");
1.2.1 by Andreas Schuldei
Import upstream version 7.19.5
553
    if (-d "../$CURLDIR/ares") {
554
      system("$make -i -C ares -f Makefile.netware prebuild");
555
    }
1.1.12 by Andreas Schuldei
Import upstream version 7.19.4
556
  }
557
  elsif ($^O eq 'linux') {
558
    system("cp -afr ../$CURLDIR/* .");
559
    system("cp -af ../$CURLDIR/Makefile.dist Makefile");
560
    system("cp -af ../$CURLDIR/include/curl/curlbuild.h.dist ./include/curl/curlbuild.h");
1.1.4 by Martin Pitt
Import upstream version 7.15.1
561
    system("$make -i -C lib -f Makefile.$targetos prebuild");
562
    system("$make -i -C src -f Makefile.$targetos prebuild");
1.2.1 by Andreas Schuldei
Import upstream version 7.19.5
563
    if (-d "../$CURLDIR/ares") {
564
      system("cp -af ../$CURLDIR/ares/ares_build.h.dist ./ares/ares_build.h");
565
      system("$make -i -C ares -f Makefile.$targetos prebuild");
566
    }
567
  }
568
}
569
570
if(-f "./libcurl.pc") {
571
  logit_spaced "display libcurl.pc";
572
  if(open(F, "<./libcurl.pc")) {
573
    while(<F>) {
574
      my $ll = $_;
575
      print $ll if(($ll !~ /^ *#/) && ($ll !~ /^ *$/));
576
    }
577
    close(F);
1.1.2 by LaMont Jones
Import upstream version 7.12.3
578
  }
579
}
580
1.1.12 by Andreas Schuldei
Import upstream version 7.19.4
581
if(-f "./include/curl/curlbuild.h") {
1.2.1 by Andreas Schuldei
Import upstream version 7.19.5
582
  logit_spaced "display include/curl/curlbuild.h";
1.1.12 by Andreas Schuldei
Import upstream version 7.19.4
583
  if(open(F, "<./include/curl/curlbuild.h")) {
584
    while(<F>) {
585
      my $ll = $_;
1.2.1 by Andreas Schuldei
Import upstream version 7.19.5
586
      print $ll if(($ll =~ /^ *# *define *CURL_/) && ($ll !~ /__CURL_CURLBUILD_H/));
1.1.12 by Andreas Schuldei
Import upstream version 7.19.4
587
    }
588
    close(F);
589
  }
590
}
591
else {
592
  mydie "no curlbuild.h created/found";
593
}
594
1.2.7 by Ramakrishnan Muthukrishnan
Import upstream version 7.21.2
595
logit_spaced "display lib/$confheader";
596
open(F, "lib/$confheader") or die "lib/$confheader: $!";
1.1.2 by LaMont Jones
Import upstream version 7.12.3
597
while (<F>) {
598
  print if /^ *#/;
599
}
600
close(F);
601
1.2.18 by Alessandro Ghedini
Import upstream version 7.27.0
602
if (($have_embedded_ares) &&
603
    (grepfile("^#define USE_ARES", "lib/$confheader"))) {
1.2.1 by Andreas Schuldei
Import upstream version 7.19.5
604
  print "\n";
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
605
  logit "setup to build ares";
606
1.2.1 by Andreas Schuldei
Import upstream version 7.19.5
607
  if(-f "./ares/libcares.pc") {
608
    logit_spaced  "display ares/libcares.pc";
609
    if(open(F, "<./ares/libcares.pc")) {
610
      while(<F>) {
611
        my $ll = $_;
612
        print $ll if(($ll !~ /^ *#/) && ($ll !~ /^ *$/));
613
      }
614
      close(F);
615
    }
616
  }
617
618
  if(-f "./ares/ares_build.h") {
619
    logit_spaced "display ares/ares_build.h";
620
    if(open(F, "<./ares/ares_build.h")) {
621
      while(<F>) {
622
        my $ll = $_;
623
        print $ll if(($ll =~ /^ *# *define *CARES_/) && ($ll !~ /__CARES_BUILD_H/));
624
      }
625
      close(F);
626
    }
627
  }
628
  else {
629
    mydie "no ares_build.h created/found";
630
  }
631
1.2.7 by Ramakrishnan Muthukrishnan
Import upstream version 7.21.2
632
  $confheader =~ s/curl/ares/;
633
  logit_spaced "display ares/$confheader";
634
  if(open(F, "ares/$confheader")) {
1.1.3 by Matthias Klose
Import upstream version 7.14.0
635
      while (<F>) {
636
          print if /^ *#/;
637
      }
638
      close(F);
639
  }
640
1.2.1 by Andreas Schuldei
Import upstream version 7.19.5
641
  print "\n";
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
642
  logit "build ares";
643
  chdir "ares";
1.1.2 by LaMont Jones
Import upstream version 7.12.3
644
1.1.3 by Matthias Klose
Import upstream version 7.14.0
645
  if ($targetos && !$configurebuild) {
1.1.4 by Martin Pitt
Import upstream version 7.15.1
646
      logit "$make -f Makefile.$targetos";
647
      open(F, "$make -f Makefile.$targetos 2>&1 |") or die;
1.1.3 by Matthias Klose
Import upstream version 7.14.0
648
  }
649
  else {
1.1.4 by Martin Pitt
Import upstream version 7.15.1
650
      logit "$make";
651
      open(F, "$make 2>&1 |") or die;
1.1.2 by LaMont Jones
Import upstream version 7.12.3
652
  }
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
653
  while (<F>) {
654
    s/$pwd//g;
655
    print;
656
  }
657
  close(F);
658
1.1.2 by LaMont Jones
Import upstream version 7.12.3
659
  if (-f "libcares$libext") {
660
    logit "ares is now built successfully (libcares$libext)";
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
661
  } else {
1.2.2 by Domenico Andreoli
Import upstream version 7.19.7
662
    mydie "ares build failed (libcares$libext)";
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
663
  }
664
665
  # cd back to the curl build dir
666
  chdir "$pwd/$build";
667
}
668
1.2.2 by Domenico Andreoli
Import upstream version 7.19.7
669
my $mkcmd = "$make -i" . ($targetos && !$configurebuild ? " $targetos" : "");
670
logit "$mkcmd";
671
open(F, "$mkcmd 2>&1 |") or die;
672
while (<F>) {
673
  s/$pwd//g;
674
  print;
675
}
676
close(F);
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
677
1.1.2 by LaMont Jones
Import upstream version 7.12.3
678
if (-f "lib/libcurl$libext") {
1.1.5 by Martin Pitt
Import upstream version 7.15.4
679
  logit "libcurl was created fine (libcurl$libext)";
1.1.3 by Matthias Klose
Import upstream version 7.14.0
680
}
681
else {
1.1.5 by Martin Pitt
Import upstream version 7.15.4
682
  mydie "libcurl was not created (libcurl$libext)";
1.1.2 by LaMont Jones
Import upstream version 7.12.3
683
}
684
685
if (-f "src/curl$binext") {
1.1.5 by Martin Pitt
Import upstream version 7.15.4
686
  logit "curl was created fine (curl$binext)";
1.1.3 by Matthias Klose
Import upstream version 7.14.0
687
}
688
else {
1.1.5 by Martin Pitt
Import upstream version 7.15.4
689
  mydie "curl was not created (curl$binext)";
1.1.2 by LaMont Jones
Import upstream version 7.12.3
690
}
691
1.1.11 by Michael Vogt
Import upstream version 7.18.2
692
if (!$crosscompile || (($extvercmd ne '') && (-x $extvercmd))) {
693
  logit "display curl${binext} --version output";
694
  my $cmd = ($extvercmd ne '' ? $extvercmd.' ' : '')."./src/curl${binext} --version|";
695
  open(F, $cmd);
1.1.3 by Matthias Klose
Import upstream version 7.14.0
696
  while(<F>) {
1.2.2 by Domenico Andreoli
Import upstream version 7.19.7
697
    # strip CR from output on non-win32 platforms (wine on Linux)
698
    s/\r// if ($^O ne 'MSWin32');
699
    print;
1.1.3 by Matthias Klose
Import upstream version 7.14.0
700
  }
701
  close(F);
1.1.2 by LaMont Jones
Import upstream version 7.12.3
702
}
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
703
1.1.3 by Matthias Klose
Import upstream version 7.14.0
704
if ($configurebuild && !$crosscompile) {
1.3.1 by Alessandro Ghedini
Import upstream version 7.29.0
705
  my $host_triplet = get_host_triplet();
706
  # build example programs for selected build targets
707
  if(($host_triplet =~ /([^-]+)-([^-]+)-irix(.*)/) ||
708
     ($host_triplet =~ /([^-]+)-([^-]+)-aix(.*)/) ||
709
     ($host_triplet =~ /([^-]+)-([^-]+)-osf(.*)/) ||
710
     ($host_triplet =~ /([^-]+)-([^-]+)-solaris2(.*)/)) {
711
    chdir "$pwd/$build/docs/examples";
712
    logit_spaced "build examples";
713
    open(F, "$make -i 2>&1 |") or die;
714
    open(LOG, ">$buildlog") or die;
715
    while (<F>) {
716
      s/$pwd//g;
717
      print;
718
      print LOG;
719
    }
720
    close(F);
721
    close(LOG);
722
    chdir "$pwd/$build";
723
  }
724
  # build and run full test suite
1.1.3 by Matthias Klose
Import upstream version 7.14.0
725
  my $o;
726
  if($runtestopts) {
727
      $o = "TEST_F=\"$runtestopts\" ";
728
  }
1.1.4 by Martin Pitt
Import upstream version 7.15.1
729
  logit "$make -k ${o}test-full";
730
  open(F, "$make -k ${o}test-full 2>&1 |") or die;
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
731
  open(LOG, ">$buildlog") or die;
732
  while (<F>) {
733
    s/$pwd//g;
734
    print;
735
    print LOG;
736
  }
737
  close(F);
738
  close(LOG);
739
740
  if (grepfile("^TEST", $buildlog)) {
741
    logit "tests were run";
742
  } else {
743
    mydie "test suite failure";
744
  }
745
746
  if (grepfile("^TESTFAIL:", $buildlog)) {
747
    logit "the tests were not successful";
748
  } else {
749
    logit "the tests were successful!";
750
  }
1.2.2 by Domenico Andreoli
Import upstream version 7.19.7
751
}
752
else {
753
  if($crosscompile) {
1.2.17 by Alessandro Ghedini
Import upstream version 7.26.0
754
    my $host_triplet = get_host_triplet();
755
    # build example programs for selected cross-compiles
756
    if(($host_triplet =~ /([^-]+)-([^-]+)-mingw(.*)/) ||
757
       ($host_triplet =~ /([^-]+)-([^-]+)-android(.*)/)) {
758
      chdir "$pwd/$build/docs/examples";
759
      logit_spaced "build examples";
760
      open(F, "$make -i 2>&1 |") or die;
761
      open(LOG, ">$buildlog") or die;
762
      while (<F>) {
763
        s/$pwd//g;
764
        print;
765
        print LOG;
766
      }
767
      close(F);
768
      close(LOG);
769
      chdir "$pwd/$build";
770
    }
1.2.2 by Domenico Andreoli
Import upstream version 7.19.7
771
    # build test harness programs for selected cross-compiles
772
    if($host_triplet =~ /([^-]+)-([^-]+)-mingw(.*)/) {
773
      chdir "$pwd/$build/tests";
774
      logit_spaced "build test harness";
775
      open(F, "$make -i 2>&1 |") or die;
776
      open(LOG, ">$buildlog") or die;
777
      while (<F>) {
778
        s/$pwd//g;
779
        print;
780
        print LOG;
781
      }
782
      close(F);
783
      close(LOG);
784
      chdir "$pwd/$build";
785
    }
786
    logit_spaced "cross-compiling, can't run tests";
787
  }
1.1.3 by Matthias Klose
Import upstream version 7.14.0
788
  # dummy message to feign success
789
  print "TESTDONE: 1 tests out of 0 (dummy message)\n";
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
790
}
791
1.1.2 by LaMont Jones
Import upstream version 7.12.3
792
# create a tarball if we got that option.
1.1.11 by Michael Vogt
Import upstream version 7.18.2
793
if (($mktarball ne '') && (-x $mktarball)) {
1.1.2 by LaMont Jones
Import upstream version 7.12.3
794
  system($mktarball);
795
}
796
1.1.1 by Domenico Andreoli
Import upstream version 7.12.0.is.7.11.2
797
# mydie to cleanup
798
mydie "ending nicely";