testcurl.pl 21 KB

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