2013-04-17 02:19:26 +02:00
|
|
|
#!/usr/bin/env perl
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings;
|
|
|
|
|
|
|
|
use Getopt::Std qw(getopts);
|
|
|
|
use Cwd qw/cwd/;
|
|
|
|
|
|
|
|
sub sh ($);
|
|
|
|
|
|
|
|
my %opts;
|
2013-04-17 21:08:54 +02:00
|
|
|
getopts("lf:", \%opts) or die "Usage: $0 [-f] <cores>\n";
|
2013-04-17 02:19:26 +02:00
|
|
|
|
|
|
|
my $jobs = shift || 4;
|
|
|
|
|
|
|
|
my $cwd = cwd();
|
|
|
|
if ($cwd !~ /ngx_openresty-(\d+(?:\.\d+)+)$/) {
|
|
|
|
die "Bad current working directory: $cwd\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
my $ver = $1;
|
|
|
|
|
2013-04-17 21:08:54 +02:00
|
|
|
my ($make, $lua);
|
2013-04-17 02:19:26 +02:00
|
|
|
|
|
|
|
if ($^O eq 'freebsd' || $^O eq 'solaris') {
|
|
|
|
$make = 'gmake';
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$make = 'make';
|
|
|
|
}
|
|
|
|
|
2013-04-17 02:30:28 +02:00
|
|
|
my $cfg_opts = "--with-http_iconv_module";
|
2013-04-17 21:08:54 +02:00
|
|
|
|
|
|
|
if ($opts{l}) {
|
|
|
|
$lua = 'Lua';
|
|
|
|
|
|
|
|
} else {
|
|
|
|
$lua = 'LuaJIT';
|
|
|
|
$cfg_opts .= " --with-luajit";
|
|
|
|
}
|
|
|
|
|
2013-04-17 02:19:26 +02:00
|
|
|
my $prefix;
|
|
|
|
|
|
|
|
warn "=== Normal Build ===\n";
|
|
|
|
$prefix = "/usr/local/openresty";
|
|
|
|
unless ($opts{f}) {
|
2013-04-17 21:08:54 +02:00
|
|
|
sh "./configure $cfg_opts -j$jobs > /dev/null";
|
2013-04-17 02:19:26 +02:00
|
|
|
}
|
|
|
|
sh "$make -j$jobs > /dev/null";
|
|
|
|
sh "sudo $make install > /dev/null";
|
|
|
|
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep $ver";
|
2013-04-17 02:24:10 +02:00
|
|
|
system "sudo killall nginx > /dev/null 2>&1";
|
2013-04-17 02:19:26 +02:00
|
|
|
sh "sudo $prefix/nginx/sbin/nginx";
|
2013-04-17 21:08:54 +02:00
|
|
|
sh "curl -si localhost/lua|grep $lua";
|
2013-04-17 02:19:26 +02:00
|
|
|
sh "curl -si localhost/lua|grep $ver";
|
|
|
|
sh "sudo $prefix/nginx/sbin/nginx -sstop";
|
|
|
|
|
|
|
|
warn "\n=== Debug Build ===\n";
|
|
|
|
$prefix = "/usr/local/openresty-debug";
|
|
|
|
unless ($opts{f}) {
|
2013-04-17 21:08:54 +02:00
|
|
|
sh "./configure --with-debug $cfg_opts --prefix=$prefix -j$jobs > /dev/null";
|
2013-04-17 02:19:26 +02:00
|
|
|
}
|
|
|
|
sh "$make -j$jobs > /dev/null";
|
|
|
|
sh "sudo $make install > /dev/null";
|
|
|
|
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep $ver";
|
|
|
|
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep '\\--with-debug'";
|
2013-04-17 02:24:10 +02:00
|
|
|
system "sudo killall nginx > /dev/null 2>&1";
|
2013-04-17 02:19:26 +02:00
|
|
|
sh "sudo $prefix/nginx/sbin/nginx";
|
2013-04-17 21:08:54 +02:00
|
|
|
sh "curl -si localhost/lua|grep $lua";
|
2013-04-17 02:19:26 +02:00
|
|
|
sh "curl -si localhost/lua|grep $ver";
|
|
|
|
sh "sudo $prefix/nginx/sbin/nginx -sstop";
|
|
|
|
|
|
|
|
warn "\n=== DTrace Build ===\n";
|
|
|
|
$prefix = "/usr/local/openresty-dtrace";
|
|
|
|
unless ($opts{f}) {
|
2013-04-17 21:08:54 +02:00
|
|
|
sh "./configure $cfg_opts --with-dtrace-probes --prefix=$prefix -j$jobs > /dev/null";
|
2013-04-17 02:19:26 +02:00
|
|
|
}
|
|
|
|
sh "$make -j$jobs > /dev/null";
|
|
|
|
sh "sudo $make install > /dev/null";
|
|
|
|
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep $ver";
|
|
|
|
sh "$prefix/nginx/sbin/nginx -V 2>&1 |grep '\\--with-dtrace-probes'";
|
2013-04-17 02:24:10 +02:00
|
|
|
system "sudo killall nginx > /dev/null 2>&1";
|
2013-04-17 02:19:26 +02:00
|
|
|
sh "sudo $prefix/nginx/sbin/nginx";
|
2013-04-17 21:08:54 +02:00
|
|
|
sh "curl -si localhost/lua|grep $lua";
|
2013-04-17 02:19:26 +02:00
|
|
|
sh "curl -si localhost/lua|grep $ver";
|
|
|
|
if ($^O eq 'linux') {
|
|
|
|
sh "stap -L 'process(\"$prefix/nginx/sbin/nginx\").mark(\"*\")'|grep http__lua__coroutine__done";
|
|
|
|
|
2013-04-18 08:06:29 +02:00
|
|
|
} elsif ($^O eq 'freebsd' || $^O eq 'darwin' || $^O eq 'solaris') {
|
2013-04-17 02:19:26 +02:00
|
|
|
sh "sudo dtrace -l|grep http-lua-coroutine-done";
|
|
|
|
}
|
|
|
|
|
|
|
|
sh "sudo $prefix/nginx/sbin/nginx -sstop";
|
|
|
|
|
|
|
|
sub sh ($) {
|
|
|
|
my $cmd = shift;
|
|
|
|
system($cmd) == 0 or die "Command \"$cmd\" failed";
|
|
|
|
}
|