[njs] Added arguments validation for configure script.

Dmitry Volyntsev xeioex at nginx.com
Tue Nov 5 17:54:41 UTC 2019


details:   https://hg.nginx.org/njs/rev/4d33ea223de0
branches:  
changeset: 1224:4d33ea223de0
user:      Dmitry Volyntsev <xeioex at nginx.com>
date:      Tue Nov 05 20:49:57 2019 +0300
description:
Added arguments validation for configure script.

diffstat:

 auto/help    |  15 +++++++++++++++
 auto/make    |   9 +++++----
 auto/options |  41 +++++++++++++++++++++++++++++++++++++++++
 auto/summary |  25 +++++++++++++++++++++++++
 configure    |   5 +++--
 5 files changed, 89 insertions(+), 6 deletions(-)

diffs (152 lines):

diff -r 44e41970a160 -r 4d33ea223de0 auto/help
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/auto/help	Tue Nov 05 20:49:57 2019 +0300
@@ -0,0 +1,15 @@
+
+# Copyright (C) Igor Sysoev
+# Copyright (C) NGINX, Inc.
+
+
+cat << END
+
+./configure options:
+
+  --cc=FILE            set C compiler filename, default: "$CC"
+  --cc-opt=OPTIONS     set additional C compiler options
+  --ld-opt=OPTIONS     set additional linker options
+  --ar=FILE            set static linking program, default: "$AR"
+
+END
diff -r 44e41970a160 -r 4d33ea223de0 auto/make
--- a/auto/make	Tue Nov 05 20:49:56 2019 +0300
+++ b/auto/make	Tue Nov 05 20:49:57 2019 +0300
@@ -15,8 +15,9 @@ cat << END > $NJS_MAKEFILE
 # This file is auto-generated by configure
 
 NJS_CC = ${CC}
-NJS_AR = ${AR}
-NJS_CFLAGS = ${NJS_CFLAGS} ${CFLAGS}
+NJS_STATIC_LINK = ${AR} -r -c
+NJS_LINK = ${CC} ${NJS_LD_OPT}
+NJS_CFLAGS = ${NJS_CFLAGS} ${NJS_CC_OPT} ${CFLAGS}
 
 default: $NJS_DEFAULT_TARGET
 END
@@ -58,7 +59,7 @@ libnjs: $NJS_BUILD_DIR/libnjs.a
 	$NJS_BUILD_DIR/njs_auto_config.h \\
 	\$(NJS_LIB_OBJS)
 
-	\$(NJS_AR) -r -c $NJS_BUILD_DIR/libnjs.a \\
+	\$(NJS_STATIC_LINK) $NJS_BUILD_DIR/libnjs.a \\
 		\$(NJS_LIB_OBJS)
 
 END
@@ -98,7 +99,7 @@ cat << END >> $NJS_MAKEFILE
 $NJS_BUILD_DIR/njs: \\
 	$NJS_BUILD_DIR/libnjs.a \\
 	src/njs_shell.c
-	\$(NJS_CC) -o $NJS_BUILD_DIR/njs \$(NJS_CFLAGS) \\
+	\$(NJS_LINK) -o $NJS_BUILD_DIR/njs \$(NJS_CFLAGS) \\
 		$NJS_LIB_AUX_CFLAGS \$(NJS_LIB_INCS) -Injs \\
 		src/njs_shell.c \\
 		$NJS_BUILD_DIR/libnjs.a \\
diff -r 44e41970a160 -r 4d33ea223de0 auto/options
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/auto/options	Tue Nov 05 20:49:57 2019 +0300
@@ -0,0 +1,41 @@
+
+# Copyright (C) Igor Sysoev
+# Copyright (C) NGINX, Inc.
+
+
+NJS_CONFIGURE_OPTIONS=
+NJS_CC_OPT=${NJS_CC_OPT:--O}
+NJS_LD_OPT=${NJS_CC_OPT:--O}
+
+for njs_option
+do
+    case "$njs_option" in
+        -*=*) value=`echo "$njs_option" | sed -e 's/[-_a-zA-Z0-9]*=//'`      ;;
+           *) value="" ;;
+    esac
+
+    case "$njs_option" in
+        --cc=*)                          CC="$value"                         ;;
+        --cc-opt=*)                      NJS_CC_OPT="$value"                 ;;
+        --ld-opt=*)                      NJS_LD_OPT="$value"                 ;;
+        --ar=*)                          AR="$value"                         ;;
+
+        --help)
+            . auto/help
+            exit 0
+        ;;
+
+        *)
+            echo
+            echo $0: error: invalid option \"$njs_option\".
+            echo Run \"$0 --help\" to see available options.
+            echo
+            exit 1
+        ;;
+    esac
+
+    njs_opt=`echo $njs_option | sed -e "s/\(--[^=]*=\)\(.* .*\)/\1'\2'/"`
+
+    NJS_CONFIGURE_OPTIONS="$NJS_CONFIGURE_OPTIONS $njs_opt"
+
+done
diff -r 44e41970a160 -r 4d33ea223de0 auto/summary
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/auto/summary	Tue Nov 05 20:49:57 2019 +0300
@@ -0,0 +1,25 @@
+
+# Copyright (C) Igor Sysoev
+# Copyright (C) NGINX, Inc.
+
+
+echo
+echo "NJS configuration summary:"
+echo
+echo " + using CC: \"$CC\""
+echo " + using CFLAGS: \"$NJS_CFLAGS $NJS_CC_OPT $CFLAGS\""
+echo
+echo " + using PCRE library: $NJS_PCRE_LIB"
+
+if [ $NJS_HAVE_READLINE = YES ]; then
+  echo " + using readline library: $NJS_READLINE_LIB"
+fi
+
+echo
+echo " njs build dir: $NJS_BUILD_DIR"
+
+if [ $NJS_HAVE_READLINE = YES ]; then
+  echo " njs CLI: $NJS_BUILD_DIR/njs"
+fi
+
+echo
diff -r 44e41970a160 -r 4d33ea223de0 configure
--- a/configure	Tue Nov 05 20:49:56 2019 +0300
+++ b/configure	Tue Nov 05 20:49:57 2019 +0300
@@ -24,8 +24,6 @@ NJS_TEST_LIBS=${NJS_TEST_LIBS=}
 CC=${CC:-cc}
 AR=${AR:-ar}
 NJS_CFLAGS=${NJS_CFLAGS=}
-NJS_CC_OPT=${NJS_CC_OPT:--O}
-NJS_LD_OPT=${NJS_CC_OPT:--O}
 
 NJS_BUILD_DIR=${NJS_BUILD_DIR:-build}
 
@@ -47,6 +45,7 @@ END
 NJS_LIBRT=
 
 . auto/os
+. auto/options
 . auto/cc
 . auto/clang
 . auto/time
@@ -65,3 +64,5 @@ NJS_LIB_AUX_LIBS="$NJS_PCRE_LIB"
 . auto/make
 
 . auto/expect
+
+. auto/summary


More information about the nginx-devel mailing list