testcurl.pl 20 KB

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