testcurl.pl 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814
  1. #!/usr/bin/env perl
  2. #***************************************************************************
  3. # _ _ ____ _
  4. # Project ___| | | | _ \| |
  5. # / __| | | | |_) | |
  6. # | (__| |_| | _ <| |___
  7. # \___|\___/|_| \_\_____|
  8. #
  9. # Copyright (C) 1998 - 2017, 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.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. # 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 resonable backlog) will
  33. # be published on the curl site, at https://curl.haxx.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 '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-ssl --enable-debug --enable-ipv6 --with-krb4\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. # ignore messages pertaining to third party m4 files we don't care
  427. next if ($ll =~ /aclocal\/gtk\.m4/);
  428. next if ($ll =~ /aclocal\/gtkextra\.m4/);
  429. print $ll;
  430. print LOG $ll;
  431. }
  432. close(F);
  433. close(LOG);
  434. if (grepfile("^buildconf: OK", $buildlog)) {
  435. logit "buildconf was successful";
  436. }
  437. else {
  438. mydie "buildconf was NOT successful";
  439. }
  440. }
  441. else {
  442. logit "buildconf was successful (dummy message)";
  443. }
  444. }
  445. # Set timestamp to the one in curlver.h if this isn't a git test build.
  446. if ((-f "include/curl/curlver.h") &&
  447. (open(F, "<include/curl/curlver.h"))) {
  448. while (<F>) {
  449. chomp;
  450. if ($_ =~ /^\#define\s+LIBCURL_TIMESTAMP\s+\"(.+)\".*$/) {
  451. my $stampstring = $1;
  452. if ($stampstring !~ /DEV/) {
  453. $stampstring =~ s/\s+UTC//;
  454. $timestamp = $stampstring." UTC";
  455. }
  456. last;
  457. }
  458. }
  459. close(F);
  460. }
  461. # Show timestamp we are using for this test build.
  462. logit "timestamp = $timestamp";
  463. if ($configurebuild) {
  464. if (-f "configure") {
  465. logit "configure created (at least it exists)";
  466. } else {
  467. mydie "no configure created/found";
  468. }
  469. } else {
  470. logit "configure created (dummy message)"; # dummy message to feign success
  471. }
  472. sub findinpath {
  473. my $c;
  474. my $e;
  475. my $x = ($^O eq 'MSWin32') ? '.exe' : '';
  476. my $s = ($^O eq 'MSWin32') ? ';' : ':';
  477. my $p=$ENV{'PATH'};
  478. my @pa = split($s, $p);
  479. for $c (@_) {
  480. for $e (@pa) {
  481. if( -x "$e/$c$x") {
  482. return $c;
  483. }
  484. }
  485. }
  486. }
  487. my $make = findinpath("gmake", "make", "nmake");
  488. if(!$make) {
  489. mydie "Couldn't find make in the PATH";
  490. }
  491. # force to 'nmake' for VC builds
  492. $make = "nmake" if ($targetos =~ /vc/);
  493. # force to 'wmake' for Watcom builds
  494. $make = "wmake" if ($targetos =~ /watcom/);
  495. logit "going with $make as make";
  496. # change to build dir
  497. chdir "$pwd/$build";
  498. if ($configurebuild) {
  499. # run configure script
  500. print `$CURLDIR/configure $confopts 2>&1`;
  501. if (-f "lib/Makefile") {
  502. logit "configure seems to have finished fine";
  503. } else {
  504. mydie "configure didn't work";
  505. }
  506. } else {
  507. logit "copying files to build dir ...";
  508. if (($^O eq 'MSWin32') && ($targetos !~ /netware/)) {
  509. system("xcopy /s /q \"$CURLDIR\" .");
  510. system("buildconf.bat");
  511. }
  512. elsif ($targetos =~ /netware/) {
  513. system("cp -afr $CURLDIR/* .");
  514. system("cp -af $CURLDIR/Makefile.dist Makefile");
  515. system("$make -i -C lib -f Makefile.netware prebuild");
  516. system("$make -i -C src -f Makefile.netware prebuild");
  517. if (-d "$CURLDIR/ares") {
  518. system("$make -i -C ares -f Makefile.netware prebuild");
  519. }
  520. }
  521. elsif ($^O eq 'linux') {
  522. system("cp -afr $CURLDIR/* .");
  523. system("cp -af $CURLDIR/Makefile.dist Makefile");
  524. system("$make -i -C lib -f Makefile.$targetos prebuild");
  525. system("$make -i -C src -f Makefile.$targetos prebuild");
  526. if (-d "$CURLDIR/ares") {
  527. system("cp -af $CURLDIR/ares/ares_build.h.dist ./ares/ares_build.h");
  528. system("$make -i -C ares -f Makefile.$targetos prebuild");
  529. }
  530. }
  531. }
  532. if(-f "./libcurl.pc") {
  533. logit_spaced "display libcurl.pc";
  534. if(open(F, "<./libcurl.pc")) {
  535. while(<F>) {
  536. my $ll = $_;
  537. print $ll if(($ll !~ /^ *#/) && ($ll !~ /^ *$/));
  538. }
  539. close(F);
  540. }
  541. }
  542. logit_spaced "display lib/$confheader";
  543. open(F, "lib/$confheader") or die "lib/$confheader: $!";
  544. while (<F>) {
  545. print if /^ *#/;
  546. }
  547. close(F);
  548. if (($have_embedded_ares) &&
  549. (grepfile("^#define USE_ARES", "lib/$confheader"))) {
  550. print "\n";
  551. logit "setup to build ares";
  552. if(-f "./ares/libcares.pc") {
  553. logit_spaced "display ares/libcares.pc";
  554. if(open(F, "<./ares/libcares.pc")) {
  555. while(<F>) {
  556. my $ll = $_;
  557. print $ll if(($ll !~ /^ *#/) && ($ll !~ /^ *$/));
  558. }
  559. close(F);
  560. }
  561. }
  562. if(-f "./ares/ares_build.h") {
  563. logit_spaced "display ares/ares_build.h";
  564. if(open(F, "<./ares/ares_build.h")) {
  565. while(<F>) {
  566. my $ll = $_;
  567. print $ll if(($ll =~ /^ *# *define *CARES_/) && ($ll !~ /__CARES_BUILD_H/));
  568. }
  569. close(F);
  570. }
  571. }
  572. else {
  573. mydie "no ares_build.h created/found";
  574. }
  575. $confheader =~ s/curl/ares/;
  576. logit_spaced "display ares/$confheader";
  577. if(open(F, "ares/$confheader")) {
  578. while (<F>) {
  579. print if /^ *#/;
  580. }
  581. close(F);
  582. }
  583. print "\n";
  584. logit "build ares";
  585. chdir "ares";
  586. if ($targetos && !$configurebuild) {
  587. logit "$make -f Makefile.$targetos";
  588. open(F, "$make -f Makefile.$targetos 2>&1 |") or die;
  589. }
  590. else {
  591. logit "$make";
  592. open(F, "$make 2>&1 |") or die;
  593. }
  594. while (<F>) {
  595. s/$pwd//g;
  596. print;
  597. }
  598. close(F);
  599. if (-f "libcares$libext") {
  600. logit "ares is now built successfully (libcares$libext)";
  601. } else {
  602. mydie "ares build failed (libcares$libext)";
  603. }
  604. # cd back to the curl build dir
  605. chdir "$pwd/$build";
  606. }
  607. my $mkcmd = "$make -i" . ($targetos && !$configurebuild ? " $targetos" : "");
  608. logit "$mkcmd";
  609. open(F, "$mkcmd 2>&1 |") or die;
  610. while (<F>) {
  611. s/$pwd//g;
  612. print;
  613. }
  614. close(F);
  615. if (-f "lib/libcurl$libext") {
  616. logit "libcurl was created fine (libcurl$libext)";
  617. }
  618. else {
  619. mydie "libcurl was not created (libcurl$libext)";
  620. }
  621. if (-f "src/curl$binext") {
  622. logit "curl was created fine (curl$binext)";
  623. }
  624. else {
  625. mydie "curl was not created (curl$binext)";
  626. }
  627. if (!$crosscompile || (($extvercmd ne '') && (-x $extvercmd))) {
  628. logit "display curl${binext} --version output";
  629. my $cmd = ($extvercmd ne '' ? $extvercmd.' ' : '')."./src/curl${binext} --version|";
  630. open(F, $cmd);
  631. while(<F>) {
  632. # strip CR from output on non-win32 platforms (wine on Linux)
  633. s/\r// if ($^O ne 'MSWin32');
  634. print;
  635. }
  636. close(F);
  637. }
  638. if ($configurebuild && !$crosscompile) {
  639. my $host_triplet = get_host_triplet();
  640. # build example programs for selected build targets
  641. if(($host_triplet =~ /([^-]+)-([^-]+)-irix(.*)/) ||
  642. ($host_triplet =~ /([^-]+)-([^-]+)-aix(.*)/) ||
  643. ($host_triplet =~ /([^-]+)-([^-]+)-osf(.*)/) ||
  644. ($host_triplet =~ /([^-]+)-([^-]+)-solaris2(.*)/)) {
  645. chdir "$pwd/$build/docs/examples";
  646. logit_spaced "build examples";
  647. open(F, "$make -i 2>&1 |") or die;
  648. open(LOG, ">$buildlog") or die;
  649. while (<F>) {
  650. s/$pwd//g;
  651. print;
  652. print LOG;
  653. }
  654. close(F);
  655. close(LOG);
  656. chdir "$pwd/$build";
  657. }
  658. # build and run full test suite
  659. my $o;
  660. if($runtestopts) {
  661. $o = "TEST_F=\"$runtestopts\" ";
  662. }
  663. logit "$make -k ${o}test-full";
  664. open(F, "$make -k ${o}test-full 2>&1 |") or die;
  665. open(LOG, ">$buildlog") or die;
  666. while (<F>) {
  667. s/$pwd//g;
  668. print;
  669. print LOG;
  670. }
  671. close(F);
  672. close(LOG);
  673. if (grepfile("^TEST", $buildlog)) {
  674. logit "tests were run";
  675. } else {
  676. mydie "test suite failure";
  677. }
  678. if (grepfile("^TESTFAIL:", $buildlog)) {
  679. logit "the tests were not successful";
  680. } else {
  681. logit "the tests were successful!";
  682. }
  683. }
  684. else {
  685. if($crosscompile) {
  686. my $host_triplet = get_host_triplet();
  687. # build example programs for selected cross-compiles
  688. if(($host_triplet =~ /([^-]+)-([^-]+)-mingw(.*)/) ||
  689. ($host_triplet =~ /([^-]+)-([^-]+)-android(.*)/)) {
  690. chdir "$pwd/$build/docs/examples";
  691. logit_spaced "build examples";
  692. open(F, "$make -i 2>&1 |") or die;
  693. open(LOG, ">$buildlog") or die;
  694. while (<F>) {
  695. s/$pwd//g;
  696. print;
  697. print LOG;
  698. }
  699. close(F);
  700. close(LOG);
  701. chdir "$pwd/$build";
  702. }
  703. # build test harness programs for selected cross-compiles
  704. if($host_triplet =~ /([^-]+)-([^-]+)-mingw(.*)/) {
  705. chdir "$pwd/$build/tests";
  706. logit_spaced "build test harness";
  707. open(F, "$make -i 2>&1 |") or die;
  708. open(LOG, ">$buildlog") or die;
  709. while (<F>) {
  710. s/$pwd//g;
  711. print;
  712. print LOG;
  713. }
  714. close(F);
  715. close(LOG);
  716. chdir "$pwd/$build";
  717. }
  718. logit_spaced "cross-compiling, can't run tests";
  719. }
  720. # dummy message to feign success
  721. print "TESTDONE: 1 tests out of 0 (dummy message)\n";
  722. }
  723. # create a tarball if we got that option.
  724. if (($mktarball ne '') && (-x $mktarball)) {
  725. system($mktarball);
  726. }
  727. # mydie to cleanup
  728. mydie "ending nicely";