added the --with-pg_config option to ./configure script as per 罗翼's suggestion. released ngx_openresty 1.0.4.2rc6.

This commit is contained in:
agentzh (章亦春) 2011-08-05 15:21:58 +08:00
parent 2654f60c1b
commit 6431074de4
3 changed files with 137 additions and 14 deletions

View File

@ -2,7 +2,7 @@
use t::Config;
plan tests => 83;
plan tests => 96;
#no_diff();
@ -49,6 +49,7 @@ __DATA__
--with-luajit enable LuaJIT 2.0
--with-libdrizzle=DIR specify the libdrizzle 1.0 (or drizzle) installation prefix
--with-libpq=DIR specify the libpq (or postgresql) installation prefix
--with-pg_config=PATH specify the path of the pg_config utility
Options directly inherited from nginx
@ -599,6 +600,7 @@ clean:
--with-luajit enable LuaJIT 2.0
--with-libdrizzle=DIR specify the libdrizzle 1.0 (or drizzle) installation prefix
--with-libpq=DIR specify the libpq (or postgresql) installation prefix
--with-pg_config=PATH specify the path of the pg_config utility
Options directly inherited from nginx
@ -1188,3 +1190,82 @@ clean:
rm -rf build
=== TEST 23: --with-libpq & --with-pg_config
--- cmd: ./configure --with-libpq=/foo/bar --with-pg_config=/baz
--- exit: 255
--- err
--with-pg_config is not allowed when --with-libpq is already specified.
--- out
=== TEST 24: --with-pg_config & --with-libpq
--- cmd: ./configure --with-pg_config=/baz --with-libpq=/foo/bar
--- exit: 255
--- err
--with-libpq is not allowed when --with-pg_config is already specified.
--- out
=== TEST 25: ngx_postgres enabled and --with-pg_config is specified
--- cmd: ./configure --with-pg_config=pg_config --with-http_postgres_module --dry-run
--- out
platform: linux (linux)
cp -rp bundle/ build/
cd build
export LIBPQ_LIB='/usr/lib64'
export LIBPQ_INC='/usr/include'
cd lua-5.1.4
make linux
make install INSTALL_TOP=$OPENRESTY_BUILD_DIR/lua-root/usr/local/openresty/lua
export LUA_LIB='$OPENRESTY_BUILD_DIR/lua-root/usr/local/openresty/lua/lib'
export LUA_INC='$OPENRESTY_BUILD_DIR/lua-root/usr/local/openresty/lua/include'
cd ..
cd nginx-1.0.4
./configure --prefix=/usr/local/openresty/nginx \
--add-module=../ngx_devel_kit-0.2.17 \
--add-module=../echo-nginx-module-0.37rc1 \
--add-module=../xss-nginx-module-0.03rc3 \
--add-module=../set-misc-nginx-module-0.22rc2 \
--add-module=../form-input-nginx-module-0.07rc5 \
--add-module=../encrypted-session-nginx-module-0.01 \
--add-module=../ngx_postgres-0.9rc1 \
--add-module=../ngx_lua-0.2.1rc2 \
--add-module=../headers-more-nginx-module-0.15 \
--add-module=../srcache-nginx-module-0.12 \
--add-module=../array-var-nginx-module-0.03rc1 \
--add-module=../memc-nginx-module-0.12 \
--add-module=../redis2-nginx-module-0.07 \
--add-module=../upstream-keepalive-nginx-module-0.3 \
--add-module=../auth-request-nginx-module-0.2 \
--add-module=../rds-json-nginx-module-0.12rc1 \
--with-ld-opt='-Wl,-rpath,/usr/lib64' \
--with-http_ssl_module
cd ../..
--- err
--- makefile
.PHONY: all install clean
all:
cd build/lua-5.1.4 && $(MAKE) linux
cd build/nginx-1.0.4 && $(MAKE)
install:
cd build/lua-5.1.4 && $(MAKE) install INSTALL_TOP=$(DESTDIR)/usr/local/openresty/lua
cd build/nginx-1.0.4 && $(MAKE) install DESTDIR=$(DESTDIR)
clean:
rm -rf build
=== TEST 26: ngx_postgres not enabled but specify --with-pg_config
--- cmd: ./configure --with-pg_config=pg_config --dry-run
--- out
platform: linux (linux)
--- err
The http_postgres_module is not enabled while --with-pg_config is specified.
--- exit: 255

66
util/configure vendored
View File

@ -159,6 +159,17 @@ for my $opt (@ARGV) {
} elsif ($opt =~ /^--with-libpq=(.*)/) {
$resty_opts{libpq} = $1;
if ($resty_opts{pg_config}) {
die "--with-libpq is not allowed when ",
"--with-pg_config is already specified.\n";
}
} elsif ($opt =~ /^--with-pg_config=(.*)/) {
$resty_opts{pg_config} = $1;
if ($resty_opts{libpq}) {
die "--with-pg_config is not allowed when ",
"--with-libpq is already specified.\n";
}
} elsif ($opt eq '--with-no-pool-patch') {
$resty_opts{no_pool} = 1;
@ -281,6 +292,10 @@ sub build_resty_opts {
die "The http_postgres_module is not enabled while --with-libpq is specified.\n";
}
if (! $opts->{http_postgres} && $opts->{pg_config}) {
die "The http_postgres_module is not enabled while --with-pg_config is specified.\n";
}
if ($platform eq 'linux' && $opts->{luajit} && ! can_run("ldconfig")) {
die "you need to have ldconfig in your PATH env when enabling luajit.\n";
}
@ -335,6 +350,30 @@ sub build_resty_opts {
push @ngx_rpaths, $pg_lib;
}
if (my $pg_config = $opts->{pg_config}) {
if (!can_run($pg_config)) {
die "pg_config is not runnable.\n";
}
my $cmd = "$pg_config --libdir";
my $pg_lib = `$cmd`;
chomp $pg_lib;
if (!defined $pg_lib) {
die "Failed to run command $cmd\n";
}
$cmd = "$pg_config --includedir";
my $pg_inc = `$cmd`;
chomp $pg_inc;
if (!defined $pg_inc) {
die "Failed to run command $cmd\n";
}
env LIBPQ_LIB => $pg_lib;
env LIBPQ_INC => $pg_inc;
push @ngx_rpaths, $pg_lib;
}
if ($opts->{luajit}) {
my $luajit_src = auto_complete 'LuaJIT';
my $luajit_prefix = "$prefix/luajit";
@ -510,6 +549,7 @@ _EOC_
--with-luajit enable LuaJIT 2.0
--with-libdrizzle=DIR specify the libdrizzle 1.0 (or drizzle) installation prefix
--with-libpq=DIR specify the libpq (or postgresql) installation prefix
--with-pg_config=PATH specify the path of the pg_config utility
Options directly inherited from nginx
@ -663,21 +703,23 @@ sub gen_makefile {
# check if we can run some command
sub can_run {
my ($cmd) = @_;
my ($cmd) = @_;
#warn "can run: @_\n";
my $_cmd = $cmd;
return $_cmd if -x $_cmd;
#warn "can run: @_\n";
my $_cmd = $cmd;
return $_cmd if -x $_cmd;
# FIXME: this is a hack; MSWin32 is not supported anyway
my $path_sep = ':';
return undef if $_cmd =~ m{[\\/]};
for my $dir ((split /$path_sep/, $ENV{PATH}), '.') {
next if $dir eq '';
my $abs = File::Spec->catfile($dir, $_[0]);
return $abs if -x $abs;
}
# FIXME: this is a hack; MSWin32 is not supported anyway
my $path_sep = ':';
return;
for my $dir ((split /$path_sep/, $ENV{PATH}), '.') {
next if $dir eq '';
my $abs = File::Spec->catfile($dir, $_[0]);
return $abs if -x $abs;
}
return undef;
}

View File

@ -1,7 +1,7 @@
#!/bin/bash
main_ver=1.0.4
minor_ver=2rc5
minor_ver=2rc6
version=$main_ver.$minor_ver
echo $version