Added configure and command line option --help.

This commit is contained in:
Igor Sysoev
2017-08-26 13:37:44 +03:00
parent 0d65c896cf
commit 93f7104a65
8 changed files with 154 additions and 42 deletions

42
auto/help Normal file
View File

@@ -0,0 +1,42 @@
# Copyright (C) Igor Sysoev
# Copyright (C) NGINX, Inc.
cat << END
./configure options:
--cc=FILE set C compiler file name, default: $CC
--cc-opt=OPTIONS set additional C compiler options
--ld-opt=OPTIONS set additional linker options
--prefix=DIRECTORY set prefix for relative path names, no by default
--pid=FILE set pid file name, default: $NXT_PID
--log=FILE set log file name, default: $NXT_LOG
--modules=DIRECTORY set modules directory, default: $NXT_MODULES
--control=ADDRESS set address of control API socket
default: $NXT_CONTROL
--user=USER set non-privileged processes to run as specified user
default: $NXT_USER
--group=GROUP set non-privileged processes to run as specified group
default: user's primary group
--no-ipv6 disable IPv6 support
--no-unix-sockets disable Unix domain sockets support
--debug enable debug logging
python OPTIONS configure Python module
run "./configure python --help" to see available options
php OPTIONS configure PHP module
run "./configure php --help" to see available options
go OPTIONS configure Go module
run "./configure go --help" to see available options
END

View File

@@ -3,16 +3,6 @@
# Copyright (C) NGINX, Inc. # Copyright (C) NGINX, Inc.
if [ ! -f $NXT_AUTOCONF_DATA ]; then
echo
echo Please run common $0 before configuring module \"$nxt_module\".
echo
exit 1
fi
. $NXT_AUTOCONF_DATA
case "$nxt_module" in case "$nxt_module" in
python) python)

View File

@@ -10,7 +10,7 @@ NXT_GO=go
for nxt_option; do for nxt_option; do
case "$nxt_option" in case "$nxt_option" in
-*=*) value=`$echo "$nxt_option" | sed -e 's/[-_a-zA-Z0-9]*=//'` ;; -*=*) value=`echo "$nxt_option" | sed -e 's/[-_a-zA-Z0-9]*=//'` ;;
*) value="" ;; *) value="" ;;
esac esac
@@ -29,9 +29,9 @@ END
;; ;;
*) *)
$echo echo
$echo $0: error: invalid Go option \"$nxt_option\" echo $0: error: invalid Go option \"$nxt_option\"
$echo echo
exit 1 exit 1
;; ;;
@@ -40,6 +40,16 @@ END
done done
if [ ! -f $NXT_AUTOCONF_DATA ]; then
echo
echo Please run common $0 before configuring module \"$nxt_module\".
echo
exit 1
fi
. $NXT_AUTOCONF_DATA
$echo "configuring Go package" $echo "configuring Go package"
$echo "configuring Go package ..." >> $NXT_AUTOCONF_ERR $echo "configuring Go package ..." >> $NXT_AUTOCONF_ERR

View File

@@ -9,7 +9,7 @@ shift
for nxt_option; do for nxt_option; do
case "$nxt_option" in case "$nxt_option" in
-*=*) value=`$echo "$nxt_option" | sed -e 's/[-_a-zA-Z0-9]*=//'` ;; -*=*) value=`echo "$nxt_option" | sed -e 's/[-_a-zA-Z0-9]*=//'` ;;
*) value="" ;; *) value="" ;;
esac esac
@@ -21,27 +21,36 @@ for nxt_option; do
--help) --help)
cat << END cat << END
--config=NAME set php-config name --config=FILE set php-config filename
--module=NAME set php module name --module=NAME set unit php module name
--lib-path=PATH set path to libphp.so library --lib-path=DIRECTORY set directory path to libphp.so library
END END
exit 0 exit 0
;; ;;
*) *)
$echo echo
$echo $0: error: invalid PHP option \"$nxt_option\" echo $0: error: invalid PHP option \"$nxt_option\"
$echo echo
exit 1 exit 1
;; ;;
esac esac
done done
if [ ! -f $NXT_AUTOCONF_DATA ]; then
echo
echo Please run common $0 before configuring module \"$nxt_module\".
echo
exit 1
fi
. $NXT_AUTOCONF_DATA
NXT_PHP_CONFIG=${NXT_PHP_CONFIG=php-config} NXT_PHP_CONFIG=${NXT_PHP_CONFIG=php-config}
NXT_PHP=${NXT_PHP_CONFIG%-config*} NXT_PHP=${NXT_PHP_CONFIG%-config*}
NXT_PHP_MODULE=${NXT_PHP_MODULE=${NXT_PHP##*/}} NXT_PHP_MODULE=${NXT_PHP_MODULE=${NXT_PHP##*/}}

View File

@@ -9,7 +9,7 @@ shift
for nxt_option; do for nxt_option; do
case "$nxt_option" in case "$nxt_option" in
-*=*) value=`$echo "$nxt_option" | sed -e 's/[-_a-zA-Z0-9]*=//'` ;; -*=*) value=`echo "$nxt_option" | sed -e 's/[-_a-zA-Z0-9]*=//'` ;;
*) value="" ;; *) value="" ;;
esac esac
@@ -21,17 +21,17 @@ for nxt_option; do
--help) --help)
cat << END cat << END
--config=NAME set python-config name --config=FILE set python-config filename
--module=NAME set python module name --module=NAME set unit python module name
END END
exit 0 exit 0
;; ;;
*) *)
$echo echo
$echo $0: error: invalid Python option \"$nxt_option\" echo $0: error: invalid Python option \"$nxt_option\"
$echo echo
exit 1 exit 1
;; ;;
esac esac
@@ -39,6 +39,16 @@ END
done done
if [ ! -f $NXT_AUTOCONF_DATA ]; then
echo
echo Please run common $0 before configuring module \"$nxt_module\".
echo
exit 1
fi
. $NXT_AUTOCONF_DATA
NXT_PYTHON_CONFIG=${NXT_PYTHON_CONFIG=python-config} NXT_PYTHON_CONFIG=${NXT_PYTHON_CONFIG=python-config}
NXT_PYTHON=${NXT_PYTHON_CONFIG%-config*} NXT_PYTHON=${NXT_PYTHON_CONFIG%-config*}
NXT_PYTHON_MODULE=${NXT_PYTHON_MODULE=${NXT_PYTHON##*/}} NXT_PYTHON_MODULE=${NXT_PYTHON_MODULE=${NXT_PYTHON##*/}}

View File

@@ -4,23 +4,13 @@
# Copyright (C) NGINX, Inc. # Copyright (C) NGINX, Inc.
CC=${CC:-cc}
NXT_BUILD_DIR=build
NXT_CONFIGURE_OPTIONS= NXT_CONFIGURE_OPTIONS=
NXT_CFLAGS= NXT_CFLAGS=
NXT_CC_OPT= NXT_CC_OPT=
NXT_LD_OPT= NXT_LD_OPT=
NXT_BUILD_DIR=build
NXT_PREFIX= NXT_PREFIX=
NXT_PID="nginext.pid"
NXT_LOG="nginext.log"
NXT_MODULES="modules"
NXT_CONTROL="unix:control.unit.sock"
NXT_USER="nobody"
NXT_GROUP=
NXT_DEBUG=NO NXT_DEBUG=NO
@@ -103,7 +93,8 @@ do
*) *)
$echo $echo
$echo "$0: error: invalid option \"$nxt_option\"". $echo $0: error: invalid option \"$nxt_option\".
$echo Run \"$0 --help\" to see available options.
$echo $echo
exit 1 exit 1
;; ;;

20
configure vendored
View File

@@ -30,10 +30,25 @@ NXT_AUTO_CONFIG_H=$NXT_BUILD_DIR/nxt_auto_config.h
NXT_MAKEFILE=$NXT_BUILD_DIR/Makefile NXT_MAKEFILE=$NXT_BUILD_DIR/Makefile
NXT_BIN=nginext NXT_BIN=nginext
nxt_module=${1:-no}
CC=${CC:-cc}
NXT_PID="nginext.pid"
NXT_LOG="nginext.log"
NXT_MODULES="modules"
NXT_CONTROL="unix:control.unit.sock"
NXT_USER="nobody"
NXT_GROUP=
nxt_module=${1:-""}
case $nxt_module in case $nxt_module in
no|--*) --help)
. auto/help
exit 0
;;
""|--*)
;; ;;
unit) unit)
@@ -46,6 +61,7 @@ case $nxt_module in
;; ;;
esac esac
. auto/os/test . auto/os/test
. auto/options . auto/options

View File

@@ -800,6 +800,37 @@ nxt_runtime_conf_read_cmd(nxt_task_t *task, nxt_runtime_t *rt)
static const char no_modules[] = static const char no_modules[] =
"option \"--modules\" requires directory\n"; "option \"--modules\" requires directory\n";
static const char help[] =
"\n"
"nginext options:\n"
"\n"
" --version print nginext version and configure options\n"
"\n"
" --no-daemon run nginext in non-daemon mode\n"
"\n"
" --control ADDRESS set address of control API socket\n"
" default: \"" NXT_CONTROL_SOCK "\"\n"
"\n"
" --pid FILE set pid file name\n"
" default: \"" NXT_PID "\"\n"
"\n"
" --log FILE set log file name\n"
" default: \"" NXT_LOG "\"\n"
"\n"
" --modules DIRECTORY set modules directory\n"
" default: \"" NXT_MODULES "\"\n"
"\n"
" --user USER set non-privileged processes to run"
" as specified user\n"
" default: \"" NXT_USER "\"\n"
"\n"
" --group GROUP set non-privileged processes to run"
" as specified group\n"
" default: ";
static const char group[] = "\"" NXT_GROUP "\"\n\n";
static const char primary[] = "user's primary group\n\n";
argv = &nxt_process_argv[1]; argv = &nxt_process_argv[1];
while (*argv != NULL) { while (*argv != NULL) {
@@ -908,6 +939,19 @@ nxt_runtime_conf_read_cmd(nxt_task_t *task, nxt_runtime_t *rt)
exit(0); exit(0);
} }
if (nxt_strcmp(p, "--help") == 0) {
write(STDOUT_FILENO, help, sizeof(help) - 1);
if (sizeof(NXT_GROUP) == 1) {
write(STDOUT_FILENO, primary, sizeof(primary) - 1);
} else {
write(STDOUT_FILENO, group, sizeof(group) - 1);
}
exit(0);
}
end = nxt_sprintf(buf, buf + sizeof(buf), "unknown option \"%s\"\n", p); end = nxt_sprintf(buf, buf + sizeof(buf), "unknown option \"%s\"\n", p);
write(STDERR_FILENO, buf, end - buf); write(STDERR_FILENO, buf, end - buf);